summaryrefslogtreecommitdiff
path: root/lib/scripts/helpers.js
diff options
context:
space:
mode:
authorKate Arzamastseva <pshns@ukr.net>2011-06-24 11:32:51 +0300
committerKate Arzamastseva <pshns@ukr.net>2011-06-24 11:32:51 +0300
commita2dc299eb0593f35454deb21a2cb5d51a235e80a (patch)
tree5b14bf906bbd13495826ebbe86d3af1c8fd88f71 /lib/scripts/helpers.js
parent70c3cc9a17d47d8986cba0805d943c1a68af1740 (diff)
parentc949174a2e8c324e3e463a9d10e9e6dc07b0ba9e (diff)
downloadrpg-a2dc299eb0593f35454deb21a2cb5d51a235e80a.tar.gz
rpg-a2dc299eb0593f35454deb21a2cb5d51a235e80a.tar.bz2
Merge branch 'master' of git://github.com/splitbrain/dokuwiki into media-revisions
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);
+}