Skip to content

Commit

Permalink
Add info about sets affected by override (proginosko#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
proginosko committed Nov 26, 2022
1 parent a8e8932 commit 6d58a8f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions override.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
</div>
<div id="alertOverrideActivated" title="LeechBlock Override">
<p>Override activated. Blocking will be suspended until <strong><span id="alertOverrideEndTime"></span></strong>.</p>
<p id="alertOverrideNoSets"><strong>Note:</strong> Override will have no effect because you have not selected<br>"Allow temporary override for these sites" for any block sets.</p>
<p id="alertOverrideSets" style="display: none;">Override will be applied to sites in: <span id="alertOverrideSetList"></span></p>
</div>
</div>

Expand Down
19 changes: 19 additions & 0 deletions override.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var gAccessRequiredInput;
var gClockOffset;
var gOverrideConfirm;
var gOverrideMins;
var gOverrideSetNames = [];
var gClockTimeOpts;

// Initialize form
Expand Down Expand Up @@ -61,6 +62,19 @@ function initializePage() {
gOverrideConfirm = options["orc"];
gOverrideMins = options["orm"];

// Get list of sets to override
let numSets = +options["numSets"];
for (let set = 1; set <= numSets; set++) {
if (options[`allowOverride${set}`]) {
let setName = options[`setName${set}`];
if (setName) {
gOverrideSetNames.push(`Block Set ${set} (${setName})`);
} else {
gOverrideSetNames.push(`Block Set ${set}`);
}
}
}

confirmAccess(options);
}

Expand Down Expand Up @@ -224,6 +238,11 @@ function activateOverride() {
// Show confirmation dialog
endTime = new Date(endTime * 1000);
$("#alertOverrideEndTime").html(endTime.toLocaleTimeString(undefined, gClockTimeOpts));
if (gOverrideSetNames.length > 0) {
$("#alertOverrideNoSets").hide();
$("#alertOverrideSets").show();
$("#alertOverrideSetList").html("<ul><li>" + gOverrideSetNames.join("</li><li>") + "</li></ul>");
}
$("#alertOverrideActivated").dialog("open");
} else {
// Close page immediately (no confirmation dialog)
Expand Down

0 comments on commit 6d58a8f

Please sign in to comment.