v1.0.0
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<div class="page-options">
|
||||
<div class="option checkbox">
|
||||
<input
|
||||
class="custom-checkbox"
|
||||
id="page-options-notifications"
|
||||
type="checkbox"
|
||||
onchange="Options.optionPush.edit(this.checked)"
|
||||
/>
|
||||
<label for="page-options-notifications"> Повідомлення: </label>
|
||||
</div>
|
||||
|
||||
<div class="option inputs">
|
||||
<label for="page-options-fontSize">Розмір шрифту:</label>
|
||||
<select id="page-options-fontSize" onchange="Options.optionFont.edit(this.value)">
|
||||
<option value="small">Маленький</option>
|
||||
<option value="medium">Середній</option>
|
||||
<option value="large">Великий</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,51 @@
|
||||
const Options = {
|
||||
init: async () => {
|
||||
let html = await fetch('/lib/pages/options/index.html').then((response) => response.text());
|
||||
app.innerHTML = html;
|
||||
app.innerHTML = html;
|
||||
|
||||
await Options.optionPush.init();
|
||||
Options.optionFont.init();
|
||||
},
|
||||
optionPush: {
|
||||
init: async () => {
|
||||
const element = document.getElementById("page-options-notifications");
|
||||
const permission = await Notification.requestPermission();
|
||||
|
||||
if (!('serviceWorker' in navigator) || !('PushManager' in window) || permission !== 'granted') {
|
||||
element.disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const registration = await navigator.serviceWorker.ready;
|
||||
let subscription = await registration.pushManager.getSubscription();
|
||||
|
||||
if (subscription) {
|
||||
element.checked = true;
|
||||
} else {
|
||||
element.checked = false;
|
||||
}
|
||||
},
|
||||
edit: (state) => {
|
||||
if (state) {
|
||||
webPush.init();
|
||||
} else {
|
||||
webPush.unsubscribe();
|
||||
}
|
||||
}
|
||||
},
|
||||
optionFont: {
|
||||
init: () => {
|
||||
const element = document.getElementById("page-options-fontSize");
|
||||
|
||||
let fontSize = localStorage.getItem("fontSize")
|
||||
? localStorage.getItem("fontSize")
|
||||
: 'medium';
|
||||
|
||||
element.value = fontSize;
|
||||
},
|
||||
edit: (mode) => {
|
||||
localStorage.setItem("fontSize", mode);
|
||||
applyFontMode(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
.page-options {
|
||||
position: relative;
|
||||
width: calc(100% - 40px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 20px 20px 0 20px;
|
||||
}
|
||||
|
||||
.page-options>.option {
|
||||
text-align: left;
|
||||
font-weight: 400;
|
||||
padding: 20px;
|
||||
margin: 0 0 15px;
|
||||
border-radius: 15px;
|
||||
font-size: var(--FontSize5);
|
||||
background: var(--ColorThemes1);
|
||||
color: var(--ColorThemes3);
|
||||
border: 1px solid var(--ColorThemes2);
|
||||
box-shadow: var(--shadow-l1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.page-options>.option>label {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
flex-direction: row;
|
||||
font-size: var(--FontSize1);
|
||||
font-weight: 500;
|
||||
margin: 5px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.page-options>.option>select {
|
||||
width: 100%;
|
||||
min-width: 140px;
|
||||
padding: 0 5px;
|
||||
border-radius: calc(var(--border-radius) - 5px - 4px);
|
||||
height: 30px;
|
||||
background-color: var(--ColorThemes0);
|
||||
color: var(--ColorThemes3);
|
||||
}
|
||||
|
||||
.page-options>.option>.custom-checkbox+label {
|
||||
font-size: var(--FontSize4);
|
||||
font-weight: 400;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
user-select: none;
|
||||
flex-direction: row-reverse;
|
||||
justify-content: space-between;
|
||||
cursor: pointer;
|
||||
margin: 5px 0;
|
||||
}
|
||||
Reference in New Issue
Block a user