diff options
Diffstat (limited to 'data/assets/js/util.js')
-rw-r--r-- | data/assets/js/util.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/data/assets/js/util.js b/data/assets/js/util.js index 3abaabe..cde0f25 100644 --- a/data/assets/js/util.js +++ b/data/assets/js/util.js @@ -27,6 +27,26 @@ jQuery(function($) { }); }; + window.gripe = function(r, action) { + // get error + var error = r.responseText; + + // handle json response + try { + var data = $.parseJSON(r.responseText); + if (data.error) + error = data.error; + } catch (e) {} + + // build prefix + var prefix = 'Error: '; + if (action) + prefix += " Couldn't " + action + ": "; + + // display error message + alert(prefix + error); + } + LuigiTemplate.FILTERS.json = function(val) { return JSON.stringify(val); }; |