aboutsummaryrefslogtreecommitdiff
path: root/data/assets/js/util.js
blob: ed048ec21a4f5e86f782df516bf1f4afcc2716a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
  };
});