summaryrefslogtreecommitdiff
path: root/lib/scripts/helpers.js
diff options
context:
space:
mode:
authorAdrian Lang <mail@adrianlang.de>2011-06-22 21:05:17 +0200
committerAdrian Lang <mail@adrianlang.de>2011-06-23 18:04:16 +0200
commitc949174a2e8c324e3e463a9d10e9e6dc07b0ba9e (patch)
tree46188ecb6faa8eed7765e408ff4905197e868e38 /lib/scripts/helpers.js
parent0748b4c7cb6a4918212b51bdedad710322ab2a0b (diff)
downloadrpg-c949174a2e8c324e3e463a9d10e9e6dc07b0ba9e.tar.gz
rpg-c949174a2e8c324e3e463a9d10e9e6dc07b0ba9e.tar.bz2
Fix and refactor ajax.js
* Move file to qsearch.js * Rename object to dw_qsearch * Remove unnecessary usage of Delay * Use $ prefix for jQuery objects * Fix result list hiding on click * Fix namespace shorting
Diffstat (limited to 'lib/scripts/helpers.js')
-rw-r--r--lib/scripts/helpers.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/scripts/helpers.js b/lib/scripts/helpers.js
index 129964d29..77e7ffc4a 100644
--- a/lib/scripts/helpers.js
+++ b/lib/scripts/helpers.js
@@ -144,3 +144,22 @@ function hasFlash(version){
if(ver >= version) return true;
return false;
}
+
+/**
+ * A PHP-style substr_replace
+ *
+ * Supports negative start and length and omitting length, but not
+ * str and replace arrays.
+ * See http://php.net/substr-replace for further documentation.
+ */
+function substr_replace(str, replace, start, length) {
+ var a2, b1;
+ a2 = (start < 0 ? str.length : 0) + start;
+ if (typeof length === 'undefined') {
+ length = str.length - a2;
+ } else if (length < 0 && start < 0 && length <= start) {
+ length = 0;
+ }
+ b1 = (length < 0 ? str.length : a2) + length;
+ return str.substring(0, a2) + replace + str.substring(b1);
+}