added defaultStream option to overview

This commit is contained in:
Cat 2019-10-30 15:18:21 +01:00
parent 58f86bfc82
commit c0aee45f99
2 changed files with 67 additions and 54 deletions

View file

@ -40,11 +40,11 @@ k.itemLabel+"?",classes:["red"]}}]},{type:"buttons",buttons:[{label:"Cancel",typ
typeof b?a.push(c):a[b]=c;i.setval(a);u.html("");g.show();z.show()}}]}]));u.html(c);g.hide();z.hide()});var m=f;g.click(function(){m.data("build")({})});h.unshift({type:"str",label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+b.itemLabel+". It won't be used by MistServer.",pointer:{main:b.saveas,index:"x-LSP-name"}});f.data("savelist",[]);f.append(l).append(g);c.append(u);break;default:f=$("<input>").attr("type","text")}f.addClass("field").data("opts",b);"pointer"in typeof b?a.push(c):a[b]=c;i.setval(a);u.html("");g.show();z.show()}}]}]));u.html(c);g.hide();z.hide()});var m=f;g.click(function(){m.data("build")({})});h.unshift({type:"str",label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+b.itemLabel+". It won't be used by MistServer.",pointer:{main:b.saveas,index:"x-LSP-name"}});f.data("savelist",[]);f.append(l).append(g);c.append(u);break;default:f=$("<input>").attr("type","text")}f.addClass("field").data("opts",b);"pointer"in
b&&f.attr("name",b.pointer.index);e.append(f);if("classes"in b)for(n in b.classes)f.addClass(b.classes[n]);"placeholder"in b&&f.attr("placeholder",b.placeholder);"default"in b&&f.attr("placeholder",b["default"]);"unit"in b&&e.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(f.attr("readonly","readonly"),f.click(function(){$(this).select()}));"qrcode"in b&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a= b&&f.attr("name",b.pointer.index);e.append(f);if("classes"in b)for(n in b.classes)f.addClass(b.classes[n]);"placeholder"in b&&f.attr("placeholder",b.placeholder);"default"in b&&f.attr("placeholder",b["default"]);"unit"in b&&e.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(f.attr("readonly","readonly"),f.click(function(){$(this).select()}));"qrcode"in b&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=
String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&e.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()), String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&e.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),
b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);var h=$(this);setTimeout(function(){h.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in b&&f.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(e.addClass("LTSonly"),f.prop("disabled",!0));if("dependent"in b)for(d in b.dependent)o.attr("data-dependent-"+ b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in b&&f.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(e.addClass("LTSonly"),f.prop("disabled",!0));if("dependent"in b)for(d in b.dependent)o.attr("data-dependent-"+
d,b.dependent[d]);switch(b.type){case "browse":l=$("<div>").addClass("grouper").append(o);c.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});e.append(l);l.click(function(){function a(b){f.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");f.html(k.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var g=a.browse.subdirectories[b]; d,b.dependent[d]);switch(b.type){case "browse":l=$("<div>").addClass("grouper").append(o);c.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});e.append(l);l.click(function(){function a(b){f.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");f.html(k.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var h=a.browse.subdirectories[b];
f.append(k.clone(true).attr("title",e.text()+i+g).text(g))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var g=a.browse.files[b],j=e.text()+i+g,g=$("<a>").text(g).addClass("file").attr("title",j);f.append(g);if(o){var m=true,l;for(l in o)if(typeof o[l]!="undefined"&&mist.inputMatch(o[l],j)){m=false;break}m&&g.hide()}g.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);h.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"), f.append(k.clone(true).attr("title",e.text()+i+h).text(h))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var h=a.browse.files[b],j=e.text()+i+h,h=$("<a>").text(h).addClass("file").attr("title",j);f.append(h);if(o){var m=true,l;for(l in o)if(typeof o[l]!="undefined"&&mist.inputMatch(o[l],j)){m=false;break}m&&h.hide()}h.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),
c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),h=$(this),g=$("<button>").text("Stop browsing").click(function(){h.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),f=$("<div>").addClass("browse_contents"),k=$("<a>").addClass("folder"),o=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(e).append(g))).append(f); c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),h=$("<button>").text("Stop browsing").click(function(){g.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),f=$("<div>").addClass("browse_contents"),k=$("<a>").addClass("folder"),o=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(e).append(h))).append(f);
var i="/";mist.data.config.version.indexOf("indows")>-1&&(i="\\");k.click(function(){var b=e.text()+i+$(this).text();a(b)});b=d.getval();g=b.split("://");g.length>1&&(b=g[0]=="file"?g[1]:"");b=b.split(i);b.pop();b=b.join(i);h.hide();a(b)});break;case "geolimited":case "hostlimited":l={field:f};l.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));l.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":l.prototype= var i="/";mist.data.config.version.indexOf("indows")>-1&&(i="\\");k.click(function(){var b=e.text()+i+$(this).text();a(b)});b=d.getval();h=b.split("://");h.length>1&&(b=h[0]=="file"?h[1]:"");b=b.split(i);b.pop();b=b.join(i);g.hide();a(b)});break;case "geolimited":case "hostlimited":l={field:f};l.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));l.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":l.prototype=
$("<select>").append($("<option>").val("").text("[Select a country]"));for(d in UI.countrylist)l.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":l.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}l.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});l.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c= $("<select>").append($("<option>").val("").text("[Select a country]"));for(d in UI.countrylist)l.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":l.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}l.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});l.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=
$(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(l.blackwhite.prop("disabled",!0),l.prototype.prop("disabled",!0));l.values.append(l.prototype.clone(!0));e.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in b&&(f.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(l=b.pointer.main[b.pointer.index], $(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(l.blackwhite.prop("disabled",!0),l.prototype.prop("disabled",!0));l.values.append(l.prototype.clone(!0));e.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in b&&(f.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(l=b.pointer.main[b.pointer.index],
"undefined"!=l&&f.setval(l)));(""==f.getval()||null==f.getval())&&"value"in b&&f.setval(b.value);if("datalist"in b)for(d in l="datalist_"+d+MD5(f[0].outerHTML),f.attr("list",l),l=$("<datalist>").attr("id",l),e.append(l),b.datalist)l.append($("<option>").val(b.datalist[d]));e=$("<span>").addClass("help_container");o.append(e);"help"in b&&(e.append($("<span>").addClass("ih_balloon").html(b.help)),f.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")})); "undefined"!=l&&f.setval(l)));(""==f.getval()||null==f.getval())&&"value"in b&&f.setval(b.value);if("datalist"in b)for(d in l="datalist_"+d+MD5(f[0].outerHTML),f.attr("list",l),l=$("<datalist>").attr("id",l),e.append(l),b.datalist)l.append($("<option>").val(b.datalist[d]));e=$("<span>").addClass("help_container");o.append(e);"help"in b&&(e.append($("<span>").addClass("ih_balloon").html(b.help)),f.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));
@ -53,7 +53,7 @@ a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname
classes:["red"]}}};break;case "streamname_with_wildcard":l=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.", classes:["red"]}}};break;case "streamname_with_wildcard":l=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",
classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;case "streamname_with_wildcard_and_variables":l=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.", classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;case "streamname_with_wildcard_and_variables":l=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",
classes:["red"]};if(streampart.replace(/[^\da-z_$]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;default:l=function(){}}o.push(l)}f.data("validate_functions",o).data("help_container",e).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(), classes:["red"]};if(streampart.replace(/[^\da-z_$]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;default:l=function(){}}o.push(l)}f.data("validate_functions",o).data("help_container",e).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(),
d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var h in d){var e=d[h](c,a);if(e){$err=$("<span>").addClass("err_balloon").html(e.msg);for(var f in e.classes)$err.addClass(e.classes[f]);g.prepend($err);b&&$(a).focus();return typeof e=="object"&&"break"in e?e["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=f.getval()&&f.trigger("change")}"function"in b&&(f.on("change keyup", d=$(a).data("validate_functions"),h=$(a).data("help_container");h.find(".err_balloon").remove();for(var g in d){var e=d[g](c,a);if(e){$err=$("<span>").addClass("err_balloon").html(e.msg);for(var f in e.classes)$err.addClass(e.classes[f]);h.prepend($err);b&&$(a).focus();return typeof e=="object"&&"break"in e?e["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=f.getval()&&f.trigger("change")}"function"in b&&(f.on("change keyup",
b["function"]),f.trigger("change"))}}c.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&b.length&&(b.trigger("click"),a.stopPropagation())});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),d=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),b=[];d.append($("<td>"));for(var f in a.labels)b.push($("<tr>").append($("<td>").html(""== b["function"]),f.trigger("change"))}}c.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&b.length&&(b.trigger("click"),a.stopPropagation())});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),d=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),b=[];d.append($("<td>"));for(var f in a.labels)b.push($("<tr>").append($("<td>").html(""==
a.labels[f]?"&nbsp;":a.labels[f]+":")));for(var n in a.content)for(f in d.append($("<td>").html(a.content[n].header)),a.content[n].body)b[f].append($("<td>").html(a.content[n].body[f]));c.append($("<tbody>").append(d).append(b));return c},plot:{addGraph:function(a,c){var d={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(d.elements.legend);d.elements.cont.append(d.elements.plot).append(d.elements.legend); a.labels[f]?"&nbsp;":a.labels[f]+":")));for(var n in a.content)for(f in d.append($("<td>").html(a.content[n].header)),a.content[n].body)b[f].append($("<td>").html(a.content[n].body[f]));c.append($("<tbody>").append(d).append(b));return c},plot:{addGraph:function(a,c){var d={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(d.elements.legend);d.elements.cont.append(d.elements.plot).append(d.elements.legend);
c.append(d.elements.cont);return d},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},d;for(d in a)for(var b in a[d].datasets){var f=a[d].datasets[b];switch(f.datatype){case "clients":case "upbps":case "downbps":switch(f.origin[0]){case "total":c.totals.push({fields:[f.datatype],end:-15});break;case "stream":c.totals.push({fields:[f.datatype],streams:[f.origin[1]],end:-15});break;case "protocol":c.totals.push({fields:[f.datatype],protocols:[f.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities= c.append(d.elements.cont);return d},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},d;for(d in a)for(var b in a[d].datasets){var f=a[d].datasets[b];switch(f.datatype){case "clients":case "upbps":case "downbps":switch(f.origin[0]){case "total":c.totals.push({fields:[f.datatype],end:-15});break;case "stream":c.totals.push({fields:[f.datatype],streams:[f.origin[1]],end:-15});break;case "protocol":c.totals.push({fields:[f.datatype],protocols:[f.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities=
@ -84,34 +84,35 @@ type:"str",validate:["required"],help:"Enter your desired username. In the futur
{label:"Repeat password",type:"password",validate:["required",function(a,b){return a!=$(".match_password.field").not($(b)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}}); {label:"Repeat password",type:"password",validate:["required",function(a,b){return a!=$(".match_password.field").not($(b)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});
mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>"); mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>");
else{d.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],c;for(c in a.capabilities.connectors)if(a.capabilities.connectors[c].required)d.append('Could not enable protocol "'+c+'" because it has required settings.<br>');else{b.push({connector:c});d.append('Enabled protocol "'+c+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}}, else{d.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],c;for(c in a.capabilities.connectors)if(a.capabilities.connectors[c].required)d.append('Could not enable protocol "'+c+'" because it has required settings.<br>');else{b.push({connector:c});d.append('Enabled protocol "'+c+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},
{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var f=$("<span>").text("Loading.."),n=$("<span>"),o=$("<span>").addClass("logs"),e=$("<span>"),r=$("<span>"),j=$("<span>").text("Unknown"),l=$("<span>"),u=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus}, {label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var f=$("<span>").text("Loading.."),n=$("<span>"),o=$("<span>").addClass("logs"),e=$("<span>"),r=$("<span>"),j=$("<span>").text("Unknown"),l=$("<span>"),u=$("<span>"),g={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus,
h={};"bandwidth"in mist.data&&(h=mist.data.bandwidth,null==h&&(h={}),h.limit||(h.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "}, defaultStream:mist.data.config.defaultStream},h={};"bandwidth"in mist.data&&(h=mist.data.bandwidth,null==h&&(h={}),h.limit||(h.limit=""));var k=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s")),b=parseURL(mist.user.host),b=b.protocol+b.host+b.port;d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:r},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active licenses",value:j,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:n},{type:"span", {type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:r},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:"",LTSonly:!0},{type:"span",label:"Active licenses",value:j,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:n},{type:"span",
label:"Current connections",value:e},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:u},{type:"span",label:"Recent problems",value:o},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:g,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:g,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."}, label:"Current connections",value:e},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:u},{type:"span",label:"Recent problems",value:o},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:g,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:g,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},
{type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+b+"/PASSPHRASE or "+ {type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:g,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:g,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+b+"/PASSPHRASE or "+
b+"/PASSPHRASE.json.",LTSonly:!0},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:k},"Custom"]],pointer:{main:h,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:h,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>", b+"/PASSPHRASE.json.",LTSonly:!0},{type:"selectinput",label:"Load balancer bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:k},"Custom"]],pointer:{main:h,index:"limit"},help:"This setting only applies when MistServer is combined with a load balancer. This is the amount of traffic this server is willing to handle.",LTSonly:!0},{type:"inputlist",label:"Load balancer bandwidth exceptions",pointer:{main:h,index:"exceptions"},help:"This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>",
LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:g},b={};b.limit=h.limit?k.val()*h.limit:0;b.exceptions=h.exceptions;if(b.exceptions===null)b.exceptions= LTSonly:!0},{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:g,index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",LTSonly:!0},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},
[];a.bandwidth=b;if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var i=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}} {type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:g},b={};b.limit=h.limit?k.val()*h.limit:0;b.exceptions=h.exceptions;if(b.exceptions===null)b.exceptions=[];a.bandwidth=b;if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var i=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},
if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&i(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green");else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+ {update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&i(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green");
" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target","_blank").text("Manual download");d[0].protocol= else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");
"https:";f.append($("<div>").append(d))}c(a.log)}};i(mist.data);if("license"in mist.data.config){if("active_products"in mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var z=$("<table>").css("text-indent","0");j.html(z);z.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(var m in mist.data.config.license.active_products)b= mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target","_blank").text("Manual download");d[0].protocol="https:";f.append($("<div>").append(d))}c(a.log)}};i(mist.data);if("license"in mist.data.config){if("active_products"in mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var z=$("<table>").css("text-indent","0");j.html(z);z.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));
mist.data.config.license.active_products[m],z.append($("<tr>").append($("<td>").append(b.name)).append($("<td>").append(b.updates_final?b.updates_final:"&infin;")).append($("<td>").append(b.use_final?b.use_final:"&infin;")).append($("<td>").append(b.amount?b.amount:"&infin;")))}else j.text("None. ");j.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else f.text("");m=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true}; for(var m in mist.data.config.license.active_products)b=mist.data.config.license.active_products[m],z.append($("<tr>").append($("<td>").append(b.name)).append($("<td>").append(b.updates_final?b.updates_final:"&infin;")).append($("<td>").append(b.use_final?b.use_final:"&infin;")).append($("<td>").append(b.amount?b.amount:"&infin;")))}else j.text("None. ");j.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else f.text("");m=function(){var a=
if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){fa()},a)};var fa=function(){n.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";e.text(a);r.text(UI.format.dateTime(mist.data.config.time,"long"));o.html("");a=0;"license"in mist.data.config&&"user_msg"in {totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){fa()},a)};var fa=function(){n.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";e.text(a);r.text(UI.format.dateTime(mist.data.config.time,
mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),g=c[2].split("|");for(b in g)d.append($("<span>").text(g[b]));o.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&o.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b]; "long"));o.html("");a=0;"license"in mist.data.config&&"user_msg"in mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),g=c[2].split("|");for(b in g)d.append($("<span>").text(g[b]));o.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&o.html("None.");
a.indexOf(d.connector)>-1||a.push(d.connector)}l.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);u.text(c.length?c.join(", "):"None.")}else u.text("Loading..")};m();fa();UI.interval.set(m,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var A=$("<tbody>");d.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols= a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];a.indexOf(d.connector)>-1||a.push(d.connector)}l.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);u.text(c.length?c.join(", "):"None.")}else u.text("Loading..")};m();fa();UI.interval.set(m,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");
[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n "; return}var A=$("<tbody>");d.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=
c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){if(mist.data.config.protocols===null)mist.data.config.protocols=[];for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear", Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n ";c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<
"both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(A));var ga=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],g=["required","optional"],e;for(e in g)for(var f in c[g[e]])b[f]&&b[f]!=""?d.push(f+": "+b[f]):c[g[e]][f]["default"]&&d.push(f+": "+c[g[e]][f]["default"]);return $("<span>").addClass("description").text(d.join(", "))} 0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){if(mist.data.config.protocols===null)mist.data.config.protocols=[];for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear","both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(A));
A.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b],d=mist.data.capabilities.connectors[c.connector];A.append($("<tr>").data("index",b).append($("<td>").text(d&&d.friendly?d.friendly:c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a= var ga=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],g=["required","optional"],e;for(e in g)for(var f in c[g[e]])b[f]&&b[f]!=""?d.push(f+": "+b[f]):c[g[e]][f]["default"]&&d.push(f+": "+c[g[e]][f]["default"]);return $("<span>").addClass("description").text(d.join(", "))}A.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b],d=mist.data.capabilities.connectors[c.connector];A.append($("<tr>").data("index",b).append($("<td>").text(d&&
$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};ga();UI.interval.set(function(){mist.send(function(){ga()})},1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");return}var E= d.friendly?d.friendly:c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},
!1;""!=c&&0<=c&&(E=!0);var L={};for(m in mist.data.config.protocols)L[mist.data.config.protocols[m].connector]=1;var ha=function(a){var b=mist.data.capabilities.connectors[a],c=mist.convertBuildOptions(b,p);if(E)var d=$.extend({},p);c.push({type:"hidden",pointer:{main:p,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};E?a.updateprotocol=[d,p]:a.addprotocol=p;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel", {deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};ga();UI.interval.set(function(){mist.send(function(){ga()})},1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");return}var E=!1;""!=c&&0<=c&&(E=!0);var L={};for(m in mist.data.config.protocols)L[mist.data.config.protocols[m].connector]=1;var ha=function(a){var b=mist.data.capabilities.connectors[a],c=
"function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){z=$("<span>").text("Dependencies:");$ul=$("<ul>");z.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var g in b.deps){a=$("<li>").text(b.deps[g]+" ");$ul.append(a);typeof L[b.deps[g]]!="undefined"||typeof L[b.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:z[0].innerHTML})}return UI.buildUI(c)}, mist.convertBuildOptions(b,p);if(E)var d=$.extend({},p);c.push({type:"hidden",pointer:{main:p,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};E?a.updateprotocol=[d,p]:a.addprotocol=p;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){z=$("<span>").text("Dependencies:");$ul=$("<ul>");z.append($ul);if(typeof b.deps=="string")b.deps=
L={};for(m in mist.data.config.protocols)L[mist.data.config.protocols[m].connector]=1;if(E){var s=mist.data.config.protocols[c],p=s;d.find("h2").append(' "'+s.connector+'"');d.append(ha(s.connector))}else{d.html($("<h2>").text("New Protocol"));var p={},t=[["",""]];for(m in mist.data.capabilities.connectors)t.push([m,mist.data.capabilities.connectors[m].friendly?mist.data.capabilities.connectors[m].friendly:m]);var I=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){$(this).getval()!= b.deps.split(", ");for(var g in b.deps){a=$("<li>").text(b.deps[g]+" ");$ul.append(a);typeof L[b.deps[g]]!="undefined"||typeof L[b.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:z[0].innerHTML})}return UI.buildUI(c)},L={};for(m in mist.data.config.protocols)L[mist.data.config.protocols[m].connector]=1;if(E){var s=mist.data.config.protocols[c],p=s;d.find("h2").append(' "'+
""&&I.html(ha($(this).getval()))}}])).append(I)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}m=$("<button>");var F=$("<span>").text("Loading..");d.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(m).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(F); s.connector+'"');d.append(ha(s.connector))}else{d.html($("<h2>").text("New Protocol"));var p={},t=[["",""]];for(m in mist.data.capabilities.connectors)t.push([m,mist.data.capabilities.connectors[m].friendly?mist.data.capabilities.connectors[m].friendly:m]);var I=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){$(this).getval()!=""&&I.html(ha($(this).getval()))}}])).append(I)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},
""==c&&(g=mist.stored.get(),"viewmode"in g&&(c=g.viewmode));m.text("Switch to "+("thumbnails"==c?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",c=="thumbnails"?"list":"thumbnails");UI.navto("Streams",c=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),T=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},U=function(b,c,g){F.remove();switch(b){case "thumbnails":var f=$("<div>").addClass("preview_icons"), {capabilities:!0});return}m=$("<button>");var F=$("<span>").text("Loading..");d.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(m).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(F);""==c&&(g=mist.stored.get(),"viewmode"in g&&(c=g.viewmode));m.text("Switch to "+
e;e=g||[];c.sort();c.unshift("");F.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:c,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();f.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));c.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(f); ("thumbnails"==c?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",c=="thumbnails"?"list":"thumbnails");UI.navto("Streams",c=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),T=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},U=function(b,c,g){F.remove();switch(b){case "thumbnails":var f=$("<div>").addClass("preview_icons"),e;e=g||[];c.sort();c.unshift("");F.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",
for(var h in c){var b=c[h],j="",k=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),i=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),g=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}), type:"datalist",datalist:c,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();f.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));c.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(f);for(var h in c){var b=c[h],j="",k=$("<button>").text("Delete").click(function(){var a=
l=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),o=$("<span>").addClass("image");if(b.indexOf("+")>-1){j=b.split("+");j=mist.data.streams[j[0]].source+j[1];i=k="";o.addClass("wildcard")}else{j=mist.data.streams[b].source;if(e.indexOf(b)>-1){l=g="";o.addClass("folder")}}f.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(o).append($("<span>").addClass("description").text(j)).append($("<span>").addClass("button_container").append(i).append(k).append(g).append(l)).attr("title", $(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),i=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),g=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),l=$("<button>").text("Embed").click(function(){UI.navto("Embed",
$(this).closest("div").attr("data-stream"))}),o=$("<span>").addClass("image");if(b.indexOf("+")>-1){j=b.split("+");j=mist.data.streams[j[0]].source+j[1];i=k="";o.addClass("wildcard")}else{j=mist.data.streams[b].source;if(e.indexOf(b)>-1){l=g="";o.addClass("folder")}}f.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(o).append($("<span>").addClass("description").text(j)).append($("<span>").addClass("button_container").append(i).append(k).append(g).append(l)).attr("title",
b).attr("data-stream",b))}break;default:var m=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(m); b).attr("data-stream",b))}break;default:var m=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(m);
d.append(h);h.stupidtable();var n=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;m.html("");c.sort();for(var b in c){var d=c[b],g;g=d in mist.data.streams?mist.data.streams[d]:y[d];var e=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!= d.append(h);h.stupidtable();var n=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;m.html("");c.sort();for(var b in c){var d=c[b],g;g=d in mist.data.streams?mist.data.streams[d]:y[d];var e=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!=
"undefined"){var h=mist.data.totals[d].all_protocols.clients,f=0;if(h.length){for(a in h)f=f+h[a][1];f=Math.round(f/h.length)}}e.html(UI.format.number(f));if(f==0&&g.online==1)g.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in g)||!g.ischild)&&f.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+ "undefined"){var h=mist.data.totals[d].all_protocols.clients,f=0;if(h.length){for(a in h)f=f+h[a][1];f=Math.round(f/h.length)}}e.html(UI.format.number(f));if(f==0&&g.online==1)g.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in g)||!g.ischild)&&f.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
@ -161,29 +162,29 @@ $(this).getval()==1;switch($(this).getval()){case 0:q.controls=false;break;case
$(this).getval();$(".embed_code").setval(w(q))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:q,index:"muted"},"function":function(){q.muted=$(this).getval();$(".embed_code").setval(w(q))},help:"If the video should restart when the end is reached."},{label:"Fill available space",type:"checkbox",pointer:{main:q,index:"fillSpace"},"function":function(){q.fillSpace=$(this).getval();$(".embed_code").setval(w(q))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."}, $(this).getval();$(".embed_code").setval(w(q))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:q,index:"muted"},"function":function(){q.muted=$(this).getval();$(".embed_code").setval(w(q))},help:"If the video should restart when the end is reached."},{label:"Fill available space",type:"checkbox",pointer:{main:q,index:"fillSpace"},"function":function(){q.fillSpace=$(this).getval();$(".embed_code").setval(w(q))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."},
{label:"Poster",type:"str",pointer:{main:q,index:"poster"},"function":function(){q.poster=$(this).getval();$(".embed_code").setval(w(q))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:q,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){q.urlappend=$(this).getval();$(".embed_code").setval(w(q))}}, {label:"Poster",type:"str",pointer:{main:q,index:"poster"},"function":function(){q.poster=$(this).getval();$(".embed_code").setval(w(q))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:q,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){q.urlappend=$(this).getval();$(".embed_code").setval(w(q))}},
{label:"Preselect tracks",type:"DOMfield",DOMfield:K,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:q,index:"monitor_action"},"function":function(){q.monitor_action=$(this).getval();$(".embed_code").setval(w(q))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),aa]));$.ajax({type:"GET",url:H+"json_"+C+".js",success:function(a){var b= {label:"Preselect tracks",type:"DOMfield",DOMfield:K,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:q,index:"monitor_action"},"function":function(){q.monitor_action=$(this).getval();$(".embed_code").setval(w(q))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),aa]));$.ajax({type:"GET",url:H+"json_"+C+".js",success:function(a){var b=
[],c=N.find(".field.forceType"),d=N.find(".field.prioritize_type"),g;for(g in a.source){var e=a.source[g],f=UI.humanMime(e.type);b.push({label:f?f+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(e.type);if(c.children('option[value="'+e.type+'"]').length==0){c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type));d.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}}c.val(q.forceType); [],c=N.find(".field.forceType"),d=N.find(".field.prioritize_type"),e;for(e in a.source){var g=a.source[e],f=UI.humanMime(g.type);b.push({label:f?f+" <span class=description>("+g.type+")</span>":UI.format.capital(g.type),type:"str",value:g.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(g.type);if(c.children('option[value="'+g.type+'"]').length==0){c.append($("<option>").text(f?f+" ("+g.type+")":UI.format.capital(g.type)).val(g.type));d.append($("<option>").text(f?f+" ("+g.type+")":UI.format.capital(g.type)).val(g.type))}}c.val(q.forceType);
d.val(q.prioritize_type);aa.html(UI.buildUI(b));K.html("");b={};for(g in a.meta.tracks){c=a.meta.tracks[g];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!="video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){K.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){g=a[h];if(b[g]&& d.val(q.prioritize_type);aa.html(UI.buildUI(b));K.html("");b={};for(e in a.meta.tracks){c=a.meta.tracks[e];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!="video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){K.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){e=a[h];if(b[e]&&
b[g].length){c=$("<select>").attr("data-type",g).css("flex-grow","1").change(function(){$(this).val()==""?delete q.setTracks[$(this).attr("data-type")]:q.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(w(q))});K.append(c);g=="subtitle"?b[g].unshift(["","No "+g]):b[g].push([-1,"No "+g]);for(var i in b[g])c.append($("<option>").val(b[g][i][0]).text(b[g][i][1]));if(g in q.setTracks){c.val(q.setTracks[g]);if(c.val()==null){c.val("");delete q.setTracks[g];$(".embed_code").setval(w(q))}}}}}else K.closest("label").hide(); b[e].length){c=$("<select>").attr("data-type",e).css("flex-grow","1").change(function(){$(this).val()==""?delete q.setTracks[$(this).attr("data-type")]:q.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(w(q))});K.append(c);e=="subtitle"?b[e].unshift(["","No "+e]):b[e].push([-1,"No "+e]);for(var i in b[e])c.append($("<option>").val(b[e][i][0]).text(b[e][i][1]));if(e in q.setTracks){c.val(q.setTracks[e]);if(c.val()==null){c.val("");delete q.setTracks[e];$(".embed_code").setval(w(q))}}}}}else K.closest("label").hide();
O=true},error:function(){aa.html("Error while retrieving stream info.");K.closest("label").hide();q.setTracks={}}});m=document.createElement("script");m.src=J+"player.js";document.head.appendChild(m);m.onload=function(){var a=N.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};m.onerror=function(){document.head.removeChild(this)};break;case "Push":var D=$("<div>").text("Loading..");d.append(D);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d= O=true},error:function(){aa.html("Error while retrieving stream info.");K.closest("label").hide();q.setTracks={}}});m=document.createElement("script");m.src=J+"player.js";document.head.appendChild(m);m.onload=function(){var a=N.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};m.onerror=function(){document.head.removeChild(this)};break;case "Push":var D=$("<div>").text("Loading..");d.append(D);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=
false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,e;for(e in c.push_list)if(a.indexOf(c.push_list[e][0])>-1){d=false;break}}else d=true;if(d)for(e in a)g.find("tr[data-pushid="+a[e]+"]").remove();else b()},{push_list:1})},1E3)}function c(e,f){var h=$("<span>");if(f=="Automatic"&&e.length>=4){h.append($("<span>").text(e[2]));e[3]&&h.append($("<span>").text(", schedule on "+(new Date(e[3]*1E3)).toLocaleString()));e.length>=5&&e[4]&&h.append($("<span>").text(", complete on "+(new Date(e[4]* false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,g;for(g in c.push_list)if(a.indexOf(c.push_list[g][0])>-1){d=false;break}}else d=true;if(d)for(g in a)e.find("tr[data-pushid="+a[g]+"]").remove();else b()},{push_list:1})},1E3)}function c(g,f){var h=$("<span>");if(f=="Automatic"&&g.length>=4){h.append($("<span>").text(g[2]));g[3]&&h.append($("<span>").text(", schedule on "+(new Date(g[3]*1E3)).toLocaleString()));g.length>=5&&g[4]&&h.append($("<span>").text(", complete on "+(new Date(g[4]*
1E3)).toLocaleString()))}else e.length>=4&&e[2]!=e[3]?h.append($("<span>").text(e[2])).append($("<span>").html("&#187").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(e[3])):h.append($("<span>").text(e[2]));var i=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+e[1]+" to "+e[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f== 1E3)).toLocaleString()))}else g.length>=4&&g[2]!=g[3]?h.append($("<span>").text(g[2])).append($("<span>").html("&#187").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(g[3])):h.append($("<span>").text(g[2]));var i=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+g[1]+" to "+g[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f==
"Automatic"?"Removing..":"Stopping..")));if(f=="Automatic"){var c=e.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([e[0]])},{push_stop:[e[0]]})}}));if(f=="Automatic"){i.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+e[1]+" to "+e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.": "Automatic"?"Removing..":"Stopping..")));if(f=="Automatic"){var c=g.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([g[0]])},{push_stop:[g[0]]})}}));if(f=="Automatic"){i.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+g[1]+" to "+g[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":
""))){var c=$(this);c.text("Stopping pushes..");var f=[],h;for(h in a.push_list)if(e[1]==a.push_list[h][1]&&e[2]==a.push_list[h][2]){f.push(a.push_list[h][0]);g.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(f)},{push_stop:f,push_settings:{wait:0}})}}))}return $("<tr>").attr("data-pushid",e[0]).append($("<td>").text(e[1])).append($("<td>").append(h.children())).append(i)}D.html(UI.buildUI([{type:"help", ""))){var c=$(this);c.text("Stopping pushes..");var f=[],h;for(h in a.push_list)if(g[1]==a.push_list[h][1]&&g[2]==a.push_list[h][2]){f.push(a.push_list[h][0]);e.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(f)},{push_stop:f,push_settings:{wait:0}})}}))}return $("<tr>").attr("data-pushid",g[0]).append($("<td>").text(g[1])).append($("<td>").append(h.children())).append(i)}D.html(UI.buildUI([{type:"help",
help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."}]));var d=a.push_settings;d||(d={});var g=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),e=g.clone();if("push_list"in a)for(var f in a.push_list)g.append(c(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list){var h=a.push_auto_list[f].slice();h.unshift(-1);e.append(c(h,"Automatic"))}D.append($("<h3>").text("Automatic pushes")).append(UI.buildUI([{label:"Delay before retry", help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."}]));var d=a.push_settings;d||(d={});var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),g=e.clone();if("push_list"in a)for(var f in a.push_list)e.append(c(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list){var h=a.push_auto_list[f].slice();h.unshift(-1);g.append(c(h,"Automatic"))}D.append($("<h3>").text("Automatic pushes")).append(UI.buildUI([{label:"Delay before retry",
unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"},LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")}, unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"},LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},
{push_settings:d})}}]}])).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));e.find("tr").length==1?D.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):D.append(e);D.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(g.find("tr").length==1)D.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top", {push_settings:d})}}]}])).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));g.find("tr").length==1?D.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):D.append(g);D.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)D.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top",
"0.5em"));else{var e=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(f in a.push_list){e.indexOf(a.push_list[f][1])==-1&&e.push(a.push_list[f][1]);h.indexOf(a.push_list[f][2])==-1&&h.push(a.push_list[f][2])}e.sort();h.sort();for(f in e)i.append($("<option>").text(e[f]));for(f in h)j.append($("<option>").text(h[f]));D.append($("<button>").text("Stop all pushes").click(function(){var c= "0.5em"));else{var g=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(f in a.push_list){g.indexOf(a.push_list[f][1])==-1&&g.push(a.push_list[f][1]);h.indexOf(a.push_list[f][2])==-1&&h.push(a.push_list[f][2])}g.sort();h.sort();for(f in g)i.append($("<option>").text(g[f]));for(f in h)j.append($("<option>").text(h[f]));D.append($("<button>").text("Stop all pushes").click(function(){var c=
[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},{push_stop:c});g.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size", [],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},{push_stop:c});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size",
"0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var e={},f;for(f in a.push_list)if((c==""||a.push_list[f][1]==c)&&(d==""||a.push_list[f][2]==d))e[a.push_list[f][0]]=a.push_list[f];if(Object.keys(e).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(f in e)c=c+(e[f][1]+ "0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var g={},f;for(f in a.push_list)if((c==""||a.push_list[f][1]==c)&&(d==""||a.push_list[f][2]==d))g[a.push_list[f][0]]=a.push_list[f];if(Object.keys(g).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(f in g)c=c+(g[f][1]+
" to "+e[f][2]+"\n");if(confirm(c)){e=Object.keys(e);mist.send(function(){b(e)},{push_stop:e});for(f in e)g.find("tr[data-pushid="+e[f]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(g)}},{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});return}var v,S=function(a){var b=false,e=c.split("_"); " to "+g[f][2]+"\n");if(confirm(c)){g=Object.keys(g);mist.send(function(){b(g)},{push_stop:g});for(f in g)e.find("tr[data-pushid="+g[f]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}},{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});return}var v,S=function(a){var b=false,g=c.split("_");
c=e[0];e.length==2&&(b=e[1]);if(b!==false&&typeof a=="undefined")mist.send(function(a){S(a.push_auto_list[b])},{push_auto_list:1});else{var g=[],f;for(f in mist.data.capabilities.connectors){e=mist.data.capabilities.connectors[f];"push_urls"in e&&(g=g.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var h={};if(c=="auto"&&typeof a!="undefined"){h={stream:a[0],target:a[1]};if(a.length>=3)h.scheduletime=a[2];if(a.length>=4)h.completetime=a[3];if(h.target.indexOf("recstartunix=")> c=g[0];g.length==2&&(b=g[1]);if(b!==false&&typeof a=="undefined")mist.send(function(a){S(a.push_auto_list[b])},{push_auto_list:1});else{var e=[],f;for(f in mist.data.capabilities.connectors){g=mist.data.capabilities.connectors[f];"push_urls"in g&&(e=e.concat(g.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var h={};if(c=="auto"&&typeof a!="undefined"){h={stream:a[0],target:a[1]};if(a.length>=3)h.scheduletime=a[2];if(a.length>=4)h.completetime=a[3];if(h.target.indexOf("recstartunix=")>
-1){f=h.target.split("recstartunix=")[1];h.recstartunix=f.split("&")[0];h.target=h.target.replace("recstartunix="+h.recstartunix,"").replace("?&","?").replace("&&","&");if(h.target[h.target.length-1]=="?")h.target=h.target.slice(0,-1)}}f=[{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use: <ul> <li><i>a</i>: the stream configured as <i>a</i></li> <li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li> <li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li> </ul>", -1){f=h.target.split("recstartunix=")[1];h.recstartunix=f.split("&")[0];h.target=h.target.replace("recstartunix="+h.recstartunix,"").replace("?&","?").replace("&&","&");if(h.target[h.target.length-1]=="?")h.target=h.target.slice(0,-1)}}f=[{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use: <ul> <li><i>a</i>: the stream configured as <i>a</i></li> <li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li> <li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li> </ul>",
pointer:{main:h,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["orange"],"break":false}}],datalist:v,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid formats: <ul> <li>"+g.join("</li><li>")+"</li> </ul> Valid text replacements: <ul> <li>$stream - inserts the stream name used to push to MistServer</li> <li>$day - inserts the current day number</li><li>$month - inserts the current month number</li> <li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li> <li>$minute - inserts the minute timestamp the stream was received</li> <li>$seconds - inserts the seconds timestamp when the stream was received</li> <li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li> </ul> Valid URL parameters: <ul> <li>recstart=123 - media timestamp in milisseconds where the push should start</li> <li>recstop=456 - media timestamp in miliseconds where the push should stop</li> <li>recstartunix=150000000 - unix time in seconds where the push should start. This will override the recstart parameter.</li> <li>recstopunix=150000000 - unix time in seconds where the push should stop. This will override the recstop parameter.</li> </ul>", pointer:{main:h,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["orange"],"break":false}}],datalist:v,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid formats: <ul> <li>"+e.join("</li><li>")+"</li> </ul> Valid text replacements: <ul> <li>$stream - inserts the stream name used to push to MistServer</li> <li>$day - inserts the current day number</li><li>$month - inserts the current month number</li> <li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li> <li>$minute - inserts the minute timestamp the stream was received</li> <li>$seconds - inserts the seconds timestamp when the stream was received</li> <li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li> </ul> Valid URL parameters: <ul> <li>recstart=123 - media timestamp in milisseconds where the push should start</li> <li>recstop=456 - media timestamp in miliseconds where the push should stop</li> <li>recstartunix=150000000 - unix time in seconds where the push should start. This will override the recstart parameter.</li> <li>recstopunix=150000000 - unix time in seconds where the push should stop. This will override the recstop parameter.</li> </ul>",
pointer:{main:h,index:"target"},validate:["required",function(a){for(var b in g)if(mist.inputMatch(g[b],a))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+g.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1}];c=="auto"&&f.push($("<h4>").text("Optional parameters"),{type:"unix",label:"Schedule time",min:0,help:"The time where the push will become active. The default is to start immediately.",pointer:{main:h,index:"scheduletime"}},{type:"unix",label:"Recording start time", pointer:{main:h,index:"target"},validate:["required",function(a){for(var b in e)if(mist.inputMatch(e[b],a))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+e.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1}];c=="auto"&&f.push($("<h4>").text("Optional parameters"),{type:"unix",label:"Schedule time",min:0,help:"The time where the push will become active. The default is to start immediately.",pointer:{main:h,index:"scheduletime"}},{type:"unix",label:"Recording start time",
min:0,help:"Where in the media buffer the recording will start. Defaults to the most recently received keyframe.<br>Only makes sense for live streams.",pointer:{main:h,index:"recstartunix"}},{type:"unix",label:"Complete time",min:0,help:"The time where the push will stop. Defaults to never stop automatically.<br>Only makes sense for live streams.",pointer:{main:h,index:"completetime"}});f.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save", min:0,help:"Where in the media buffer the recording will start. Defaults to the most recently received keyframe.<br>Only makes sense for live streams.",pointer:{main:h,index:"recstartunix"}},{type:"unix",label:"Complete time",min:0,help:"The time where the push will stop. Defaults to never stop automatically.<br>Only makes sense for live streams.",pointer:{main:h,index:"completetime"}});f.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",
label:"Save","function":function(){var b={};h.recstartunix?b.recstartunix="recstartunix="+h.recstartunix:h.scheduletime&&(b.recstartunix="recstartunix="+h.scheduletime);delete h.recstartunix;if(Object.keys(b).length){var d="?",e=h.target.split("?");if(e.length>1){var d="&",e=e[e.length-1],e=e.split("&"),g;for(g in e){var f=e[g].split("=")[0];f in b&&delete b[f]}}if(Object.keys(b).length){d=d+Object.values(b).join("&");h.target=h.target+d}}b={};b[c=="auto"?"push_auto_add":"push_start"]=h;if(typeof a!= label:"Save","function":function(){var b={};h.recstartunix?b.recstartunix="recstartunix="+h.recstartunix:h.scheduletime&&(b.recstartunix="recstartunix="+h.scheduletime);delete h.recstartunix;if(Object.keys(b).length){var d="?",g=h.target.split("?");if(g.length>1){var d="&",g=g[g.length-1],g=g.split("&"),e;for(e in g){var f=g[e].split("=")[0];f in b&&delete b[f]}}if(Object.keys(b).length){d=d+Object.values(b).join("&");h.target=h.target+d}}b={};b[c=="auto"?"push_auto_add":"push_start"]=h;if(typeof a!=
"undefined"&&(a[0]!=h.stream||a[1]!=h.target))b.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},b)}}]});d.append(UI.buildUI(f))}};mist.data.LTS?mist.send(function(a){(v=a.active_streams)||(v=[]);var a=[],b;for(b in v)v[b].indexOf("+")!=-1&&a.push(v[b].replace(/\+.*/,"")+"+");v=v.concat(a);var c=0,d=0;for(b in mist.data.streams){v.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){v.push(b+"+");mist.send(function(a,b){var e=b.stream,g;for(g in a.browse.files)for(var f in mist.data.capabilities.inputs)f.indexOf("Buffer")>= "undefined"&&(a[0]!=h.stream||a[1]!=h.target))b.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},b)}}]});d.append(UI.buildUI(f))}};mist.data.LTS?mist.send(function(a){(v=a.active_streams)||(v=[]);var a=[],b;for(b in v)v[b].indexOf("+")!=-1&&a.push(v[b].replace(/\+.*/,"")+"+");v=v.concat(a);var c=0,d=0;for(b in mist.data.streams){v.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){v.push(b+"+");mist.send(function(a,b){var g=b.stream,e;for(e in a.browse.files)for(var f in mist.data.capabilities.inputs)f.indexOf("Buffer")>=
0||(f.indexOf("Folder")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[g])&&v.push(e+"+"+a.browse.files[g]);d++;if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();S()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();S()}},{active_streams:1}):(v=Object.keys(mist.data.streams),S());break;case "Triggers":if(!("triggers"in 0||(f.indexOf("Folder")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[e])&&v.push(g+"+"+a.browse.files[e]);d++;if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();S()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();S()}},{active_streams:1}):(v=Object.keys(mist.data.streams),S());break;case "Triggers":if(!("triggers"in
mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};A=$("<tbody>");b=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(A);d.append(UI.buildUI([{type:"help",help:"Triggers are a way to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(b); mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};A=$("<tbody>");b=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(A);d.append(UI.buildUI([{type:"help",help:"Triggers are a way to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(b);
b.stupidtable();b=mist.data.config.triggers;for(m in b)for(j in b[m])s=triggerRewrite(b[m][j]),A.append($("<tr>").attr("data-index",m+","+j).append($("<td>").text(m)).append($("<td>").text("streams"in s?s.streams.join(", "):"")).append($("<td>").text(s.handler)).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(","); b.stupidtable();b=mist.data.config.triggers;for(m in b)for(j in b[m])s=triggerRewrite(b[m][j]),A.append($("<tr>").attr("data-index",m+","+j).append($("<td>").text(m)).append($("<td>").text("streams"in s?s.streams.join(", "):"")).append($("<td>").text(s.handler)).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");
if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading.."); if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");
@ -196,7 +197,7 @@ pointer:{main:p,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:$
"function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a={handler:p.url,sync:p.async?true:false,streams:typeof p.appliesto=="undefined"?[]:p.appliesto,params:p.params,"default":p["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};p.triggeron in mist.data.config.triggers||(mist.data.config.triggers[p.triggeron]=[]);mist.data.config.triggers[p.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change"); "function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a={handler:p.url,sync:p.async?true:false,streams:typeof p.appliesto=="undefined"?[]:p.appliesto,params:p.params,"default":p["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};p.triggeron in mist.data.config.triggers||(mist.data.config.triggers[p.triggeron]=[]);mist.data.config.triggers[p.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");
break;case "Logs":var ta=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){ca();ta.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);d.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60, break;case "Logs":var ta=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){ca();ta.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);d.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,
"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){ca()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:ta,help:"Instantly refresh the table below."}]));d.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));A=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(A)); "minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){ca()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:ta,help:"Instantly refresh the table below."}]));d.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));A=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(A));
var va=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},ca=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();A.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),e;for(e in d)c.append($("<span>").text(d[e]));A.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(va(a[b][1])).css("text-align", var va=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},ca=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();A.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),g;for(g in d)c.append($("<span>").text(d[g]));A.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(va(a[b][1])).css("text-align",
"center")).append($("<td>").html(c).css("text-align","left")))}}};ca();break;case "Statistics":var B=$("<span>").text("Loading..");d.append(B);var p={graph:"new"},x=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},P={};for(m in mist.data.streams)P[m]=!0;for(m in mist.data.active_streams)P[mist.data.active_streams[m]]=!0;var P=Object.keys(P).sort(),da=[];for(m in mist.data.config.protocols)da.push(mist.data.config.protocols[m].connector);da.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores= "center")).append($("<td>").html(c).css("text-align","left")))}}};ca();break;case "Statistics":var B=$("<span>").text("Loading..");d.append(B);var p={graph:"new"},x=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},P={};for(m in mist.data.streams)P[m]=!0;for(m in mist.data.active_streams)P[mist.data.active_streams[m]]=!0;var P=Object.keys(P).sort(),da=[];for(m in mist.data.config.protocols)da.push(mist.data.config.protocols[m].connector);da.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=
0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:p,index:"graph"},classes:["graph_ids"], 0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:p,index:"graph"},classes:["graph_ids"],
"function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(x).length+1)).closest("label").show()}else{var c=x[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}}, "function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(x).length+1)).closest("label").show()}else{var c=x[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},
@ -204,7 +205,7 @@ var va=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("o
false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:p,index:"datatype"}, false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:p,index:"datatype"},
classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",P],["protocol","The protocol:",da]],pointer:{main:p,index:"origin"},value:["total"], classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",P],["protocol","The protocol:",da]],pointer:{main:p,index:"origin"},value:["total"],
classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(p.graph=="new"){a=UI.plot.addGraph(p,b);x[a.id]=a;B.find("input.graph_id").val("");B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=x[p.graph];var c=UI.plot.datatype.getOptions({datatype:p.datatype,origin:p.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(x)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=B.find("select.graph_ids"); classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(p.graph=="new"){a=UI.plot.addGraph(p,b);x[a.id]=a;B.find("input.graph_id").val("");B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=x[p.graph];var c=UI.plot.datatype.getOptions({datatype:p.datatype,origin:p.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(x)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=B.find("select.graph_ids");
for(a in x){var e=UI.plot.addGraph(x[a],b);c.append($("<option>").text(e.id)).val(e.id);var g=[],f;for(f in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[f].datatype,origin:x[a].datasets[f].origin});g.push(h)}e.datasets=g;x[e.id]=e}c.trigger("change");UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0}); for(a in x){var g=UI.plot.addGraph(x[a],b);c.append($("<option>").text(g.id)).val(g.id);var e=[],f;for(f in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[f].datatype,origin:x[a].datasets[f].origin});e.push(h)}g.datasets=e;x[g.id]=g}c.trigger("change");UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});
d.append("Loading..");return}var ea=$("<table>"),F=$("<table>"),j={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(m in mist.data.capabilities.cpu)b=mist.data.capabilities.cpu[m],j.content.push({header:"CPU #"+(Number(m)+1),body:[b.model,UI.format.addUnit(UI.format.number(b.mhz),"MHz"),b.cores,b.threads]});m=UI.buildVheaderTable(j);var ua=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory",labels:["Used", d.append("Loading..");return}var ea=$("<table>"),F=$("<table>"),j={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(m in mist.data.capabilities.cpu)b=mist.data.capabilities.cpu[m],j.content.push({header:"CPU #"+(Number(m)+1),body:[b.model,UI.format.addUnit(UI.format.number(b.mhz),"MHz"),b.cores,b.threads]});m=UI.buildVheaderTable(j);var ua=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory",labels:["Used",
"Cached","Available","Total"],content:[{header:"Physical memory",body:[UI.format.bytes(a.used*1048576)+" ("+UI.format.addUnit(b.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);ea.replaceWith(a);ea=a;b={vheader:"Load average", "Cached","Available","Total"],content:[{header:"Physical memory",body:[UI.format.bytes(a.used*1048576)+" ("+UI.format.addUnit(b.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);ea.replaceWith(a);ea=a;b={vheader:"Load average",
labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:"&nbsp;",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);F.replaceWith(b);F=b};ua();d.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width", labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:"&nbsp;",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);F.replaceWith(b);F=b};ua();d.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width",
@ -216,8 +217,8 @@ var mist={data:{},user:{name:"",password:"",host:host},send:function(a,c,d){var
f);delete mist.user.loggedin;if(!d.hide){switch(e){case "timeout":e=$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append($("<span>").text(e)).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")}, f);delete mist.user.loggedin;if(!d.hide){switch(e){case "timeout":e=$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append($("<span>").text(e)).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")},
success:function(f){log("Receive",$.extend(true,{},f),"as reply to",d.sendData);delete mist.user.loggedin;switch(f.authorize.status){case "OK":if("streams"in f)if(f.streams)if("incomplete list"in f.streams){delete f.streams["incomplete list"];$.extend(mist.data.streams,f.streams)}else mist.data.streams=f.streams;else mist.data.streams={};var e=$.extend({},f),n=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth"],j;for(j in e)n.indexOf(j)==-1&&delete e[j]; success:function(f){log("Receive",$.extend(true,{},f),"as reply to",d.sendData);delete mist.user.loggedin;switch(f.authorize.status){case "OK":if("streams"in f)if(f.streams)if("incomplete list"in f.streams){delete f.streams["incomplete list"];$.extend(mist.data.streams,f.streams)}else mist.data.streams=f.streams;else mist.data.streams={};var e=$.extend({},f),n=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth"],j;for(j in e)n.indexOf(j)==-1&&delete e[j];
if("bandwidth"in b&&!("bandwidth"in f))e.bandwidth=null;$.extend(mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));f.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(f.log){e=f.log[f.log.length-1];UI.elements.connection.msg.append($("<br>")).append($("<span>").text("Last log entry: "+ if("bandwidth"in b&&!("bandwidth"in f))e.bandwidth=null;$.extend(mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));f.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(f.log){e=f.log[f.log.length-1];UI.elements.connection.msg.append($("<br>")).append($("<span>").text("Last log entry: "+
UI.format.time(e[0])+" ["+e[1]+"] "+e[2]))}if("totals"in f){e=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([m,0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var j=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(f in c.data){if(f==0){m=c.start*1E3;var n=0}else{m=m+c.interval[n][1]*1E3;c.interval[n][0]--;if(c.interval[n][0]<=0){n++;n<c.interval.length-1&&(j=j+2)}}if(j%2==1){d();j--}for(var o in c.data[f])e[c.fields[o]].push([m, UI.format.time(e[0])+" ["+e[1]+"] "+e[2]))}if("totals"in f){e=function(a,b,c){var d;d=function(){for(var a in c.fields)f[c.fields[a]].push([m,0])};var f={},e;for(e in c.fields)f[c.fields[e]]=[];var j=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(e in c.data){if(e==0){m=c.start*1E3;var n=0}else{m=m+c.interval[n][1]*1E3;c.interval[n][0]--;if(c.interval[n][0]<=0){n++;n<c.interval.length-1&&(j=j+2)}}if(j%2==1){d();j--}for(var o in c.data[e])f[c.fields[o]].push([m,
c.data[f][o]]);if(j){d();j--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in f.totals)e(c.totals.streams, c.data[e][o]]);if(j){d();j--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(mist.data.config.time-15)*1E3;d()}d=f;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in f.totals)e(c.totals.streams,
c.totals.protocols,f.totals);else for(j in f.totals)e(c.totals[j].streams,c.totals[j].protocols,f.totals[j])}a&&a(f,d);break;case "CHALL":if(f.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=f.authorize.challenge;mist.send(a,c,d);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host, c.totals.protocols,f.totals);else for(j in f.totals)e(c.totals[j].streams,c.totals[j].protocols,f.totals[j])}a&&a(f,d);break;case "CHALL":if(f.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=f.authorize.challenge;mist.send(a,c,d);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,
name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete c.authorize;mist.send(a,c,d);break;default:UI.navto("Login")}}};d.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){n.abort()}));var n=$.ajax(f)},inputMatch:function(a,c){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var d in a){var b= name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete c.authorize;mist.send(a,c,d);break;default:UI.navto("Login")}}};d.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){n.abort()}));var n=$.ajax(f)},inputMatch:function(a,c){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var d in a){var b=
a[d].replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+b+"(?:\\?[^\\?]*)?$","i").test(c))return true}return false},convertBuildOptions:function(a,c){function d(a,b,d){var e={label:UI.format.capital(d.name?d.name:b),pointer:{main:c,index:b},validate:[]};f[a]=="required"&&(!("default"in d)||d["default"]=="")&&e.validate.push("required");if("default"in d){e.placeholder=d["default"];if(d.type=="select")for(var j in d.select)if(d.select[j][0]==d["default"]){e.placeholder= a[d].replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+b+"(?:\\?[^\\?]*)?$","i").test(c))return true}return false},convertBuildOptions:function(a,c){function d(a,b,d){var e={label:UI.format.capital(d.name?d.name:b),pointer:{main:c,index:b},validate:[]};f[a]=="required"&&(!("default"in d)||d["default"]=="")&&e.validate.push("required");if("default"in d){e.placeholder=d["default"];if(d.type=="select")for(var j in d.select)if(d.select[j][0]==d["default"]){e.placeholder=

View file

@ -2366,7 +2366,8 @@ var UI = {
serverid: mist.data.config.serverid, serverid: mist.data.config.serverid,
debug: mist.data.config.debug, debug: mist.data.config.debug,
accesslog: mist.data.config.accesslog, accesslog: mist.data.config.accesslog,
prometheus: mist.data.config.prometheus prometheus: mist.data.config.prometheus,
defaultStream: mist.data.config.defaultStream
}; };
var b = {}; var b = {};
if ("bandwidth" in mist.data) { if ("bandwidth" in mist.data) {
@ -2520,6 +2521,16 @@ var UI = {
}, },
help: "This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>", help: "This setting only applies when MistServer is combined with a load balancer. Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>",
LTSonly: true LTSonly: true
},{
type: "str",
validate: ['streamname_with_wildcard_and_variables'],
label: 'Fallback stream',
pointer: {
main: s,
index: "defaultStream"
},
help: "When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",
LTSonly: true
},{ },{
type: 'checkbox', type: 'checkbox',
label: 'Force configurations save', label: 'Force configurations save',
@ -2590,6 +2601,7 @@ var UI = {
} }
if ((!d.update) || (!('uptodate' in d.update))) { if ((!d.update) || (!('uptodate' in d.update))) {
$versioncheck.text('Unknown, checking..'); $versioncheck.text('Unknown, checking..');
setTimeout(function(){ setTimeout(function(){
mist.send(function(d){ mist.send(function(d){