Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/popup/qrcode.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
</div>
</div>
</div>
<label>
<input type="checkbox" id="disable-tips-checkbox">
Disable random tips
</label>
<textarea id="qrcodetext"
class="browser-style"
placeholder="Enter text for QR code here to generate it."
Expand Down
41 changes: 37 additions & 4 deletions src/popup/qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,40 @@ import * as RandomTips from "/common/modules/RandomTips/RandomTips.js";

import "./modules/InitQrCode.js";

RandomTips.init(tips).then(() => {
RandomTips.setContext("popup");
RandomTips.showRandomTipIfWanted();
});
const CHECKBOX_ID = "disable-tips-checkbox";

/*Check browser's storage if user wants to receive the tips*/
async function ShowTips() {
const result = await browser.storage.local.get("showTips");
return result.showTips !== false;
}

/*Functionality for checkbox changes */
function SetupCheckbox() {
const checkbox = document.getElementById(CHECKBOX_ID);
if (!checkbox) return;

/*Load initial state whether users wants to see tips */
browser.storage.local.get("showTips").then((result) => {
checkbox.checked = result.showTips === false;
});

checkbox.addEventListener("change", () => {
const show = !checkbox.checked;
browser.storage.local.set({ showTips: show });
});
}

async function init()
{
SetupCheckbox();
if (await ShowTips())
{
RandomTips.init(tips).then(() => {
RandomTips.setContext("popup");
RandomTips.showRandomTipIfWanted();
});
}
}

init();
Loading