87 lines
3.3 KiB
JavaScript
87 lines
3.3 KiB
JavaScript
/************************************************************************
|
|
Copyright (C) Ayushya Amitabh - All Rights Reserved
|
|
Unauthorized copying of this file, via any medium is strictly prohibited
|
|
Proprietary and confidential
|
|
Written by Ayushya Amitabh <admin@chromewatchparty.com>, 2020 - 2021
|
|
https://www.chromewatchparty.com/copyright
|
|
=========================================================================
|
|
ALL CONTENT ON WATCH PARTY'S WEBSITE OR IN WATCH PARTY'S CHROME EXTENSION APP, UNLESS OTHERWISE
|
|
CITED ARE THE SOLE INTELLECTUAL PROPERTY OF AYUSHYA AMITABH, AND MAY NOT BE
|
|
COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
|
|
************************************************************************/
|
|
window.onload = function () {
|
|
const MDCSwitch = mdc.switchControl.MDCSwitch;
|
|
const showToggleControl = new MDCSwitch(document.querySelector('.mdc-switch#show-toggle'));
|
|
const changelogToggleControl = new MDCSwitch(
|
|
document.querySelector('.mdc-switch#changelog-toggle')
|
|
);
|
|
|
|
function clearLocal() {
|
|
window.localStorage.removeItem('parties');
|
|
return 0;
|
|
}
|
|
|
|
function setShowWPButton(v) {
|
|
window.localStorage.setItem('showWPButton', v);
|
|
}
|
|
function setShowChangelog(v) {
|
|
window.localStorage.setItem('showChangelog', v);
|
|
}
|
|
|
|
function getShowWPButton() {
|
|
return window.localStorage.getItem('showWPButton')
|
|
? JSON.parse(window.localStorage.getItem('showWPButton'))
|
|
: true;
|
|
}
|
|
function getShowChangelog() {
|
|
return window.localStorage.getItem('showChangelog')
|
|
? JSON.parse(window.localStorage.getItem('showChangelog'))
|
|
: false;
|
|
}
|
|
|
|
function toggleShowWPButton() {
|
|
const currentStatus = getShowWPButton();
|
|
setShowWPButton(!currentStatus);
|
|
showToggleControl.checked = !currentStatus;
|
|
changeShowWPButtonDescription();
|
|
}
|
|
function toggleShowChangelog() {
|
|
const currentStatus = getShowChangelog();
|
|
setShowChangelog(!currentStatus);
|
|
changelogToggleControl.checked = !currentStatus;
|
|
changeShowChangelogDescription();
|
|
}
|
|
|
|
function changeShowWPButtonDescription() {
|
|
const currentStatus = getShowWPButton();
|
|
if (currentStatus === true) {
|
|
document.querySelector('#show-toggle + .label-container span').innerText =
|
|
'Currently showing Watch Party button';
|
|
} else {
|
|
document.querySelector('#show-toggle + .label-container span').innerText =
|
|
'Watch Party button is currently hidden';
|
|
}
|
|
}
|
|
function changeShowChangelogDescription() {
|
|
const currentStatus = getShowChangelog();
|
|
if (currentStatus === true) {
|
|
document.querySelector('#changelog-toggle + .label-container span').innerText =
|
|
'Will open changelog on Watch Party update';
|
|
} else {
|
|
document.querySelector('#changelog-toggle + .label-container span').innerText =
|
|
'Will not open changelog on Watch Party update';
|
|
}
|
|
}
|
|
|
|
showToggleControl.checked = getShowWPButton();
|
|
changeShowWPButtonDescription();
|
|
document.querySelector('.mdc-switch#show-toggle').onchange = toggleShowWPButton;
|
|
|
|
changelogToggleControl.checked = getShowChangelog();
|
|
changeShowChangelogDescription();
|
|
document.querySelector('.mdc-switch#changelog-toggle').onchange = toggleShowChangelog;
|
|
|
|
mdc.ripple.MDCRipple.attachTo(document.getElementById('clear-button'));
|
|
document.getElementById('clear-button').onclick = clearLocal;
|
|
};
|