diff options
author | plegall <plg@piwigo.org> | 2013-10-28 16:25:46 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2013-10-28 16:25:46 +0000 |
commit | 2fdcfdddfecb66c7d654004cd1d44ceb6a1233c7 (patch) | |
tree | 19ec3a89f6857f8e82f05ddad7a1ed07d4aebabf /admin/themes/default/js | |
parent | 7367858be89bef8163d77ac9b1aed18c8c17555f (diff) |
feature 1668, in progress: redesign user manager (jQuery datatables, AJAX calls)
git-svn-id: http://piwigo.org/svn/trunk@25194 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/themes/default/js')
-rw-r--r-- | admin/themes/default/js/common.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/admin/themes/default/js/common.js b/admin/themes/default/js/common.js new file mode 100644 index 000000000..d0e460bd8 --- /dev/null +++ b/admin/themes/default/js/common.js @@ -0,0 +1,50 @@ +function array_delete(arr, item) { + var i = arr.indexOf(item); + if (i != -1) arr.splice(i, 1); +} + +function sprintf() { + var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = ''; + while (f) { + if (m = /^[^\x25]+/.exec(f)) { + o.push(m[0]); + } + else if (m = /^\x25{2}/.exec(f)) { + o.push('%'); + } + else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) { + if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) { + throw('Too few arguments.'); + } + if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) { + throw('Expecting number but found ' + typeof(a)); + } + + switch (m[7]) { + case 'b': a = a.toString(2); break; + case 'c': a = String.fromCharCode(a); break; + case 'd': a = parseInt(a); break; + case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break; + case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break; + case 'o': a = a.toString(8); break; + case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break; + case 'u': a = Math.abs(a); break; + case 'x': a = a.toString(16); break; + case 'X': a = a.toString(16).toUpperCase(); break; + } + + a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a); + c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' '; + x = m[5] - String(a).length - s.length; + p = m[5] ? str_repeat(c, x) : ''; + o.push(s + (m[4] ? a + p : p + a)); + } + else { + throw('Huh ?!'); + } + + f = f.substring(m[0].length); + } + + return o.join(''); +}
\ No newline at end of file |