Skip to content

Commit

Permalink
Add button to reset rollover time
Browse files Browse the repository at this point in the history
  • Loading branch information
proginosko committed Nov 20, 2022
1 parent 55e28ac commit e45c77c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
24 changes: 24 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var gTabs = [];
var gSetCounted = [];
var gSavedTimeData = [];
var gRegExps = [];
var gActiveTabId = 0;
var gPrevActiveTabId = 0;
var gFocusWindowId = 0;
var gAllFocused = false;
Expand Down Expand Up @@ -1253,6 +1254,23 @@ function applyOverride(endTime) {
updateIcon();
}

// Reset rollover time for all sets applicable to active tab
//
function resetRolloverTime() {
//log("resetRolloverTime");

if (!gGotOptions || !gActiveTabId) {
return;
}

// Get block set for currently active time limit
let set = gTabs[gActiveTabId].secsLeftSet;
if (set) {
// Reset rollover time
gOptions[`timedata${set}`][5] = 0;
}
}

// Open extension page (either create new tab or activate existing tab)
//
function openExtensionPage(url) {
Expand Down Expand Up @@ -1422,6 +1440,11 @@ function handleMessage(message, sender, sendResponse) {
gTabs[sender.tab.id].referrer = message.referrer;
break;

case "reset-rollover":
// Reset rollover time
resetRolloverTime();
break;

case "restart":
// Restart time data requested by statistics page
restartTimeData(message.set);
Expand Down Expand Up @@ -1475,6 +1498,7 @@ function handleTabActivated(activeInfo) {
let tabId = activeInfo.tabId;
//log("handleTabActivated: " + tabId);

gActiveTabId = tabId;
gPrevActiveTabId = activeInfo.previousTabId;

initTab(tabId);
Expand Down
1 change: 1 addition & 0 deletions es/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<button id="stats" type="button">Estadísticas</button>
<br><br>
<button id="cancelOverride" type="button">Cancelar Anulación</button>
<button id="resetRollover" type="button">Restablecer Tiempo<br>de Transferencia</button>
</div>
<script src="/popup.js"></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions he/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<button id="stats" type="button">Statistics</button>
<br><br>
<button id="cancelOverride" type="button">Cancel Override</button>
<button id="resetRollover" type="button">Reset Rollover Time</button>
</div>
<script src="/popup.js"></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions it/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<button id="stats" type="button">Statistiche</button>
<br><br>
<button id="cancelOverride" type="button">Annulla Permesso</button>
<button id="resetRollover" type="button">Reimposta il Tempo<br>di Rollover</button>
</div>
<script src="/popup.js"></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<button id="stats" type="button">Statistics</button>
<br><br>
<button id="cancelOverride" type="button">Cancel Override</button>
<button id="resetRollover" type="button">Reset Rollover Time</button>
</div>
<script src="/popup.js"></script>
</body>
Expand Down
12 changes: 12 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,22 @@ function cancelOverride() {
window.close();
}

// Reset rollover
//
function resetRollover() {
let message = {
type: "reset-rollover",
};
browser.runtime.sendMessage(message);

window.close();
}

document.querySelector("#options").addEventListener("click", openOptions);
document.querySelector("#lockdown").addEventListener("click", openLockdown);
document.querySelector("#override").addEventListener("click", openOverride);
document.querySelector("#stats").addEventListener("click", openStats);
document.querySelector("#cancelOverride").addEventListener("click", cancelOverride);
document.querySelector("#resetRollover").addEventListener("click", resetRollover);

document.addEventListener("DOMContentLoaded", initializePage);

0 comments on commit e45c77c

Please sign in to comment.