Spaces:
Running
Running
v0.4: mobile containment
Browse files
common.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
| 1 |
-
/* Shared runtime for ViKernel Desktop extension apps: session id, live API helper, highlight styles. */
|
| 2 |
-
(() => {
|
| 3 |
-
'use strict';
|
| 4 |
-
try { window.VK_SID = sessionStorage.getItem('vk_sid') || ('s' + Math.random().toString(36).slice(2, 10)); sessionStorage.setItem('vk_sid', window.VK_SID); }
|
| 5 |
-
catch (e) { window.VK_SID = 's' + Math.random().toString(36).slice(2, 10); }
|
| 6 |
-
window.VK_OVERRIDES = window.VK_OVERRIDES || {};
|
| 7 |
-
window.VK_EXTRA_APPS = window.VK_EXTRA_APPS || [];
|
| 8 |
-
window.VK_API = async (path, body, timeoutMs) => {
|
| 9 |
-
const ctl = new AbortController(); const to = setTimeout(() => ctl.abort(), timeoutMs || 120000);
|
| 10 |
-
try {
|
| 11 |
-
const r = await fetch('api/ag/' + path, body === undefined ? {cache:'no-store', signal:ctl.signal} :
|
| 12 |
-
{method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body), signal:ctl.signal});
|
| 13 |
-
if (r.status === 429) throw new Error('rate');
|
| 14 |
-
if (!r.ok) throw new Error('http ' + r.status);
|
| 15 |
-
return await r.json();
|
| 16 |
-
} finally { clearTimeout(to); }
|
| 17 |
-
};
|
| 18 |
-
const css = document.createElement('style');
|
| 19 |
-
css.textContent = `@keyframes vkpulse{0%{box-shadow:0 0 0 0 rgba(99,102,241,.55)}70%{box-shadow:0 0 0 12px rgba(99,102,241,0)}100%{box-shadow:0 0 0 0 rgba(99,102,241,0)}}
|
| 20 |
-
.icon.hl .g,.dk.hl .g{outline:2px solid #818CF8;outline-offset:2px;animation:vkpulse 2.2s ease-out infinite}
|
| 21 |
-
.icon.hl{position:relative}.icon.hl::after{content:'NEW';position:absolute;top:2px;right:8px;background:#E11D48;color:#fff;font:800 9px/1 system-ui,sans-serif;padding:3px 5px;border-radius:6px;letter-spacing:.5px}
|
| 22 |
-
.dk.hl{position:relative}.dk.hl::after{content:'';position:absolute;top:4px;right:4px;width:8px;height:8px;border-radius:50%;background:#E11D48}
|
| 23 |
-
@media (
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
| 1 |
+
/* Shared runtime for ViKernel Desktop extension apps: session id, live API helper, highlight styles. */
|
| 2 |
+
(() => {
|
| 3 |
+
'use strict';
|
| 4 |
+
try { window.VK_SID = sessionStorage.getItem('vk_sid') || ('s' + Math.random().toString(36).slice(2, 10)); sessionStorage.setItem('vk_sid', window.VK_SID); }
|
| 5 |
+
catch (e) { window.VK_SID = 's' + Math.random().toString(36).slice(2, 10); }
|
| 6 |
+
window.VK_OVERRIDES = window.VK_OVERRIDES || {};
|
| 7 |
+
window.VK_EXTRA_APPS = window.VK_EXTRA_APPS || [];
|
| 8 |
+
window.VK_API = async (path, body, timeoutMs) => {
|
| 9 |
+
const ctl = new AbortController(); const to = setTimeout(() => ctl.abort(), timeoutMs || 120000);
|
| 10 |
+
try {
|
| 11 |
+
const r = await fetch('api/ag/' + path, body === undefined ? {cache:'no-store', signal:ctl.signal} :
|
| 12 |
+
{method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body), signal:ctl.signal});
|
| 13 |
+
if (r.status === 429) throw new Error('rate');
|
| 14 |
+
if (!r.ok) throw new Error('http ' + r.status);
|
| 15 |
+
return await r.json();
|
| 16 |
+
} finally { clearTimeout(to); }
|
| 17 |
+
};
|
| 18 |
+
const css = document.createElement('style');
|
| 19 |
+
css.textContent = `@keyframes vkpulse{0%{box-shadow:0 0 0 0 rgba(99,102,241,.55)}70%{box-shadow:0 0 0 12px rgba(99,102,241,0)}100%{box-shadow:0 0 0 0 rgba(99,102,241,0)}}
|
| 20 |
+
.icon.hl .g,.dk.hl .g{outline:2px solid #818CF8;outline-offset:2px;animation:vkpulse 2.2s ease-out infinite}
|
| 21 |
+
.icon.hl{position:relative}.icon.hl::after{content:'NEW';position:absolute;top:2px;right:8px;background:#E11D48;color:#fff;font:800 9px/1 system-ui,sans-serif;padding:3px 5px;border-radius:6px;letter-spacing:.5px}
|
| 22 |
+
.dk.hl{position:relative}.dk.hl::after{content:'';position:absolute;top:4px;right:4px;width:8px;height:8px;border-radius:50%;background:#E11D48}
|
| 23 |
+
@media (max-width:700px){.win .body{overflow-x:hidden}.win .body *{max-width:100%;box-sizing:border-box}.win .body pre,.win .body code{white-space:pre-wrap;word-break:break-word}.win .body table{display:block;overflow-x:auto}}
|
| 24 |
+
@media (prefers-reduced-motion:reduce){.icon.hl .g,.dk.hl .g{animation:none}}`;
|
| 25 |
+
document.head.append(css);
|
| 26 |
+
})();
|