mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
golf
This commit is contained in:
parent
6041df8370
commit
9838c2f0ce
|
@ -151,7 +151,7 @@
|
|||
readme = {{ readme|tojson }},
|
||||
ls0 = {{ ls0|tojson }};
|
||||
|
||||
document.documentElement.setAttribute("class", localStorage.theme || dtheme);
|
||||
document.documentElement.className = localStorage.theme || dtheme;
|
||||
</script>
|
||||
<script src="/.cpr/util.js?_={{ ts }}"></script>
|
||||
<script src="/.cpr/baguettebox.js?_={{ ts }}"></script>
|
||||
|
|
|
@ -2508,7 +2508,7 @@ var showfile = (function () {
|
|||
|
||||
el = el || QS('#doc>code');
|
||||
Prism.highlightElement(el);
|
||||
if (el.getAttribute('class') == 'language-ans')
|
||||
if (el.className == 'language-ans')
|
||||
r.ansify(el);
|
||||
}
|
||||
catch (ex) { }
|
||||
|
@ -2529,7 +2529,7 @@ var showfile = (function () {
|
|||
el.textContent = txt;
|
||||
el.innerHTML = '<code>' + el.innerHTML + '</code>';
|
||||
if (!window['no_prism']) {
|
||||
el.setAttribute('class', 'prism linkable-line-numbers line-numbers language-' + lang);
|
||||
el.className = 'prism linkable-line-numbers line-numbers language-' + lang;
|
||||
if (!defer)
|
||||
fun(el.firstChild);
|
||||
else
|
||||
|
@ -2659,7 +2659,7 @@ var showfile = (function () {
|
|||
};
|
||||
|
||||
var bdoc = ebi('bdoc');
|
||||
bdoc.setAttribute('class', 'line-numbers');
|
||||
bdoc.className = 'line-numbers';
|
||||
bdoc.innerHTML = (
|
||||
'<div id="hdoc" class="ghead">\n' +
|
||||
'<a href="#" class="btn" id="xdoc" tt="return to folder view$NHotkey: M">❌ close</a>\n' +
|
||||
|
@ -2854,12 +2854,12 @@ var thegrid = (function () {
|
|||
|
||||
for (var a = 0, aa = ths.length; a < aa; a++) {
|
||||
var tr = ebi(ths[a].getAttribute('ref')).closest('tr'),
|
||||
cl = tr.getAttribute('class') || '';
|
||||
cl = tr.className || '';
|
||||
|
||||
if (noq_href(ths[a]).endsWith('/'))
|
||||
cl += ' dir';
|
||||
|
||||
ths[a].setAttribute('class', cl);
|
||||
ths[a].className = cl;
|
||||
}
|
||||
var uns = QS('#ggrid a[ref="unsearch"]');
|
||||
if (uns)
|
||||
|
@ -3876,7 +3876,7 @@ var treectl = (function () {
|
|||
cl = 'par';
|
||||
}
|
||||
|
||||
links[a].setAttribute('class', cl);
|
||||
links[a].className = cl;
|
||||
links[a].onclick = treego;
|
||||
links[a].onmouseenter = nowrap ? menter : null;
|
||||
links[a].onmouseleave = nowrap ? mleave : null;
|
||||
|
@ -3943,7 +3943,7 @@ var treectl = (function () {
|
|||
return true;
|
||||
|
||||
ev(e);
|
||||
if (this.getAttribute('class') == 'hl' &&
|
||||
if (this.className == 'hl' &&
|
||||
this.previousSibling.textContent == '-') {
|
||||
treegrow.call(this.previousSibling, e);
|
||||
return;
|
||||
|
@ -4209,7 +4209,7 @@ var treectl = (function () {
|
|||
function enspin(sel) {
|
||||
despin(sel);
|
||||
var d = mknod('div');
|
||||
d.setAttribute('class', 'dumb_loader_thing');
|
||||
d.className = 'dumb_loader_thing';
|
||||
d.innerHTML = '🌲';
|
||||
var tgt = QS(sel);
|
||||
tgt.insertBefore(d, tgt.childNodes[0]);
|
||||
|
@ -4315,7 +4315,7 @@ function find_file_col(txt) {
|
|||
for (var a = 0; a < tds.length; a++) {
|
||||
var spans = tds[a].getElementsByTagName('span');
|
||||
if (spans.length && spans[0].textContent == txt) {
|
||||
min = (tds[a].getAttribute('class') || '').indexOf('min') !== -1;
|
||||
min = (tds[a].className || '').indexOf('min') !== -1;
|
||||
i = a;
|
||||
break;
|
||||
}
|
||||
|
@ -4461,7 +4461,7 @@ var filecols = (function () {
|
|||
tds = QSA('#files>tbody>tr>td:nth-child(' + (a + 1) + ')');
|
||||
|
||||
for (var b = 0, bb = tds.length; b < bb; b++)
|
||||
tds[b].setAttribute('class', cls);
|
||||
tds[b].className = cls;
|
||||
}
|
||||
if (window['tt']) {
|
||||
tt.att(ebi('hcols'));
|
||||
|
@ -4623,9 +4623,9 @@ var settheme = (function () {
|
|||
light = !!(theme.indexOf('y') + 1);
|
||||
|
||||
function freshen() {
|
||||
var cl = document.documentElement.getAttribute('class');
|
||||
var cl = document.documentElement.className;
|
||||
cl = cl.replace(/\b(light|dark|[a-z]{1,2})\b/g, '').replace(/ +/g, ' ');
|
||||
document.documentElement.setAttribute('class', cl + ' ' + theme + ' ');
|
||||
document.documentElement.className = cl + ' ' + theme + ' ';
|
||||
|
||||
pbar.drawbuf();
|
||||
pbar.drawpos();
|
||||
|
|
|
@ -140,7 +140,7 @@ var md_opt = {
|
|||
btn = document.getElementById("lightswitch"),
|
||||
f = function (e) {
|
||||
if (e) { e.preventDefault(); drk = !drk; }
|
||||
document.documentElement.setAttribute("class", drk? "z":"y");
|
||||
document.documentElement.className = drk? "z":"y";
|
||||
btn.innerHTML = "go " + (drk ? "light":"dark");
|
||||
l.light = drk? 0:1;
|
||||
};
|
||||
|
|
|
@ -278,7 +278,7 @@ function convert_markdown(md_text, dest_dom) {
|
|||
if (!txt)
|
||||
nodes[a].textContent = href;
|
||||
else if (href !== txt)
|
||||
nodes[a].setAttribute('class', 'vis');
|
||||
nodes[a].className = 'vis';
|
||||
}
|
||||
|
||||
// todo-lists (should probably be a marked extension)
|
||||
|
@ -294,7 +294,7 @@ function convert_markdown(md_text, dest_dom) {
|
|||
var clas = done ? 'done' : 'pend';
|
||||
var char = done ? 'Y' : 'N';
|
||||
|
||||
dom_li.setAttribute('class', 'task-list-item');
|
||||
dom_li.className = 'task-list-item';
|
||||
dom_li.style.listStyleType = 'none';
|
||||
var html = dom_li.innerHTML;
|
||||
dom_li.innerHTML =
|
||||
|
@ -468,11 +468,11 @@ function init_toc() {
|
|||
for (var a = 0; a < anchors.length; a++) {
|
||||
if (anchors[a].active) {
|
||||
anchors[a].active = false;
|
||||
links[a].setAttribute('class', '');
|
||||
links[a].className = '';
|
||||
}
|
||||
}
|
||||
anchors[hit].active = true;
|
||||
links[hit].setAttribute('class', 'act');
|
||||
links[hit].className = 'act';
|
||||
}
|
||||
|
||||
var pane_height = parseInt(getComputedStyle(dom_toc).height);
|
||||
|
|
|
@ -144,16 +144,16 @@ redraw = (function () {
|
|||
map_pre = genmap(dom_pre, map_pre);
|
||||
}
|
||||
function setsbs() {
|
||||
dom_wrap.setAttribute('class', '');
|
||||
dom_swrap.setAttribute('class', '');
|
||||
dom_wrap.className = '';
|
||||
dom_swrap.className = '';
|
||||
onresize();
|
||||
}
|
||||
function modetoggle() {
|
||||
var mode = dom_nsbs.innerHTML;
|
||||
dom_nsbs.innerHTML = mode == 'editor' ? 'preview' : 'editor';
|
||||
mode += ' single';
|
||||
dom_wrap.setAttribute('class', mode);
|
||||
dom_swrap.setAttribute('class', mode);
|
||||
dom_wrap.className = mode;
|
||||
dom_swrap.className = mode;
|
||||
onresize();
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ var modpoll = new Modpoll();
|
|||
|
||||
|
||||
window.onbeforeunload = function (e) {
|
||||
if ((ebi("save").getAttribute('class') + '').indexOf('disabled') >= 0)
|
||||
if ((ebi("save").className + '').indexOf('disabled') >= 0)
|
||||
return; //nice (todo)
|
||||
|
||||
e.preventDefault(); //ff
|
||||
|
@ -321,7 +321,7 @@ window.onbeforeunload = function (e) {
|
|||
function save(e) {
|
||||
if (e) e.preventDefault();
|
||||
var save_btn = ebi("save"),
|
||||
save_cls = save_btn.getAttribute('class') + '';
|
||||
save_cls = save_btn.className + '';
|
||||
|
||||
if (save_cls.indexOf('disabled') >= 0)
|
||||
return toast.inf(2, "no changes");
|
||||
|
@ -678,7 +678,7 @@ function reLastIndexOf(txt, ptn, end) {
|
|||
// table formatter
|
||||
function fmt_table(e) {
|
||||
if (e) e.preventDefault();
|
||||
//dom_tbox.setAttribute('class', '');
|
||||
//dom_tbox.className = '';
|
||||
|
||||
var txt = dom_src.value,
|
||||
ofs = dom_src.selectionStart,
|
||||
|
@ -829,7 +829,7 @@ function fmt_table(e) {
|
|||
// show unicode
|
||||
function mark_uni(e) {
|
||||
if (e) e.preventDefault();
|
||||
dom_tbox.setAttribute('class', '');
|
||||
dom_tbox.className = '';
|
||||
|
||||
var txt = dom_src.value,
|
||||
ptn = new RegExp('([^' + js_uni_whitelist + ']+)', 'g'),
|
||||
|
@ -989,14 +989,14 @@ var set_lno = (function () {
|
|||
|
||||
ebi('tools').onclick = function (e) {
|
||||
if (e) e.preventDefault();
|
||||
var is_open = dom_tbox.getAttribute('class') != 'open';
|
||||
dom_tbox.setAttribute('class', is_open ? 'open' : '');
|
||||
var is_open = dom_tbox.className != 'open';
|
||||
dom_tbox.className = is_open ? 'open' : '';
|
||||
};
|
||||
|
||||
|
||||
ebi('help').onclick = function (e) {
|
||||
if (e) e.preventDefault();
|
||||
dom_tbox.setAttribute('class', '');
|
||||
dom_tbox.className = '';
|
||||
|
||||
var dom = ebi('helpbox');
|
||||
var dtxt = dom.getElementsByTagName('textarea');
|
||||
|
|
|
@ -37,7 +37,7 @@ var lightswitch = (function () {
|
|||
drk = l.light != 1,
|
||||
f = function (e) {
|
||||
if (e) drk = !drk;
|
||||
document.documentElement.setAttribute("class", drk? "z":"y");
|
||||
document.documentElement.className = drk? "z":"y";
|
||||
l.light = drk? 0:1;
|
||||
};
|
||||
f();
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
<a href="#" id="repl">π</a>
|
||||
<script>
|
||||
|
||||
document.documentElement.setAttribute("class", localStorage.light == 1 ? "y" : "z");
|
||||
document.documentElement.className = localStorage.light == 1 ? "y" : "z";
|
||||
|
||||
</script>
|
||||
<script src="/.cpr/util.js?_={{ ts }}"></script>
|
||||
|
|
|
@ -624,11 +624,11 @@ function up2k_init(subtle) {
|
|||
|
||||
function setmsg(msg, type) {
|
||||
if (msg !== undefined) {
|
||||
ebi('u2err').setAttribute('class', type);
|
||||
ebi('u2err').className = type;
|
||||
ebi('u2err').innerHTML = msg;
|
||||
}
|
||||
else {
|
||||
ebi('u2err').setAttribute('class', '');
|
||||
ebi('u2err').className = '';
|
||||
ebi('u2err').innerHTML = '';
|
||||
}
|
||||
if (msg == suggest_up2k) {
|
||||
|
@ -1938,19 +1938,17 @@ function up2k_init(subtle) {
|
|||
|
||||
if (btn.parentNode !== parent) {
|
||||
parent.appendChild(btn);
|
||||
ebi('u2conf').setAttribute('class', wide);
|
||||
ebi('u2cards').setAttribute('class', wide);
|
||||
ebi('u2etaw').setAttribute('class', wide);
|
||||
ebi('u2conf').className = ebi('u2cards').className = ebi('u2etaw').className = wide;
|
||||
}
|
||||
|
||||
wide = write && wem > 78 ? 'ww' : wide;
|
||||
parent = ebi(wide == 'ww' && write ? 'u2c3w' : 'u2c3t');
|
||||
var its = [ebi('u2etaw'), ebi('u2cards')];
|
||||
if (its[0].parentNode !== parent) {
|
||||
ebi('u2conf').setAttribute('class', wide);
|
||||
ebi('u2conf').className = wide;
|
||||
for (var a = 0; a < 2; a++) {
|
||||
parent.appendChild(its[a]);
|
||||
its[a].setAttribute('class', wide);
|
||||
its[a].className = wide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ function clgot(el, cls) {
|
|||
if (el.classList)
|
||||
return el.classList.contains(cls);
|
||||
|
||||
var lst = (el.getAttribute('class') + '').split(/ /g);
|
||||
var lst = (el.className + '').split(/ /g);
|
||||
return has(lst, cls);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue