i/jkp.js
by webproger on 2022-03-24
ᐥ<script src='/i/jkp.js'></script>ᐥ
var jkp = {
    insert: function(s) {
        document.getElementsByTagName('textarea')[0].focus();
        document.execCommand('insertText',false,s);
    }
    ,hide: function(i) {
        document.getElementById(i).style.visibility='hidden';
    }
    ,show: function(i) {
        document.getElementById(i).style.visibility='visible';
    }
    ,start : function() {
        var a,d,i,s,t;
        d = document.createElement("div");
        d.setAttribute("id","jkpb");
        d.style.position = "fixed";
        d.style.left = "0px";
        d.style.top  = "0px";
        d.style.backgroundColor  = "silver";
        d.style.padding = "3px";
        d.style.textAlign  = "left";
        d.style.lineHeight = "2.5em";
        d.style.zIndex = "1000";
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("√");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.show('jkpm');");
            d.appendChild(s);
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("∀");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.show('jkpl');");
            d.appendChild(s);
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("ᵢ");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.show('jkps');");
            d.appendChild(s);
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("φ");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.show('jkpg');");
            d.appendChild(s);
        document.getElementsByTagName('body')[0].appendChild(d);
        // --------------------------------------------------------------------------------- math
        d = document.createElement("div");
        d.setAttribute("id","jkpm");
        d.style.position = "fixed";
        d.style.left = "0px";
        d.style.top  = "0px";
        d.style.width = "100%";
        d.style.backgroundColor  = "silver";
        d.style.padding = "5px";
        d.style.textAlign  = "left";
        d.style.lineHeight = "2.5em";
        d.style.wordBreak = "break-all";
        d.style.zIndex = "1001";
        d.style.visibility = "hidden";
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
              t = document.createTextNode("≪");
              s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpm');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("∀");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpm');jkp.show('jkpl');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("ᵢ");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpm');jkp.show('jkps');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("φ");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpm');jkp.show('jkpg');");
            d.appendChild(s);
            
            a = new Array('「','Ꝑ','Ꞓ','Ƚ','Σ','Π','Ƨ','→','」','[','|','∠',']','(',')','{','}','+','−','±','×','·','!','/','⸤','⸥','⸢','⸣','∘','⌝','²','˄','˅','√','⍻','ᐁ','ᐃ','↑','↓','→','←','↗','↙','=','≈','≠','<','>','≤','≥','∞','π');
            for(i=0; i<a.length; i++) {  
                s = document.createElement("span");
                s.style.padding = "5px";
                s.style.border = "1px solid whitesmoke";
                s.style.margin = "2px";
                    t = document.createTextNode(a[i]);
                    s.appendChild(t);
                s.setAttribute("onclick","jkp.insert('"+a[i]+"');");
                d.appendChild(s);
            }
        document.getElementsByTagName('body')[0].appendChild(d);
        // -------------------------------------------------------------------------------- logic
        d = document.createElement("div");
        d.setAttribute("id","jkpl");
        d.style.position = "fixed";
        d.style.left = "0px";
        d.style.top  = "0px";
        d.style.width = "100%";
        d.style.backgroundColor  = "silver";
        d.style.padding = "5px";
        d.style.textAlign  = "left";
        d.style.lineHeight = "2.5em";
        d.style.wordBreak = "break-all";
        d.style.zIndex = "1001";
        d.style.visibility = "hidden";
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
              t = document.createTextNode("≪");
              s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpl');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("√");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpl');jkp.show('jkpm');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("ᵢ");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpl');jkp.show('jkps');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("φ");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpl');jkp.show('jkpg');");
            d.appendChild(s);
            
            a = new Array('∀','∃','∧','∨','⇒','∈','∉','⊂','⊃','⋂','⋃','ℕ','ℤ','ℚ','ℝ','ℂ','ᐥ','┆','┄','♡','♢','♤','♧','▷','▶','✓','➔','⟐','_','▐');
            for(i=0; i<a.length; i++) {  
                s = document.createElement("span");
                s.style.padding = "5px";
                s.style.border = "1px solid whitesmoke";
                s.style.margin = "2px";
                    t = document.createTextNode(a[i]);
                    s.appendChild(t);
                s.setAttribute("onclick","jkp.insert('"+a[i]+"');");
                d.appendChild(s);
            }
        document.getElementsByTagName('body')[0].appendChild(d);
        // -------------------------------------------------------------------- super & subscript
        d = document.createElement("div");
        d.setAttribute("id","jkps");
        d.style.position = "fixed";
        d.style.left = "0px";
        d.style.top  = "0px";
        d.style.width = "100%";
        d.style.backgroundColor  = "silver";
        d.style.padding = "5px";
        d.style.textAlign  = "left";
        d.style.lineHeight = "2.5em";
        d.style.wordBreak = "break-all";
        d.style.zIndex = "1001";
        d.style.visibility = "hidden";
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
              t = document.createTextNode("≪");
              s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkps');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("√");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkps');jkp.show('jkpm');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("∀");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkps');jkp.show('jkpl');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("φ");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkps');jkp.show('jkpg');");
            d.appendChild(s);
            
            a = new Array('⁰','¹','²','³','⁴','⁵','⁶','⁷','⁸','⁹','ⁿ','⁺','⁻','❶','❷','❸','❹','❺','❻','❼','❽','❾','❿','①','②','③','④','⑤','⑥','⑦','⑧','⑨','⑩','₀','₁','₂','₃','₄','₅','₆','₇','₈','₉','ₙ','ᵢ','ⱼ','ₖ','₊','₋');
            for(i=0; i<a.length; i++) {  
                s = document.createElement("span");
                s.style.padding = "5px";
                s.style.border = "1px solid whitesmoke";
                s.style.margin = "2px";
                    t = document.createTextNode(a[i]);
                    s.appendChild(t);
                s.setAttribute("onclick","jkp.insert('"+a[i]+"');");
                d.appendChild(s);
            }
        document.getElementsByTagName('body')[0].appendChild(d);
        // -------------------------------------------------------------------------------- Greek
        d = document.createElement("div");
        d.setAttribute("id","jkpg");
        d.style.position = "fixed";
        d.style.left = "0px";
        d.style.top  = "0px";
        d.style.width = "100%";
        d.style.backgroundColor  = "silver";
        d.style.padding = "5px";
        d.style.textAlign  = "left";
        d.style.lineHeight = "2.5em";
        d.style.wordBreak = "break-all";
        d.style.zIndex = "1001";
        d.style.visibility = "hidden";
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
              t = document.createTextNode("≪");
              s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpg');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("√");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpg');jkp.show('jkpm');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("∀");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpg');jkp.show('jkpl');");
            d.appendChild(s);
            
            s = document.createElement("span");
            s.style.padding = "5px";
            s.style.border = "1px solid black";
            s.style.margin = "2px";
                t = document.createTextNode("ᵢ");
                s.appendChild(t);
            s.setAttribute("onclick","jkp.hide('jkpg');jkp.show('jkps');");
            d.appendChild(s);
            
            a = new Array('Α','α','Β','β','Γ','γ','Δ','δ','Ε','ε','Ζ','ζ','Η','η','Θ','θ','Ι','ι','Κ','κ','Λ','λ','Μ','μ','Ν','ν','Ξ','ξ','Ο','ο','Π','π','Ρ','ρ','ϱ','Σ','σ','Τ','τ','Υ','υ','Φ','φ','Χ','χ','Ψ','ψ','Ω','ω');
            for(i=0; i<a.length; i++) {  
                s = document.createElement("span");
                s.style.padding = "5px";
                s.style.border = "1px solid whitesmoke";
                s.style.margin = "2px";
                    t = document.createTextNode(a[i]);
                    s.appendChild(t);
                s.setAttribute("onclick","jkp.insert('"+a[i]+"');");
                d.appendChild(s);
            }
        document.getElementsByTagName('body')[0].appendChild(d);

    }
    ,attach: function(o,t,f) {
        if(o.addEventListener) { o.addEventListener(t,f); }
        else if(o.attachEvent) { o.attachEvent('on'+t,f); }
        else o.onclick = f;
    }
}
jkp.attach(window,'load',jkp.start);