var LOGGING_ENABLED=true,TIMER_DEBUG=false;jQuery.support.xhrUpload=window.XMLHttpRequest&&((new window.XMLHttpRequest).upload?true:false);jQuery.extend(jQuery.expr[":"],{focus:function(b){return b==document.activeElement},nofocus:function(b){return b!=document.activeElement},shown:function(b){return!(jQuery(b).is(":hidden")||jQuery(b).parents(":hidden").length)}});
(function(b){b.ajaxSetup({contentType:"application/x-www-form-urlencoded; charset=UTF-8"});b.jpass_hint="********";b.jpost=function(a,c,d,f){var g=b("body").attr("sitename");b.ajax({type:"POST",url:"/api"+(g?"/s/"+g:"")+a,data:{json:b.toJSON(c)},success:function(h,j,l){j=l.status==200;b.jpost.fnReflectConnectionStatus&&b.jpost.fnReflectConnectionStatus(j);if(!j){f&&f(h);return false}b.jpost.handle_repsponse(h,d,f)},error:function(h){if(h.status==401||h.status==400)b.jpost.handle_repsponse(b.parseJSON(h.response),
d,f);else b.jpost.fnReflectConnectionStatus&&b.jpost.fnReflectConnectionStatus(false)}})};b.jpost.handle_repsponse=function(a,c,d){var f=a.meta,g=false;if(f.rc=="error"){if(f.msg=="api.err.LoginRequired"){if(!b.jpost.session_expired){b.jpost.session_expired=true;location.href="/login?expired=1"}}else if(f.msg!="api.err.ServerBusy")(g=ApiMsg[f.msg])?alert(V.localizeMsg(g,f)):alert("~"+f.msg+"~");g=true}g&&d&&d(a);!g&&c&&c(a)};b.jcmd=function(a,c,d,f,g){d=d||{};d.cmd=c;b.jpost("/cmd/"+a,d,f,g)};b.jcmd.restart_ap=
function(a){var c=b(a).attr("mac");b.jcmd("devmgr","restart",{mac:c},function(){b("#model-aps").jtablemodel("findrow","mac",c).state=0;b("#model-aps").jtablemodel("firechanged")})};b.jcmd.adopt_ap=function(a){b.jcmd("devmgr","adopt",{mac:b(a).attr("mac")},function(c){c.meta.rc=="error"&&alert(V.localizeMsg(ApiMsg[c.meta.msg],c.meta));b("#model-aps").jtablemodel("refresh")})};b.jcmd.upgrade_ap=function(a,c){var d=b(a).attr("mac");b(c).disable();b.jcmd("devmgr","upgrade",{mac:d},function(){b("#model-aps").jtablemodel("findrow",
"mac",d).state=4;b("#model-aps").jtablemodel("firechanged")},function(){b(c).enable()})};b.jcmd.scan_ap=function(a){b.jcmd("devmgr","scan",{mac:b(a).attr("mac")},function(){b("#model-aps").jtablemodel("refresh")})};b.jhighlight_ap=function(a){b("#MainPanel").tabs("select",0);var c=b("#maplet").get(0);c&&c.flexcall("highlightAp",{_id:b(a).attr("_id")})};b.jcmd.locate_ap=function(a){if(a.adopted){a.locating=!a.locating;b("#model-aps").jtablemodel("firechanged")}else a.locating=false;b.jcmd("devmgr",
a.adopted?a.locating?"set-locate":"unset-locate":"locate",{mac:b(a).attr("mac")},function(){a.state==1&&a.locating&&b.jhighlight_ap(a)})};b.jcmd.block_sta=function(a){var c=b(a).attr("mac");b.jcmd("stamgr","block-sta",{mac:c},function(){b("#model-stas").jtablemodel("deleterow","mac",c);b.event.trigger("jcmd_stablocked")})};b.jcmd.unblock_sta=function(a){a=b(a).attr("mac");b.jcmd("stamgr","unblock-sta",{mac:a},function(){b.event.trigger("jcmd_staunblocked")})};b.jcmd.kick_sta=function(a){var c=b(a).attr("mac");
b.jcmd("stamgr","kick-sta",{mac:c},function(){b("#model-stas").jtablemodel("deleterow","mac",c)})};b.jcmd.unauthorize_guest=function(a){var c=b(a).attr("mac");b.jcmd("stamgr","unauthorize-guest",{mac:c},function(){b("#model-stas").jtablemodel("deleterow","mac",c)})};b.jcmd.authorize_guest=function(a){var c=b(a).attr("mac");b.jcmd("stamgr","authorize-guest",{mac:c},function(){b("#model-stas").jtablemodel("findrow","mac",c).authorized=true;b("#model-stas").jtablemodel("firechanged")})};b.log=function(){if(LOGGING_ENABLED)if(window.console!=
undefined)if(console.log.apply)console.log.apply(console,arguments);else{for(var a="",c=0;c<arguments.length;c++)a+=" "+arguments[c];console.log(a)}};b.trace=function(){LOGGING_ENABLED&&window.console&&window.console.trace&&console.trace()};b.compare=function(a,c){if(V.isNumber(a)&&V.isNumber(c)){a=parseFloat(a);c=parseFloat(c)}return a>c?1:a<c?-1:0};var e={};b.jtstart=function(a){if(TIMER_DEBUG){var c=(new Date).getTime();a="["+a+"]";e[a]=c;b.log(a+" start");return a}};b.jtend=function(a){if(TIMER_DEBUG){var c=
e[a],d=(new Date).getTime();if(c){e[c]=null;b.log(a+" end ("+(d-c)+"ms)")}}};b.fn.disable=function(){return this.each(function(){b(this).attr("disabled","disabled").addClass("disabled ui-state-disabled")})};b.fn.enable=function(){return this.each(function(){b(this).attr("disabled","").removeClass("disabled ui-state-disabled")})};b.fn.setenabled=function(a){return a?b(this).enable():b(this).disable()};b.fn.setvisible=function(a){return a?b(this).show():b(this).hide()};b.fn.checked=function(){return b(this).is(":checked")};
b.fn.check_radio=function(a,c){return this.find('input[name="'+a+'"][value="'+c+'"]').attr("checked","checked").change()};b.fn.val_radio=function(a){return this.find('input[name="'+a+'"]:checked').val()};b.fn.setchecked=function(a){return this.each(function(){b(this).attr("checked",a?"checked":"").change()})};b.fn.attr_get=function(a,c){var d=b(this);if(d.length<1)return c;d=d.attr(a);if(typeof d=="undefined")return c;return d};b.fn.attr_is=function(a,c){var d=b(this).attr(a);if(typeof d=="boolean")return d;
if(typeof d=="undefined")return c;return d=="true"};b.widget("ui.jtable",{options:{pagesize:8,sortby:"",sortdir:"+",sortbyserver:false,viewsize:1500,viewstart:0,selectable:false,model:null,emptydiv:null,debug:false,hidetoolbar:false,showhidden:false,showactions:true,fnrowhover:null,rows:null},_setOption:function(a,c){this.options[a]=c;a==="rows"&&this._model_refreshed();return this},_create:function(){var a=this;if(this._inited){b.log("ERROR! already a "+this.widgetName,a.element);b.trace()}else this._inited=
true;if(this.options.rows)this.options.model={bind:function(){},jtablemodel:function(c){if(c=="rows")return a.options.rows;else b.log("jtable.jtablemodel("+c+") not implemented")}};if(!this.options.model)this.options.model=b(this.element).jtablemodel(this.options);this._model=this.options.model;this._model.bind("jtablemodel_refresh-done",function(){a._model_refreshed()});this.table=b("<table></table>").addClass("data-table dataTables_wrapper").appendTo(this.element);if(this.options.fnrowhover){this.table.addClass("rowhoverable");
this.table.data("fnrowhover",this.options.fnrowhover)}this.options.className&&this.table.addClass(this.options.className);this.emptydiv=this.options.emptydiv||b("#"+this.element.attr("id")+"-none");this.emptydiv.hide();this.element.addClass("data-table-container");this._coldefs=[];this._actions=[];this._filters={};this.page=0;return a},destroy:function(){if(this.element.data("jtable")){this.element.removeClass("data-table-container").empty().unbind("jtable").removeData("jtable");return this}},addcol:function(a,
c,d,f,g){this._coldefs.push({display:a,name:c,sortable:d,renderer:f,compareRenderer:g,shown:true})},addaction:function(a,c,d,f){this._actions.push({display:a,key:c,shown:d,fnclasses:f})},addfilter:function(a,c){this._filters[a]=c},delfilter:function(a){delete this._filters[a]},setsort:function(a,c){this.options.sortby=a;this.options.sortdir=c?"+":"-"},hidecol:function(a){if(a=="actions")this.options.showactions=false;else if(a=this._getcol(a))a.shown=false},showcol:function(a){if(a=="actions")this.options.showactions=
true;else if(a=this._getcol(a))a.shown=true},selectall:function(){b(this.table).find(".sel,.allsel").attr("checked","checked")},selectnone:function(){b(this.table).find(".sel,.allsel").attr("checked","")},getselected:function(){return b(this.table).find(".sel:checked").map(function(){return b.data(this,"o")})},setparams:function(a){this.options.params=a},_getcol:function(a){for(var c=0;c<this._coldefs.length;c++)if(this._coldefs[c].name==a)return this._coldefs[c];return null},repaint:function(){this._paint()},
_paint:function(){var a=this;if(!this._shown){this._filter();this._sort()}a.options.pagesize=parseInt(this.options.pagesize)||10;this.numpages=Math.floor((this._shown.length+this.options.pagesize-1)/this.options.pagesize);if(this._shown.length==0){this.element.hide();this.emptydiv.show()}else{this.emptydiv.hide();this.element.show();this.table.empty();var c=b("<thead></thead>"),d=b("<tr></tr>");this.page==0&&d.addClass("first-row");if(this.options.selectable){var f=b('<input type="checkbox" class="allsel"/>');
f.click(function(){a.table.find("input.allsel").attr("checked")?b(a.table).find("input.sel").attr("checked","checked"):b(a.table).find("input.sel").attr("checked","")});d.append(b("<th></th>").append(f))}b.each(a._coldefs,function(){var o=this;if(!o.shown)return true;var m=b("<th></th>"),q=b("<span>"+o.display+"</span>");m.append(q);var p=a.options.sortby,r=a.options.sortdir=="+";if(p&&o.name==p)q.addClass(r?"ascending":"descending");if(this.sortable){m.addClass("sortable");m.click(function(){if(o.name==
p)r=!r;else{p=o.name;r=true}a.setsort(p,r);a.sort()})}d.append(m)});d.find("th:first-child").addClass("first-col");a._actions.length>0&&this.options.showactions&&d.append(b("<th>"+Msg.Actions+"</th>"));c.append(d);a.table.append(c);var g=b("<tbody></tbody>"),h=true;if(a._shown.length<a.page*a.options.pagesize)a.page=0;b.each(a._shown,function(o,m){if(o<a.page*a.options.pagesize)return true;if(o>=(a.page+1)*a.options.pagesize)return false;var q=b('<tr class="'+(h?"odd":"even")+'"></tr>');h=!h;q.data("o",
m);if(a.options.selectable){var p=b('<input type="checkbox" class="sel" />');b.data(p.get(0),"o",m);q.append(b("<td></td>").append(p))}b.each(a._coldefs,function(){if(!this.shown)return true;var n=m[this.name],s=b("<td></td>");this.renderer&&this.renderer.className?s.addClass(this.renderer.className):s.addClass(this.name);n=this.renderer?this.renderer(n,m):a._defaultRenderer(n);typeof n=="string"?s.text(n):s.append(n);q.append(s)});if(a.options.showactions&&a._actions.length>0){var r=b('<td class="actions"></td>');
b.each(a._actions,function(){var n=this;if(n.shown?n.shown(m):true){var s=b('<a href="javascript:void(0);" class="button">'+n.display+"</a>").data("o",m).click(function(t){a._trigger(n.key,t,m);return false});n.fnclasses&&s.addClass(n.fnclasses(m));s.appendTo(r)}});q.append(r)}g.append(q)});a.table.append(g);f=g.find("tr:last");c=f.find("td").size();if(this.page+1==this.numpages){f.addClass("last-row");if(this.numpages>1){f=this.options.pagesize-g.find("tr").size();for(var j=0;j<f;j++)g.append(b('<tr class="empty-row"><td colspan="'+
c+'">&nbsp;</td></tr>'))}}if(a.numpages>0&&!a.options.hidetoolbar){if(!a.toolbar){a.toolbar=b('<div class="data-table-status"></div>').appendTo(a.element);a.toolbar.append(b('<span class="data-table-paging-details"></span>'));c=b('<div class="data-table-paging"></div>');f=b('<a href="javascript:void(0);" class="back-button">back</a>');var l=b('<div class="handle-page-number"><span class="ui-corner-all">1</span></div>'),k=b('<div class="data-table-slider"></div>');j=b('<a href="javascript:void(0);" class="next-button">next</a>');
j.addClass(a.page==a.numpages-1?"next-button-disabled":"next-button");j.click(function(){a.page=Math.min(a.numpages-1,a.page+1);a._paint();k.slider("value",a.page);l.find("span").html(Math.round(a.page)+1);l.show().delay(1E3).fadeOut("slow")});f.addClass(a.page==0?"back-button-disabled":"back-button");f.click(function(){a.page=Math.max(0,a.page-1);a._paint();k.slider("value",a.page);l.find("span").html(Math.round(a.page)+1);l.show().delay(1E3).fadeOut("slow")});k.slider({min:0,max:a.numpages-1,value:a.page,
start:function(o,m){a.page=Math.round(m.value);l.find("span").html(Math.round(a.page)+1)},slide:function(o,m){k.find("div.handle-page-number span").html(Math.round(m.value)+1)},change:function(o,m){a.page=Math.round(m.value);a._paint()}});l.find("span").html(Math.round(a.page)+1);l.hide();k.find(".ui-slider-handle").append(l).mousedown(function(){l.show()}).mouseup(function(){l.hide()});c.append(f).append(k).append(j);a.toolbar.append(c)}a.toolbar.find("span.data-table-paging-details").html(this.page*
this.options.pagesize+1+" - "+Math.min((this.page+1)*this.options.pagesize,this._shown.length)+" / "+this._shown.length);a.toolbar.find("div.data-table-slider").slider("option","max",a.numpages-1)}a.element.find(".data-table-paging").setvisible(a.numpages>1)}},sort:function(){if(this.options.sortby){this.page=0;if(this.options.sortbyserver)this.refresh();else{this._sort();this._paint()}}},_sort:function(){if(this.options.sortby){var a=this.options.sortby,c=this.options.sortdir!="-",d=this._getcol(a).compareRenderer;
this._shown=b(this._shown).sort(function(f,g){var h=f[a],j=g[a];if(d){h=d(h,f);j=d(j,g)}h=h==null?0:h;j=j==null?0:j;h=b.compare(h,j);return(c?1:-1)*h})}},size:function(){return(this._shown||[]).length},filter:function(){this.page=0;if(this.options.sortbyserver)this.refresh();else{if(this.toolbar){this.toolbar.empty().remove();this.toolbar=null}this._filter();this._sort();this._paint()}},_filter:function(){var a=this._model.jtablemodel("rows"),c=b.jtstart("filtering "+this.element.attr("id")+"("+a.length+
")"),d=this;this._shown=[];this._hidden=[];b.each(a,function(f,g){var h=this,j=true;if(g.attr_hidden&&!d.options.showhidden)return true;for(var l in d._filters){var k=d._filters[l];if(k!=null)if(l=="*"){var o=RegExp(k,"i"),m=false;b.each(d._coldefs,function(){if(!this.shown)return true;var p=h[this.name];p=this.renderer?this.renderer(p,h):d._defaultRenderer(p);if(p==undefined)return true;if(p instanceof jQuery){var r=[p.text()],n=p.attr("title");n&&r.push(n);b.each(p.find('[title^=""]'),function(s,
t){r.push(t.title)});p=r.join(" ")}if(typeof p!="string")p=p.toString();if(p.search(o)>=0){m=true;return false}});if(!m){j=false;break}}else if(b(h).attr(l)==null){j=false;break}else{var q=false;b.each(k instanceof Array?k:[k],function(p,r){var n=b(h).attr(l);if(n==r||n.toString().search(RegExp(r,"i"))>=0){q=true;return false}});if(!q){j=false;break}}}j&&d._shown.push(h)});b.jtend(c)},refresh:function(a){this._model.jtablemodel("refresh",a)},_apply_options:function(){var a=this;if(this.options.rows)this.options.model=
{bind:function(){},jtablemodel:function(c){if(c=="rows")return a.options.rows;else b.log("jtable.jtablemodel("+c+") not implemented")}};if(!this.options.model)this.options.model=b(this.element).jtablemodel(this.options);this._model=this.options.model;this._model.bind("jtablemodel_refresh-done",function(){a._model_refreshed()});this.options.className&&this.table.addClass(this.options.className);this.emptydiv=this.options.emptydiv||b("#"+this.element.attr("id")+"-none");this.emptydiv.hide()},refresh_options:function(){this._apply_options();
this._model_refreshed()},model:function(){return this._model},_model_refreshed:function(){this._filter();this._sort();if(this.toolbar){this.toolbar.empty().remove();this.toolbar=null}this._paint();this._trigger("refresh-done",0,this)},_defaultRenderer:function(a){return a},widgetEventPrefix:"jtable_"});b.widget("ui.jtablemodel",{options:{url:null,params:{},mapkey:null,autoRefresh:false},_create:function(){this._rows=[];this._map={}},rows:function(){return this._rows},map:function(){return this._map},
findrow:function(a,c){var d=null;b.each(this._rows,function(){if(b(this).attr(a)==c){d=this;return false}});return d},deleterow:function(a,c){var d=this,f=-1;b.each(this._rows,function(g,h){if(b(h).attr(a)==c){d._rows.splice(g,1);d.options.mapkey&&_deleterowfrommap(h);f=g;d._trigger("refresh-done",0,d);return false}});return f},appendrows:function(a){this._rows=this._rows.concat(a);this.options.mapkey&&this._addrowstomap(a);this._trigger("refresh-done",0,this)},prependrows:function(a){this._rows=
a.concat(this._rows);this.options.mapkey&&this._addrowstomap(a);this._trigger("refresh-done",0,this)},_addrowstomap:function(a){var c=this;b.each(a,function(d,f){c._map[f[c.options.mapkey]]=f})},_deleterowfrommap:function(a){delete this._map[a[this.options.mapkey]]},model:function(){return this},firechanged:function(){this._trigger("refresh-done",0,this)},refresh:function(a){var c=this;a=b.extend(b.extend({},this.options.params),a);c._map={};b.jpost(this.options.url,a,function(d){c._rows=d.data;c.options.mapkey&&
c._addrowstomap(c._rows);c._trigger("refresh-done",0,c)})},widgetEventPrefix:"jtablemodel_"});b.widget("ui.jusagechart",{options:{attrs:[],legend_x:0,by_attr:"ap",no_data_msg:"Waiting for more data",legendRenderer:null,limit:10,autoResize:false},_create:function(){var a=this;a.options.autoResize&&b(window).resize(function(){if(a._timer){clearTimeout(a._timer);a._timer=null}a._timer=setTimeout(function(){if(a._paper){a._paper.clear();a._paper.remove();a._paper=null;a.element.data("paper",null)}a.element.is(":shown")&&
a._paint()},200)})},setAttrs:function(a,c){this.options.attrs[c].name=a},set_model:function(a){var c=this;c.series=[];c.labels=[];b.each(c.options.attrs,function(d,f){var g=[];b.each(a,function(h,j){if(d==0)c.labels.push({name:(c.options.legendRenderer||Renderer.original)(j[c.options.by_attr])});j[f.name]&&g.push(j[f.name])});c.series.push(g)});c._paint()},_hoverin:function(){var a=this.sector,c=a.paper.chart;if(!a.tag){a.tag=a.paper.g.label(this.mx,this.my,(this.value.value*100/this.total).toFixed(2)+
"%").attr({opacity:0});a.tag.insertBefore(this.cover)}a.tag.animate({opacity:1},100);c.labels[this.value.order].icon.animate({scale:1.5},100);c.labels[this.value.order].txt.attr({"font-weight":800})},_hoverout:function(){var a=this.sector.paper.chart;this.sector.tag.animate({opacity:0},100);a.labels[this.value.order].icon.animate({scale:1},100);a.labels[this.value.order].txt.attr({"font-weight":400})},_msgbox:function(a){a=this._paper.text(this._paper.width/2,this._paper.height/2,a).attr({font:"16px Arial, sans-serif"});
var c=a.getBBox();this._paper.rect(c.x-10,c.y-10,c.width+20,c.height+20,5).attr({"stroke-width":5,stroke:"#555",fill:"#eee"});a.toFront()},_paint:function(){if(!this._paper){this._paper=Raphael(this.element.get(0),this.element.width(),this.element.height());this._paper.chart=this}this._paper.clear();if(!this.labels||this.labels.length==0)this._msgbox(this.options.no_data_msg);else{var a=0,c=true;b.each(this.series,function(m,q){a+=q.length;if(q.length==0)c=false});if(a==0||!c)this._msgbox(this.options.no_data_msg);
else{var d=this.element.height(),f=this.options.legend_x||this.element.width()-150,g=this.options.attrs.length;this.pies=[];for(var h=0;h<g;h++){var j=f-f/g*(h+1)+10,l=j+50+d/2-10,k=d/2,o=d/2*0.8;this._paper.text(j,10,this.options.attrs[h].label).attr({font:"16px Arial, sans-serif","text-anchor":"start"});this.pies[h]=this._paper.g.piechart(l,k,o,this.series[h].slice(0));this.pies[h].hover(this._hoverin,this._hoverout)}d=this._paper.set();for(h=0;h<this.labels.length;h++)if(this.pies[0].series[h]){g=
this.labels[h].color=this.pies[0].series[h].attr("fill")||"#ccc";g=this.labels[h].icon=this._paper.g.square(f+5,10+h*20,5).attr({fill:g,stroke:"none"});j=this.labels[h].txt=this._paper.g.text(f+20,10+h*20,this.labels[h].name).attr({"text-anchor":"start"});d.push(g);d.push(j)}}}}});b.widget("ui.jtimechart",{options:{model:null,timeRenderer:null,tooltip_width:60,autoResize:false},_create:function(){var a=this;if(!this.options.model)this.options.model=this.element.jtimechartmodel(this.options);this._model=
this.options.model;this._model.bind("jtimechartmodel_refresh-done",function(){a._model_refreshed()});a=this;a.options.autoResize&&b(window).resize(function(){if(a._timer){clearTimeout(a._timer);a._timer=null}a._timer=setTimeout(function(){if(a._paper){a._paper.clear();a._paper.remove();a._paper=null;a.element.data("paper",null)}a.element.is(":shown")&&a._paint()},200)})},setScope:function(a){this._model.jtimechartmodel("setScope",a)},overlay:function(a){this.options.model_2=a;this._paint()},repaint:function(){this._paint()},
refresh:function(){this._model.jtimechartmodel("refresh")},_model_refreshed:function(){this._paint()},_paintGrid:function(a,c,d,f,g,h,j,l){g=g||"#000";var k=[],o=f/3,m=h.length-1,q=d/m;k=k.concat(["M",a,c+o,"L",a+d,c+o]);for(d=1;d<m;d++)if(h[d])k=k.concat(["M",a+d*q,c,"L",a+d*q,c+f]);this._paper.path(k.join(",")).attr({stroke:g});this._paper.text(a+2,c+o-5,l).attr({"text-anchor":"start",fill:g});for(d=0;d<m;d++)h[d]&&this._paper.text(a+d*q+2,c+f-7,h[d]).attr({"text-anchor":"start",fill:j})},_paintSeries:function(a,
c,d,f,g,h,j,l){var k=this,o=this._paper.path().attr({stroke:g,"stroke-width":4,"stroke-linejoin":"round"}),m=this._paper.path().attr({stroke:"none",opacity:0.3,fill:g}).moveTo(a,c+f),q=d/(h.length-1),p=j==0?f/10:f/1.5/j/1;b.each(h,function(r,n){var s=a+q*r,t=c+f-p*n;m[r==0?"lineTo":"cplineTo"](s,t,10);o[r==0?"moveTo":"cplineTo"](s,t,10);if(n){var u=k._paper.circle(s,t,5).attr({fill:g,stroke:"#fff"}),v=k._paper.rect(s-q/2,c,s+q/2,c+f).attr({stroke:"none",fill:"#fff",opacity:0});b(v.node).hover(function(){var w=
l?l(n):n;k._showTooltip(s+8,t-33,w,u)},function(){k._hideTooltip(u)})}});m.lineTo(a+d,c+f).andClose()},_paint:function(){var a=this;if(a.element.is(":shown")){if(!a._paper){a._paper=Raphael(a.element.get(0),a.element.width(),a.element.height());a.element.data("paper",a._paper)}a._paper.clear();var c=[],d=[],f=[],g=[],h=0,j=0,l=[],k=this._model.jtimechartmodel("data");b.each(k,function(r,n){var s=n[0],t=n[1],u=t.num_sta||0;c.push(u);h=Math.max(h,u);t=t.bytes||0;d.push(t);j=Math.max(j,t);l.push(r%2==
1?(a.options.timeRenderer||Renderer.timeHour24)(s):null)});this.options.model_2&&b.each(this.options.model_2.jtimechartmodel("data"),function(r,n){var s=n[1];f.push(s.num_sta||0);g.push(s.bytes||0)});k=3;var o=a.element.width()-6,m=a.element.height()/2-6,q="hsb("+[0.6,1,0.75]+")",p="hsb("+[0.2,1,0.75]+")";a._paintGrid(3,k,o,m,"#eee",l,q,h);a._paintSeries(3,k,o,m,q,c,h);this.options.model_2&&a._paintSeries(3,k,o,m,p,f,h);a._paper.text(5,k+8,"# of Clients").attr({font:"16px Arial, sans-serif","text-anchor":"start"});
k+=a.element.height()/2;a._paintGrid(3,k,o,m,"#eee",l,q,Renderer.pktsBytes(j));a._paintSeries(3,k,o,m,q,d,j,Renderer.pktsBytes);this.options.model_2&&a._paintSeries(3,k,o,m,p,g,j,Renderer.pktsBytes);a._paper.text(5,k+5,"Traffic").attr({font:"16px Arial, sans-serif","text-anchor":"start"});a._tooltip_box=a._paper.rect(10,10,a.options.tooltip_width,25,5).attr({fill:"#000",stroke:"#474747","stroke-width":2}).hide();a._tooltip_label=a._paper.text(a.options.tooltip_width/2,10,"15").attr({font:"12px Fontin-Sans, Arial",
fill:"#fff"}).hide()}},_showTooltip:function(a,c,d,f){if(a+this.options.tooltip_width>this.element.width())a=a-this.options.tooltip_width-10;clearTimeout(this._hidetooltip_timer);this._tooltip_box.show().animate({x:a,y:c},200*self._tooltip_visible);this._tooltip_label.attr({text:d}).show().animateWith(this._tooltip_box,{x:a+this.options.tooltip_width/2,y:c+12},200*self._tooltip_visible);f.attr("r",7);self._tooltip_visible=true},_hideTooltip:function(a){var c=this;a.attr("r",5);this._hidetooltip_timer=
setTimeout(function(){c._tooltip_box.hide();c._tooltip_label.hide();c._tooltip_visible=false},1)}});b.widget("ui.jtimechartmodel",{tzoffsetMilli:(new Date).getTimezoneOffset()*60*1E3,hourMilli:36E5,dayMilli:864E5,options:{scope:"system",scale:"hourly",end_utc:null,attrs:["bytes","num_sta","time"]},_create:function(){},setend:function(a){a.setUTCMinutes(0);a.setUTCSeconds(0);a.setUTCMilliseconds(0);this.end_utc=a.getTime();this.dt=this.options.scale=="hourly"?this.hourMilli:this.dayMilli;this.n=this.options.scale==
"hourly"?24:30;this.start_utc=this.end_utc-this.n*this.dt},setScope:function(a){this.options.scope=a==null?"system":"map."+a},refresh:function(){var a=this;this.end_utc||this.setend(this.options.end_utc?new Date(this.options.end_utc):new Date);b.jpost("/stat/report/"+this.options.scale+"."+this.options.scope,{attrs:a.options.attrs,start:a.start_utc,end:a.end_utc},function(c){a.response=c;a._data=[];var d=a.end_utc;for(b.each(c.data,function(f,g){if(g.o=="ap")return true;for(;g.time<d;){a._data.unshift([d,
{}]);d-=a.dt}g.time!=d&&b.log("error",d,g.time);a._data.unshift([d,g]);d-=a.dt});a.start_utc<=d;){a._data.unshift([d,{}]);d-=a.dt}a._trigger("refresh-done",0,a)})},data:function(){return this._data},widgetEventPrefix:"jtimechartmodel_"});b.widget("ui.jsysinfo",{options:{},_create:function(){},data:function(){return this._data},refresh:function(){var a=this;b.jpost("/stat/sysinfo",{},function(c){a._data=c.data[0];a._trigger("changed",0,a)})},widgetEventPrefix:"jsysinfo_"});b.widget("ui.jdateslider",
{options:{scale:"24h",scales:["24h","30d"],date:null},_create:function(){var a=this;this.older=b("<button></button>").button({text:false,icons:{primary:"ui-icon-triangle-1-w"}}).click(function(){a._slide(false)}).appendTo(a.element);this.dp=b('<div class="dateslider" />').appendTo(b("body")).datepicker({onSelect:function(c,d){var f=a.get_date();f.setYear(d.selectedYear);f.setMonth(d.selectedMonth);f.setDate(d.selectedDay);a.set_date(f);a._hide()}}).css({position:"absolute",display:"none","z-index":11}).hide();
this.display=b('<button class="dateslider"></button>').button().click(function(){a._shown?a._hide():a._show()}).appendTo(a.element);this.scale=b('<ul class="dateslider choose-scale buttonbar thin"></ul>').css({position:"absolute",display:"none","z-index":11}).bind("jchoose_selected",function(c,d){a.options.scale=d;a.set_date(a.get_date());a._hide()}).appendTo(b("body"));this.later=b("<button></button>").button({text:false,icons:{primary:"ui-icon-triangle-1-e"}}).click(function(){a._slide(true)}).appendTo(this.element);
b.each(a.options.scales,function(c,d){var f=b('<li><a href="#'+d+'">'+d+"</a></li>").appendTo(a.scale);a.options.scale==d&&f.addClass("ui-tabs-selected")});this.scale.jchoose();this.set_date(this.options.date||new Date)},_show:function(){var a=this.display.offset();this.scale.css({left:a.left,top:a.top-this.scale.height()-5}).show();this.dp.css({left:a.left,top:a.top+this.display.height()+5}).show();this._shown=true},_hide:function(){this.dp.hide();this.scale.hide();this._shown=false},extclick:function(){this._shown&&
this._hide()},_slide:function(a){a=(this.options.scale.match(/d$/)?864E5:36E5)*(a?1:-1);this.set_date(new Date(this.get_date().getTime()+a))},firechanged:function(){this._trigger("changed",0,this)},set_date:function(a){function c(g){return g<10?"0"+g:g}var d=this.options.scale,f=d.match(/d$/)?864E5:36E5;a.setMilliseconds(0);a.setSeconds(0);a.setMinutes(0);d.match(/d$/)&&a.setHours(0);this.options.end=this._end=a;a=this.options.start=this._start=new Date(a.getTime()-(parseInt(d)||1)*f);f=this._end;
this.display.button("option","label",d=="24h"?a.getHours()+":00 - "+f.getFullYear()+"/"+c(f.getMonth()+1)+"/"+c(f.getDate())+"  "+f.getHours()+":00":d=="30d"?a.getFullYear()+"/"+c(a.getMonth()+1)+"/"+c(a.getDate())+" - "+f.getFullYear()+"/"+c(f.getMonth()+1)+"/"+c(f.getDate()):d=="1d"?f.getFullYear()+"/"+c(f.getMonth()+1)+"/"+c(f.getDate()):d=="7d"?a.getFullYear()+"/"+c(a.getMonth()+1)+"/"+c(a.getDate())+" - "+f.getFullYear()+"/"+c(f.getMonth()+1)+"/"+c(f.getDate()):d=="1h"?f.getFullYear()+"/"+c(f.getMonth()+
1)+"/"+c(f.getDate())+"  "+f.getHours()+":00":Renderer.timestamp(f.getTime())+" ("+d+")");this.firechanged()},get_date:function(){return this._end},widgetEventPrefix:"jdateslider_"});b.widget("ui.jtimer",{options:{interval:120},_create:function(){var a=this;this.element.val(this.options.interval);this.element.change(function(){a.start()})},start:function(){var a=this,c=a.element.val();a.stop();if(c!=0)a.timer=setInterval(function(){a.trigger()},c*1E3)},stop:function(){this.timer&&clearInterval(this.timer);
this.timer=0},trigger:function(){this._trigger("due",0,this)},val:function(a){if(a==undefined)return this.element.val();this.element.val(a);return a},widgetEventPrefix:"jtimer_"});b.widget("ui.jpass",{options:{hint:b.jpass_hint,shown:false},_create:function(){var a=this;this.value=this.options.value||"";this.shown=this.options.shown;this.element.focus(function(){a.element.val(a.value);a.shown=true});this.element.blur(function(){a.save();a.shown=false;a.element.val(a.options.hint)});this.element.mousedown(function(){a.element.val(a.value);
a.shown=true});this.element.val(this.shown?this.value:this.options.hint)},hide:function(){this.shown=false;this.element.val(this.options.hint)},show:function(){this.show=true;this.element.val(this.value)},save:function(){var a=this.element.val();if(a!=this.options.hint&&a!=this.value)this.value=a},val:function(a){if(a==undefined)return this.shown?this.element.val():this.value;else{this.value=a;this.shown&&this.element.val(this.value)}}});b.widget("ui.jlistmodel",{options:{url:null,params:{},tableModel:null,
tableModelRowConverter:null,rows:null,selected:"*",autoRefresh:false},_create:function(){var a=this;this._rows=[];if(this.options.tableModel)this.options.tableModel.bind("jtablemodel_refresh-done",function(){a._rows=[];b.each(a.options.tableModel.jtablemodel("rows"),function(c,d){var f=a.options.tableModelRowConverter?a.options.tableModelRowConverter(d):d;f&&a._rows.push(f)});a._trigger("refresh-done",0,a)});else if(this.options.rows)a._rows=this.options.rows},rows:function(){return this._rows},selected:function(){return this.options.selected},
setselected:function(a){this.options.selected=a;this._trigger("select-changed",0,this)},findrow:function(a,c){var d=null;b.each(this._rows,function(){if(b(this).attr(a)==c){d=this;return false}});return d},deleterow:function(a,c){var d=this;b.each(this._rows,function(f,g){if(b(g).attr(a)==c){d._rows.splice(f,1);d._trigger("refresh-done",0,d);return false}})},addrow:function(a){if(this.options.tableModel)alert("jlistmodel.addrow for tableModel not implemented");else{this._rows.push(a);this._trigger("refresh-done",
0,this)}},refresh:function(a){var c=this;if(this.options.tableModel){b.log("refreshing the underneath jtablemodel");this.options.tableModel.jtablemodel("refresh")}else if(c.options.rows)c._trigger("refresh-done",0,c);else{a=b.extend(this.options.params,a);b.jpost(this.options.url,a,function(d){c._rows=d.data;c._trigger("refresh-done",0,c)})}},widgetEventPrefix:"jlistmodel_"});b.widget("ui.jselect",{options:{model:null,fancy:false,fancy_paint:null,sortby:null,compareRenderer:null,renderer:null,defaultItem:null,
showhidden:false,selectionSynchronized:false},_create:function(){var a=this;this._model=this.options.model;this._model.bind("jlistmodel_refresh-done",function(){a._paint()});if(a.options.selectionSynchronized){this._model.bind("jlistmodel_select-changed",function(){a.element.val()!=a._model.jlistmodel("option","selected")&&a.element.val(a._model.jlistmodel("option","selected"))});this.element.change(function(){a._model.jlistmodel("setselected",a.element.val())})}a.options.fancy&&this.element.selectmenu()},
_paint:function(){var a=this,c=a.element.val();this.element.empty();a.options.defaultItem&&b('<option value="">'+a.options.defaultItem+"</option>").appendTo(a.element);var d=b.extend([],a._model.jlistmodel("rows")),f=this.options.sortby,g=this.options.compareRenderer;if(f)d=b(d).sort(function(h,j){var l=h[f],k=j[f];if(g){l=g(l,h);k=g(k,j)}return b.compare(l,k)});b.each(d,function(h,j){if(j.attr_hidden&&!a.options.showhidden)return true;var l=a.options.renderer?a.options.renderer(j.name,j):j.name;
if(l==null)return true;(typeof l=="string"?b('<option value="'+j._id+'"></option>').text(l):l).appendTo(a.element)});if(a.options.selectionSynchronized)this.element.val(a._model.jlistmodel("option","selected"));else{if(c!=null&&a.element.find("option[value="+c+"]").length==0)c=null;if(c==null&&a.element.find("option").length>0)a.options.defaultItem!=null?a.element.val(a.options.defaultItem):a.element.val(a.element.find("option:first").val());else a.element.val(c)}this._prevselected=this.element.val();
if(a.options.fancy){a.options.fancy_paint&&a.options.fancy_paint(a);a.element.selectmenu("destroy").selectmenu({style:"dropdown"})}},getselected:function(){return this._model.jlistmodel("findrow","_id",this.element.val())},getprevselected:function(){return this._prevselected},repaint:function(){this._paint()}});b.extend(b.ui.autocomplete.prototype,{_renderItem:function(a,c){b.log(c);var d=b("<li></li>").data("item.autocomplete",c).append(b("<a></a>").text(c.label));if(c.term){var f=RegExp("("+c.term+
")","i");f=d.find("a").text().replace(f,"<strong>$1</strong>");d.find("a").html(f)}d.appendTo(a);return d}});b.widget("ui.jsearch",{options:{delay:300,autocomplete:false,autocomplete_source:null},_create:function(){var a=this;this.element.attr("placeholder","Search");this.element[0].form&&b(this.element[0].form).submit(function(){return false});this.element.click(function(){a.element.select()});this.element.keydown(function(c){if(c.ctrlKey||c.metaKey||c.altKey)return true;if(a._timer){clearTimeout(a._timer);
a._timer=null}a._timer=setTimeout(function(){a._trigger("search",0,a)},a.options.delay)})},widgetEventPrefix:"jsearch_"});b.widget("ui.jform",{options:{japply:null,detect_change:true,model:null,populate:null,get_posts:[],validate:null},_create:function(){var a=this;this.japply=this.options.japply||this.element.find("input[name=apply]");this.japply.japply({get_posts:this.options.get_posts,validate:this.options.validate,done:function(c){a.snapshot=a._snapshot();a.options.done&&a.options.done(c)},jform:a});
this.options.model&&this.set_model(model)},_snapshot:function(){var a;if(this.options.get_posts){a=this.options.get_posts(this.options.model);b.isArray(a)||(a=[a])}else a=[];var c=[];b.each(a,function(d,f){c.push(f.url);c.push(f.payload)});return b.toJSON(c)},set_model:function(a){if((this.options.model=a)&&this.options.populate){this.options.populate(this.options.model);this.snapshot=this._snapshot(this)}},model:function(){return this.options.model},changed:function(){return this._snapshot()!=this.snapshot},
widgetEventPrefix:"jform_"});b.widget("ui.japply",{options:{submitbyenter:true},_create:function(){var a=this;this.element.click(function(){a.submit();return false});b(this.element.attr("form")).submit(function(){a.options.submitbyenter&&a.submit();return false})},model:function(){return this.options.jform?this.options.jform.model():null},submit:function(){this.element.disable();if(this.options.validate&&!this.options.validate(this.model()))this.element.enable();else if(this.options.detect_change&&
this.options.jform&&!this.options.jform.changed()){this.element.enable();this.done(this.options.jform.model())}else{if(this.options.get_posts){this.posts=this.options.get_posts(this.model());if(!b.isArray(this.posts))this.posts=[this.posts]}else this.posts=[];this.nextapply()}return false},nextapply:function(a){for(var c=this;this.posts.length>0;){a=this.posts.shift();b.jpost(a.url,a.payload,function(d){c.nextapply(d)},function(){setTimeout(function(){c.element.enable()},500)});return}c.done(a)},
done:function(a){var c=this;setTimeout(function(){c.element.enable()},500);typeof c.options.done=="function"&&c.options.done(a)}});b.widget("ui.jchoose",{option:{},_create:function(){var a=this;if(!this.options.selected)this.options.selected=(a.element.find("a").attr("href")||"#").substring(1);a.element.find("li").click(function(c){c=b(c.currentTarget);a._select(c);a._trigger("selected",0,a.options.selected);return false})},_select:function(a){if(a)if(!a.hasClass("ui-tabs-selected")){this.element.find("li.ui-tabs-selected").removeClass("ui-tabs-selected");
a.addClass("ui-tabs-selected");this.options.selected=(a.find("a").attr("href")||"#").substring(1)}},select:function(a){if(a=this.element.find("a[href=#"+a+"]")){this._select(a.parent());this._trigger("selected",0,this.options.selected)}},selected:function(){return this.options.selected},widgetEventPrefix:"jchoose_"});b.widget("ui.jupload",{options:{autostart:true,url:"/upload/backup"},_create:function(){var a=this;a._id=this.element.attr("id");this.element.val("");this._progress=b('<div class="jupload-progress ui-corner-all"></div>').hide().insertAfter(this.element);
this._filename=b('<span class="filename"></span>').appendTo(this._progress);this._bar=b('<div class="bar"></div>').progressbar().appendTo(this._progress);this._cancel=b('<a class="cancel-button button"></a>').html("Cancel").appendTo(this._progress).click(function(){a.cancel()});this._confirm=b("#"+a._id+"-confirm");this._confirm.appendTo(a._progress);this._tryagain=b('<div class="error-restore button"></div>').hide().appendTo(this._progress);this._error=b('<div class="error-text button"></div>').appendTo(this._tryagain);
b('<a class="cancel-button button"></a>').html("Try Again").appendTo(this._tryagain).click(function(){a.cancel()});if(!jQuery.support.xhrUpload){a._form=b('<form method="post" enctype="multipart/form-data"></form>').attr("id",a._id+"form").attr("target",a._id+"IF").attr("action",a.options.url).insertBefore(this.element);a.element.appendTo(this._form);a._iframe=b('<iframe src="/iframe.html" class="jupload-IF"></iframe>').attr("id",a._id+"IF").attr("name",a._id+"IF").appendTo(this._form);b('<input type="hidden" name="id" value="'+
a._id+'"/>').appendTo(this._form);a._form.height(1)}this.element.change(function(){a.options.autostart&&a.element.val()!=""&&a.upload()});b(".cancel button",this._progress).html("Cancel")},destroy:function(){},upload:function(){var a=this;a.element.hide();a._progress.show();a._tryagain.hide();a._confirm.hide();a._filename.addClass("busy");a._bar.show().progressbar("value",0);a._cancel.show();if(jQuery.support.xhrUpload){var c=a.element.attr("files")[0],d=c.name||c.fileName,f=c.size||c.fileSize;a._filename.html(d+
" ("+Renderer.pktsBytes(f)+" bytes)");var g=new XMLHttpRequest;g.upload.onprogress=function(h){a._bar.progressbar("value",h.loaded/h.total*100)};g.onload=function(){a._bar.progressbar("value",100);a._uploaded(b.parseJSON(g.responseText).meta)};g.onabort=g.onerror=function(){a.cancel()};g.open("POST",a.options.url,true);g.setRequestHeader("Cache-Control","no-cache");g.setRequestHeader("X-Requested-With","XMLHttpRequest");g.setRequestHeader("X-File-Name",d);g.setRequestHeader("X-File-Size",f);g.setRequestHeader("Content-Type",
"multipart/form-data");g.send(c)}else{a._iframe.contents().find("div#"+a._id).remove();a._filename.html("Uploading ...");this._form.get(0).submit();this._monitor(this)}},_uploaded:function(a){this._cancel.hide();this._filename.removeClass("busy");if(a.rc=="error"){this._error.html(V.localizeMsg(ApiMsg[a.msg],a));this._tryagain.show()}else{this._confirm.show();this._trigger("uploaded",0,a)}},_monitor:function(a){var c=a._iframe.contents().find("div#"+a._id);if(c.size()>0){c=b.parseJSON(c.attr("response")).meta;
a._filename.text(c.filename+" ("+Renderer.pktsBytes(c.filesize)+" bytes)");a._bar.progressbar("value",100);a._uploaded(c)}else setTimeout(function(){a._monitor(a)},1E3)},cancel:function(){this._confirm.hide();this._progress.hide();this._tryagain.hide();this.element.show();this.element.val("")},widgetEventPrefix:"jupload_"})})(jQuery);
$(function(){var b=$("#ConnectionDropped");b.dialog({autoOpen:false,modal:true,draggable:false,resizable:false,closeOnEscape:false,width:320,closeText:"",dialogClass:"ui-dark",buttons:[{"class":"ui-positive-alert",text:"Try Again",click:function(){$("#RefreshSelect").jtimer("trigger");return false}}]});b.prev().find("a.ui-dialog-titlebar-close").hide();var e=false;$.jpost.fnReflectConnectionStatus=function(a){if(!$.jpost.session_expired)if(!a&&!e){e=true;b.dialog("open")}else if(e&&a){e=false;b.dialog("close")}};
$('input[placeholder!=""]').live("focus",function(){var a=$(this).attr("placeholder");if(a){$(this).data("placeholder",a);$(this).attr("placeholder","")}});$('input[placeholder=""]').live("blur",function(){var a=$(this).data("placeholder");a&&$(this).attr("placeholder",a)});$(document).mousedown(function(a){$(a.target).parents(".dateslider").length==0&&$("div.datetime-slider").jdateslider("extclick")})});window.Renderer=function(){};Renderer.original=function(b){return b};
Renderer.pktsBytes=function(b){var e=["","K","M","G","T"];b=parseInt(b)||0;for(var a=0;a<e.length;a++)if(b<999.5)return b.toPrecision(3)+e[a];else if(b<1024)return b.toFixed(0)+e[a];else b/=1024;return b.toFixed(0)+e[e.length-1]};Renderer.pktsBytes.className="number";Renderer.activityBar=function(b){var e=$('<ul class="activity-bar"></ul>');$.each([2048E3,512E3,64E3,8E3,500],function(a,c){b>c&&$("<li>&nbsp;</li>").appendTo(e)});return e};Renderer.boolValue=function(b){return b?"true":"false"};
Renderer.number=function(b){b=parseFloat(b);return V.isNumber(b)?b:""};Renderer.number.className="number";Renderer.activityNumber=function(b){return Renderer.pktsBytes(b)+"B/s"};Renderer.percentage=function(b,e){return typeof e=="undefined"?parseFloat(b).toFixed(1)+"%":e==0?"0%":(parseInt(b)/e).toFixed(1)+"%"};Renderer.staRadio=function(b,e){if(e.is_11ac)return"ac";return e.is_11n?e.is_11a?"na":"ng":e.radio=="na"?"a":e.is_11b?"b":"g"};
Renderer.staChannel=function(b,e){return b+" (11"+Renderer.staRadio(b,e)+")"};Renderer.rssiWithRadio=function(b,e){return $("<div>"+Renderer.rssi(b)+"</div>").addClass(Renderer.staRadio(b,e)+"-"+(e.powersave_enabled?"pwrsave":"pwr"))};Renderer.rssi=function(b){b=parseFloat(b);if(!b)return"N/A";if(b>45)b=45;if(b<5)b=5;return((b-5)/40*99).toPrecision(2)+"%"};Renderer.rssi.className="number";
Renderer.timestamp=function(b){function e(c){return c<10?"0"+c:c}if(b==null||isNaN(b))return"";var a=new Date;a.setTime(parseInt(b));b=a.getFullYear()+"/"+e(a.getMonth()+1)+"/"+e(a.getDate());b+="  ";b+=e(a.getHours())+":"+e(a.getMinutes())+":"+e(a.getSeconds());return b};Renderer.timestamp_sec=function(b){if(b==null||isNaN(b))return"";try{return Renderer.timestamp(parseInt(b)*1E3)}catch(e){return""}};
Renderer.lastseen=function(b){var e=(new Date).getTime()-parseInt(b);if(isNaN(e))return"N/A";return e<864E5?Renderer.uptime(e/1E3)+" ago":Renderer.timestamp(b)};Renderer.timeHour24=function(b){return(new Date(b)).getHours()+":00"};Renderer.timeMonthDay=function(b){b=new Date(b);return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][b.getMonth()]+". "+b.getDate()};
Renderer.ip2str15=function(b){function e(a,c,d){d=d-a.length;for(var f=0;f<d;f++)a=c+a;return a}return function(a){try{var c=a.match(/(\d+).(\d+).(\d+).(\d+)/);return[e(c[1],"0",3),e(c[2],"0",3),e(c[3],"0",3),e(c[4],"0",3)].join(".")}catch(d){return""}}(b)};
Renderer.apModel=function(b){if(b=="BZ2")return"UniFi AP";else if(b=="BZ2LR")return"UniFi AP-LR";else if(b=="U2S48")return"UniFi AP";else if(b=="U2L48")return"UniFi AP-LR";else if(b=="U2HSR")return"UniFi AP-Outdoor+";else if(b=="U2O")return"UniFi AP-Outdoor";else if(b=="U5O")return"UniFi AP-Outdoor 5G";else if(b=="U7P")return"UniFi AP-Pro";else if(b=="U2M")return"UniFi AP-Mini";else if(b=="U7E")return"UniFi AP-AC";else if(b=="U7O")return"UniFi AP-AC Outdoor";else if(b=="p2N")return"PicoStation M2";
else if(b=="U7Ev2")return"UniFi AP-AC v2"};Renderer.apIcon=function(b){var e=$("<span></span>");e.addClass("dev-model").addClass("model-"+b);return e};Renderer.apStatusType=function(b){b=parseInt(b)||0;switch(b){case 1:case 4:case 5:return"ok";case 2:case 7:case 13:return"pending";case 0:case 3:case 9:case 10:case 11:return"error";default:return"error"}};Renderer.mapId=function(b){return b};
Renderer.apStatus=function(b,e){var a=$("<span></span>"),c,d=e.uplink||{};b=parseInt(b);if(isNaN(b))b=0;if(b==1){c=Msg.APConnected;if(!e.isolated)if(d.type=="wire"){if(d.max_speed!=d.speed||!d.full_duplex){c+=" ("+d.speed+" "+(d.full_duplex?"FDX":"HDX")+")";a.attr("title","Ethernet connected at "+d.speed+"Mbps/"+(d.full_duplex?"Full":"Half")+"-Duplex")}}else if(d.type=="wireless")c+=" (wireless)";if(e.version_incompatible)c+=" (needs upgrade)"}else if(b==0)c=Msg.APDisconnected;else if(b==3)c=Msg.APFirmwareMismatch;
else if(b==4)c=Msg.APUpgrading;else if(b==5)c=Msg.APProvisioning;else if(b==2)c=e["default"]?e.discovered_via=="scan"?Msg.APIsolatedPending:Msg.APPending:Msg.APManagedByOthers;else if(b==6)c=Msg.APHeartbeatMissed;else if(b==7){c=Msg.APAdopting;if(d.type=="wireless")c+=" (wireless)"}else if(b==8)c=Msg.APDeleting;else if(b==9)c=Msg.APManagedByOthers;else if(b==10)c=Msg.APAdoptFailed;else if(b==11)c=Msg.APIsolated;a.addClass(Renderer.apStatusType(b));a.text(c);return a};
Renderer.apChannel=function(b,e){if(!e.vap_table)return"";var a=[];$.each(e.vap_table,function(c,d){if(d.channel==0)return true;if((d.state||"RUN")!="RUN")return true;var f=d.radio;if(f=="na"&&(e.model=="U7E"||e.model=="U7O"||e.model=="U7Ev2"))f="ac";f=d.channel+" ("+f+")";if($.inArray(f,a)<0)if(d.radio=="ng")a=[f].concat(a);else a.push(f)});return a.join(", ")};Renderer.apChannel.className="number";
Renderer.apDualChannel=function(b,e){return(parseInt(e["ng-channel"])||0)*1E3+(parseInt(e["na-channel"])||0)};Renderer.apXRate=function(b){if(isNaN(b))return"N/A";return parseInt(b)/1E3+"M"};Renderer.staName=function(b,e){if(!e)return b;return e.name||e.hostname||e.mac};Renderer.staNameLower=function(b,e){return Renderer.staName(b,e).toLowerCase()};Renderer.apName=function(b,e){return $("#model-aps").data("ap_names")[b]||(e?e.name:"")||b};
Renderer.apNameLower=function(b,e){return Renderer.apName(b,e).toLowerCase()};Renderer.apDetailLink=function(b){var e=$("#model-aps").data("ap_names")[b]||b;return $('<a href="javascript:void(0);" class="ap-link" title="'+b+'"></a>').text(e)};Renderer.apDetailLink.className="ap-name";Renderer.staDetailLink=function(b,e){var a=$("#model-stas").data("sta_names")[b]||Renderer.staName(b,e);return $('<a href="javascript:void(0);" class="sta-link" title="'+b+'"></a>').text(a)};
Renderer.staCount=function(b,e){if(!b||!e)return"";try{return $("#model-stas").data("sta_counts")[b][e]||0}catch(a){return""}};
Renderer.eventMessage=function(b,e){if(!b)return"";b=b.replace(/AP\[([0-9a-fA-F:]+)\]/g,'AP[<a href="javascript:void(0);" title="$1" class="ap-link">$1</a>]');b=b.replace(/User\[([0-9a-fA-F:]+)\]/g,'User[<a href="javascript:void(0);" title="$1" class="sta-link">$1</a>]');b=b.replace(/Guest\[([0-9a-fA-F:]+)\]/g,'Guest[<a href="javascript:void(0);" title="$1" class="sta-link">$1</a>]');b=b.replace(/Client\[([0-9a-fA-F:]+)\]/g,'Client[<a href="javascript:void(0);" title="$1" class="sta-link">$1</a>]');
var a=$("<span></span>").html(b);a.find("a.ap-link").each(function(){var c=$(this).attr("title");c=$("#model-aps").data("ap_names")[c]||c;$(this).text(c)});a.find("a.sta-link").each(function(){var c=$(this).attr("title");c=$("#model-stas").data("sta_names")[c]||e.hostname||c;$(this).text(c)});return a};Renderer.rogueType=function(b,e){return b+(e.is_adhoc?" (Ad-Hoc)":"")};Renderer.ccq=function(b){if(b==0||isNaN(b))return"N/A";return b/10+"%"};Renderer.ccq.className="number";
Renderer.uptime=function(b){var e=[];if(isNaN(b)||b==0)return"0s";var a=["d","h","m","s"],c=[86400,3600,60,1];b=parseInt(b);for(var d=0;d<a.length;d++){var f=Math.floor(b/c[d]);if(f){e.push(f+a[d]);b%=c[d]}if(e.length>2)break}return e.join(" ")};Renderer.uptime.className="number";Renderer.amount=function(b,e){if(b){var a=$(e).attr_get("currency","USD");switch(a){case "USD":return"$"+b;case "EUR":return"\u20ac"+b}return b+"("+a+")"}return b};window.V=function(){};V.reWhitespace=/^\s+$/;
V.reAlphanumeric=/^[a-zA-Z0-9]+$/;V.reInteger=/^\d+$/;V.reSsid=/^.{1,32}$/;V.rePassphrase=/(^([\x20-\x7E]){8,63}$)/;V.reWEP64=/^([0-9a-fA-F]){10}$/;V.reWEP128=/^([0-9a-fA-F]){26}$/;V.reWEP=/^([0-9a-fA-F]){10}$|^([0-9a-fA-F]){26}$|^([\x20-\x7E]){5}$|^([\x20-\x7E]){13}$/;V.reAdminName=/^[a-zA-Z0-9]+$/;V.reAdminPassword=/^[a-zA-Z0-9][\x21-\x7E]+$/;V.reIPv4Loose=/^\d+.\d+.\d+.\d+$/;V.reSubnetSpec=/^\d+.\d+.\d+.\d+\/\d+$/;V.reEmail=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,10}$/;V.reHostname=/^[a-zA-Z0-9.-]+$/;
V.isNumber=function(b){if(typeof b==="boolean")return false;return b!=null&&!isNaN(b)};V.ip2long=function(b){var e=false,a=[];if(b.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)){a=b.split(".");e=a[0]*16777216+a[1]*65536+a[2]*256+a[3]*1}return e};V.isIP=function(b,e){if(V.reIPv4Loose.test(b)){var a=b.match(/[0-9]+/g);if(a.length==4){if(a[0]==0||a[0]>parseInt(e))return false;for(var c=1;c<4;c++)if(a[c]>255)return false;return true}}return false};
V.error=function(b,e){b=$(b).get(0);if(!$.data(b,"v_error")){$(b).wrap('<span class="v-error"></span>');$.data(b,"v_error",true);$(b).select();$(b).focus();alert(e)}};V.normal=function(b){b=$(b).get(0);if($.data(b,"v_error")){$.removeData(b,"v_error");var e=$(b).parent();$(b).insertAfter(e);e.remove()}};V.getval=function(b){return b.data("jpass")?b.jpass("val"):b.val()};V.checkSsid=function(b,e){V.normal(b);var a=V.getval(b);if(!V.reSsid.test(a)){V.error(b,V.localize(Msg.E_InvalidSSID,e));return false}return true};
V.checkPassphrase=function(b,e){V.normal(b);var a=V.getval(b);if(!V.rePassphrase.test(a)){V.error(b,V.localize(Msg.E_InvalidPassphrase,e));return false}return true};V.checkAdminName=function(b,e){V.normal(b);var a=V.getval(b);if(!V.reAdminName.test(a)){V.error(b,V.localize(Msg.E_InvalidAdminName,e));return false}return true};
V.checkAdminPasswords=function(b,e,a,c){V.normal(b);V.normal(e);var d=b.val(),f=e.val();if(d==$.jpass_hint&&f==$.jpass_hint)return true;if($.trim(d)==""){V.error(b,V.localize(Msg.E_CannotBeEmpty,a));return false}if(!V.reAdminPassword.test(d)){V.error(b,V.localize(Msg.E_InvalidAdminPassword,a));return false}if(d!=f){V.error(e,V.localize(Msg.E_DifferentPass,a,c));return false}return true};
V.checkEmpty=function(b,e){V.normal(b);var a=V.getval(b);if($.trim(a)==""){V.error(b,V.localize(Msg.E_CannotBeEmpty,e));return false}return true};V.checkRE=function(b,e,a,c){V.normal(b);var d=V.getval(b);if(!a.test(d)){V.error(b,V.localize(c,e));return false}return true};V.checkLength=function(b,e,a,c){V.normal(b);var d=V.getval(b);if(d.length<e||d.length>a){V.error(b,V.localize(Msg.E_IncorrectLength,c,e,a));return false}return true};
V.checkMinMax=function(b,e,a,c){V.normal(b);var d=V.getval(b);if(!V.isNumber(d)||d>a||d<e){V.error(b,V.localize(Msg.E_IncorrectNumberRance,c,e,a));return false}return true};V.checkIP=function(b,e){V.normal(b);var a=V.getval(b);if(!V.isIP(a,223)){V.error(b,V.localize(Msg.E_IncorrectIPAddress,e));return false}return true};
V.checkNetmask=function(b,e,a){V.normal(b);var c=V.getval(b),d=V.ip2long(c);a=V.ip2long(a);var f=~parseInt(d)&4294967295;if((f+1&f)!=0||!V.isIP(c,255)){V.error(b,V.localize(Msg.E_IncorrectNetmask,e));return false}if(!(a^a&d)){V.error(b,V.localize(Msg.E_IncorrectIPMaskCombination,e));return false}return true};
V.checkSubnetSpec=function(b,e){V.normal(b);var a=V.getval(b);if(V.reSubnetSpec.test(a)){var c=a.indexOf("/"),d=a.substring(0,c);a=parseInt(a.substring(c+1));if(V.isIP(d,255))if(!(a>32))return true}V.error(b,V.localize(Msg.E_IncorrectSubnetSpec,e));return false};V.checkEmail=function(b,e){V.normal(b);var a=V.getval(b);if(!V.reEmail.test(a)){V.error(b,V.localize(Msg.E_IncorrectEmailAddress,e));return false}return true};
V.checkInteger=function(b,e){V.normal(b);var a=V.getval(b);if(!V.reInteger.test(a)){V.error(b,V.localize(Msg.E_IncorrectIntegerType,e));return false}return true};V.localizer_re=[];for(var i=0;i<=16;i++)V.localizer_re.push(eval("/\\{"+i+"\\}/g"));V.localize=function(b){for(var e=b,a=arguments.length-1,c=1;c<=a;c++)e=e.replace(V.localizer_re[c],arguments[c]);return e};
V.localizeMsg=function(b,e){var a=b.substring(0);do{var c=a.match(/{([a-z]+)}/);if(!c)break;var d=c[1],f=e[d];if(d=="timestamp")f=Renderer.timestamp(f);a=a.replace(c[0],f)}while(1);return a};window.ApiMsg=function(){};ApiMsg["api.err.BackupFailed"]=Msg.E_BackupFailed;ApiMsg["api.err.DownlinksNotUpgraded"]=Msg.E_DownlinksNotUpgraded;ApiMsg["api.err.DuplicateAdminName"]=Msg.E_DuplicateAdminName;ApiMsg["api.err.DuplicateSiteName"]=Msg.E_DuplicateSiteName;ApiMsg["api.err.IdInvalid"]=Msg.E_IdInvalid;
ApiMsg["api.err.IdRequired"]=Msg.E_IdRequired;ApiMsg["api.err.InvalidAdminName"]=Msg.E_InvalidAdminName;ApiMsg["api.err.InvalidApiKey"]=Msg.E_InvalidApiKey;ApiMsg["api.err.InvalidArgs"]=Msg.E_InvalidArgs;ApiMsg["api.err.InvalidBackup"]=Msg.E_InvalidBackup;ApiMsg["api.err.InvalidBackupVersion"]=Msg.E_InvalidBackupVersion;ApiMsg["api.err.InvalidEmail"]=Msg.E_InvalidEmail;ApiMsg["api.err.InvalidObject"]=Msg.E_InvalidObject;ApiMsg["api.err.InvalidSiteName"]=Msg.E_InvalidSiteName;
ApiMsg["api.err.InvalidTarget"]=Msg.E_InvalidTarget;ApiMsg["api.err.LoginRequired"]=Msg.E_LoginRequired;ApiMsg["api.err.NoPermission"]=Msg.E_NoPermission;ApiMsg["api.err.NoSuchCommand"]=Msg.E_NoSuchCommand;ApiMsg["api.err.NoUplinkAvailable"]=Msg.E_NoUplinkAvailable;ApiMsg["api.err.NotImplemented"]=Msg.E_NotImplemented;ApiMsg["api.err.ObjectExisted"]=Msg.E_ObjectExisted;ApiMsg["api.err.ObjectReferredBy"]=Msg.E_ObjectReferredBy;ApiMsg["api.err.ServerBusy"]=Msg.E_ServerBusy;
ApiMsg["api.err.SmtpAuthFailed"]=Msg.E_SmtpAuthFailed;ApiMsg["api.err.SmtpNoSuchRcpt"]=Msg.E_SmtpNoSuchRcpt;ApiMsg["api.err.SmtpNotEnabled"]=Msg.E_SmtpNotEnabled;ApiMsg["api.err.SmtpSendFailed"]=Msg.E_SmtpSendFailed;ApiMsg["api.err.SmtpUnknownFailed"]=Msg.E_SmtpUnknownFailed;ApiMsg["api.err.UnknownDevice"]=Msg.E_UnknownDevice;ApiMsg["api.err.UnknownGuest"]=Msg.E_UnknownGuest;ApiMsg["api.err.UnknownMap"]=Msg.E_UnknownMap;ApiMsg["api.err.UnknownPayment"]=Msg.E_UnknownPayment;
ApiMsg["api.err.UnknownPaymentGateway"]=Msg.E_UnknownPaymentGateway;ApiMsg["api.err.UnknownStation"]=Msg.E_UnknownStation;ApiMsg["api.err.UnknownUser"]=Msg.E_UnknownUser;ApiMsg["api.err.WirelessUplinkDisabled"]=Msg.E_WirelessUplinkDisabled;LOGGING_ENABLED=false;
