diff options
Diffstat (limited to 'data/assets/js/util.js')
-rw-r--r-- | data/assets/js/util.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/data/assets/js/util.js b/data/assets/js/util.js new file mode 100644 index 0000000..ed048ec --- /dev/null +++ b/data/assets/js/util.js @@ -0,0 +1,31 @@ +$.fn.reduce = (function() { + if (Array.prototype.reduce) { + return Array.prototype.reduce; + } else { + return function(a, cb, r) { + a = [].concat(a); + + for (var i = 0, l = a.length; i < l; i++) + r = cb(r, a[i]); + + return r; + }; + } +})(); + +jQuery(function($) { + "use strict"; + + window.send = function(fn, args) { + return $.ajax({ + url: "/api/" + fn, + method: 'POST', + dataType: 'json', + data: args, + }); + }; + + LuigiTemplate.FILTERS.json = function(val) { + return JSON.stringify(val); + }; +}); |