v1.7.5/version bump
- fix popup styling - add changelog toggle
This commit is contained in:
+41
-6
@@ -11,40 +11,75 @@ COPIED, EDITED, OR REPRODUCED WITHOUT PERMISSION.
|
||||
************************************************************************/
|
||||
window.onload = function () {
|
||||
const MDCSwitch = mdc.switchControl.MDCSwitch;
|
||||
const switchControl = new MDCSwitch(document.querySelector('.mdc-switch'));
|
||||
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);
|
||||
switchControl.checked = !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('.switch-wrapper span').innerText =
|
||||
document.querySelector('#show-toggle + .label-container span').innerText =
|
||||
'Currently showing Watch Party button';
|
||||
} else {
|
||||
document.querySelector('.switch-wrapper span').innerText =
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
switchControl.checked = getShowWPButton();
|
||||
showToggleControl.checked = getShowWPButton();
|
||||
changeShowWPButtonDescription();
|
||||
document.querySelector('.mdc-switch').onchange = toggleShowWPButton;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user