From eff4be8428511284694fcd6602b41aac40c2ea32 Mon Sep 17 00:00:00 2001 From: James Anderson Date: Sun, 7 Aug 2016 20:27:49 -0400 Subject: [PATCH] Moved functions out of inline script nodes --- chrome/content/browser.js | 27 ++++++++++++++ chrome/content/browser.xul | 20 +++-------- chrome/content/lockdown.js | 21 ++++++++++- chrome/content/lockdown.xul | 17 ++------- chrome/content/options.js | 70 +++++++++++++++++++++++++++++++++++++ chrome/content/options.xul | 64 ++++----------------------------- chrome/content/stats.js | 2 +- chrome/content/stats.xul | 4 +-- 8 files changed, 133 insertions(+), 92 deletions(-) diff --git a/chrome/content/browser.js b/chrome/content/browser.js index 461669f..ec8e287 100644 --- a/chrome/content/browser.js +++ b/chrome/content/browser.js @@ -840,6 +840,33 @@ LeechBlock.openLockdownDialog = function () { "leechblock-lockdown", "chrome,centerscreen"); } +// Shows alert dialog with block warning +// +LeechBlock.alertBlockWarning = function (set, setName, secsLeft) { + if (setName == "") { + setName = LeechBlock.locale_blockSet + " " + set; + } + LeechBlock.PROMPTS.alert(null, + LeechBlock.locale_warning_title, + LeechBlock.locale_warning_alertBlock + .replace(/\$B/, setName) + .replace(/\$S/, secsLeft)); +} + +// Returns label for item for add site menu +// +LeechBlock.getAddSiteMenuItemLabel = function (site, set, setName) { + if (setName != "") { + return LeechBlock.locale_menu_addThisSiteLabel + .replace(/\$S/, site) + .replace(/\$B/, setName); + } else { + return LeechBlock.locale_menu_addThisSiteLabel + .replace(/\$S/, site) + .replace(/\$B/, LeechBlock.locale_blockSet + " " + set); + } +} + // Prepares menu (either context menu or toolbar menu) // LeechBlock.prepareMenu = function (menu, win) { diff --git a/chrome/content/browser.xul b/chrome/content/browser.xul index f1a8e20..d517155 100644 --- a/chrome/content/browser.xul +++ b/chrome/content/browser.xul @@ -10,22 +10,10 @@ diff --git a/chrome/content/lockdown.js b/chrome/content/lockdown.js index a6e740c..5e4b61b 100644 --- a/chrome/content/lockdown.js +++ b/chrome/content/lockdown.js @@ -40,7 +40,7 @@ LeechBlock.lockdownInit = function () { let lockdown = (sets & (1 << (set - 1))) != 0; document.getElementById("lb-lockdown-set" + set).checked = lockdown; document.getElementById("lb-lockdown-set" + set).label += " " - + LeechBlock.getLockdownBlockSetLabel(set); + + LeechBlock.getBlockSetName(set); } } @@ -91,3 +91,22 @@ LeechBlock.lockdownOK = function () { LeechBlock.lockdownCancel = function () { return true; } + +// Shows alert dialog with end time +// +LeechBlock.alertLockdown = function (endTime) { + LeechBlock.PROMPTS.alert(null, + LeechBlock.locale_lockdown_title, + LeechBlock.locale_lockdown_alertLockdown + " " + endTime); +} + +// Returns name of block set +// +LeechBlock.getBlockSetName = function (set) { + let setName = LeechBlock.getUniCharPref("setName" + set); + if (setName != "") { + return setName; + } else { + return LeechBlock.locale_blockSet + " " + set; + } +} diff --git a/chrome/content/lockdown.xul b/chrome/content/lockdown.xul index cc73323..f51dd80 100644 --- a/chrome/content/lockdown.xul +++ b/chrome/content/lockdown.xul @@ -15,20 +15,9 @@ diff --git a/chrome/content/options.js b/chrome/content/options.js index 9b542c9..712b464 100644 --- a/chrome/content/options.js +++ b/chrome/content/options.js @@ -751,3 +751,73 @@ LeechBlock.importOptions = function () { } LeechBlock.updatePasswordOptions(); } + +// Shows alert dialog for bad time periods entry +// +LeechBlock.alertBadTimes = function () { + LeechBlock.PROMPTS.alert(null, + LeechBlock.locale_options_title, + LeechBlock.locale_options_alertBadTimes); +} + +// Shows alert dialog for bad time limit entry +// +LeechBlock.alertBadTimeLimit = function () { + LeechBlock.PROMPTS.alert(null, + LeechBlock.locale_options_title, + LeechBlock.locale_options_alertBadTimeLimit); +} + +// Shows alert dialog for bad seconds entry +// +LeechBlock.alertBadSeconds = function () { + LeechBlock.PROMPTS.alert(null, + LeechBlock.locale_options_title, + LeechBlock.locale_options_alertBadSeconds); +} + +// Shows confirmation dialog for preventing access to options all day +// +LeechBlock.confirmPrevOptsAllDay = function () { + let check = {value: false}; + let flags = + LeechBlock.PROMPTS.BUTTON_POS_0 * LeechBlock.PROMPTS.BUTTON_TITLE_YES + + LeechBlock.PROMPTS.BUTTON_POS_1 * LeechBlock.PROMPTS.BUTTON_TITLE_NO; + let button = LeechBlock.PROMPTS.confirmEx(null, + LeechBlock.locale_options_title, + LeechBlock.locale_options_confPrevOptsAllDay, + flags, "", "", "", null, check); + return (button == 0); +} + +// Shows confirmation dialog for canceling lockdown +// +LeechBlock.confirmCancelLockdown = function () { + let check = {value: false}; + let flags = + LeechBlock.PROMPTS.BUTTON_POS_0 * LeechBlock.PROMPTS.BUTTON_TITLE_YES + + LeechBlock.PROMPTS.BUTTON_POS_1 * LeechBlock.PROMPTS.BUTTON_TITLE_NO; + let button = LeechBlock.PROMPTS.confirmEx(null, + LeechBlock.locale_options_title, + LeechBlock.locale_options_confCancelLockdown, + flags, "", "", "", null, check); + return (button == 0); +} + +// Shows prompt dialog for password +// +LeechBlock.requestPassword = function (hide) { + let userpassword = {}, check = {}; + if (hide) { + LeechBlock.PROMPTS.promptPassword(null, + LeechBlock.locale_options_title, + LeechBlock.locale_options_passwordPrompt, + userpassword, null, check); + } else { + LeechBlock.PROMPTS.prompt(null, + LeechBlock.locale_options_title, + LeechBlock.locale_options_passwordPrompt, + userpassword, null, check); + } + return userpassword.value; +} diff --git a/chrome/content/options.xul b/chrome/content/options.xul index 2dc2968..92256cf 100644 --- a/chrome/content/options.xul +++ b/chrome/content/options.xul @@ -15,63 +15,13 @@ diff --git a/chrome/content/stats.js b/chrome/content/stats.js index c78c49a..cb1356c 100644 --- a/chrome/content/stats.js +++ b/chrome/content/stats.js @@ -22,7 +22,7 @@ LeechBlock.statsRefresh = function () { // Update block set name if (setName == "") { - setName = LeechBlock.getDefaultSetName(set); + setName = LeechBlock.locale_blockSet + " " + set; } document.getElementById("lb-set-name" + set).value = setName; diff --git a/chrome/content/stats.xul b/chrome/content/stats.xul index d25d167..860fd80 100644 --- a/chrome/content/stats.xul +++ b/chrome/content/stats.xul @@ -13,9 +13,7 @@