';Dom.add(closebox,box);let msgbox = Dom.make('div');msgbox.innerHTML = s;Dom.add(msgbox,box);let scover = Dom.make('div');scover.id = 'alertboxscreen';scover.style.display='block';scover.style.position='absolute';scover.style.zIndex='98';scover.style.left='0px';scover.style.top='0px';scover.style.width='100%';scover.style.height='100%';scover.style.backgroundColor='rgba(0,0,0,.25)';scover.onclick=removeAlertBox;Dom.add(scover,d.body);let divwidth = box.offsetWidth;let divheight = box.offsetHeight;let topposition = parseInt(((viewheight-divheight)/2)+scrolltop);let leftposition = parseInt(((viewwidth-divwidth)/2)+scrollleft);if(topposition<0) topposition = 0;if(leftposition<0) leftposition = 0;box.style.top = topposition + "px";box.style.left = leftposition + "px";}/******** Numpad ***************/var numpad = {hwrap: null,hpad: null,hdisplay: null,hbwrap: null,hbuttons: {},init: () => {numpad.hwrap = document.createElement("div");numpad.hwrap.id = "numWrap";numpad.hpad = document.createElement("div");numpad.hpad.id = "numPad";numpad.hwrap.appendChild(numpad.hpad);numpad.hdisplay = document.createElement("input");numpad.hdisplay.id = "numDisplay";numpad.hdisplay.type = "text";numpad.hdisplay.disabled = true;numpad.hdisplay.value = "";numpad.hpad.appendChild(numpad.hdisplay);numpad.hbwrap = document.createElement("div");numpad.hbwrap.id = "numBWrap";numpad.hpad.appendChild(numpad.hbwrap);let buttonator = (txt, css, fn) => {let button = document.createElement("div");button.innerHTML = txt;button.classList.add(css);button.onclick = fn;numpad.hbwrap.appendChild(button);numpad.hbuttons[txt] = button;};for (let i=7; i<=9; i++) { buttonator(i, "num", () => { numpad.digit(i); }); }buttonator("⤆", "del", numpad.delete);for (let i=4; i<=6; i++) { buttonator(i, "num", () => { numpad.digit(i); }); }buttonator("Borrar", "clr", numpad.reset);for (let i=1; i<=3; i++) { buttonator(i, "num", () => { numpad.digit(i); }); }buttonator("Cerrar", "cx", () => { numpad.hide(1); });buttonator(".", "dot", numpad.dot);/*buttonator("✔", "ok", numpad.select);*/buttonator("OK", "zero", numpad.select);/*actually OK*//*buttonator("⤆", "del", numpad.delete);for (let i=4; i<=6; i++) { buttonator(i, "num", () => { numpad.digit(i); }); }buttonator("C", "clr", numpad.reset);for (let i=1; i<=3; i++) { buttonator(i, "num", () => { numpad.digit(i); }); }buttonator("✖", "cx", () => { numpad.hide(1); });buttonator(".", "dot", numpad.dot);buttonator("✔", "zero", numpad.select);*/d.body.appendChild(numpad.hwrap);},nowTarget: null,nowMax: 0,digit: (num) => {let current = numpad.hdisplay.value;if (current.length < numpad.nowMax) {if (current==""){numpad.hdisplay.value = num;}else{numpad.hdisplay.value += num;}}},dot: () => {if (numpad.hdisplay.value.indexOf(".") == -1) {if (numpad.hdisplay.value==""){numpad.hdisplay.value = ".";}else{numpad.hdisplay.value += ".";}}},delete: () => {var length = numpad.hdisplay.value.length;if (length == 1){numpad.hdisplay.value = '';}else{numpad.hdisplay.value = numpad.hdisplay.value.substring(0, length - 1);}},reset: () => {numpad.hdisplay.value = "";},select: () => {numpad.nowTarget.value = numpad.hdisplay.value;numpad.nowTarget.focus();numpad.hide();numpad.nowTarget.dispatchEvent(new Event("numpadok"));numpad.nowTarget.focus();},attach: (opt) => {/*OPTIONStarget: required, target field.max: optional, maximum number of characters. Default 255.decimal: optional, allow decimal? Default true.onselect: optional, function to call after selecting number.oncancel: optional, function to call after canceling.*/if (opt.max === undefined){opt.max = 255;}if (opt.decimal === undefined){opt.decimal = true;}opt.target.readOnly = true;opt.target.dataset.max = opt.max;opt.target.dataset.decimal = opt.decimal;opt.target.addEventListener("click", () => { numpad.show(opt.target); });if (opt.onselect){opt.target.addEventListener("numpadok", opt.onselect);}if (opt.oncancel){opt.target.addEventListener("numpadcx", opt.oncancel);}},show: (target) => {let cv = target.value;numpad.hdisplay.value = cv;numpad.nowMax = target.dataset.max;if (target.dataset.decimal == "true"){numpad.hbwrap.classList.remove("noDec");}else{numpad.hbwrap.classList.add("noDec");}numpad.nowTarget = target;numpad.hwrap.classList.add("open");},hide: (manual) => {if (manual){numpad.nowTarget.dispatchEvent(new Event("numpadcx"));}numpad.hwrap.classList.remove("open");}};window.addEventListener("DOMContentLoaded", numpad.init);