52 lines
2.0 KiB
JavaScript
52 lines
2.0 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
|
|
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 switchControl = new MDCSwitch(document.querySelector('.mdc-switch'));
|
|
|
|
function clearLocal() {
|
|
window.localStorage.removeItem('parties');
|
|
return 0;
|
|
}
|
|
function setShowWPButton(v) {
|
|
window.localStorage.setItem('showWPButton', v);
|
|
}
|
|
function getShowWPButton() {
|
|
return window.localStorage.getItem('showWPButton')
|
|
? JSON.parse(window.localStorage.getItem('showWPButton'))
|
|
: true;
|
|
}
|
|
function toggleShowWPButton() {
|
|
const currentStatus = getShowWPButton();
|
|
setShowWPButton(!currentStatus);
|
|
switchControl.checked = !currentStatus;
|
|
changeShowWPButtonDescription();
|
|
}
|
|
function changeShowWPButtonDescription() {
|
|
const currentStatus = getShowWPButton();
|
|
if (currentStatus === true) {
|
|
document.querySelector('.switch-wrapper span').innerText =
|
|
'Currently showing Watch Party button';
|
|
} else {
|
|
document.querySelector('.switch-wrapper span').innerText =
|
|
'Watch Party button is currently hidden';
|
|
}
|
|
}
|
|
|
|
switchControl.checked = getShowWPButton();
|
|
changeShowWPButtonDescription();
|
|
document.querySelector('.mdc-switch').onchange = toggleShowWPButton;
|
|
|
|
mdc.ripple.MDCRipple.attachTo(document.getElementById('clear-button'));
|
|
document.getElementById('clear-button').onclick = clearLocal;
|
|
};
|