Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
proginosko committed Sep 17, 2023
2 parents b08e74e + 7837a44 commit 8e7ef3c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 3 deletions.
4 changes: 4 additions & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Version 1.5.8 (17 Sep 2023)
* Added option to allow/disallow override during lockdown.
* Bug fixes.

### Version 1.5.7 (02 Jul 2023)
* Allowed drive specifiers in site list (e.g., C:/path/).
* Added link to online documentation.
Expand Down
7 changes: 6 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ function checkTab(id, isBeforeNav, isRepeat) {
let closeTab = gOptions[`closeTab${set}`];
let activeBlock = gOptions[`activeBlock${set}`];
let allowOverride = gOptions[`allowOverride${set}`];
let allowOverLock = gOptions[`allowOverLock${set}`];
let showTimer = gOptions[`showTimer${set}`];
let allowKeywords = gOptions[`allowKeywords${set}`];

Expand Down Expand Up @@ -602,7 +603,8 @@ function checkTab(id, isBeforeNav, isRepeat) {
let lockdown = (timedata[4] > now);

// Check override condition
let override = (overrideEndTime > now) && allowOverride;
let override = (overrideEndTime > now)
&& allowOverride && (allowOverLock || !lockdown);

// Determine whether this page should now be blocked
let doBlock = lockdown
Expand Down Expand Up @@ -1207,6 +1209,9 @@ function getUnblockTime(set) {
0, mp.end);
}
}

// Return end time for current time limit period
return new Date(timedata[2] * 1000 + limitPeriod * 1000);
}
}

Expand Down
1 change: 1 addition & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const PER_SET_OPTIONS = {
delayCancel: { type: "boolean", def: true, id: "delayCancel" },
reloadSecs: { type: "string", def: "", id: "reloadSecs" },
allowOverride: { type: "boolean", def: false, id: "allowOverride" },
allowOverLock: { type: "boolean", def: true, id: "allowOverLock" },
prevOpts: { type: "boolean", def: false, id: "prevOpts" },
prevGenOpts: { type: "boolean", def: false, id: "prevGenOpts" },
prevExts: { type: "boolean", def: false, id: "prevExts" },
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
"webNavigation"
],

"version": "1.5.7"
"version": "1.5.8"

}
5 changes: 5 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@
<input id="allowOverride1" type="checkbox">
<label for="allowOverride1">Allow temporary override for these sites</label>
</p>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;
<input id="allowOverLock1" type="checkbox">
<label for="allowOverLock1">Allow temporary override during lockdown</label>
</p>
</fieldset>
<p>
<button id="resetOpts1" type="button">Reset Options to Defaults</button>
Expand Down
37 changes: 36 additions & 1 deletion options.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const browser = chrome;

const DEFAULT_OPTIONS_FILE = "LeechBlockOptions.txt";

const SUB_OPTIONS = {
"allowOverride" : "allowOverLock"
};

function log(message) { console.log("[LBNG] " + message); }
function warn(message) { console.warn("[LBNG] " + message); }

Expand Down Expand Up @@ -75,6 +79,9 @@ function initForm(numSets) {
$("#tabs").tabs("option", "active", set);
});
$(`#setName${set}`).change(function (e) { updateBlockSetName(set, $(`#setName${set}`).val()); });
for (let name in SUB_OPTIONS) {
$(`#${name}${set}`).change(function (e) { updateSubOptions(set); });
}
$(`#allDay${set}`).click(function (e) { $(`#times${set}`).val(ALL_DAY_TIMES); });
$(`#defaultPage${set}`).click(function (e) { $(`#blockURL${set}`).val(DEFAULT_BLOCK_URL); });
$(`#delayingPage${set}`).click(function (e) { $(`#blockURL${set}`).val(DELAYED_BLOCK_URL); });
Expand Down Expand Up @@ -553,6 +560,9 @@ function retrieveOptions() {

// Apply custom set name to tab (if specified)
updateBlockSetName(set, options[`setName${set}`]);

// Update enabled/disabled state of sub-options
updateSubOptions(set);
}

// General options
Expand Down Expand Up @@ -775,6 +785,9 @@ function applyImportOptions(options) {

// Apply custom set name to tab (if specified)
updateBlockSetName(set, options[`setName${set}`]);

// Update enabled/disabled state of sub-options
updateSubOptions(set);
}

// General options
Expand Down Expand Up @@ -876,6 +889,14 @@ function importOptions() {
return;
}

// Preserve passwords if not imported
if (options["password"] == undefined) {
options["password"] = getElement("accessPassword").value;
}
if (options["orp"] == undefined) {
options["orp"] = getElement("overridePassword").value;
}

cleanOptions(options);
applyImportOptions(options);

Expand Down Expand Up @@ -941,7 +962,7 @@ function openDiagnostics() {
// Swap options for two block sets
//
function swapSetOptions(set1, set2) {
// Swap disabled status
// Swap disabled state
let cl_disabled1 = getElement(`cancelLockdown${set1}`).disabled;
let cl_disabled2 = getElement(`cancelLockdown${set2}`).disabled;
let disabled1 = gSetDisabled[set1];
Expand Down Expand Up @@ -1013,6 +1034,9 @@ function resetSetOptions(set) {
}
}
}

// Update enabled/disabled state of sub-options
updateSubOptions(set);
}

// Disable (or re-enable) options for block set
Expand Down Expand Up @@ -1082,6 +1106,17 @@ function disableImportOptions() {
}
}

// Update enabled/disabled state of sub-options
//
function updateSubOptions(set) {
for (let name in SUB_OPTIONS) {
let subname = SUB_OPTIONS[name];
let comp1 = getElement(`${name}${set}`);
let comp2 = getElement(`${subname}${set}`);
comp2.disabled = comp1.disabled || !comp1.checked;
}
}

// Initialize access control prompt
//
function initAccessControlPrompt(prompt) {
Expand Down

0 comments on commit 8e7ef3c

Please sign in to comment.