From 0c2d54c6159cf4b9e4c93e43c18ad4d08bf54faf Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 29 Jul 2016 17:10:50 -0400 Subject: enable generate secret button and add gripe() --- data/assets/js/util.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'data/assets/js/util.js') 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); }; -- cgit v1.2.3