removed annoying popups

This commit is contained in:
wukko
2022-10-02 20:13:33 +06:00
parent 9a65e9117c
commit fe3ada0323
8 changed files with 100 additions and 67 deletions

View File

@@ -4,6 +4,7 @@
--border-15: 0.15rem solid var(--accent);
--border-10: 0.1rem solid var(--accent);
--font-mono: 'Noto Sans Mono', 'Consolas', 'SF Mono', monospace;
--red: rgb(255, 0, 61);
}
@media (prefers-color-scheme: dark) {
:root {
@@ -251,6 +252,13 @@ input[type="checkbox"] {
padding: 0.6rem 1.2rem!important;
align-content: center;
}
.notification-dot {
width: 8px;
height: 8px;
background: var(--red);
margin-right: 0.4rem;
border-radius: 99rem;
}
.text-backdrop {
background: var(--accent);
color: var(--background);
@@ -268,7 +276,7 @@ input[type="checkbox"] {
visibility: hidden;
position: fixed;
height: auto;
width: 30%;
width: 32%;
z-index: 999;
padding: 3rem 2rem 2rem 2rem;
font-size: 0.9rem;
@@ -542,6 +550,9 @@ input[type="checkbox"] {
.popup.small {
width: 25%
}
.popup {
width: 35%;
}
}
@media screen and (max-width: 1440px) {
#cobalt-main-box {
@@ -554,7 +565,12 @@ input[type="checkbox"] {
width: 40%;
}
}
@media screen and (max-width: 1100px) {
@media screen and (max-width: 1300px) {
.popup {
width: 46%;
}
}
@media screen and (max-width: 1200px) {
#cobalt-main-box {
width: 70%;
}

View File

@@ -1,6 +1,7 @@
let isIOS = navigator.userAgent.toLowerCase().match("iphone os");
let version = 11;
let version = 12;
let regex = new RegExp(/https:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/);
let notification = `<div class="notification-dot"></div>`
let switchers = {
"theme": ["auto", "light", "dark"],
@@ -105,6 +106,35 @@ function changeTab(evnt, tabId, tabClass) {
}
eid(tabId).style.display = "block";
evnt.currentTarget.dataset.enabled = "true";
if (tabId == "tab-about-changelog" && sGet("changelogStatus") != `${version}`) notificationCheck("changelog");
if (tabId == "tab-about-about" && !sGet("seenAbout")) notificationCheck("about");
}
function notificationCheck(type) {
let changed = true;
switch (type) {
case "about":
sSet("seenAbout", "true");
break;
case "changelog":
sSet("changelogStatus", version)
break;
default:
changed = false;
break;
}
if (changed && sGet("changelogStatus") == `${version}` || type == "disable") {
setTimeout(() => {
eid("about-footer").innerHTML = eid("about-footer").innerHTML.replace(notification, '');
eid("tab-button-about-changelog").innerHTML = eid("tab-button-about-changelog").innerHTML.replace(notification, '')
}, 900)
}
if (sGet("disableChangelog") != "true") {
if (!sGet("seenAbout") && !eid("about-footer").innerHTML.includes(notification)) eid("about-footer").innerHTML = `${notification}${eid("about-footer").innerHTML}`;
if (sGet("changelogStatus") != `${version}`) {
if (!eid("about-footer").innerHTML.includes(notification)) eid("about-footer").innerHTML = `${notification}${eid("about-footer").innerHTML}`;
if (!eid("tab-button-about-changelog").innerHTML.includes(notification)) eid("tab-button-about-changelog").innerHTML = `${notification}${eid("tab-button-about-changelog").innerHTML}`;
}
}
}
function hideAllPopups() {
let filter = document.getElementsByClassName('popup');
@@ -116,52 +146,40 @@ function hideAllPopups() {
eid("popup-backdrop").style.visibility = "hidden";
}
function popup(type, action, text) {
if (action == 1) hideAllPopups();
eid("popup-backdrop").style.visibility = vis(action);
switch (type) {
case "about":
let tabId = text ? text : "changelog";
if (tabId == "changelog") {
sSet("changelogStatus", version)
}
eid(`tab-button-${type}-${tabId}`).click();
eid("popup-about").style.visibility = vis(action);
if (!sGet("seenAbout")) sSet("seenAbout", "true");
break;
case "settings":
eid(`tab-button-${type}-video`).click();
eid("popup-settings").style.visibility = vis(action);
break;
case "error":
eid("desc-error").innerHTML = text;
eid("popup-error").style.visibility = vis(action);
break;
case "download":
if (action == 1) {
if (action == 1) {
hideAllPopups(); // hide the previous popup before showing a new one
switch (type) {
case "about":
let tabId = sGet("seenAbout") ? "changelog" : "about";
eid(`tab-button-${type}-${tabId}`).click();
break;
case "settings":
eid(`tab-button-${type}-video`).click();
break;
case "error":
eid("desc-error").innerHTML = text;
break;
case "download":
eid("pd-download").href = text;
eid("pd-copy").setAttribute("onClick", `copy('pd-copy', '${text}')`);
}
eid("popup-download").style.visibility = vis(action);
break;
case "imagePicker":
switch (action) {
case 1:
eid("imagepicker-download").href = text.url;
for (let i in text.images) {
eid("imagepicker-holder").innerHTML += `<div class="imagepicker-image-container"><img class="imagepicker-image" src="${text.images[i]}" onerror="this.parentNode.style.display='none'"></img></div>`
}
break;
case 0:
eid("imagepicker-download").href = '/';
eid("imagepicker-holder").innerHTML = ''
break;
}
eid("popup-imagePicker").style.visibility = vis(action);
break;
default:
eid(`popup-${type}`).style.visibility = vis(action);
break;
break;
case "imagePicker":
eid("imagepicker-download").href = text.url;
for (let i in text.images) {
eid("imagepicker-holder").innerHTML += `<div class="imagepicker-image-container"><img class="imagepicker-image" src="${text.images[i]}" onerror="this.parentNode.style.display='none'"></img></div>`
}
break;
default:
break;
}
} else {
if (type == "imagePicker") {
eid("imagepicker-download").href = '/';
eid("imagepicker-holder").innerHTML = ''
}
}
eid("popup-backdrop").style.visibility = vis(action);
eid(`popup-${type}`).style.visibility = vis(action);
}
function changeSwitcher(li, b) {
if (b) {
@@ -194,6 +212,7 @@ function checkbox(action) {
if (action == "alwaysVisibleButton") button();
if (action == "disableClipboardButton") eid("pasteFromClipboard").style.display = "flex";
}
sGet(action) == "true" ? notificationCheck("disable") : notificationCheck();
}
function updateToggle(toggl, state) {
switch(state) {
@@ -359,11 +378,7 @@ window.onload = () => {
eid("cobalt-main-box").style.visibility = 'visible';
eid("footer").style.visibility = 'visible';
eid("url-input-area").value = "";
if (!sGet("seenAbout")) {
popup('about', 1, "about");
} else if (sGet("changelogStatus") != `${version}` && sGet("disableChangelog") != "true") {
popup('about', 1, "changelog");
}
notificationCheck();
if (isIOS) sSet("downloadPopup", "true");
let urlQuery = new URLSearchParams(window.location.search).get("u");
if (urlQuery !== null) {