See espterm.github.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
47 KiB

7 years ago
'use strict';var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a};(function(){'use strict';function a(){var a;for(p=!0,a=0;a<n.length;a+=1)n[a]();n=[]}function b(){var b;for(q=!0,p||a(),b=0;b<o.length;b+=1)o[b]();o=[]}function c(a,b){var c;for(c=b.length-1;0<=c;c-=1)a(b[c])}function e(a){return a.replace(/-\w/g,function(a){return a.charAt(1).toUpperCase()})}function f(a,b){return a.currentStyle?a.currentStyle[e(b)]:d.getComputedStyle?d.getComputedStyle(a,null).getPropertyValue(b):null}function g(a,b){return encodeURIComponent(a).replace(/%20/g,'+')+'='+encodeURIComponent(b).replace(/%20/g,'+')}function h(a,b,c){try{a.style[e(b)]=c}catch(a){}}function i(a){a.style.display='','none'===f(a,'display')&&(a.style.display='block')}function j(a){var b,d,e,f='';if(a.constructor===Object){for(b in a)if(a.hasOwnProperty(b))if(a[b].constructor===Array)for(d=0;d<a[b].length;d+=1)f+='&'+g(b,a[b][d]);else f+='&'+g(b,a[b]);}else c(function(a){if('FORM'===a.nodeName)for(d=0;d<a.elements.length;d+=1)if(b=a.elements[d],!b.disabled)switch(b.type){case'button':case'image':case'file':case'submit':case'reset':break;case'select-one':0<b.length&&(f+='&'+g(b.name,b.value));break;case'select-multiple':for(e=0;e<b.length;e+=1)b[e].selected&&(f+='&'+g(b.name,b[e].value));break;case'checkbox':case'radio':b.checked&&(f+='&'+g(b.name,b.value));break;default:f+='&'+g(b.name,b.value);}},a);return 0<f.length?f.substring(1):''}function k(a,b,d){var e,f,g=!1;return a&&(e=a.split(/\s+/),c(function(a){for(f=0;f<e.length;f+=1){var c=e[f];if('remove'===b)a.classList.remove(c);else if('add'===b)a.classList.add(c);else if('toggle'===b)a.classList.toggle(c);else if('has'===b&&a.classList.contains(c)){g=!0;break}}},d)),g}function l(a,b,d){var e,f;a&&c(function(c){for(e=r.createElement('div'),e.innerHTML=a;null!==(f=e.lastChild);)try{'before'===b?c.parentNode.insertBefore(f,c):'after'===b?c.parentNode.insertBefore(f,c.nextSibling):'append'===b?c.appendChild(f):'prepend'===b&&c.insertBefore(f,c.firstChild)}catch(a){break}},d)}function m(a){var b,g,j,n=[],o=!1;if(a)if(a.nodeType&&1===a.nodeType)n=[a];else if('object'===('undefined'==typeof a?'undefined':_typeof(a)))o='number'!=typeof a.length,n=a;else if('string'==typeof a)for(g=r.querySelectorAll(a),j=0;j<g.length;j+=1)n[j]=g[j];return b=o?{}:n,b.each=function(a){return'function'==typeof a&&c(function(b){return a.apply(b,arguments)},n),b},b.first=function(){return m(n.shift())},b.last=function(){return m(n.pop())},b.odd=function(){var a,b=[];for(a=0;a<n.length;a+=2)b.push(n[a]);return m(b)},b.even=function(){var a,b=[];for(a=1;a<n.length;a+=2)b.push(n[a]);return m(b)},b.hide=function(){return c(function(a){a.style.display='none'},n),b},b.show=function(){return c(function(a){i(a)},n),b},b.toggle=function(a){return'undefined'==typeof a?c(function(a){'none'===f(a,'display')?i(a):a.style.display='none'},n):a?b.show():b.hide(),b},b.remove=function(){return c(function(a){try{a.parentNode.removeChild(a)}catch(a){}},n),m()},b.css=function(a,d){if(a){if(d||''===d)return c(function(b){h(b,a,d)},n),b;if(n[0]){if(n[0].style[e(a)])return n[0].style[e(a)];if(f(n[0],a))return f(n[0],a)}}},b.getClass=function(){if(n[0]&&0<n[0].className.length)return n[0].className.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,'').replace(/\s+/,' ')},b.setClass=function(a){return(a||''===a)&&c(function(b){b.className=a},n),b},b.addClass=function(a){return k(a,'add',n),b},b.removeClass=function(a){return k(a,'remove',n),b},b.toggleClass=function(a,c){var d='undefined'==typeof c?'toggle':+c?'add':'remove';return k(a,d,n),b},b.hasClass=function(a){return k(a,'has',n)},b.html=function(a){return a||''===a?(c(function(b){b.innerHTML=a},n),b):n[0]?n[0].innerHTML:void 0},b.htmlBefore=function(a){return l(a,'before',n),b},b.htmlAfter=function(a){return l(a,'after',n),b},b.htmlAppend=function(a){return l(a,'append',n),b},b.htmlPrepend=function(a){return l(a,'prepend',n),b},b.attr=function(a,d){if(a){i
'use strict';(function(a){function b(a,b){for(var c=a.length;c--;)if(a[c]===b)return c;return-1}function c(a,b){if(a.length!=b.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0}function d(a){for(j in n)n[j]=a[s[j]]}function e(a){var c,e,h,j,i,l;if(c=a.keyCode,-1==b(r,c)&&r.push(c),(93==c||224==c)&&(c=91),c in n){for(h in n[c]=!0,o)o[h]==c&&(f[h]=!0);return}if((d(a),!!f.filter.call(this,a))&&c in m)for(l=g(),j=0;j<m[c].length;j++)if(e=m[c][j],e.scope==l||'all'==e.scope){for(h in i=0<e.mods.length,n)(!n[h]&&-1<b(e.mods,+h)||n[h]&&-1==b(e.mods,+h))&&(i=!1);(0!=e.mods.length||n[16]||n[18]||n[17]||n[91])&&!i||!1!==e.method(a,e)||(a.preventDefault?a.preventDefault():a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.cancelBubble&&(a.cancelBubble=!0))}}function f(a,b,c){var d,e;d=h(a),c===void 0&&(c=b,b='all');for(var f=0;f<d.length;f++)e=[],a=d[f].split('+'),1<a.length&&(e=l(a),a=[a[a.length-1]]),a=a[0],a=q(a),a in m||(m[a]=[]),m[a].push({shortcut:d[f],scope:b,method:c,key:d[f],mods:e})}function g(){return k||'all'}function h(a){var b;return a=a.replace(/\s/g,''),b=a.split(','),''==b[b.length-1]&&(b[b.length-2]+=','),b}function l(a){var b=a.slice(0,a.length-1);for(var c=0;c<b.length;c++)b[c]=o[b[c]];return b}function i(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent('on'+b,function(){c(window.event)})}var j,m={},n={16:!1,17:!1,18:!1,91:!1},k='all',o={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,command:91},p={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,home:36,end:35,pageup:33,pagedown:34,",":188,".":190,"/":191,"`":192,"-":189,"=":187,";":186,"'":222,"[":219,"]":221,"\\":220,insert:45,np_0:96,np_1:97,np_2:98,np_3:99,np_4:100,np_5:101,np_6:102,np_7:103,np_8:104,np_9:105,np_mul:106,np_add:107,np_sub:109,np_point:110,np_div:111,numlock:144},q=function(a){return p[a]||a.toUpperCase().charCodeAt(0)},r=[];for(j=1;20>j;j++)p['f'+j]=111+j;var s={16:'shiftKey',17:'ctrlKey',18:'altKey',91:'metaKey'};for(j in o)f[j]=!1;i(document,'keydown',function(a){e(a)}),i(document,'keyup',function(a){var c,d=a.keyCode,e=b(r,d);if(0<=e&&r.splice(e,1),(93==d||224==d)&&(d=91),d in n)for(c in n[d]=!1,o)o[c]==d&&(f[c]=!1)}),i(window,'focus',function(){for(j in n)n[j]=!1;for(j in o)f[j]=!1});var t=a.key;a.key=f,a.key.setScope=function(a){k=a||'all'},a.key.getScope=g,a.key.deleteScope=function(a){var b,c,d;for(b in m)for(c=m[b],d=0;d<c.length;)c[d].scope===a?c.splice(d,1):d++},a.key.filter=function(a){var b=(a.target||a.srcElement).tagName;return'INPUT'!=b&&'SELECT'!=b&&'TEXTAREA'!=b},a.key.isPressed=function(a){return'string'==typeof a&&(a=q(a)),-1!=b(r,a)},a.key.isModifier=function(a){return'control'==a||'ctrl'==a?n[17]:'shift'==a?n[16]:'meta'==a?n[91]:!('alt'!=a)&&n[18]},a.key.getPressedKeyCodes=function(){return r.slice(0)},a.key.noConflict=function(){var b=a.key;return a.key=t,b},a.key.unbind=function(a,b){var d,e,f,i,j,k=[];for(d=h(a),i=0;i<d.length;i++){if(e=d[i].split('+'),1<e.length&&(k=l(e)),a=e[e.length-1],a=q(a),void 0===b&&(b=g()),!m[a])return;for(f=0;f<m[a].length;f++)j=m[a][f],j.scope===b&&c(j.mods,k)&&(m[a][f]={})}},'undefined'!=typeof module&&(module.exports=f)})(window);
'use strict';String.fromCodePoint||function(){var a=function(){try{var a={};var b=Object.defineProperty;var c=b(a,a,a)&&b}catch(a){}return c}();var b=String.fromCharCode;var c=Math.floor;var d=function(){var a=[];var d;var e;var f=-1;var g=arguments.length;if(!g)return'';for(var h='';++f<g;){var i=+arguments[f];if(!isFinite(i)||0>i||1114111<i||c(i)!=i)throw RangeError('Invalid code point: '+i);65535>=i?a.push(i):(i-=65536,d=(i>>10)+55296,e=i%1024+56320,a.push(d,e)),(f+1==g||a.length>16384)&&(h+=b.apply(null,a),a.length=0)}return h};a?a(String,'fromCodePoint',{value:d,configurable:!0,writable:!0}):String.fromCodePoint=d}();
'use strict';function mk(a){return document.createElement(a)}function qs(a){return document.querySelector(a)}function qsa(a){return document.querySelectorAll(a)}function bool(a){return 1===a||'1'===a||!0===a||'true'===a}function cr(a){return function(b){(10===b.which||13===b.which||32===b.which)&&a()}}function extend(a,b){var c={};return Object.keys(a).forEach(function(b){c[b]=a[b]}),Object.keys(b).forEach(function(a){c[a]=b[a]}),c}function rgxe(a){return a.replace(/[-[\]/{}()*+?.\\^$|]/g,'\\$&')}function numfmt(a,b){var c=Math.pow(10,b);return Math.round(a*c)/c}function msNow(){return+new Date}function msElapsed(a){return msNow()-a}Math.log10=Math.log10||function(a){return Math.log(a)/Math.LN10};function esc(a){return $.htmlEscape(a)}function undef(a){return'undefined'==typeof a}function jsp(a){try{return JSON.parse(a)}catch(a){return console.error(a),null}}function Chr(a){return String.fromCharCode(a)}function parse2B(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0;return a.charCodeAt(b++)-1+127*(a.charCodeAt(b)-1)}function parse3B(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0;return a.charCodeAt(b)-1+127*(a.charCodeAt(b+1)-1)+127*(127*(a.charCodeAt(b+2)-1))}function encode2B(a){var b,c;return b=a%127,a=(a-b)/127,b+=1,c=a+1,Chr(b)+Chr(c)}function encode3B(a){var b,c,d;return b=a%127,a=(a-b)/127,b+=1,c=a%127,a=(a-c)/127,c+=1,d=a+1,Chr(b)+Chr(c)+Chr(d)}
'use strict';(function(){var a={};var b=null;a.show=function(a,c){var d=$(a);d.removeClass('hidden visible'),setTimeout(function(){d.addClass('visible')},1),b=c},a.hide=function(a){var c=$(a);c.removeClass('visible'),setTimeout(function(){c.addClass('hidden'),b&&b()},500)},a.init=function(){$('.Modal').on('click',function(){$(this).hasClass('no-close')||a.hide(this)}),$('.Dialog').on('click',function(a){a.stopImmediatePropagation()}),$(window).on('keydown',function(b){27===b.which&&a.hide('.Modal')})},window.Modal=a})();
'use strict';window.Notify=function(){var a={};var b='#notif';var c;var d;return a.show=function(e,f){$(b).html(e),Modal.show(b),clearTimeout(c),clearTimeout(d),undef(f)&&(f=2500),c=setTimeout(a.hide,f)},a.hide=function(){var a=$(b);a.removeClass('visible'),d=setTimeout(function(){a.addClass('hidden')},250)},a.init=function(){$(b).on('click',function(){a.hide(this)})},a}();
'use strict';$.ready(function(){$('.Row.checkbox').forEach(function(a){var b=a.querySelector('input');var c=a.querySelector('.box');$(c).toggleClass('checked',b.value);var d=function(){b.value=1-b.value,$(c).toggleClass('checked',b.value)};$(a).on('click',d).on('keypress',cr(d))}),$('.Box.mobcol,.Box.fold').forEach(function(a){var b=a.querySelector('h2');var c=function(){$(a).toggleClass('expanded')};$(b).on('click',c).on('keypress',cr(c))}),$('form').forEach(function(a){$(a).on('keypress',function(b){(10===b.keyCode||13===b.keyCode)&&b.ctrlKey&&a.submit()})}),setInterval(function(){$('.anim-dots').each(function(a){var b=$(a);var c=b.html()+'.';5===c.length&&(c='.'),b.html(c)})},1e3),$('input[type=number]').on('mousewheel',function(a){var b=$(this);var c=+b.val();isNaN(c)&&(c=1);var d=+(b.attr('step')||1);var e=+b.attr('min');var f=+b.attr('max');if(0<a.wheelDelta?c+=d:c-=d,undef(e)&&(c=Math.max(c,+e)),undef(f)&&(c=Math.min(c,+f)),b.val(c),'createEvent'in document){var g=document.createEvent('HTMLEvents');g.initEvent('change',!1,!0),b[0].dispatchEvent(g)}else b[0].fireEvent('onchange');a.preventDefault()});var a=location.search.indexOf('err=');if(-1!==a&&qs('.Box.errors')){var b=location.search.substr(a+4).split(',');var c=[];b.forEach(function(a){var b=qs('label[for="'+a+'"]');b?(b.classList.add('error'),c.push(b.childNodes[0].textContent.trim().replace(/: ?$/,''))):c.push(a)}),qs('.Box.errors .list').innerHTML=c.join(', '),qs('.Box.errors').classList.remove('hidden')}if(Modal.init(),Notify.init(),550<window.innerWidth){$('.Box h2').forEach(function(a){a.removeAttribute('tabindex')});var d=qs('#brand');d&&d.addEventListener('click',function(){location.href='/'})}}),$._loader=function(a){$('#loader').toggleClass('show',a)};function showPage(){$('#content').addClass('load')}$.ready(function(){!0!==window.noAutoShow&&setTimeout(function(){showPage()},1)});
"use strict";var _tr={"wifi.connected_ip_is":"Connected, IP is ","wifi.not_conn":"Not connected.","wifi.enter_passwd":"Enter password for \":ssid:\""};function tr(a){return _tr[a]||"?"+a+"?"}
'use strict';(function(a){function b(a){return Math.round(100*(a.value/a.max))+'%'}function c(a,b,c){$('#sta_ssid').val(a),$('#sta_password').val(b),$('#sta-nw').toggleClass('hidden',0===a.length),$('#sta-nw-nil').toggleClass('hidden',0<a.length),$('#sta-nw .essid').html(esc(a));var d=undef(b)||0===b.length;$('#sta-nw .passwd').toggleClass('hidden',d),$('#sta-nw .nopasswd').toggleClass('hidden',!d),$('#sta-nw .ip').html(0<c.length?tr('wifi.connected_ip_is')+c:tr('wifi.not_conn'))}function d(a,b){if(200!==b)return void f(5e3);try{a=JSON.parse(a)}catch(a){return console.log(a),void f(5e3)}var d=!bool(a.result.inProgress)&&0<a.result.APs.length;if(f(d?15000:1e3),!!d){var e=$('#ap-list');$('#ap-list .AP').remove(),e.toggleClass('hidden',!d),$('#ap-loader').toggleClass('hidden',d),a.result.APs.sort(function(c,a){return a.rssi-c.rssi}).forEach(function(a){if(a.enc=parseInt(a.enc),!(4<a.enc)){var b=mk('div');var d=$(b).data('ssid',a.essid).data('pwd',a.enc).attr('tabindex',0).addClass('AP');a.essid===h&&d.addClass('selected');var f=mk('div');var i=$.htmlEscape(a.essid);$(f).addClass('inner').htmlAppend('<div class="rssi">'+a.rssi_perc+'</div>').htmlAppend('<div class="essid" title="'+i+'">'+i+'</div>').htmlAppend('<div class="auth">'+g[a.enc]+'</div>'),d.on('click',function(){var a=$(this);var b=a.data('ssid');var d='';+a.data('pwd')&&(d=prompt(tr('wifi.enter_passwd').replace(':ssid:',b)),!d)||($('#sta_password').val(d),$('#sta_ssid').val(b),c(b,d,''))}),b.appendChild(f),e[0].appendChild(b)}})}}function e(){_demo?d(_demo_aps,200):$.get('http://'+_root+'/cfg/wifi/scan',d)}function f(a){setTimeout(e,a)}var g=['Open','WEP','WPA','WPA2','WPA/WPA2'];var h;a.init=function(a){$('.Row.range').forEach(function(a){var c=a.querySelector('input');var d=a.querySelector('.x-disp1');var e=a.querySelector('.x-disp2');var f=b(c);$(d).html(f),$(e).html(f),$(c).on('input',function(){f=b(c),$(d).html(f),$(e).html(f)})}),$('#forget-sta').on('click',function(){return c('','',''),!1}),c(a.sta_ssid,a.sta_password,a.sta_active_ip),h=a.sta_active_ssid},a.startScanning=function(){$('#ap-loader').removeClass('hidden'),$('#ap-scan').addClass('hidden'),$('#ap-loader .anim-dots').html('.'),e()}})(window.WiFi={});
'use strict';window.Conn=function(){function a(){console.log('CONNECTED'),f(),d('i')}function b(a){console.warn('SOCKET CLOSED, code '+a.code+'. Reconnecting...'),clearTimeout(m),m=setTimeout(function(){e()},2e3)}function c(a){try{switch(a.data.charAt(0)){case'.':break;case'-':k=!0,l=setTimeout(function(){k=!1},250);break;case'+':k=!1,clearTimeout(l);break;default:Screen.load(a.data),n||(showPage(),n=!0);}f()}catch(a){console.error(a)}}function d(a){return _demo?(console.log('TX: ',a),!0):k?(console.log('Can\'t send, flood control.'),!1):!!h&&(1===h.readyState?('string'!=typeof a&&(a=JSON.stringify(a)),h.send(a),!0):(console.error('Socket not ready'),!1))}function e(){return _demo?(console.log('Demo mode!'),Screen.load(_demo_screen),void showPage()):void(clearTimeout(m),clearTimeout(i),h=new WebSocket('ws://'+_root+'/term/update.ws'),h.onopen=a,h.onclose=b,h.onmessage=c,console.log('Opening socket.'),f())}function f(){clearTimeout(i),i=setTimeout(g,2e3)}function g(){console.error('Heartbeat lost, probing server...'),j=setInterval(function(){console.log('> ping'),$.get('http://'+_root+'/system/ping',function(a,b){200===b&&(clearInterval(j),console.info('Server ready, reloading page...'),location.reload())},{timeout:100})},1e3)}var h;var i;var j;var k=!1;var l;var m;var n=!1;return{ws:null,init:e,send:d,canSend:function(){return!k}}}();
'use strict';window.Input=function(){function a(a){return Conn.send('s'+a)}function b(a){Conn.send('b'+Chr(a))}function c(a,b){return j.fn_alt?a:b}function d(a,b){return j.cu_alt?a:b}function e(a,b){return j.np_alt?a:b}function f(){var a={tab:'\t',backspace:'\b',enter:j.crlf_mode?'\r\n':'\r',"ctrl+enter":'\n',esc:'\x1B',up:d('\x1BOA','\x1B[A'),down:d('\x1BOB','\x1B[B'),right:d('\x1BOC','\x1B[C'),left:d('\x1BOD','\x1B[D'),home:d('\x1BOH',c('\x1B[H','\x1B[1~')),insert:'\x1B[2~',delete:'\x1B[3~',end:d('\x1BOF',c('\x1B[F','\x1B[4~')),pageup:'\x1B[5~',pagedown:'\x1B[6~',f1:c('\x1BOP','\x1B[11~'),f2:c('\x1BOQ','\x1B[12~'),f3:c('\x1BOR','\x1B[13~'),f4:c('\x1BOS','\x1B[14~'),f5:'\x1B[15~',f6:'\x1B[17~',f7:'\x1B[18~',f8:'\x1B[19~',f9:'\x1B[20~',f10:'\x1B[21~',f11:'\x1B[23~',f12:'\x1B[24~',"shift+f1":c('\x1BO1;2P','\x1B[25~'),"shift+f2":c('\x1BO1;2Q','\x1B[26~'),"shift+f3":c('\x1BO1;2R','\x1B[28~'),"shift+f4":c('\x1BO1;2S','\x1B[29~'),"shift+f5":c('\x1B[15;2~','\x1B[31~'),"shift+f6":c('\x1B[17;2~','\x1B[32~'),"shift+f7":c('\x1B[18;2~','\x1B[33~'),"shift+f8":c('\x1B[19;2~','\x1B[34~'),"shift+f9":c('\x1B[20;2~','\x1B[35~'),"shift+f10":c('\x1B[21;2~','\x1B[36~'),"shift+f11":c('\x1B[22;2~','\x1B[37~'),"shift+f12":c('\x1B[23;2~','\x1B[38~'),np_0:e('\x1BOp','0'),np_1:e('\x1BOq','1'),np_2:e('\x1BOr','2'),np_3:e('\x1BOs','3'),np_4:e('\x1BOt','4'),np_5:e('\x1BOu','5'),np_6:e('\x1BOv','6'),np_7:e('\x1BOw','7'),np_8:e('\x1BOx','8'),np_9:e('\x1BOy','9'),np_mul:e('\x1BOR','*'),np_add:e('\x1BOl','+'),np_sub:e('\x1BOS','-'),np_point:e('\x1BOn','.'),np_div:e('\x1BOQ','/')};for(var b in a)a.hasOwnProperty(b)&&g(b,a[b])}function g(b,c){-1!==b.indexOf('ctrl+')&&(b+=','+b.replace('ctrl','command')),key.unbind(b),key(b,function(b){j.no_keys||(b.preventDefault(),a(c))})}function h(){var b=String.fromCharCode;window.addEventListener('keypress',function(b){if(!j.no_keys){var c='';b.key?c=b.key:b.which&&(c=String.fromCodePoint(b.which)),0<c.length&&32<=c.charCodeAt(0)&&(32===b.which&&b.preventDefault(),a(c))}});for(var c=1;26>=c;c++)g('ctrl+'+b(96+c),b(c));g('ctrl+]','\x1B'),g('ctrl+\\','\x1C'),g('ctrl+[','\x1D'),g('ctrl+^','\x1E'),g('ctrl+_','\x1F'),g('ctrl+left','\x1F[1;5D'),g('ctrl+right','\x1F[1;5C'),g('ctrl+up','\x1F[1;5A'),g('ctrl+down','\x1F[1;5B'),g('ctrl+home','\x1F[1;5H'),g('ctrl+end','\x1F[1;5F'),g('shift+left','\x1F[1;2D'),g('shift+right','\x1F[1;2C'),g('shift+up','\x1F[1;2A'),g('shift+down','\x1F[1;2B'),g('shift+home','\x1F[1;2H'),g('shift+end','\x1F[1;2F'),g('\u2325+left','\x1Fb'),g('\u2325+right','\x1Ff'),g('\u2318+left','\x01'),g('\u2318+right','\x05'),g('\u2325+backspace','\x17'),g('\u2318+backspace','\x15'),f()}function i(){return(key.isModifier('ctrl')?1:0)|(key.isModifier('shift')?2:0)|(key.isModifier('alt')?4:0)|(key.isModifier('meta')?8:0)}var j={np_alt:!1,cu_alt:!1,fn_alt:!1,mt_click:!1,mt_move:!1,no_keys:!1,crlf_mode:!1};var k=0;var l=0;var n=0;return{init:function(){h(),$('#action-buttons button').forEach(function(a){a.addEventListener('click',function(){b(+this.dataset.n)})}),window.addEventListener('mousedown',function(a){0===a.button&&(k=1),1===a.button&&(l=1),2===a.button&&(n=1)}),window.addEventListener('mouseup',function(a){0===a.button&&(k=0),1===a.button&&(l=0),2===a.button&&(n=0)})},sendString:a,setAlts:function setAlts(a,b,c,d){(j.cu_alt!==a||j.np_alt!==b||j.fn_alt!==c||j.crlf_mode!==d)&&(j.cu_alt=a,j.np_alt=b,j.fn_alt=c,j.crlf_mode=d,f())},setMouseMode:function setMouseMode(a,b){j.mt_click=a,j.mt_move=b},onMouseMove:function onMouseMove(a,c){if(j.mt_move){var d=k?1:l?2:n?3:0;var b=i();Conn.send('m'+encode2B(c)+encode2B(a)+encode2B(d)+encode2B(b))}},onMouseDown:function onMouseDown(a,c,d){if(j.mt_click&&!(3<d||1>d)){var b=i();Conn.send('p'+encode2B(c)+encode2B(a)+encode2B(d)+encode2B(b))}},onMouseUp:function onMouseUp(a,c,d){if(j.mt_click&&!(3<d||1>d)){var b=i();Conn.send('r'+encode2B(c)+encode2B(a)+encode2B(d)+encode2B(b))}},onMouseWheel:function onMouseWheel(a,c,d){if(j.mt_click){var e=i();var f=0>d?4:5;Conn.send('p'+encode2B(c)+encode2B(a)+encode2B(f)+encode2B(e))}},mouseTracksClicks:function mouseTracksClicks(){retu
'use strict';var _slicedToArray=function(){function a(a,b){var c=[];var d=!0;var e=!1;var f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{!d&&h['return']&&h['return']()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}();var _createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,'value'in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _toConsumableArray(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var frakturExceptions={C:'\u212D',H:'\u210C',I:'\u2111',R:'\u211C',Z:'\u2128'};var SEQ_REPEAT=2;var SEQ_SET_COLORS=3;var SEQ_SET_ATTRS=4;var SEQ_SET_FG=5;var SEQ_SET_BG=6;var SELECTION_BG='#b2d7fe';var SELECTION_FG='#333';var themes=[['#111213','#CC0000','#4E9A06','#C4A000','#3465A4','#75507B','#06989A','#D3D7CF','#555753','#EF2929','#8AE234','#FCE94F','#729FCF','#AD7FA8','#34E2E2','#EEEEEC'],['#000000','#aa0000','#00aa00','#aa5500','#0000aa','#aa00aa','#00aaaa','#aaaaaa','#555555','#ff5555','#55ff55','#ffff55','#5555ff','#ff55ff','#55ffff','#ffffff'],['#000000','#cd0000','#00cd00','#cdcd00','#0000ee','#cd00cd','#00cdcd','#e5e5e5','#7f7f7f','#ff0000','#00ff00','#ffff00','#5c5cff','#ff00ff','#00ffff','#ffffff'],['#000000','#cd0000','#00cd00','#cdcd00','#0000cd','#cd00cd','#00cdcd','#faebd7','#404040','#ff0000','#00ff00','#ffff00','#0000ff','#ff00ff','#00ffff','#ffffff'],['#2e3436','#cc0000','#4e9a06','#c4a000','#3465a4','#75507b','#06989a','#d3d7cf','#555753','#ef2929','#8ae234','#fce94f','#729fcf','#ad7fa8','#34e2e2','#eeeeec'],['#073642','#dc322f','#859900','#b58900','#268bd2','#d33682','#2aa198','#eee8d5','#002b36','#cb4b16','#586e75','#657b83','#839496','#6c71c4','#93a1a1','#fdf6e3']];var colorTable256=Array(16).fill('rgba(0, 0, 0, 0)');for(var red=0;6>red;red++)for(var green=0;6>green;green++)for(var blue=0;6>blue;blue++){var redValue=40*red+(red?55:0);var greenValue=40*green+(green?55:0);var blueValue=40*blue+(blue?55:0);colorTable256.push('rgb('+redValue+', '+greenValue+', '+blueValue+')')}for(var gray=0;24>gray;gray++){var value=10*gray+8;colorTable256.push('rgb('+value+', '+value+', '+value+')')}var TermScreen=function(){function a(){var b=this;_classCallCheck(this,a),this.canvas=mk('canvas'),this.ctx=this.canvas.getContext('2d'),'AudioContext'in window||'webkitAudioContext'in window?this.audioCtx=new(window.AudioContext||window.webkitAudioContext):console.warn('No AudioContext!'),this.cursor={x:0,y:0,fg:7,bg:0,attrs:0,blinkOn:!1,blinking:!0,visible:!0,hanging:!1,style:'block',blinkEnable:!0,blinkInterval:0},this._palette=null,this._window={width:0,height:0,devicePixelRatio:1,fontFamily:'"DejaVu Sans Mono", "Liberation Mono", "Inconsolata", "Menlo", monospace',fontSize:20,gridScaleX:1,gridScaleY:1.2,blinkStyleOn:!0,blinkInterval:null,fitIntoWidth:0,fitIntoHeight:0,debug:!1},this.windowState={width:0,height:0,devicePixelRatio:0,gridScaleX:0,gridScaleY:0,fontFamily:'',fontSize:0,fitIntoWidth:0,fitIntoHeight:0},this.selection={selectable:!0,start:[0,0],end:[0,0]},this.mouseMode={clicks:!1,movement:!1},this._listeners={};var c=this;this.window=new Proxy(this._window,{set:function set(a,b,d){return a[b]=d,c.scheduleSizeUpdate(),c.scheduleDraw('window:'+b+'='+d),!0}}),this.blinkingCellCount=0,this.screen=[],this.screenFG=[],this.screenBG=[],this.screenAttrs=[],this.drawnScreen=[],this.drawnScreenFG=[],this.drawnScreenBG=[],this.drawnScreenAttrs=[],this.resetBlink(),this.resetCursorBlink();var d=!1;var f=function(a,c){d||(d=!0,b.selection.start=b.selection.end=b.screenToGrid(a,c),b.scheduleDraw('select-start'))};var g=function(a,c){d&&(b.selection.end=b.screenT
'use strict';window.TermUpl=function(){function a(){console.log('Upload modal closed.'),clearTimeout(h),g=0,Input.blockKeys(!1)}function b(a){qs('#fu_prog').textContent=a}function c(){if($('#fu_modal').hasClass('visible')){if(!Conn.canSend())return void(h=setTimeout(c,1));0===l&&(k=f[g++]+j);var a;if(k.length-l<=m?(a=k.substr(l,m),l=0):(a=k.substr(l,m),l+=m),!Input.sendString(a))return void b('FAILED!');var e=f.length;b(g+' / '+e+' ('+Math.round(1e3*(g/e))/10+'%)'),f.length>g||0<l?h=setTimeout(c,i):d()}}function d(){Conn.canSend()?(b('Done.'),setTimeout(function(){e()},100)):(b('Waiting for Tx buffer...'),setTimeout(d,100))}function e(){Modal.hide('#fu_modal')}var f,g,h,i,j,k,l;var m=128;return{init:function init(){qs('#fu_file').addEventListener('change',function(a){var b=new FileReader;var c=a.target.files[0];return console.log('Selected file type: '+c.type),c.type.match(/text\/.*|application\/(json|csv|.*xml.*|.*script.*)/)||confirm('This does not look like a text file: '+c.type+'\nReally load?')?void(b.onload=function(a){var b=a.target.result.replace(/[\r\n]+/,'\n');qs('#fu_text').value=b},console.log('Loading file...'),b.readAsText(c)):void(qs('#fu_file').value='')},!1)},close:e,start:function(){var a=qs('#fu_text').value;return a.length?void(f=a.split('\n'),g=0,l=0,i=qs('#fu_delay').value,0>i&&(i=0,qs('#fu_delay').value=i),j={CR:'\r',LF:'\n',CRLF:'\r\n'}[qs('#fu_crlf').value],$('#fu_form').toggleClass('busy',!0),b('Starting...'),c()):void e()},open:function(){b('Ready...'),Modal.show('#fu_modal',a),$('#fu_form').toggleClass('busy',!1),Input.blockKeys(!0)}}}();
"use strict";window.termInit=function(a,b){Conn.init(),Input.init(),TermUpl.init(),Screen.load(a,b)};
'use strict';var _slicedToArray=function(){function a(a,b){var c=[];var d=!0;var e=!1;var f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{!d&&h['return']&&h['return']()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}();$.ready(function(){var a=qs('#softkb-input');if(a){var b=!1;var c=function(){if(b){var c=Screen.gridToScreen(Screen.cursor.x,Screen.cursor.y),d=_slicedToArray(c,2),e=d[0],f=d[1];a.style.transform='translate('+e+'px, '+f+'px)'}};a.addEventListener('focus',function(){b=!0,c()}),a.addEventListener('blur',function(){return b=!1}),Screen.on('cursor-moved',c),window.kbOpen=function(d){b=d,c(),d?a.focus():a.blur()};var d='';var e=!1;var f=function(a){var b=!1;a.length>d.length?a.startsWith(d)?Input.sendString(a.substr(d.length)):b=!0:a.length<d.length?d.startsWith(a)?Input.sendString('\b'.repeat(d.length-a.length)):b=!0:a!==d&&(b=!0),b&&Input.sendString('\b'.repeat(d.length)+a),d=a};a.addEventListener('keydown',function(b){'Unidentified'===b.key||(b.preventDefault(),a.value='','Backspace'===b.key?Input.sendString('\b'):'Enter'===b.key&&Input.sendString('\r'))}),a.addEventListener('input',function(a){a.stopPropagation(),a.isComposing?f(a.data):a.data?Input.sendString(a.data):'deleteContentBackward'===a.inputType&&(d='',f(''))}),a.addEventListener('compositionstart',function(){d='',e=!0}),a.addEventListener('compositionend',function(){d='',e=!1,a.value=''}),Screen.on('open-soft-keyboard',function(){return a.focus()})}});
//# sourceMappingURL=app.js.map