aboutsummaryrefslogtreecommitdiff
path: root/data/assets/js/util.js
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-05-15 17:07:16 -0400
committerPaul Duncan <pabs@pablotron.org>2016-05-15 17:07:16 -0400
commitae667b4222a718f99091ec8bb1fb130970b051e7 (patch)
tree08b2844213893ba614896b6dd06d7cfac22f0656 /data/assets/js/util.js
downloadguff-ae667b4222a718f99091ec8bb1fb130970b051e7.tar.bz2
guff-ae667b4222a718f99091ec8bb1fb130970b051e7.zip
initial commit
Diffstat (limited to 'data/assets/js/util.js')
-rw-r--r--data/assets/js/util.js31
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);
+ };
+});