diff --git a/static/js/pandora/menu.js b/static/js/pandora/menu.js index 545ce64d..e9fa9646 100644 --- a/static/js/pandora/menu.js +++ b/static/js/pandora/menu.js @@ -149,6 +149,7 @@ pandora.ui.mainMenu = function() { pandora.site.capabilities.canSeeDebugMenu[pandora.user.level] ? [ { id: 'debugMenu', title: 'Debug', items: [ + { id: 'onload', title: 'Run on load...'}, { id: 'logs', title: 'View Logs...'}, { id: 'clearcache', title: 'Clear Cache'}, { id: 'reloadapplication', title: 'Reload Application'}, @@ -319,6 +320,8 @@ pandora.ui.mainMenu = function() { filters: pandora.site.user.ui.filters }); pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser()); + } else if (data.id == 'onload') { + pandora.$ui.onloadDialog = pandora.ui.onloadDialog().open(); } else if (data.id == 'logs') { pandora.$ui.logsDialog = pandora.ui.logsDialog().open(); } else if (data.id == 'clearcache') { diff --git a/static/js/pandora/onloadDialog.js b/static/js/pandora/onloadDialog.js new file mode 100644 index 00000000..60b176d7 --- /dev/null +++ b/static/js/pandora/onloadDialog.js @@ -0,0 +1,84 @@ +// vim: et:ts=4:sw=4:sts=4:ft=javascript + +'use strict'; + +pandora.ui.onloadDialog = function() { + + var + dialogHeight = Math.round((window.innerHeight - 48) * 0.9), + dialogWidth = Math.round(window.innerWidth * 0.9), + $text = Ox.Input({ + height: dialogHeight - 8, + id: 'onload', + placeholder: 'Paste onload code here', + type: 'textarea', + value: localStorage['pandora.onload'] || '', + width: dialogWidth - 8 + }), + + that = Ox.Dialog({ + buttons: [ + Ox.Button({ + title: 'Clear' + }) + .css({margin: '4px 4px 4px 0'}) + .bindEvent({ + click: function() { + clear(); + } + }), + Ox.Button({ + id: 'done', + title: 'Done', + width: 48 + }).bindEvent({ + click: function() { + that.close(); + } + }) + ], + closeButton: true, + content: $text, + height: dialogHeight, + maximizeButton: true, + minHeight: 256, + minWidth: 512, + padding: 0, + removeOnClose: true, + title: 'Manage Users', + width: dialogWidth + }) + .bindEvent({ + resize: resize + }); + + function resize(data) { + dialogHeight = data.height; + dialogWidth = data.width; + $text.options({ + height: dialogHeight - 8, + width: dialogWidth - 8 + }); + } + + function clear() { + delete localStorage['pandora.onload']; + $text.options({value: ''}); + + } + + that.superClose = that.close; + that.close = function() { + var value = $text.value(); + if(value) { + localStorage['pandora.onload'] = value; + } else { + delete localStorage['pandora.onload']; + } + that.superClose(); + }; + + return that; + +}; +