|
var nm; |
|
nm = nm || { // nm |
|
get: { |
|
form: { |
|
data: function() { |
|
var x = 0; |
|
var l = window.location.search + ""; |
|
if (/\?/.test(l) === !1) return !1; |
|
l = l |
|
.replace("?", "") |
|
.replace(/\\("|')/g, "\\\\\\$1") |
|
.replace(/[^\\]("|')/g, "\\$1"); |
|
if (!l || "" === l) return !1; |
|
var a = encodeURI(l) |
|
.replace(/=/g, '":"').split("&"); |
|
var R = '{"'; |
|
for (;x < a.length - 1;) { |
|
R += a[x] + '","'; |
|
x++; |
|
} |
|
R += a[x] + '"}'; |
|
R = (R + "") |
|
.replace(",\n", ","); |
|
R = JSON.parse(decodeURI(R)); |
|
return R; |
|
} |
|
} |
|
}, |
|
storage: { |
|
set: function() { |
|
for (var e = 0, t = false; e < arguments.length;) { |
|
if ("undefined" != typeof Storage) { |
|
localStorage.setItem(arguments[e], arguments[e + 1]); |
|
e += 2; |
|
t = true; |
|
} |
|
e += 2; |
|
} |
|
return t; |
|
}, |
|
check: function(e) { |
|
return !!tux.storage.get(e); |
|
}, |
|
get: function(e) { |
|
return localStorage.getItem(e); |
|
}, |
|
"delete": function(e) { |
|
localStorage.setItem(e, null); |
|
return !tux.storage.check(e); |
|
} |
|
}, |
|
attr: function(e, t, a) { |
|
if (e) if (!a) return e.getAttribute(t); else return "!" != a ? e.setAttribute(t, a) : e.getAttribute(t); |
|
}, |
|
id: function(e, t, a) { |
|
if ("!" != e && e) { |
|
var g = document.getElementById(e) || document.getElementById(e + " "); |
|
if (a) return tux.attr(g, t, a); |
|
if (t) if ("$html" != t) g.innerHTML = t; else return g.innerHTML; |
|
return g; |
|
} |
|
}, |
|
"class": function(e, t, a, r) { |
|
if ("!" != e && e) { |
|
var g = document.getElementsByClassName(e); |
|
if (!r) { |
|
if (a) if ("$html" != a) g[t].innerHTML = a; else return g[t].innerHTML; |
|
return g; |
|
} else tux.attr(g[t], a, r); |
|
} |
|
}, |
|
tag: function(e, t, a, r) { |
|
if ("!" != e && e) { |
|
var g = document.getElementsByTagName(e); |
|
if (!r) { |
|
if (a) if ("$html" != a) g[t].innerHTML = a; else return g[t].innerHTML; |
|
return g; |
|
} else tux.attr(g[t], a, r); |
|
} |
|
}, |
|
ele: function(e, t, a, r) { |
|
if ("!" != e && e) { |
|
var g = document.querySelectorAll(e); |
|
if (g.length < 2) t = 0; |
|
if (!r) { |
|
if (a) if ("$html" != a) g[t].innerHTML = a; else return g[t].innerHTML; |
|
return g; |
|
} else tux.attr(g[t], a, r); |
|
} |
|
}, |
|
save: function(e, t) { |
|
var k = window.location.pathname + ""; |
|
t = t || k.substring(k.lastIndexOf("/") + 1, k.length) + ".cache"; |
|
tux.storage.set(t, e); |
|
return tux.storage.check(t); |
|
}, |
|
load: function(e, a) { |
|
a = a || !1; |
|
e = a ? encodeURI(e) : e; |
|
var k = window.location.pathname + ""; |
|
e = e || k.substring(k.lastIndexOf("/") + 1, k.length) + ".cache"; |
|
return tux.storage.get(e); |
|
}, |
|
"delete": function(e) { |
|
var k = window.location.pathname + ""; |
|
e = e || k.substring(k.lastIndexOf("/") + 1, k.length) + ".cache"; |
|
var g = tux.storage.delete(name); |
|
return g; |
|
}, |
|
"typeof": function(e) { |
|
var n = ""; |
|
switch(typeof e) { |
|
case typeof Boolean(): |
|
n = ""; |
|
break; |
|
case typeof Function(): |
|
n = ""; |
|
break; |
|
case typeof Number(): |
|
n = ""; |
|
break; |
|
case typeof Object(): |
|
switch(e.constructor) { |
|
case RegExp: |
|
n = ""; |
|
break; |
|
case Array: |
|
n = "[]"; |
|
break; |
|
default: |
|
n = "{}"; |
|
break; |
|
} |
|
break; |
|
case typeof String(): |
|
n = "\"\""; |
|
break; |
|
case typeof Symbol(): |
|
n = ["(@@", ")"]; |
|
e = e.toString(); |
|
break; |
|
case typeof null: |
|
n = ""; |
|
break; |
|
case typeof undefined: |
|
n = ""; |
|
break; |
|
} |
|
return (n[0] || "") + e + (n[1] || ""); |
|
} |
|
}; |
|
|
|
if(history.length > 1) { |
|
// window.open(window.location); |
|
// window.close(); |
|
} |
|
|
|
if( nm.get.form.data().full == 'true' ) { |
|
fullscreen(); |
|
KP.Qy('#blush').map.setAttribute('onclick', "Alert('already in Blush+')"); |
|
} |
|
|
|
var home, toast, ___, common, types, active, background, blush; |
|
home = KP.Qy('.cbos-desktop').map.innerHTML; |
|
toast = KP.Qy('#cbos-toast-element').map; |
|
background = []; |
|
common = { |
|
url: 'URL: ', |
|
text: 'Input: ', |
|
username: 'Username: ', |
|
passowrd: 'Password: ', |
|
no: 'Number: ', |
|
search: 'Search: ' |
|
} |
|
|
|
types = { |
|
url: 'text', |
|
text: 'text', |
|
username: 'text', |
|
password: 'password', |
|
no: 'tel', |
|
search: 'text' |
|
} |
|
|
|
setTimeout(function(){ |
|
Toast('Blush will try ' + saying); |
|
KP.Qy('node-mode').$('.$no-display $display'); |
|
setTimeout(function(){ |
|
Toast('f11 for fullscreen'); |
|
KP.Qy('body').$('$random:background>ready'); |
|
KP.Qy('node-mode').$(':$display'); |
|
KP.Qy('.cbos-home-screen,.cbos-task-bar,.cbos-desktop').$('$no-display>display'); |
|
}, 5000 + (Math.random() * 3000)); |
|
}, 10000 + (Math.random() * 5000)); |
|
|
|
function Toast(m, t, c, e) { |
|
t = t || 5000; |
|
c = c || 'white'; |
|
w = toast.getAttribute('time') || 0; |
|
if(m != '!') { |
|
if(toast.getAttribute('busy') != '!') { |
|
toast.setAttribute('class', 'page paper-like open- fill-x-axis fixed-to-top text-to-none text-center opacity=10 opacity:5 :700ms background=' + c); |
|
toast.setAttribute('style', 'z-index:18'); |
|
toast.innerHTML = '' + m; |
|
toast.setAttribute('busy', '!'); |
|
toast.setAttribute('time', t); |
|
} else { |
|
//setTimeout(function(){ |
|
Toast("!", 0); |
|
Toast(m, t, c, e); |
|
//}, w + 1505); |
|
} |
|
} else { |
|
clearTimeout(window.toast_time); |
|
toast.setAttribute('class', 'opacity=0 :700ms'); |
|
toast.innerHTML = ''; |
|
toast.setAttribute('busy', 'false'); |
|
toast.setAttribute('time', '0'); |
|
} |
|
if(!e){ |
|
window.toast_time = setTimeout(function(){ |
|
toast.setAttribute('class', 'page paper-like open- fill-x-axis fixed-to-top opacity=0 :700ms'); |
|
toast.innerHTML = ''; |
|
toast.setAttribute('busy', 'false'); |
|
}, t); |
|
} else { |
|
r = document.createElement('input'); |
|
o = document.createElement('input'); |
|
g = document.createElement('input'); |
|
if(typeof e == 'function') { |
|
e = e.name; |
|
} |
|
r.setAttribute('id', 'cbos-toast-input'); |
|
r.setAttribute('type', types[common['"' + m.split(' - ')[1] + '"']] || 'text'); |
|
r.setAttribute('class', 'page paper-like background=black color=hot-pink no-border text-to-none segoe'); |
|
o.setAttribute('value', 'go'); |
|
o.setAttribute('class', 'page paper-like background=black color=hot-pink segoe'); |
|
o.setAttribute('type', 'button'); |
|
o.setAttribute('onclick', e + '(KP.Qy("#cbos-toast-input").map.value); Toast("!", 0);'); |
|
g.setAttribute('value', 'X'); |
|
g.setAttribute('class', 'page paper-like background=red color=white segoe'); |
|
g.setAttribute('type', 'button'); |
|
g.setAttribute('onclick', 'Toast("!", 0); return false;'); |
|
toast.appendChild(r); |
|
toast.appendChild(o); |
|
toast.appendChild(g); |
|
} |
|
return true; |
|
} |
|
|
|
function Notify(m, t, i, c, x) { |
|
if(!m){return} |
|
t = t || 'An app says'; |
|
Toast('<span class="material-icons">' + i + '</span> ' + t + ' - ' + m, 7000, c, x); |
|
} |
|
|
|
function Alert(m) { |
|
Notify(m, 'Oops', 'error', 'pastel:red'); |
|
} |
|
|
|
function Poke(m) { |
|
Notify(m, 'Psst', 'warning', 'gold'); |
|
} |
|
|
|
function OK(m) { |
|
Notify(m, 'OK', 'done', 'pastel:green'); |
|
} |
|
|
|
function Ask(f, m) { |
|
m = m || 'Input needed: '; |
|
Notify(m, ' ', 'mode_edit', 'update-darker opacity:7 color=update!', f); |
|
} |
|
|
|
function App(n, t, p, f, c) { // name, title, params, function | name, title, titles, actions, cbos-task-bar buttons |
|
___ = KP.Qy('.cbos-desktop').map; |
|
tb = KP.Qy('.cbos-task-bar div').map[1]; |
|
if(!!n && f != 'close') { |
|
app = { |
|
build: KP.Qy('app[app-'+n+']').map, |
|
name: (t || n), |
|
process: n, |
|
arguments: p, |
|
actions: f, |
|
buttons: c |
|
}; |
|
El = document.createElement('span'); |
|
El.setAttribute('class', unv[0] + ' button-' + app.process); |
|
El.setAttribute('title', 'Pop-out ' + app.name); |
|
El.setAttribute('onclick', 'popOut(active.src)'); |
|
El.appendChild(document.createTextNode("launch")); |
|
el = document.createElement('span'); |
|
el.setAttribute('class', unv[0] + ' button-' + app.process); |
|
el.setAttribute('title', 'Close ' + app.name); |
|
el.setAttribute('args', app.arguments); |
|
el.setAttribute('onclick', 'App("' + app.process + '","' + app.name + '","' + app.arguments + '","close");'); |
|
el.appendChild(document.createTextNode("clear")); |
|
tb.appendChild(El); |
|
tb.appendChild(el); |
|
___.innerHTML = app.build.innerHTML; |
|
active = ___.querySelector('iframe'); |
|
active.setAttribute('src', active.getAttribute('$')); |
|
KP.Qy('.button-' + app.process).$('active'); |
|
} else { |
|
KP.Qy('.button-' + app.process).$('$active>no-display'); |
|
___.innerHTML = home; |
|
Toast("- Blush Home - "); |
|
app = {}; |
|
//tb.removeChild(tb.childNodes[x]); |
|
} |
|
|
|
if(!!c) { |
|
q = c.replace(/`/g, '\'').split(';;'); // actions: close();;remove() |
|
e = f.split(','); // titles: close,remove |
|
w = p.split(' '); // buttons: clear backspace |
|
for(var x = 0; x < q.length; x++) { |
|
KP.Qy('.cbos-task-bar').map.innerHTML += '<span class="button-' + app.process + ' ' + unv[0] + '" title="' + app.name + ' - ' + e[x] + '" onclick="' + q[x] + '">' + w[x] + '</span>'; |
|
} |
|
} else { |
|
___.setAttribute('params', p); |
|
} |
|
} |
|
|
|
KP.update(function(){ |
|
date = new Date(); |
|
switch(date.getDay()) { |
|
case 0: |
|
day = 'Sun' |
|
break; |
|
case 1: |
|
day = 'Mon' |
|
break; |
|
case 2: |
|
day = 'Tue' |
|
break; |
|
case 3: |
|
day = 'Wed' |
|
break; |
|
case 4: |
|
day = 'Thur' |
|
break; |
|
case 5: |
|
day = 'Fri' |
|
break; |
|
case 6: |
|
day = 'Sat' |
|
break; |
|
} |
|
switch(date.getMonth()) { |
|
case 0: |
|
mon = 'Jan'; |
|
break; |
|
case 1: |
|
mon = 'Feb'; |
|
break; |
|
case 2: |
|
mon = 'Mar'; |
|
break; |
|
case 3: |
|
mon = 'Apr'; |
|
break; |
|
case 4: |
|
mon = 'May'; |
|
break; |
|
case 5: |
|
mon = 'June'; |
|
break; |
|
case 6: |
|
mon = 'July'; |
|
break; |
|
case 7: |
|
mon = 'Aug'; |
|
break; |
|
case 8: |
|
mon = 'Sept'; |
|
break; |
|
case 9: |
|
mon = 'Oct'; |
|
break; |
|
case 10: |
|
mon = 'Nov'; |
|
break; |
|
case 11: |
|
mon = 'Dec'; |
|
break; |
|
} |
|
_day = date.getDate(); |
|
year = date.getFullYear(); |
|
KP.Qy('.time').map.innerHTML = 'Now: ' + day + ' ' + mon + ' ' + _day + ', ' + year + ' - ' + KP.time.return(12); |
|
}, 1000); |
|
|
|
function frameBrowse(url, n){ |
|
active.setAttribute('src', '//codepen.io/Ephellon/debug/qdzebY?url=' + url); |
|
} |
|
|
|
function Background(){ |
|
if(background[0] != 1){ |
|
background[1] = active; |
|
background[2] = app; |
|
location.hash = app.process; |
|
___.innerHTML = home; |
|
KP.Qy(".button-" + app.process).$(".no-display"); |
|
Toast("- " + app.name + " minified -", 3000); |
|
KP.Qy('#tasks').$('.rotate-180').map.setAttribute('title', 'Open ' + app.name); |
|
background[0] = 1; |
|
} else { |
|
App(); |
|
app = background[2]; |
|
location.hash = ''; |
|
App(app.process, app.name, app.arguments, app.actions, app.buttons); |
|
KP.Qy('#tasks').$(':rotate-180').map.setAttribute('title', 'Minimize'); |
|
background[0] = 0; |
|
Toast("- " + app.name + " -", 3000); |
|
} |
|
} |
|
|
|
function popOut(x, w, h) { |
|
t = !(!!h); |
|
l = !(!!w); |
|
w = (w == true)?screen.availWidth:parseInt(screen.availWidth/2.6); |
|
h = (h == true)?screen.availHeight:parseInt(screen.availHeight/2.6); |
|
t = (t == true)?parseInt(h/2):0; |
|
l = (l == true)?parseInt(w/2):0; |
|
window.open(x || active.src, "_blank", "menu=no, status=no, titlebar=no, resizeable=no, top=" + t + ", left=" + l + ", width=" + w + ", height=" + h); |
|
} |
|
|
|
function fullscreen() { |
|
|
|
var el = document.body; |
|
|
|
// Supports most browsers and their versions. |
|
var requestMethod = el.requestFullScreen || el.webkitRequestFullScreen |
|
|| el.mozRequestFullScreen || el.msRequestFullScreen; |
|
|
|
if (requestMethod) { |
|
|
|
// Native full screen. |
|
requestMethod.call(el); |
|
|
|
} else if (typeof window.ActiveXObject !== "undefined") { |
|
|
|
// Older IE. |
|
var wscript = new ActiveXObject("WScript.Shell"); |
|
|
|
if (wscript !== null) { |
|
wscript.SendKeys("{F11}"); |
|
} |
|
} |
|
} |
|
|
|
blush = { |
|
toast: Toast, |
|
alert: Alert, |
|
poke: Poke, |
|
ok: OK, |
|
notify: Notify, |
|
ask: Ask |
|
}; |