-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypelink.min.js
More file actions
6 lines (6 loc) · 3.15 KB
/
typelink.min.js
File metadata and controls
6 lines (6 loc) · 3.15 KB
1
2
3
4
5
6
(function(){var o=window.onload;window.onload=function(){function h(){g=b=null;g=-1;l();i()}function p(){i();if(-1!=e&&(b=null,null!=g)){h();var a=q[e],c=r[e];"text"==m[e].type&&m[e].focus();null!=a&&1<a.length&&(window.location=a);null!=c&&1<c.length&&eval(c)()}}function l(){if(null!=b)if(s())t();else{i();if(null!=b){var a=b.length;b=b.slice(a-1,a)}s()?t():i()}}function s(){var a=!1,c=!1,u=0;v.forEach(function(d){d==b?c=!0:d.startsWith(b)&&null!=b&&(a=!0,g=d,e=u,2<j[e].length&&g.toLowerCase()!=j[e].toLowerCase()?
document.getElementById("typeLinkLabel").innerHTML="<b>"+d.slice(0,b.length)+"</b>"+d.slice(b.length,d.length)+" ("+j[e]+")":document.getElementById("typeLinkLabel").innerHTML="<b>"+d.slice(0,b.length)+"</b>"+d.slice(b.length,d.length));u++});return c?(p(),!1):a?!0:!1}function i(){document.getElementById("typeLinkLabel").style.visibility="hidden";document.getElementById("typeLinkLabelBk").style.visibility="hidden"}function t(){document.getElementById("typeLinkLabel").style.visibility="visible";document.getElementById("typeLinkLabelBk").style.visibility=
"visible"}String.prototype.startsWith=function(a){return this.match("^"+a)==a};Array.prototype.contains=function(a){for(var c=this.length;c--;)if(this[c]===a)return!0;return!1};var b=null,g=null,e=null,k=document.body,n,v=[],j=[],q=[],r=[],m=[],w=["text","select-one"];(function(){var a=document.createElement("div");a.id="typeLinkLabelBk";a.setAttribute("align","center");a.className="typeLinkBk";document.body.appendChild(a);var c=document.createElement("div");c.id="typeLinkLabel";c.setAttribute("align",
"center");c.className="typeLinkHint";a.appendChild(c)})();(function(){for(var a=document.getElementsByClassName("typelink"),c=0;c<a.length;c++){var b=a[c].dataset.hint+"";if("undefined"==b)if(1>=a[c].innerHTML.length)continue;else b=a[c].innerHTML+"";for(var b=b.split("|"),d=0;d<b.length;d++)j.push(a[c].innerHTML),v.push(b[d].toLowerCase()),q.push(a[c].href),r.push(a[c].getAttribute("onclick")),m.push(a[c])}})();l();k.onkeypress=function(a){if(!w.contains(document.activeElement.type)){var a=a||window.event,
c="number"==typeof a.which?a.which:a.keyCode;if(46==a.keyCode)h();else if(0<c){switch(a.which){case 8:null!=b&&(b=b.slice(0,b.length-1),0==b.length&&h());break;case 13:p();break;default:null==b&&(b=""),b+=String.fromCharCode(c).toLowerCase()}null!=n&&clearTimeout(n);n=setTimeout(function(){h.call()},2E3);l()}}};var k="#typeLinkLabel{position:fixed;\ttext-overflow:ellipsis;\toverflow: hidden;\twidth:20%;\tleft: 40%;\tpadding: 15px;\ttop:0;\t\tvisibility: hidden;\tfont-size: 18px;\tcolor: #222;\ttext-shadow: 0px 1px 1px #888;font-family: 'Arial';} #typeLinkLabelBk{position:fixed; background-color: #666;opacity: 0.94; height:30px; width:20%;\tleft: 40%;\tpadding: 14px;\ttop:0; visibility: hidden;\toverflow: auto;-webkit-box-shadow: 0px 2px 3px #555;\t-moz-box-shadow: 0px 2px 3px #555;\t-webkit-border-radius: 4px;border-radius: 4px;\t-moz-border-radius: 4px;}",
x=document.getElementsByTagName("head")[0],f=document.createElement("style");f.type="text/css";f.media="screen";f.styleSheet?f.styleSheet.cssText=k:f.appendChild(document.createTextNode(k));x.appendChild(f);"function"===typeof o&&o.apply(this,arguments)}})();