This commit is contained in:
ed 2022-07-15 02:07:13 +02:00
parent 8a5d0399dd
commit aa1c08962c
7 changed files with 34 additions and 46 deletions

View file

@ -229,7 +229,7 @@ window.baguetteBox = (function () {
['C', 'video: toggle auto-next'], ['C', 'video: toggle auto-next'],
['<code>[</code>, <code>]</code>', 'video: loop start / end'], ['<code>[</code>, <code>]</code>', 'video: loop start / end'],
], ],
d = mknod('table'), d = mknod('table', 'bbox-halp'),
html = ['<tbody>']; html = ['<tbody>'];
for (var a = 0; a < list.length; a++) for (var a = 0; a < list.length; a++)
@ -238,7 +238,6 @@ window.baguetteBox = (function () {
html.push('<tr><td colspan="2">tap middle of img to hide btns</td></tr>'); html.push('<tr><td colspan="2">tap middle of img to hide btns</td></tr>');
html.push('<tr><td colspan="2">tap left/right sides for prev/next</td></tr>'); html.push('<tr><td colspan="2">tap left/right sides for prev/next</td></tr>');
d.innerHTML = html.join('\n') + '</tbody>'; d.innerHTML = html.join('\n') + '</tbody>';
d.setAttribute('id', 'bbox-halp');
d.onclick = function () { d.onclick = function () {
overlay.removeChild(d); overlay.removeChild(d);
}; };
@ -487,9 +486,8 @@ window.baguetteBox = (function () {
var imagesFiguresIds = []; var imagesFiguresIds = [];
var imagesCaptionsIds = []; var imagesCaptionsIds = [];
for (var i = 0, fullImage; i < gallery.length; i++) { for (var i = 0, fullImage; i < gallery.length; i++) {
fullImage = mknod('div'); fullImage = mknod('div', 'baguette-img-' + i);
fullImage.className = 'full-image'; fullImage.className = 'full-image';
fullImage.id = 'baguette-img-' + i;
imagesElements.push(fullImage); imagesElements.push(fullImage);
imagesFiguresIds.push('bbox-figure-' + i); imagesFiguresIds.push('bbox-figure-' + i);
@ -631,16 +629,14 @@ window.baguetteBox = (function () {
if (is_vid && index != currentIndex) if (is_vid && index != currentIndex)
return; // no preload return; // no preload
var figure = mknod('figure'); var figure = mknod('figure', 'bbox-figure-' + index);
figure.id = 'bbox-figure-' + index;
figure.innerHTML = '<div class="bbox-spinner">' + figure.innerHTML = '<div class="bbox-spinner">' +
'<div class="bbox-double-bounce1"></div>' + '<div class="bbox-double-bounce1"></div>' +
'<div class="bbox-double-bounce2"></div>' + '<div class="bbox-double-bounce2"></div>' +
'</div>'; '</div>';
if (options.captions && imageCaption) { if (options.captions && imageCaption) {
var figcaption = mknod('figcaption'); var figcaption = mknod('figcaption', 'bbox-figcaption-' + index);
figcaption.id = 'bbox-figcaption-' + index;
figcaption.innerHTML = imageCaption; figcaption.innerHTML = imageCaption;
figure.appendChild(figcaption); figure.appendChild(figcaption);
} }

View file

@ -2415,8 +2415,7 @@ function eval_hash() {
}; };
})(a); })(a);
var d = mknod('div'); var d = mknod('div', 'acc_info');
d.setAttribute('id', 'acc_info');
document.body.insertBefore(d, ebi('ops')); document.body.insertBefore(d, ebi('ops'));
})(); })();
@ -2681,8 +2680,7 @@ var fileman = (function () {
var rui = ebi('rui'); var rui = ebi('rui');
if (!rui) { if (!rui) {
rui = mknod('div'); rui = mknod('div', 'rui');
rui.setAttribute('id', 'rui');
document.body.appendChild(rui); document.body.appendChild(rui);
} }
@ -3165,10 +3163,9 @@ var showfile = (function () {
return; return;
qsr('#prism_css'); qsr('#prism_css');
var el = mknod('link'); var el = mknod('link', 'prism_css');
el.rel = 'stylesheet'; el.rel = 'stylesheet';
el.href = '/.cpr/deps/prism' + (light ? '' : 'd') + '.css'; el.href = '/.cpr/deps/prism' + (light ? '' : 'd') + '.css';
el.setAttribute('id', 'prism_css');
document.head.appendChild(el); document.head.appendChild(el);
}; };
@ -3282,8 +3279,7 @@ var showfile = (function () {
fun = function (el) { }; fun = function (el) { };
qsr('#doc'); qsr('#doc');
var el = mknod('pre'); var el = mknod('pre', 'doc');
el.setAttribute('id', 'doc');
el.setAttribute('tabindex', '0'); el.setAttribute('tabindex', '0');
clmod(ebi('wrap'), 'doc', !is_md); clmod(ebi('wrap'), 'doc', !is_md);
if (is_md) { if (is_md) {
@ -3311,9 +3307,8 @@ var showfile = (function () {
hfun(get_evpath() + '?doc=' + url.split('/').pop()); hfun(get_evpath() + '?doc=' + url.split('/').pop());
qsr('#docname'); qsr('#docname');
el = mknod('span'); el = mknod('span', 'docname');
el.textContent = tname; el.textContent = tname;
el.setAttribute('id', 'docname');
ebi('path').appendChild(el); ebi('path').appendChild(el);
r.updtree(); r.updtree();
@ -3448,9 +3443,8 @@ var showfile = (function () {
var thegrid = (function () { var thegrid = (function () {
var lfiles = ebi('files'), var lfiles = ebi('files'),
gfiles = mknod('div'); gfiles = mknod('div', 'gfiles');
gfiles.setAttribute('id', 'gfiles');
gfiles.style.display = 'none'; gfiles.style.display = 'none';
gfiles.innerHTML = ( gfiles.innerHTML = (
'<div id="ghead" class="ghead">' + '<div id="ghead" class="ghead">' +

View file

@ -13,8 +13,7 @@ audio_eq.apply = function () {
var can = ebi('fft_can'); var can = ebi('fft_can');
if (!can) { if (!can) {
can = mknod('canvas'); can = mknod('canvas', 'fft_can');
can.setAttribute('id', 'fft_can');
can.style.cssText = 'position:absolute;left:0;bottom:5em;width:' + w + 'px;height:' + h + 'px;z-index:9001'; can.style.cssText = 'position:absolute;left:0;bottom:5em;width:' + w + 'px;height:' + h + 'px;z-index:9001';
document.body.appendChild(can); document.body.appendChild(can);
can.width = w; can.width = w;

View file

@ -173,8 +173,7 @@ md_plug_err = function (ex, js) {
o.textContent = lns[ln - 1]; o.textContent = lns[ln - 1];
} }
} }
var errbox = mknod('div'); var errbox = mknod('div', 'md_errbox');
errbox.setAttribute('id', 'md_errbox');
errbox.style.cssText = 'position:absolute;top:0;left:0;padding:1em .5em;background:#2b2b2b;color:#fc5' errbox.style.cssText = 'position:absolute;top:0;left:0;padding:1em .5em;background:#2b2b2b;color:#fc5'
errbox.textContent = msg; errbox.textContent = msg;
errbox.onclick = function () { errbox.onclick = function () {

View file

@ -16,8 +16,7 @@ var dom_sbs = ebi('sbs');
var dom_nsbs = ebi('nsbs'); var dom_nsbs = ebi('nsbs');
var dom_tbox = ebi('toolsbox'); var dom_tbox = ebi('toolsbox');
var dom_ref = (function () { var dom_ref = (function () {
var d = mknod('div'); var d = mknod('div', 'mtr');
d.setAttribute('id', 'mtr');
dom_swrap.appendChild(d); dom_swrap.appendChild(d);
d = ebi('mtr'); d = ebi('mtr');
// hide behind the textarea (offsetTop is not computed if display:none) // hide behind the textarea (offsetTop is not computed if display:none)

View file

@ -478,8 +478,7 @@ function U2pvis(act, btns, uc) {
if (as_html) if (as_html)
return '<tr id="f' + nfile + '">' + ret + '</tr>'; return '<tr id="f' + nfile + '">' + ret + '</tr>';
var obj = mknod('tr'); var obj = mknod('tr', 'f' + nfile);
obj.setAttribute('id', 'f' + nfile);
obj.innerHTML = ret; obj.innerHTML = ret;
return obj; return obj;
}; };
@ -2200,11 +2199,6 @@ function up2k_init(subtle) {
localStorage.removeItem('u2sort'); localStorage.removeItem('u2sort');
} }
function nop(e) {
ev(e);
this.click();
}
ebi('nthread_add').onclick = function (e) { ebi('nthread_add').onclick = function (e) {
ev(e); ev(e);
bumpthread(1); bumpthread(1);

View file

@ -16,10 +16,18 @@ var wah = '',
var ebi = document.getElementById.bind(document), var ebi = document.getElementById.bind(document),
QS = document.querySelector.bind(document), QS = document.querySelector.bind(document),
QSA = document.querySelectorAll.bind(document), QSA = document.querySelectorAll.bind(document),
mknod = document.createElement.bind(document),
XHR = XMLHttpRequest; XHR = XMLHttpRequest;
function mknod(et, eid) {
var ret = document.createElement(et);
if (eid)
ret.id = eid;
return ret;
}
function qsr(sel) { function qsr(sel) {
var el = QS(sel); var el = QS(sel);
if (el) if (el)
@ -160,8 +168,7 @@ function vis_exh(msg, url, lineNo, columnNo, error) {
try { try {
var exbox = ebi('exbox'); var exbox = ebi('exbox');
if (!exbox) { if (!exbox) {
exbox = mknod('div'); exbox = mknod('div', 'exbox');
exbox.setAttribute('id', 'exbox');
document.body.appendChild(exbox); document.body.appendChild(exbox);
var s = mknod('style'); var s = mknod('style');
@ -222,6 +229,11 @@ function ev(e) {
} }
function noope(e) {
ev(e);
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
if (!String.prototype.endsWith) if (!String.prototype.endsWith)
String.prototype.endsWith = function (search, this_len) { String.prototype.endsWith = function (search, this_len) {
@ -866,8 +878,8 @@ var timer = (function () {
var tt = (function () { var tt = (function () {
var r = { var r = {
"tt": mknod("div"), "tt": mknod("div", 'tt'),
"th": mknod("div"), "th": mknod("div", 'tth'),
"en": true, "en": true,
"el": null, "el": null,
"skip": false, "skip": false,
@ -875,8 +887,6 @@ var tt = (function () {
}; };
r.th.innerHTML = '?'; r.th.innerHTML = '?';
r.tt.setAttribute('id', 'tt');
r.th.setAttribute('id', 'tth');
document.body.appendChild(r.tt); document.body.appendChild(r.tt);
document.body.appendChild(r.th); document.body.appendChild(r.th);
@ -1045,9 +1055,8 @@ var toast = (function () {
var r = {}, var r = {},
te = null, te = null,
scrolling = false, scrolling = false,
obj = mknod('div'); obj = mknod('div', 'toast');
obj.setAttribute('id', 'toast');
document.body.appendChild(obj); document.body.appendChild(obj);
r.visible = false; r.visible = false;
r.txt = null; r.txt = null;
@ -1130,8 +1139,7 @@ var modal = (function () {
r.busy = false; r.busy = false;
r.show = function (html) { r.show = function (html) {
o = mknod('div'); o = mknod('div', 'modal');
o.setAttribute('id', 'modal');
o.innerHTML = '<table><tr><td><div id="modalc">' + html + '</div></td></tr></table>'; o.innerHTML = '<table><tr><td><div id="modalc">' + html + '</div></td></tr></table>';
document.body.appendChild(o); document.body.appendChild(o);
document.addEventListener('keydown', onkey); document.addEventListener('keydown', onkey);
@ -1497,9 +1505,8 @@ function xhrchk(xhr, prefix, e404) {
fun = toast.warn; fun = toast.warn;
qsr('#cf_frame'); qsr('#cf_frame');
var fr = mknod('iframe'); var fr = mknod('iframe', 'cf_frame');
fr.src = '/?cf_challenge'; fr.src = '/?cf_challenge';
fr.setAttribute('id', 'cf_frame');
document.body.appendChild(fr); document.body.appendChild(fr);
} }