|
|
|
function bool(t){return 1===t||"1"===t||t===!0||"true"===t}function numfmt(t,e){var n=Math.pow(10,e);return Math.round(t*n)/n}function estimateLoadTime(t,e){return 1e3/t*e+1500}function msNow(){return+new Date}function msElapsed(t){return msNow()-t}function copyToClipboard(t){if(!document.execCommand)return!1;var e="_hiddenCopyText_";if(n=document.getElementById(e),!n){var n=document.createElement("textarea");n.style.position="absolute",n.style.left="-9999px",n.style.top="0",n.id=e,document.body.appendChild(n)}n.textContent=t;var r=document.activeElement;n.focus(),n.setSelectionRange(0,n.value.length);var i;try{i=document.execCommand("copy")}catch(a){i=!1}return r&&"function"==typeof r.focus&&r.focus(),n.textContent="",i}function errorMsg(t,e){$("#notif").addClass("error"),notify.show(t,e||3e3)}function infoMsg(t,e){$("#notif").removeClass("error"),notify.show(t,e||3e3)}!function(){"use strict";function t(){var t;for(p=!0,t=0;t<f.length;t+=1)f[t]();f=[]}function e(){var e;for(m=!0,p||t(),e=0;e<d.length;e+=1)d[e]();d=[]}function n(t,e){var n;for(n=e.length-1;n>=0;n-=1)t(e[n])}function r(t){return t.replace(/-\w/g,function(t){return t.charAt(1).toUpperCase()})}function i(t,e){return t.currentStyle?t.currentStyle[r(e)]:g.getComputedStyle?g.getComputedStyle(t,null).getPropertyValue(e):null}function a(t,e){return encodeURIComponent(t).replace(/%20/g,"+")+"="+encodeURIComponent(e).replace(/%20/g,"+")}function o(t,e,n){try{t.style[r(e)]=n}catch(i){}}function s(t){t.style.display="","none"===i(t,"display")&&(t.style.display="block")}function u(t){var e,r,i,o="";if(t.constructor===Object){for(e in t)if(t.hasOwnProperty(e))if(t[e].constructor===Array)for(r=0;r<t[e].length;r+=1)o+="&"+a(e,t[e][r]);else o+="&"+a(e,t[e])}else n(function(t){if("FORM"===t.nodeName)for(r=0;r<t.elements.length;r+=1)if(e=t.elements[r],!e.disabled)switch(e.type){case"button":case"image":case"file":case"submit":case"reset":break;case"select-one":e.length>0&&(o+="&"+a(e.name,e.value));break;case"select-multiple":for(i=0;i<e.length;i+=1)e[i].selected&&(o+="&"+a(e.name,e[i].value));break;case"checkbox":case"radio":e.checked&&(o+="&"+a(e.name,e.value));break;default:o+="&"+a(e.name,e.value)}},t);return o.length>0?o.substring(1):""}function c(t,e,r){var i,a,o,s=!1;return t&&(i=t.split(/\s+/),n(function(t){for(o=0;o<i.length;o+=1)if(a=new RegExp("\\b"+i[o]+"\\b","g"),"remove"===e)t.className=t.className.replace(a,"");else if("toggle"===e)t.className=t.className.match(a)?t.className.replace(a,""):t.className+" "+i[o];else if("has"===e&&t.className.match(a)){s=!0;break}},r)),s}function l(t,e,r){var i,a;t&&n(function(n){for(i=v.createElement("div"),i.innerHTML=t;null!==(a=i.lastChild);)try{"before"===e?n.parentNode.insertBefore(a,n):"after"===e?n.parentNode.insertBefore(a,n.nextSibling):"append"===e?n.appendChild(a):"prepend"===e&&n.insertBefore(a,n.firstChild)}catch(r){break}},r)}function h(t){var e,a,x,y=[],b=!1;if(t)if(t.nodeType&&1===t.nodeType)y=[t];else if("object"==typeof t)b="number"!=typeof t.length,y=t;else if("string"==typeof t)for(v.querySelectorAll||(v.querySelectorAll=function(t){var e,n,r,a=v.getElementsByTagName("head")[0],o=[];if(e=v.createElement("STYLE"),e.type="text/css",e.styleSheet){for(e.styleSheet.cssText=t+" {a:b}",a.appendChild(e),n=v.getElementsByTagName("*"),r=0;r<n.length;r+=1)"b"===i(n[r],"a")&&o.push(n[r]);a.removeChild(e)}return o}),a=v.querySelectorAll(t),x=0;x<a.length;x+=1)y[x]=a[x];return e=b?{}:y,e.ready=function(t){if(t){if(p)return t(),e;f.push(t)}},e.loaded=function(t){if(t){if(m)return t(),e;d.push(t)}},e.each=function(t){return"function"==typeof t&&n(function(e){return t.apply(e,arguments)},y),e},e.first=function(){return h(y.shift())},e.last=function(){return h(y.pop())},e.odd=function(){var t,e=[];for(t=0;t<y.length;t+=2)e.push(y[t]);return h(e)},e.even=function(){var t,e=[];for(t=1;t<y.length;t+=2)e.push(y[t]);return h(e)},e.hide=function(){return n(function(t){t.style.display="none"},y),e},e.show=function(){return n(function(t){s(t)},y),e},e.toggle=function(t){return"undefined"!=typeof t?t?e.show():e.hide():n(function(t
|
|
|
|
}n.FixedScaleAxis=n.Axis.extend({constructor:r,projectValue:i})}(window,document,t),function(t,e,n){"use strict";function r(t,e,r,i){n.StepAxis["super"].constructor.call(this,t,r,i.ticks,i),this.stepLength=this.axisLength/(i.ticks.length-(i.stretch?1:0))}function i(t,e){return this.stepLength*e}n.StepAxis=n.Axis.extend({constructor:r,projectValue:i})}(window,document,t),function(t,e,n){"use strict";function r(t){this.data=n.normalizeData(this.data);var e={raw:this.data,normalized:n.getDataArray(this.data,t.reverseData,!0)};this.svg=n.createSvg(this.container,t.width,t.height,t.classNames.chart);var r,i,o=this.svg.elem("g").addClass(t.classNames.gridGroup),s=this.svg.elem("g"),u=this.svg.elem("g").addClass(t.classNames.labelGroup),c=n.createChartRect(this.svg,t,a.padding);r=void 0===t.axisX.type?new n.StepAxis(n.Axis.units.x,e,c,n.extend({},t.axisX,{ticks:e.raw.labels,stretch:t.fullWidth})):t.axisX.type.call(n,n.Axis.units.x,e,c,t.axisX),i=void 0===t.axisY.type?new n.AutoScaleAxis(n.Axis.units.y,e,c,n.extend({},t.axisY,{high:n.isNum(t.high)?t.high:t.axisY.high,low:n.isNum(t.low)?t.low:t.axisY.low})):t.axisY.type.call(n,n.Axis.units.y,e,c,t.axisY),r.createGridAndLabels(o,u,this.supportsForeignObject,t,this.eventEmitter),i.createGridAndLabels(o,u,this.supportsForeignObject,t,this.eventEmitter),e.raw.series.forEach(function(a,o){var u=s.elem("g");u.attr({"ct:series-name":a.name,"ct:meta":n.serialize(a.meta)}),u.addClass([t.classNames.series,a.className||t.classNames.series+"-"+n.alphaNumerate(o)].join(" "));var l=[],h=[];e.normalized[o].forEach(function(t,s){var u={x:c.x1+r.projectValue(t,s,e.normalized[o]),y:c.y1-i.projectValue(t,s,e.normalized[o])};l.push(u.x,u.y),h.push({value:t,valueIndex:s,meta:n.getMetaData(a,s)})}.bind(this));var f={lineSmooth:n.getSeriesOption(a,t,"lineSmooth"),showPoint:n.getSeriesOption(a,t,"showPoint"),showLine:n.getSeriesOption(a,t,"showLine"),showArea:n.getSeriesOption(a,t,"showArea"),areaBase:n.getSeriesOption(a,t,"areaBase")},d="function"==typeof f.lineSmooth?f.lineSmooth:f.lineSmooth?n.Interpolation.cardinal():n.Interpolation.none(),p=d(l,h);if(f.showPoint&&p.pathElements.forEach(function(e){var s=u.elem("line",{x1:e.x,y1:e.y,x2:e.x+.01,y2:e.y},t.classNames.point).attr({"ct:value":[e.data.value.x,e.data.value.y].filter(n.isNum).join(","),"ct:meta":e.data.meta});this.eventEmitter.emit("draw",{type:"point",value:e.data.value,index:e.data.valueIndex,meta:e.data.meta,series:a,seriesIndex:o,axisX:r,axisY:i,group:u,element:s,x:e.x,y:e.y})}.bind(this)),f.showLine){var m=u.elem("path",{d:p.stringify()},t.classNames.line,!0);this.eventEmitter.emit("draw",{type:"line",values:e.normalized[o],path:p.clone(),chartRect:c,index:o,series:a,seriesIndex:o,axisX:r,axisY:i,group:u,element:m})}if(f.showArea&&i.range){var v=Math.max(Math.min(f.areaBase,i.range.max),i.range.min),g=c.y1-i.projectValue(v);p.splitByCommand("M").filter(function(t){return t.pathElements.length>1}).map(function(t){var e=t.pathElements[0],n=t.pathElements[t.pathElements.length-1];return t.clone(!0).position(0).remove(1).move(e.x,g).line(e.x,e.y).position(t.pathElements.length+1).line(n.x,g)}).forEach(function(n){var s=u.elem("path",{d:n.stringify()},t.classNames.area,!0);this.eventEmitter.emit("draw",{type:"area",values:e.normalized[o],path:n.clone(),series:a,seriesIndex:o,axisX:r,axisY:i,chartRect:c,index:o,group:u,element:s})}.bind(this))}}.bind(this)),this.eventEmitter.emit("created",{bounds:i.bounds,chartRect:c,axisX:r,axisY:i,svg:this.svg,options:t})}function i(t,e,r,i){n.Line["super"].constructor.call(this,t,e,a,n.extend({},a,r),i)}var a={axisX:{offset:30,position:"end",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:n.noop,type:void 0},axisY:{offset:40,position:"start",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:n.noop,type:void 0,scaleMinSpace:20,onlyInteger:!1},width:void 0,height:void 0,showLine:!0,showPoint:!0,showArea:!1,areaBase:0,lineSmooth:!0,low:void 0,high:void 0,chartPadding:{top:15,right:15,bottom:5,left:10},fullWidth:!1,reverseData:!1,classNames:{chart:"ct-chart-line",labe
|
|
|
|
o[0].appendChild(e)}})}}function e(){$().get(_root+"/wifi/scan",t)}function n(t){setTimeout(e,t)}var r={},i=["Open","WEP","WPA","WPA2","WPA/WPA2"];return r.init=function(){e()},r}(),page_waveform=function(){function t(t){var e,n,r=window.matchMedia("screen and (min-width: 544px)"),i=!r.matches,o="FFT"==t.stats.format;o?(e="Frequency - [ Hz ]",n="Magnitude - [ mA ]"):(e="Sample time - [ ms ]",n="Current - [ mA ]");var s=Math.max(-t.stats.min,t.stats.max),l=Math.max(s,10);$("#stat-count").html(t.stats.count),$("#stat-f-s").html(numfmt(t.stats.freq,2)),$("#stat-i-peak").html(numfmt(s,2)),$("#stat-i-rms").html(numfmt(t.stats.rms,2)),$(".stats").removeClass("invis");var h=o?t.stats.freq/t.stats.count:1e3/t.stats.freq,f=_.map(t.samples,function(t,e){return{x:e*h,y:t}}),d=[Chartist.plugins.zoom({resetOnRightMouseBtn:!0,onZoom:function(t,e){a=e,u=t.options.axisX.highLow,c=t.options.axisY.highLow}})];i||d.push(Chartist.plugins.ctAxisTitle({axisX:{axisTitle:e,offset:{x:0,y:55}},axisY:{axisTitle:n,flipText:!0,offset:{x:0,y:15}}}));var p,m,v,g;u?(p=u.high,m=u.low,v=c.high,g=c.low):(v=o?void 0:l,g=o?0:-l),new Chartist.Line("#chart",{series:[{name:"a",data:f}]},{showPoint:!1,showArea:o,fullWidth:!0,chartPadding:i?{right:20,bottom:5,left:0}:{right:25,bottom:30,left:25},series:{a:{lineSmooth:Chartist.Interpolation.monotoneCubic()}},axisX:{type:Chartist.AutoScaleAxis,high:p,low:m},axisY:{type:Chartist.AutoScaleAxis,high:v,low:g},explicitBounds:{xLow:0,yLow:o?0:void 0,xHigh:f[f.length-1].x},plugins:d})}function e(e,n){if(f=!1,200!=n)errorMsg("Request failed.",1e3);else{var i=JSON.parse(e);i.success?($(".chartexport").removeClass("hidden"),v=i,t(i)):errorMsg("Sampling failed.",1e3)}d&&(m=setTimeout(r,Math.max(0,p-msElapsed(s))))}function n(){g.count=$("#count").val(),g.freq=$("#freq").val()*("fft"==o?2:1)}function r(){f&&(errorMsg("Request already pending - aborting."),l.abort()),f=!0,s=msNow();var t=g.count,n=g.freq,r=_root+"/measure/"+o+"?n="+t+"&fs="+n;return l=$().get(r,e,estimateLoadTime(n,t)),!0}function i(){p=+$("#ar-time").val(),n(),d=!d,d?r():clearTimeout(m),$("#ar-btn").toggleClass("btn-blue").toggleClass("btn-red").val(d?"Stop":"Auto")}var a,o,s,u,c,l,h={},f=!1,d=!1,p=1,m=-1,v=null,g={count:0,freq:0};return h.init=function(t){function e(){n(),r()}o=t,$("#load").on("click",e),$(".chartexport a").on("click",function(){var t=$(this).data("sep"),e="",n=v.stats.freq/v.stats.count;switch(t){case"space":e=v.samples.join(" ");break;case"comma":e=v.samples.join(",");break;case"newline":e=v.samples.join("\n");break;case"fft-csv":e=_.map(v.samples,function(t,e){return numfmt(e*n,3)+","+t}).join("\n");break;case"fft-json":e=JSON.stringify(_.map(v.samples,function(t,e){return{f:+numfmt(e*n,3),m:t}}))}if(copyToClipboard(e))infoMsg("Copy success!");else{var r=$("#copybox");r.removeClass("hidden"),r.val(e)}}),$("#count,#freq").on("keyup",function(t){13==t.which&&e()}),$("#chart").on("contextmenu",function(t){return a&&a(),a=null,u=null,c=null,t.preventDefault(),!1}),$("#ar-btn").on("click",i)},h}(),page_spectrogram=function(){function t(t){var e,n,r,i;t=Math.log10(1+t),t>2&&(t=2),0>t&&(t=0);for(var a=0;a<b.length;a++){var o=b[a],s=o[0];if(t>=s&&(e=s,r=o),s>=t){n=s,i=o;break}}var u=(t-e)/(n-e);e==n&&(u=0);var c=Math.round(r[1]+(i[1]-r[1])*u),l=Math.round(r[2]+(i[2]-r[2])*u),h=Math.round(r[3]+(i[3]-r[3])*u);return"rgb("+c+","+l+","+h+")"}function e(){var t=c.getImageData(g.x+g.dx,g.y,g.w-g.dx,g.h+10);c.fillStyle="black",c.fillRect(g.x,g.y,g.w,g.h),c.clearRect(g.x,g.y+g.h+1,g.w,10),c.putImageData(t,g.x,g.y)}function n(n){e();for(var r=x.sampCount/2,i=0;r>i;i++){var a;if(i*g.dy>g.h)break;a=i>n.length?"#000":t(n[i]),c.fillStyle=a;var o=g.x+g.w-g.dx,s=g.y+g.h-(i+1)*g.dy,u=g.dx,l=g.dy;s<g.y&&(l-=g.y-s,s=g.y),c.fillRect(o,s,u,l)}if(msElapsed(p)>=950){p=msNow();var h=!1;msElapsed(m)>9500&&(h=!0,m=msNow()),c.strokeStyle="white",c.beginPath(),c.moveTo(g.x+g.w-.5,g.y+g.h+1),c.lineTo(g.x+g.w-.5,g.y+g.h+1+(h?6:2)),c.stroke()}}function r(t,e){if(h=!1,200==e)try{var r=JSON.parse(t);r.success?n(r.samples):errorMsg("Sampling failed.",1e3)}catch(a){errorMsg(a)}e
|