From fa376dd18848085407a01a01c2a59cd879acd607 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 21 Feb 2015 16:01:52 +0530 Subject: [PATCH] allow for aborting user script by pressing escape on page load --- static/js/pandora.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static/js/pandora.js b/static/js/pandora.js index cb49e944..53fdfe84 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -52,6 +52,7 @@ appPanel && !(Math.round(navigator.userAgent.match(/MSIE (\d+)/)[1]) >= 10), isPrint = /^#print(\?.*?)?$/.test(document.location.hash), legacyThemes = {classic: 'oxlight', modern: 'oxdark'}, + loadUserScript = true, logoHeight, logoWidth, theme = getLocalStorage('Ox.theme') @@ -59,6 +60,8 @@ appPanel theme = legacyThemes[theme] || theme; + document.addEventListener('keydown', onKeydown); + loadImages(function(images) { loadScreen(images); loadOxJS(function() { @@ -429,7 +432,8 @@ appPanel }); Ox.Fullscreen.bind('exit', pandora.UI.set); pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8; - pandora.loadUserScript(); + loadUserScript && pandora.loadUserScript(); + document.removeEventListener('keydown', onKeydown); } function loadBrowserMessage() { @@ -513,6 +517,12 @@ appPanel } + function onKeydown(e) { + if (e.keyCode == 27) { + loadUserScript = false; + } + } + function startAnimation() { var css, deg = 0, loadingIcon = document.getElementById('loadingIcon'), previousTime = +new Date();