added mangler and other stuff

This commit is contained in:
Mihai Bazon
2012-08-20 17:19:30 +03:00
parent 1fe0ff9fff
commit 458e251d7e
5 changed files with 208 additions and 63 deletions

View File

@@ -98,7 +98,13 @@ var MAP = (function(){
return MAP;
})();
var BASE54_DIGITS = "etnrisouaflchpdvmgybwESxTNCkLAOM_DPHBjFIqRUzWXV$JKQGYZ0516372984";
// XXX: currently this is optimized for jQuery, though I have the
// feeling it works well in general for many scripts (well, better
// than alphabetical order). It would be nice if we could adapt it to
// the currently running script.
// var BASE54_DIGITS = "etnrisouaflchpdvmgybwESxTNCkLAOM_DPHBjFIqRUzWXV$JKQGYZ0516372984";
var BASE54_DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
function base54(num) {
var ret = "", base = 54;
@@ -109,3 +115,14 @@ function base54(num) {
} while (num > 0);
return ret;
};
function push_uniq(array, el) {
if (array.indexOf(el) < 0)
array.push(el);
};
function string_template(text, props) {
return text.replace(/\{(.+?)\}/g, function(str, p){
return props[p];
});
};