Merge remote-tracking branch 'origin/main'

This commit is contained in:
SBD
2024-01-09 22:01:13 +03:00
23 changed files with 407 additions and 34 deletions

View File

@@ -1240,7 +1240,7 @@
.not_found_routes{
width: 96%;
height: 250px;
min-height: 250px;
background: #FFFFFF;
box-shadow: -1px 4px 10px 0 rgba(198, 199, 203, 0.20), 0 -1px 10px 0 rgba(198, 199, 203, 0.20);
position: relative;

View File

@@ -773,6 +773,20 @@ span.btn_profile_name {
display: block;
}
#create_route{
border-radius: 10px;
color: #FFFFFF;
background: #FF613A;
/*height: 60px;*/
font-size: 18px;
font-weight: 500;
width: 100%;
margin-top: 10px;
display: inline-block;
padding: 15px 0px;
}
/* Change color of dropdown links on hover */
.dropdown-content-lang a:hover {background-color: #f1f1f1}
@@ -2056,6 +2070,26 @@ button.cancel_remove.show, button.confirm_remove.show{
/*Static_pages*/
.not_found_wrap{
padding-top: 20px;
}
.not_found_text{
text-align: center;
font-style: normal;
font-weight: 700;
line-height: 52px;
margin-bottom: 20px;
}
.not_found_title{
font-size: 60px;
}
.not_found_sub_title{
font-size: 26px;
}
#title_static{
text-align: center;
font-size: 44px;

View File

@@ -0,0 +1,91 @@
const registerSw = async () => {
if ('serviceWorker' in navigator) {
const reg = await navigator.serviceWorker.register('/sw.js');
initialiseState(reg)
} else {
showNotAllowed("You can't send push notifications ☹️😢")
}
};
const initialiseState = (reg) => {
if (!reg.showNotification) {
showNotAllowed('Showing notifications isn\'t supported ☹️😢');
return
}
if (Notification.permission === 'denied') {
showNotAllowed('You prevented us from showing notifications ☹️🤔');
return
}
if (!'PushManager' in window) {
showNotAllowed("Push isn't allowed in your browser 🤔");
return
}
subscribe(reg);
}
const showNotAllowed = (message) => {
const button = document.querySelector('form>button');
button.innerHTML = `${message}`;
button.setAttribute('disabled', 'true');
};
function urlB64ToUint8Array(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/');
const rawData = window.atob(base64);
const outputArray = new Uint8Array(rawData.length);
const outputData = outputArray.map((output, index) => rawData.charCodeAt(index));
return outputData;
}
const subscribe = async (reg) => {
const subscription = await reg.pushManager.getSubscription();
if (subscription) {
sendSubData(subscription);
return;
}
const vapidMeta = document.querySelector('meta[name="vapid-key"]');
const key = vapidMeta.content;
const options = {
userVisibleOnly: true,
// if key exists, create applicationServerKey property
...(key && {applicationServerKey: urlB64ToUint8Array(key)})
};
const sub = await reg.pushManager.subscribe(options);
sendSubData(sub)
};
const sendSubData = async (subscription) => {
const browser = navigator.userAgent.match(/(firefox|msie|chrome|safari|trident)/ig)[0].toLowerCase();
const data = {
status_type: 'subscribe',
subscription: subscription.toJSON(),
browser: browser,
user_agent: browser,
};
const res = await fetch('/webpush/save_information', {
method: 'POST',
body: JSON.stringify(data),
headers: {
'content-type': 'application/json',
},
credentials: "include"
});
handleResponse(res);
};
const handleResponse = (res) => {
console.log(res.status);
};
registerSw();