|
|
|
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 errorMsg(t){notify.show(t,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 s(t,e,n){try{t.style[r(e)]=n}catch(i){}}function o(t){t.style.display="","none"===i(t,"display")&&(t.style.display="block")}function u(t){var e,r,i,s="";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)s+="&"+a(e,t[e][r]);else s+="&"+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&&(s+="&"+a(e.name,e.value));break;case"select-multiple":for(i=0;i<e.length;i+=1)e[i].selected&&(s+="&"+a(e.name,e[i].value));break;case"checkbox":case"radio":e.checked&&(s+="&"+a(e.name,e.value));break;default:s+="&"+a(e.name,e.value)}},t);return s.length>0?s.substring(1):""}function c(t,e,r){var i,a,s,o=!1;return t&&(i=t.split(/\s+/),n(function(t){for(s=0;s<i.length;s+=1)if(a=new RegExp("\\b"+i[s]+"\\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[s];else if("has"===e&&t.className.match(a)){o=!0;break}},r)),o}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],s=[];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")&&s.push(n[r]);a.removeChild(e)}return s}),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){o(t)},y),e},e.toggle=function(t){return"undefined"!=typeof t?t?e.show():e.hide():n(function(t){"none"===i(t,"display")?o(t):t.style.display="none"},y),e},e.remove=function(){return n(function(t){try{t.parentNode.removeChild(t)}catch(e){}},y),h()},e.css=function(t,a){if(t){if(a||""===a)return n(function(e){s(e,t,a)},y),e;if(y[0]){if(y[0].style[r(t)])return y[0].style[r(t)];if(i(y[0],t))return i(y[0],t)}}},e.getClass=function(){return y[0]&&y[0].className.length>0?y[0].className.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"").replace(/\s+/," "):void 0},e.setClass=function(t){return(t||""===t)&&n(function(e){e.className=t},y),e},e.addClass=function(t){return t&&n(function(e){e.className+=" "+t},y),e},e.removeClass=function(t){return c(t,"remove",y),e},e.toggleClass=function(t){return c(t,"toggle",y),e
|
|
|
|
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(s,u,this.supportsForeignObject,t,this.eventEmitter),i.createGridAndLabels(s,u,this.supportsForeignObject,t,this.eventEmitter),e.raw.series.forEach(function(a,s){var u=o.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(s)].join(" "));var l=[],h=[];e.normalized[s].forEach(function(t,o){var u={x:c.x1+r.projectValue(t,o,e.normalized[s]),y:c.y1-i.projectValue(t,o,e.normalized[s])};l.push(u.x,u.y),h.push({value:t,valueIndex:o,meta:n.getMetaData(a,o)})}.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 o=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:s,axisX:r,axisY:i,group:u,element:o,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[s],path:p.clone(),chartRect:c,index:s,series:a,seriesIndex:s,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 o=u.elem("path",{d:n.stringify()},t.classNames.area,!0);this.eventEmitter.emit("draw",{type:"area",values:e.normalized[s],path:n.clone(),series:a,seriesIndex:s,axisX:r,axisY:i,chartRect:c,index:s,group:u,element:o})}.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",label:"ct-label",labelGroup:"ct-labels",series:"ct-series",line:"ct-line",point:"ct-point",area:"ct-area",grid:"ct-grid",gridGroup:"ct-grids",vertical:"ct-vertical",horizontal:"ct-horizontal",start:"ct-start",end:"ct-end"}};n.Line=n.Base.extend({constructor:i,createChart:r})}(window,document,t),function(t,e,n){"use strict";function r(t){this.data=n.normalizeData(this.data);var e,r={raw:this.data,normalized:t.distributeSeries?n.getDataArray(this.data,t.reverseData,t.horizontalBars?"x":"y").map(function(t){return[t]}):n.getDataArray(this.data,t.reverseData,t.horizontalBars?"x":"y")};this.svg=n.createSvg(this.container,t.width,t.height,t.classNames.chart+(t.horizontalBars?" "+t.classNames.horizontalBars:""));var i=this.svg.elem("g").addClass(t.classNames.gridGroup),s=this.svg.elem("g"),o=this.svg.elem("g").addClass(t.classNames.labelGroup);if(t.stackBars&&
|
|
|
|
high:v,low:g},explicitBounds:{xLow:0,yLow:u?0:void 0,xHigh:f[f.length-1].x},plugins:d})}function e(e,i){if(c=!1,200!=i)errorMsg("Request failed."),l&&r();else{var a=JSON.parse(e);if(!a.success)return errorMsg("Sampling / readout failed."),void(l&&r());t(a),l&&(f=setTimeout(n,h))}}function n(){if(c)return!1;c=!0;var t=$("#count").val(),n=$("#freq").val(),r=_root+"/api/{fmt}.json?n={n}&fs={fs}".format({fmt:a,n:t,fs:n});return $().get(r,e,{timeout:1e3/n*t+1500}),!0}function r(){h=1e3*+$("#ar-time").val(),l=!l,l?n():clearTimeout(f),$("#ar-btn").toggleClass("btn-blue").toggleClass("btn-red").val(l?"Stop":"Auto")}var i,a,s,o,u={},c=!1,l=!1,h=1,f=-1;return u.init=function(t){a=t,$("#load").on("click",n),$("#count,#freq").on("keyup",function(t){13==t.which&&n()}),$("#chart").on("contextmenu",function(t){return i&&i(),i=null,s=null,o=null,t.preventDefault(),!1}),$("input[type=number]").on("mousewheel",function(t){var e=+$(this).val(),n=+($(this).attr("step")||1);t.wheelDelta>0?e+=n:e-=n,$(this).val(e)}),$("#ar-btn").on("click",r)},u}(),page_status=function(){function t(t,a){if(200!=a)errorMsg("Update failed.");else try{var s=JSON.parse(t);n.j=s,$(".sta-only").toggle(s.sta),$(".ap-only").toggle(s.ap),$("#uptime").html(s.uptime),$("#heap").html(s.heap+" bytes"),$("#wmode").html(s.wifiMode),s.sta&&($("#staSSID").html(s.sta.SSID),$("#staRSSIperc").html(s.sta.RSSIperc),$("#staRSSI").html(s.sta.RSSI),$("#staMAC").html(s.sta.MAC)),s.ap&&($("#apSSID").html(s.ap.SSID),$("#apHidden").html(s.ap.hidden?"Yes":"No"),$("#apAuth").html(s.ap.auth),$(".ap-auth-only").toggle("Open"!=s.ap.auth),$("#apPwd").html(s.ap.pwd),$("#apChan").html(s.ap.chan),$("#apMAC").html(s.ap.MAC))}catch(o){errorMsg(o)}i||setTimeout(e,r)}function e(){$().get(_root+"/api/status.json",t)}var n={};n.j={};var r=1e4,i=!1;return n.trigReset=function(){var t="#reset-modal";$().get(_root+"/reset.cgi",function(n,r){if(200==r){modal.show(t),i=!0;var a=setInterval(function(){$().get(_root+"/ping.cgi",function(n,r){200==r&&(modal.hide(t),e(),clearInterval(a),i=!1)},{timeout:500})},1e3)}})},n.init=function(){e()},n}();
|