Skip to content

Commit

Permalink
Update GUI popup
Browse files Browse the repository at this point in the history
  • Loading branch information
gigamaster committed Jul 23, 2024
1 parent 5ac3bed commit e2208cb
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions app/asset/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@
*/
/* Color schemes, mobile, panel */
const setup = () => {
const getTheme = () => {
if (window.localStorage.getItem('dark')) {
return JSON.parse(window.localStorage.getItem('dark'))
}
return !!window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
}
const setTheme = (value) => {
window.localStorage.setItem('dark', value)
}
const getColor = () => {
if (window.localStorage.getItem('color')) {
return window.localStorage.getItem('color')
}
return 'blue'
}
const setColors = (color) => {
const root = document.documentElement
root.style.setProperty('--color-primary', `var(--color-${color})`)
root.style.setProperty('--color-primary-50', `var(--color-${color}-50)`)
root.style.setProperty('--color-primary-100', `var(--color-${color}-100)`)
root.style.setProperty('--color-primary-light', `var(--color-${color}-light)`)
root.style.setProperty('--color-primary-lighter', `var(--color-${color}-lighter)`)
root.style.setProperty('--color-primary-dark', `var(--color-${color}-dark)`)
root.style.setProperty('--color-primary-darker', `var(--color-${color}-darker)`)
this.selectedColor = color
window.localStorage.setItem('color', color)
}
return {
const getTheme = () => {
if (window.localStorage.getItem('dark')) {
return JSON.parse(window.localStorage.getItem('dark'))
}

return !!window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
}

const setTheme = (value) => {
window.localStorage.setItem('dark', value)
}

const getColor = () => {
if (window.localStorage.getItem('color')) {
return window.localStorage.getItem('color')
}
return 'blue'
}

const setColors = (color) => {
const root = document.documentElement
root.style.setProperty('--color-primary', `var(--color-${color})`)
root.style.setProperty('--color-primary-50', `var(--color-${color}-50)`)
root.style.setProperty('--color-primary-100', `var(--color-${color}-100)`)
root.style.setProperty('--color-primary-light', `var(--color-${color}-light)`)
root.style.setProperty('--color-primary-lighter', `var(--color-${color}-lighter)`)
root.style.setProperty('--color-primary-dark', `var(--color-${color}-dark)`)
root.style.setProperty('--color-primary-darker', `var(--color-${color}-darker)`)
this.selectedColor = color
window.localStorage.setItem('color', color)
}
return {
loading: true,
isDark: getTheme(),
toggleTheme() {
Expand Down Expand Up @@ -80,13 +80,9 @@ const setup = () => {
this.$nextTick(() => {
this.$refs.mobileMainMenu.focus()})
}
}
}
}

/* global LinkPreviewer */
const linkPreviewer = new LinkPreviewer();
linkPreviewer.attach('td a.preview');

/* Search palette */
document.addEventListener('alpine:init', () => {
Alpine.data('spotlight', () => ({
Expand Down Expand Up @@ -202,6 +198,7 @@ document.addEventListener('alpine:init', () => {
hiding the address bar for security reasons (phishing)
*/
function openWithSelfMain(url, title, w, h) {
e.preventDefault();
// Fixes dual-screen position Most browsers Firefox
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY;
Expand All @@ -222,6 +219,10 @@ function openWithSelfMain(url, title, w, h) {
}
}

/* global LinkPreviewer */
const linkPreviewer = new LinkPreviewer();
linkPreviewer.attach('td a.preview');

/* GitHub Fetch Repo Commits */
function commitsData() {
return {
Expand Down Expand Up @@ -267,5 +268,5 @@ function commitsData() {
};
}
/*! fetch */
var _htmlToElements=function(e){var t=document.createElement("template");t.innerHTML=e;const n=t.content.childNodes,o=[],a=[];for(var d in n)1==n[d].nodeType&&("SCRIPT"===n[d].nodeName?a.push(n[d]):o.push(n[d]));return o.concat(a)},_loadContent=function(e,t,n,o){if(0!==t||o||(document.querySelector(n).innerHTML=""),!(t<=e.length))return!0;var a=e[t];if(void 0!==a&&"SCRIPT"===a.nodeName){var d=document.createElement("script");a.type&&(d.type=a.type),Array.prototype.forEach.call(a.attributes,(function(e){d.setAttribute(e.nodeName,e.nodeValue)})),""!=a.src?(d.src=a.src,d.onload=function(){_loadContent(e,t+1,n)},document.head.appendChild(d)):(d.text=a.text,document.body.appendChild(d),_loadContent(e,t+1,n))}else void 0!==a&&document.querySelector(n).appendChild(a),_loadContent(e,t+1,n)},loadData=async function(e,t,n=!1){return _loadContent(_htmlToElements(e),0,t,n)};
// var _htmlToElements=function(e){var t=document.createElement("template");t.innerHTML=e;const n=t.content.childNodes,o=[],a=[];for(var d in n)1==n[d].nodeType&&("SCRIPT"===n[d].nodeName?a.push(n[d]):o.push(n[d]));return o.concat(a)},_loadContent=function(e,t,n,o){if(0!==t||o||(document.querySelector(n).innerHTML=""),!(t<=e.length))return!0;var a=e[t];if(void 0!==a&&"SCRIPT"===a.nodeName){var d=document.createElement("script");a.type&&(d.type=a.type),Array.prototype.forEach.call(a.attributes,(function(e){d.setAttribute(e.nodeName,e.nodeValue)})),""!=a.src?(d.src=a.src,d.onload=function(){_loadContent(e,t+1,n)},document.head.appendChild(d)):(d.text=a.text,document.body.appendChild(d),_loadContent(e,t+1,n))}else void 0!==a&&document.querySelector(n).appendChild(a),_loadContent(e,t+1,n)},loadData=async function(e,t,n=!1){return _loadContent(_htmlToElements(e),0,t,n)};

0 comments on commit e2208cb

Please sign in to comment.