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
17 lines
47 KiB
'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){if(a=a.toLowerCase(),'undefined'!=typeof d)return c(function(b){'style'===a?b.style.cssText=d:'class'===a?b.className=d:b.setAttribute(a,d)},n),b;if(n[0])if('style'===a){if(n[0].style.cssText)return n[0].style.cssText;}else if('class'===a){if(n[0].className)return n[0].className;}else if(n[0].getAttribute(a))return n[0].getAttribute(a)}},b.data=function(a,c){if(a)return b.attr('data-'+a,c)},b.val=function(a){var d,e,f;if('undefined'!=typeof a)return c(function(b){switch(b.nodeName){case'SELECT':for(('string'==typeof a||'number'==typeof a)&&(a=[a]),e=0;e<b.length;e+=1)for(f=0;f<a.length;f+=1)if(b[e].selected='',b[e].value===''+a[f]){b[e].selected='selected';break}break;case'INPUT':case'TEXTAREA':case'BUTTON':b.value=a;}},n),b;if(n[0])switch(n[0].nodeName){case'SELECT':for(d=[],e=0;e<n[0].length;e+=1)n[0][e].selected&&d.push(n[0][e].value);return 1<d.length?d:d[0];case'INPUT':case'TEXTAREA':case'BUTTON':return n[0].value;}},b.checked=function(a){return'boolean'==typeof a?(c(function(b){'INPUT'===b.nodeName&&('checkbox'===b.type||'radio'===b.type)&&(b.checked=a)},n),b):n[0]&&'INPUT'===n[0].nodeName&&('checkbox'===n[0].type||'radio'===n[0].type)?!!n[0].checked:void 0},b.on=function(e,f){return(a===d||a===r)&&(n=[a]),c(function(a){r.addEventListener?a.addEventListener(e,f,!1):r.attachEvent&&(a[e+f]=function(){return f.apply(a,arguments)},a.attachEvent('on'+e,a[e+f]))},n),b},b.off=function(e,f){return(a===d||a===r)&&(n=[a]),c(function(a){r.addEventListener?a.removeEventListener(e,f,!1):r.attachEvent&&(a.detachEvent('on'+e,a[e+f]),a[e+f]=null)},n),b},b}var n=[],o=[],p=!1,q=!1,r=document,d=window;r.addEventListener?(r.addEventListener('DOMContentLoaded',a,!1),d.addEventListener('load',b,!1)):r.attachEvent?(r.attachEvent('onreadystatechange',a),d.attachEvent('onload',b)):d.onload=b,m.ajax=function(a){var b=extend({method:'GET',nocache:!0,timeout:5e3,loader:!0,callback:null},a);b.method=b.method.toUpperCase();var c=b.loader?m._loader:function(){};var d=b.url;var e=b.method;var f=null;b.data&&(f=j(b.data)),f&&'GET'===e&&(d+=-1===d.indexOf('?')?'?'+f:'&'+f,f=null);var g=new XMLHttpRequest;if(b.nocache){var h=(+new Date).toString(36);d+=(-1===d.indexOf('?')?'?':'&')+'_='+h}c(!0),g.open(e,d,!0),g.timeout=b.timeout;var i=setTimeout(function(){console.error('XHR timed out.'),g.abort(),c(!1)},b.timeout+10);return g.onreadystatechange=function(){4===g.readyState&&(c(!1),b.callback&&b.callback(g.responseText,g.status),clearTimeout(i))},g.setRequestHeader('X-Requested-With','XMLHttpRequest'),'POST'===e&&g.setRequestHeader('Content-Type','application/x-www-form-urlencoded'),g.send(f),g},m._loader=function(){},m.get=function(a,b,c){return c=c||{},c.url=a,c.callback=b,c.method='GET',m.ajax(c)},m.post=function(a,b,c){return c=c||{},c.url=a,c.callback=b,c.method='POST',m.ajax(c)},m.ready=function(a){if(a){if(p)return a(),m;n.push(a)}},m.loaded=function(a){if(a){if(q)return a(),m;o.push(a)}};var t={"&":'&',"<":'<',">":'>','"':'"',"'":''',"/":'/',"`":'`',"=":'='};m.htmlEscape=function(a){return(a+'').replace(/[&<>"'`=\/]/g,function(a){return t[a]})},d.$=m})();
|
|
'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(){return j.mt_click},blockKeys:function blockKeys(a){j.no_keys=a}}}();
|
|
'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.screenToGrid(a,c),b.scheduleDraw('select-move'))};var h=function(a,c){d&&(d=!1,b.selection.end=b.screenToGrid(a,c),b.scheduleDraw('select-end'),Object.assign(b.selection,b.getNormalizedSelection()))};this.canvas.addEventListener('mousedown',function(a){if((b.selection.selectable||a.altKey)&&0===a.button)f(a.offsetX,a.offsetY);else{var c;(c=Input).onMouseDown.apply(c,_toConsumableArray(b.screenToGrid(a.offsetX,a.offsetY)).concat([a.button+1]))}}),window.addEventListener('mousemove',function(a){g(a.offsetX,a.offsetY)}),window.addEventListener('mouseup',function(a){h(a.offsetX,a.offsetY)});var i=null;var j=0;var k=!1;var l=function(a){var c=b.canvas.getBoundingClientRect();return[a.clientX-c.left,a.clientY-c.top]};this.canvas.addEventListener('touchstart',function(a){i=l(a.touches[0]),k=!1,j=Date.now()}),this.canvas.addEventListener('touchmove',function(a){i=l(a.touches[0]),d||!1!=k?d&&(a.preventDefault(),g.apply(void 0,_toConsumableArray(i))):j<Date.now()-500&&f.apply(void 0,_toConsumableArray(i)),k=!0}),this.canvas.addEventListener('touchend',function(a){if(a.touches[0]&&(i=l(a.touches[0])),d){a.preventDefault(),h.apply(void 0,_toConsumableArray(i));var c=qs('#touch-select-menu');c.classList.add('open');var e=c.getBoundingClientRect();var f=b.gridToScreen((b.selection.start[0]+b.selection.end[0])/2,b.selection.start[1]-1);f[0]-=e.width/2,f[1]-=e.height/2,c.style.transform='translate('+f[0]+'px, '+f[1]+'px)'}k||b.emit('tap',Object.assign(a,{x:i[0],y:i[1]})),i=null}),this.on('tap',function(a){b.selection.start[0]!==b.selection.end[0]||b.selection.start[1]!==b.selection.end[1]?(b.selection.start=b.selection.end=[0,0],qs('#touch-select-menu').classList.remove('open'),b.scheduleDraw('select-reset')):(a.preventDefault(),b.emit('open-soft-keyboard'))}),$.ready(function(){var a=qs('#touch-select-copy-btn');a&&a.addEventListener('click',function(){b.copySelectionToClipboard()})}),this.canvas.addEventListener('mousemove',function(a){if(!d){var c;(c=Input).onMouseMove.apply(c,_toConsumableArray(b.screenToGrid(a.offsetX,a.offsetY)))}}),this.canvas.addEventListener('mouseup',function(a){if(!d){var c;(c=Input).onMouseUp.apply(c,_toConsumableArray(b.screenToGrid(a.offsetX,a.offsetY)).concat([a.button+1]))}}),this.canvas.addEventListener('wheel',function(a){if(b.mouseMode.clicks){var c;(c=Input).onMouseWheel.apply(c,_toConsumableArray(b.screenToGrid(a.offsetX,a.offsetY)).concat([0<a.deltaY?1:-1])),a.preventDefault()}}),this.canvas.addEventListener('contextmenu',function(a){b.mouseMode.clicks&&a.preventDefault(),h(a.offsetX,a.offsetY)}),key('\u2303+\u21E7+c',function(a){a.preventDefault(),b.copySelectionToClipboard()})}var b=Math.ceil;var c=Math.floor;return _createClass(a,[{key:'on',value:function on(a,b){this._listeners[a]||(this._listeners[a]=[]),this._listeners[a].push({listener:b})}},{key:'once',value:function once(a,b){this._listeners[a]||(this._listeners[a]=[]),this._listeners[a].push({listener:b,once:!0})}},{key:'off',value:function off(a,b){var c=this._listeners[a];if(c)for(var d in c)if(c[d].listener===b){c.splice(d,1);break}}},{key:'emit',value:function emit(a){var b=this._listeners[a];if(b){var p=[];for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];var f=!0;var g=!1;var h=void 0;try{for(var i,j=b[Symbol.iterator]();!(f=(i=j.next()).done);f=!0){var q=i.value;try{q.listener.apply(q,d),q.once&&p.push(q)}catch(a){console.error(a)}}}catch(a){g=!0,h=a}finally{try{!f&&j.return&&j.return()}finally{if(g)throw h}}var k=!0;var l=!1;var m=void 0;try{for(var n,o=p[Symbol.iterator]();!(k=(n=o.next()).done);k=!0){var r=n.value;b.splice(b.indexOf(r),1)}}catch(a){l=!0,m=a}finally{try{!k&&o.return&&o.return()}finally{if(l)throw m}}}}},{key:'getColor',value:function getColor(a){if(this.palette[a])return this.palette[a];if(-1===a)return SELECTION_FG;if(-2===a)return SELECTION_BG;if(15<a&&256>a)return colorTable256[a];if(255<a){a-=256;var b=255&a>>16;var c=255&a>>8;var d=255&a;return'rgb('+b+', '+c+', '+d+')'}return'rgba(0, 0, 0, 0)'}},{key:'scheduleSizeUpdate',value:function scheduleSizeUpdate(){var a=this;clearTimeout(this._scheduledSizeUpdate),this._scheduledSizeUpdate=setTimeout(function(){return a.updateSize()},1)}},{key:'scheduleDraw',value:function scheduleDraw(a){var b=this;var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;clearTimeout(this._scheduledDraw),this._scheduledDraw=setTimeout(function(){return b.draw(a)},c)}},{key:'getFont',value:function getFont(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};var b=a.style||'normal';var c=a.weight||'normal';return b+' normal '+c+' '+this.window.fontSize+'px '+this.window.fontFamily}},{key:'getCharSize',value:function getCharSize(){return this.ctx.font=this.getFont(),{width:c(this.ctx.measureText(' ').width),height:this.window.fontSize}}},{key:'getCellSize',value:function getCellSize(){var a=this.getCharSize();return{width:b(a.width*this.window.gridScaleX),height:b(a.height*this.window.gridScaleY)}}},{key:'updateSize',value:function updateSize(){this._window.devicePixelRatio=window.devicePixelRatio||1;var a=!1;for(var j in this.windowState)this.windowState.hasOwnProperty(j)&&this.windowState[j]!==this.window[j]&&(a=!0,this.windowState[j]=this.window[j]);if(a){var b=this.window,c=b.width,d=b.height,e=b.devicePixelRatio,f=b.gridScaleX,g=b.gridScaleY,h=b.fitIntoWidth,i=b.fitIntoHeight;var k=this.getCellSize();var l=c*k.width;var m=d*k.height;if(!(h&&i))h&&l>h?(m=h/(l/m),l=h):i&&m>i&&(l=i*(l/m),m=i);else if(l>h||m>i){var n=l/m;n<h/i?(m=i,l=m*n):(l=h,m=l/n)}this.canvas.width=c*e*k.width,this.canvas.style.width=l+'px',this.canvas.height=d*e*k.height,this.canvas.style.height=m+'px',this.drawnScreen=[],this.drawnScreenFG=[],this.drawnScreenBG=[],this.drawnScreenAttrs=[],this.draw('init')}}},{key:'resetCursorBlink',value:function resetCursorBlink(){var a=this;this.cursor.blinkOn=!0,clearInterval(this.cursor.blinkInterval),this.cursor.blinkInterval=setInterval(function(){a.cursor.blinkOn=!a.cursor.blinking||!a.cursor.blinkOn,a.cursor.blinking&&a.scheduleDraw('cursor-blink')},500)}},{key:'resetBlink',value:function resetBlink(){var a=this;this.window.blinkStyleOn=!0,clearInterval(this.window.blinkInterval);var b=0;this.window.blinkInterval=setInterval(function(){0>=a.blinkingCellCount||(b++,4<=b&&a.window.blinkStyleOn?(a.window.blinkStyleOn=!1,b=0):1<=b&&!a.window.blinkStyleOn&&(a.window.blinkStyleOn=!0,b=0))},200)}},{key:'getNormalizedSelection',value:function getNormalizedSelection(){var a=this.selection,b=a.start,c=a.end;if(b[1]>c[1]||b[1]===c[1]&&b[0]>c[0]){var d=[c,b];b=d[0],c=d[1]}return{start:b,end:c}}},{key:'isInSelection',value:function isInSelection(a,b){var c=this.getNormalizedSelection(),d=c.start,e=c.end;var f=d[0]<=a;var g=a<e[0];var h=b===d[1];var i=b===e[1];return h&&i?f&&g:h?f:i?g:d[1]<b&&b<e[1]}},{key:'getSelectedText',value:function getSelectedText(){var a=this.window.width*this.window.height;var b=[];var d=-1;for(var e=0;e<a;e++){var f=e%this.window.width;var g=c(e/this.window.width);this.isInSelection(f,g)&&(d!==g&&(d=g,b.push('')),b[b.length-1]+=this.screen[e])}return b.join('\n')}},{key:'copySelectionToClipboard',value:function copySelectionToClipboard(){var a=this.getSelectedText();if(a){var b=mk('textarea');document.body.appendChild(b),b.value=a,b.select(),document.execCommand('copy')?Notify.show('Copied to clipboard'):Notify.show('Failed to copy'),document.body.removeChild(b)}}},{key:'screenToGrid',value:function screenToGrid(a,b){var d=this.getCellSize();return[c((a+d.width/2)/d.width),c(b/d.height)]}},{key:'gridToScreen',value:function gridToScreen(a,b){var c=this.getCellSize();return[a*c.width,b*c.height]}},{key:'drawCellBackground',value:function drawCellBackground(a){var c=a.x,d=a.y,e=a.cellWidth,f=a.cellHeight,g=a.bg;var h=this.ctx;h.fillStyle=this.getColor(g),h.clearRect(c*e,d*f,b(e),b(f)),h.fillRect(c*e,d*f,b(e),b(f))}},{key:'drawCell',value:function drawCell(b){var c=Math.round;var d=b.x,e=b.y,f=b.charSize,g=b.cellWidth,h=b.cellHeight,i=b.text,j=b.fg,k=b.bg,l=b.attrs;if(i){var m=this.ctx;var n=!1;var o=!1;var p=!1;if(2&l&&(m.globalAlpha=0.5),8&l&&(n=!0),32&l&&(i=a.alphaToFraktur(i)),64&l&&(o=!0),128&l&&(p=!0),m.fillStyle=this.getColor(j),m.fillText(i,(d+0.5)*g,(e+0.5)*h),n||o||p){if(m.strokeStyle=this.getColor(j),m.lineWidth=1,m.lineCap='round',m.beginPath(),n){var q=c(e*h+f.height)+0.5;m.moveTo(d*g,q),m.lineTo((d+1)*g,q)}if(o){var r=c((e+0.5)*h)+0.5;m.moveTo(d*g,r),m.lineTo((d+1)*g,r)}if(p){var s=c(e*h)+0.5;m.moveTo(d*g,s),m.lineTo((d+1)*g,s)}m.stroke()}m.globalAlpha=1}}},{key:'getAdjacentCells',value:function getAdjacentCells(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;var c=this.window,d=c.width,e=c.height;var f=[];for(var g=-b;g<=b;g++)for(var h=-b;h<=b;h++)(0!==g||0!==h)&&f.push(a+g+h*d);return f.filter(function(a){return 0<=a&&a<d*e})}},{key:'draw',value:function draw(a){var b=this;var d=this.ctx;var e=this.window,f=e.width,g=e.height,h=e.devicePixelRatio,i=e.gridScaleX,j=e.gridScaleY;var k=this.getCharSize();var l=this.getCellSize(),m=l.width,n=l.height;d.setTransform(h,0,0,h,0,0),this.window.debug&&(d.fillStyle='rgba(255, 0, 255, 0.3)',d.fillRect(0,0,f*m,g*n),console.log('draw: '+a)),d.font=this.getFont(),d.textAlign='center',d.textBaseline='middle';var o=new Map;var p=new Map;for(var la=0;la<f*g;la++){var ma=la%f;var x=c(la/f);var y=!this.cursor.hanging&&this.cursor.x===ma&&this.cursor.y===x;var na=y&&this.cursor.blinkOn&&'block'===this.cursor.style;var oa=this.isInSelection(ma,x);var pa=this.screen[la];var qa=na?this.screenBG[la]:this.screenFG[la];var ra=na?this.screenFG[la]:this.screenBG[la];var sa=this.screenAttrs[la];16&sa&&!this.window.blinkStyleOn&&(pa=''),na&&qa===ra&&(ra=0===qa?7:0),oa&&(qa=-1,ra=-2);var ta=pa!==this.drawnScreen[la]||qa!==this.drawnScreenFG[la]||ra!==this.drawnScreenBG[la]||sa!==this.drawnScreenAttrs[la]||y;var ua=sa&5;o.has(ua)||o.set(ua,[]),o.get(ua).push([la,ma,x,pa,qa,ra,sa,y]),p.set(la,ta)}var q=new Map;var r=function(a){return' '!==a&&d.measureText(a).width>=m+0.05};var s=function(a){var c=p.get(a)||q.get(a);var d=b.screen[a];var e=r(d);var g=e?2:1;if(!c){var u=!1;var h=!0;var i=!1;var j=void 0;try{for(var k,l=b.getAdjacentCells(a,g)[Symbol.iterator]();!(h=(k=l.next()).done);h=!0){var v=k.value;if(p.get(v)){u=!0;break}}}catch(a){i=!0,j=a}finally{try{!h&&l.return&&l.return()}finally{if(i)throw j}}u&&(c=!0)}if(c&&e){var m=!0;var n=!1;var o=void 0;try{for(var s,t=b.getAdjacentCells(a)[Symbol.iterator]();!(m=(s=t.next()).done);m=!0){var w=s.value;q.set(w,!0)}}catch(a){n=!0,o=a}finally{try{!m&&t.return&&t.return()}finally{if(n)throw o}}for(var x=a-1;0<x;){var y=b.screen[x];var z=r(y);if(q.get(x-1))break;if(q.set(x-f,!0),q.set(x+f,!0),q.set(x--,!0),!z)break}}q.set(a,c)};var t=!0;var u=!1;var v=void 0;try{for(var w,z=p.keys()[Symbol.iterator]();!(t=(w=z.next()).done);t=!0){var va=w.value;s(va)}}catch(a){u=!0,v=a}finally{try{!t&&z.return&&z.return()}finally{if(u)throw v}}var A=!0;var B=!1;var C=void 0;try{for(var D,E=o.keys()[Symbol.iterator]();!(A=(D=E.next()).done);A=!0){var wa=D.value;var F=!0;var G=!1;var H=void 0;try{for(var I,J=o.get(wa)[Symbol.iterator]();!(F=(I=J.next()).done);F=!0){var xa=I.value;var K=_slicedToArray(xa,8),L=K[0],M=K[1],N=K[2],O=K[3],P=K[4],Q=K[5],R=K[6],S=K[7];q.get(L)&&this.drawCellBackground({x:M,y:N,cellWidth:m,cellHeight:n,bg:Q})}}catch(a){G=!0,H=a}finally{try{!F&&J.return&&J.return()}finally{if(G)throw H}}}}catch(a){B=!0,C=a}finally{try{!A&&E.return&&E.return()}finally{if(B)throw C}}var T=!0;var U=!1;var V=void 0;try{for(var W,X=o.keys()[Symbol.iterator]();!(T=(W=X.next()).done);T=!0){var ya=W.value;var za={};1&ya&&(za.weight='bold'),4&ya&&(za.style='italic'),d.font=this.getFont(za);var Y=!0;var Z=!1;var _=void 0;try{for(var aa,ba=o.get(ya)[Symbol.iterator]();!(Y=(aa=ba.next()).done);Y=!0){var Aa=aa.value;var ca=_slicedToArray(Aa,8),da=ca[0],ea=ca[1],fa=ca[2],ga=ca[3],ha=ca[4],ia=ca[5],ja=ca[6],ka=ca[7];if(q.get(da)&&(this.drawCell({x:ea,y:fa,charSize:k,cellWidth:m,cellHeight:n,text:ga,fg:ha,bg:ia,attrs:ja}),this.drawnScreen[da]=ga,this.drawnScreenFG[da]=ha,this.drawnScreenBG[da]=ia,this.drawnScreenAttrs[da]=ja,this.window.debug&&(d.save(),d.fillStyle='#0f0',d.font='6px monospace',d.textAlign='left',d.textBaseline='top',d.fillText(+r(ga),ea*m,fa*n),d.fillText(+p.get(da),ea*m,fa*n+6),d.restore())),ka&&this.cursor.blinkOn&&'block'!==this.cursor.style){if(d.save(),d.beginPath(),'bar'===this.cursor.style){d.rect(ea*m,fa*n,2,n)}else if('line'===this.cursor.style){d.rect(ea*m,fa*n+k.height,m,2)}d.clip(),ha=this.screenBG[da],ia=this.screenFG[da],ha===ia&&(ia=0===ha?7:0),this.drawCell({x:ea,y:fa,charSize:k,cellWidth:m,cellHeight:n,text:ga,fg:ha,bg:ia,attrs:ja}),d.restore()}}}catch(a){Z=!0,_=a}finally{try{!Y&&ba.return&&ba.return()}finally{if(Z)throw _}}}}catch(a){U=!0,V=a}finally{try{!T&&X.return&&X.return()}finally{if(U)throw V}}}},{key:'loadContent',value:function loadContent(a){var b=this;var c=0;var d=parse2B(a,c);var e=parse2B(a,c+2);var f=this.window.height!==d||this.window.width!==e;this.window.height=d,this.window.width=e,c+=4;var g=[parse2B(a,c),parse2B(a,c+2)],h=g[0],i=g[1];c+=4;var k=i!==this.cursor.x||h!==this.cursor.y;this.cursor.x=i,this.cursor.y=h,k&&(this.resetCursorBlink(),this.emit('cursor-moved'));var l=parse3B(a,c);c+=3,this.cursor.visible=!!(1&l),this.cursor.hanging=!!(2&l),Input.setAlts(!!(4&l),!!(8&l),!!(16&l),!!(4096&l));var m=!!(32&l);var n=!!(64&l);var o=7&l>>9;0<o&&o--;var p=o>>1;var q=!(1&o);0==p?this.cursor.style='block':1==p?this.cursor.style='line':2==p&&(this.cursor.style='bar'),this.cursor.blinking!==q&&(this.cursor.blinking=q,this.resetCursorBlink()),Input.setMouseMode(m,n),this.selection.selectable=!n,$(this.canvas).toggleClass('selectable',!n),this.mouseMode={clicks:m,movement:n};$('.x-term-conf-btn').toggleClass('hidden',!!!(256&l)),$('#action-buttons').toggleClass('hidden',!!!(128&l));var r=7;var s=0;var t=0;var u=0;var v=' ';var w=this.window.width*this.window.height;f&&(this.updateSize(),this.blinkingCellCount=0,this.screen=Array(w).fill(' '),this.screenFG=Array(w).fill(' '),this.screenBG=Array(w).fill(' '),this.screenAttrs=Array(w).fill(' '));var x=undef(Array.from)?a.split(''):Array.from(a);var y=16;for(var z=function(){var a=t;0!=(a&y)&&(' '==v&&0==(a&200)||r==s)&&(a^=y),(b.screenAttrs[u]&y)!=(a&y)&&(a&y?b.blinkingCellCount++:b.blinkingCellCount--),b.screen[u]=v,b.screenFG[u]=r,b.screenBG[u]=s,b.screenAttrs[u]=a};c<x.length&&u<w;){var A=x[c++];var B=A.codePointAt(0);var C=void 0;switch(B){case SEQ_REPEAT:var D=parse2B(x[c]+x[c+1]);c+=2;for(var E=0;E<D&&(z(u),!(++u>w));E++);break;case SEQ_SET_COLORS:C=parse3B(x[c]+x[c+1]+x[c+2]),c+=3,r=255&C,s=255&C>>8;break;case SEQ_SET_ATTRS:C=parse2B(x[c]+x[c+1]),c+=2,t=255&C;break;case SEQ_SET_FG:C=parse2B(x[c]+x[c+1]),c+=2,r=255&C;break;case SEQ_SET_BG:C=parse2B(x[c]+x[c+1]),c+=2,s=255&C;break;default:32>B&&(A='\uFFFD'),v=A,z(u),u++;}}this.window.debug&&console.log('Blinky cells = '+this.blinkingCellCount),this.scheduleDraw('load',16),this.emit('load')}},{key:'loadLabels',value:function loadLabels(a){var b=a.split('\x01');qs('h1').textContent=b[0],$('#action-buttons button').forEach(function(a,c){var d=b[c+1].trim();a.innerHTML=d?esc(d):' ',a.style.opacity=d?1:0.2})}},{key:'showNotification',value:function showNotification(a){if(console.info('Notification: '+a),Notification&&'granted'===Notification.permission){var b=new Notification('ESPTerm',{body:a});b.addEventListener('click',function(){return window.focus()})}else Notification&&'denied'!==Notification.permission?Notification.requestPermission():Notify.show(a)}},{key:'load',value:function load(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1;var c=a.substr(1);switch(0<=b&&b<themes.length&&(Screen.palette=themes[b]),a[0]){case'S':this.loadContent(c);break;case'T':this.loadLabels(c);break;case'B':this.beep();break;case'G':this.showNotification(c);break;default:console.warn('Bad data message type; ignoring.\n'+JSON.stringify(a));}}},{key:'beep',value:function beep(){var a=this.audioCtx;if(a&&!(this._lastBeep&&this._lastBeep>Date.now()-50)){this._lastBeep=Date.now();var b,c;b=a.createOscillator(),c=a.createGain(),b.connect(c),c.connect(a.destination),c.gain.value=0.5,b.frequency.value=750,b.type='sine',b.start(),b.stop(a.currentTime+0.05),b=a.createOscillator(),c=a.createGain(),b.connect(c),c.connect(a.destination),c.gain.value=0.2,b.frequency.value=400,b.type='sine',b.start(a.currentTime+0.05),b.stop(a.currentTime+0.08)}}},{key:'palette',get:function get(){return this._palette||themes[0]},set:function set(a){this._palette!==a&&(this._palette=a,this.scheduleDraw('palette'))}}],[{key:'alphaToFraktur',value:function alphaToFraktur(a){var b=String.fromCodePoint;return'a'<=a&&'z'>=a?a=b(119997+a.charCodeAt(0)):'A'<=a&&'Z'>=a&&(a=frakturExceptions[a]||b(120003+a.charCodeAt(0))),a}}]),a}();var Screen=new TermScreen;Screen.once('load',function(){qs('#screen').appendChild(Screen.canvas)});var fitScreen=!1;function fitScreenIfNeeded(){Screen.window.fitIntoWidth=fitScreen?window.innerWidth-20:0,Screen.window.fitIntoHeight=fitScreen?window.innerHeight:0}fitScreenIfNeeded(),window.addEventListener('resize',fitScreenIfNeeded),window.toggleFitScreen=function(){fitScreen=!fitScreen;var a=qs('#resize-button-icon');fitScreen?(a.classList.remove('icn-resize-small'),a.classList.add('icn-resize-full')):(a.classList.remove('icn-resize-full'),a.classList.add('icn-resize-small')),fitScreenIfNeeded()};
|
|
'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
|