diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-07-29 17:10:50 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-07-29 17:10:50 -0400 |
commit | 0c2d54c6159cf4b9e4c93e43c18ad4d08bf54faf (patch) | |
tree | 743a1f36336db69c2e95fc9d02e7a5e26fe2f963 /data/assets/js/util.js | |
parent | 80c76ca5320ca3b45ed6bf4a2d4530c6dad59c3c (diff) | |
download | guff-0c2d54c6159cf4b9e4c93e43c18ad4d08bf54faf.tar.bz2 guff-0c2d54c6159cf4b9e4c93e43c18ad4d08bf54faf.zip |
enable generate secret button and add gripe()
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); }; |