-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabel.mini.js
1 lines (1 loc) · 6.92 KB
/
label.mini.js
1
$.fn.extend({backspace:function(e,t){var n;return n=$.extend({callback:function(){},keypress:function(){},t:100,e:.04},t),this.each(function(){var t;t=this,$(t).queue(function(){var i,a;a=function(e,i){e?(t[/(np|x)/i.test(t.tagName)?"value":"innerHTML"]=t[/(np|x)/i.test(t.tagName)?"value":"innerHTML"].slice(0,-1),n.keypress.call(t),setTimeout(function(){a(e-1,i)},n.t)):(n.callback.call(t),$(t).dequeue())},i=function(e,a){e?(t[/(np|x)/i.test(t.tagName)?"value":"innerHTML"]+=e[0],n.keypress.call(t),setTimeout(function(){i(e.slice(1),a)},n.t)):a()},a(e)})})},typetype:function(e,t){var n;return n=$.extend({callback:function(){},keypress:function(){},t:100,e:.04},t),this.each(function(){var t;t=this,$(t).queue(function(){var i,a,c;a=function(e,i){e?(t[/(np|x)/i.test(t.tagName)?"value":"innerHTML"]=t[/(np|x)/i.test(t.tagName)?"value":"innerHTML"].slice(0,-1),n.keypress.call(t),setTimeout(function(){a(e-1,i)},n.t)):i()},i=function(e,a){e?(t[/(np|x)/i.test(t.tagName)?"value":"innerHTML"]+=e[0],n.keypress.call(t),setTimeout(function(){i(e.slice(1),a)},n.t)):a()},(c=function(u){var s,l;s=function(){return setTimeout(function(){c(u)},Math.random()*n.t*(e[u-1]===e[u]?1.6:"."===e[u-1]?12:"!"===e[u-1]?12:"?"===e[u-1]?12:"\n"===e[u-1]?12:","===e[u-1]?8:";"===e[u-1]?8:":"===e[u-1]?8:" "===e[u-1]?3:2))},l=Math.random()/n.e,e.length>=u?.3>l&&e[u-1]!==e[u]&&e.length>u+4?i(e.slice(u,u+4),function(){a(4,s)}):.7>l&&u>1&&/[A-Z]/.test(e[u-2]&&e.length>u+4)?i(e[u-1].toUpperCase()+e.slice(u,u+4),function(){a(5,s)}):.5>l&&e[u-1]!==e[u]&&e.length>u?i(e[u],function(){a(1,s)}):1>l&&e[u-1]!==e[u]&&e.length>u?i(e[u]+e[u-1],function(){a(2,s)}):.5>l&&/[A-Z]/.test(e[u])?i(e[u].toLowerCase(),function(){a(1,s)}):(t[/(np|x)/i.test(t.tagName)?"value":"innerHTML"]+=e[u-1],n.keypress.call(t),setTimeout(function(){c(u+1)},Math.random()*n.t*(e[u-1]===e[u]?1.6:"."===e[u-1]?12:"!"===e[u-1]?12:"?"===e[u-1]?12:"\n"===e[u-1]?12:","===e[u-1]?8:";"===e[u-1]?8:":"===e[u-1]?8:" "===e[u-1]?3:2))):(n.callback.call(t),$(t).dequeue())})(1)})})}});function Labels(d,e){this.cells=JSON.parse(e);this.content=d;this.colors=JSON.parse('[{"id":"0","value":"#AA6666"},{"id":"1","value":"#AA6699"},{"id":"2","value":"#666699"},{"id":"3","value":"#FF9900"},{"id":"4","value":"#AA6600"},{"id":"5","value":"#0099CC"},{"id":"6","value":"#CCCC99"},{"id":"7","value":"#CC3399"},{"id":"8","value":"#99CC00"},{"id":"9","value":"#FF6666"},{"id":"10","value":"#666600"},{"id":"11","value":"#3399CC"},{"id":"12","value":"#CC6600"},{"id":"13","value":"#999999"},{"id":"14","value":"#CCCC33"},{"id":"15","value":"#FF9933"},{"id":"16","value":"#FFFFCC"},{"id":"17","value":"#009933"},{"id":"18","value":"#0099CC"},{"id":"19","value":"#CCCCCC"},{"id":"20","value":"#FF6666"},{"id":"21","value":"#FF6600"},{"id":"22","value":"#FFFF66"},{"id":"23","value":"#009966"},{"id":"24","value":"#CC6633"},{"id":"25","value":"#FFCC99"},{"id":"26","value":"#CC6600"},{"id":"27","value":"#CC0066"},{"id":"28","value":"#009999"},{"id":"29","value":"#FFCC33"}]');this.getColor=function(b){b%=30;var a="";this.colors.forEach(function(c){if(c.id==b)return a=c.value});return a};this.load=function(){$.browser.msie?(jQuery||$("head").append("\x3cscript src\x3d'http://cdn.bootcss.com/jquery/1.8.3/jquery.js'\x3e\x3c/script\x3e"),$("head").append("\x3cscript src\x3d'http://cdn.bootcss.com/json2/20150503/json2.js'\x3e\x3c/script\x3e"),$("head").append("\x3cstyle type\x3d'text/css'\x3e.button{color:#666;background-color:#EEE;border-color:#EEE;font-weight:300;font-size:14px;font-family:'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;text-decoration:none;text-align:center;line-height:25px;height:25px;padding:0 10px;margin:3px;display:inline-block;appearance:none;cursor:pointer;border:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:.3s;transition-duration:.3s}.button:visited{color:#666}.button:focus,.button:hover{background-color:#f6f6f6;text-decoration:none;outline:0}.button.active,.button.is-active,.button:active{text-shadow:0 1px 0 rgba(255,255,255,.3);text-decoration:none;background-color:#eee;border-color:#cfcfcf;color:#d4d4d4;-webkit-transition-duration:0s;transition-duration:0s;-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,.2);box-shadow:inset 0 1px 3px rgba(0,0,0,.2)}.button-primary{background-color:#1B9AF7;border-color:#1B9AF7;color:#FFF}.button-primary:visited{color:#FFF}.button-primary:focus,.button-primary:hover{background-color:#4cb0f9;border-color:#4cb0f9;color:#FFF}.button-primary.active,.button-primary.is-active,.button-primary:active{background-color:#2798eb;border-color:#2798eb;color:#0880d7}\x3c/style\x3e")):(jQuery||document.write("\x3cscript src\x3d'http://cdn.bootcss.com/jquery/1.8.3/jquery.js'\x3e\x3c/script\x3e"),document.write("\x3cscript src\x3d'http://cdn.bootcss.com/json2/20150503/json2.js'\x3e\x3c/script\x3e"),document.write("\x3cstyle type\x3d'text/css'\x3e.button{color:#666;background-color:#EEE;border-color:#EEE;font-weight:300;font-size:14px;font-family:'Helvetica Neue Light','Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif;text-decoration:none;text-align:center;line-height:25px;height:25px;padding:0 10px;margin:3px;display:inline-block;appearance:none;cursor:pointer;border:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:.3s;transition-duration:.3s}.button:visited{color:#666}.button:focus,.button:hover{background-color:#f6f6f6;text-decoration:none;outline:0}.button.active,.button.is-active,.button:active{text-shadow:0 1px 0 rgba(255,255,255,.3);text-decoration:none;background-color:#eee;border-color:#cfcfcf;color:#d4d4d4;-webkit-transition-duration:0s;transition-duration:0s;-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,.2);box-shadow:inset 0 1px 3px rgba(0,0,0,.2)}.button-primary{background-color:#1B9AF7;border-color:#1B9AF7;color:#FFF}.button-primary:visited{color:#FFF}.button-primary:focus,.button-primary:hover{background-color:#4cb0f9;border-color:#4cb0f9;color:#FFF}.button-primary.active,.button-primary.is-active,.button-primary:active{background-color:#2798eb;border-color:#2798eb;color:#0880d7}\x3c/style\x3e"))};this.init=function(){var b=this,a=b.rnd(0,30);this.cells.forEach(function(c){c.id=a++;$(".labels").append('\x3ca onclick\x3d"label.select('+c.id+')" class\x3d"button button-primary" style\x3d"background-color:'+b.getColor(a)+';"\x3e'+c.value+"\x3c/a\x3e",function(a,b){})})};this.select=function(b){var a="";this.cells.forEach(function(c){c.id==b&&(a=c.key)});$.browser.msie?($("#"+this.content).focus(),a="{{}"+a+"{}}",(new ActiveXObject("WScript.Shell")).SendKeys(a)):($("#"+this.content).typetype("{"+a+"}",{callback:function(){this.typetype=void 0},t:10,e:0}),$("#"+this.content).focus())};this.sleep=function(b){var a=new Date;for(b=a.getTime()+b;!(a=new Date,a.getTime()>b););};this.rnd=function(b,a){return Math.floor(Math.random()*(a-b)+b)};this.load()};