LSP: fixed embed option propagation; invisible but clickable menu
This commit is contained in:
parent
9fdb550735
commit
680f9acfa8
3 changed files with 87 additions and 78 deletions
|
@ -98,6 +98,12 @@ nav .menu {
|
|||
margin: 1em 0;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
.hide {
|
||||
opacity: 0;
|
||||
}
|
||||
nav .menu.hide a {
|
||||
cursor: default;
|
||||
}
|
||||
nav a, nav a:hover {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
|
|
131
lsp/minified.js
131
lsp/minified.js
|
@ -19,21 +19,21 @@ ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Su
|
|||
UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela, Bolivarian Republic of",VN:"Viet Nam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},tooltip:{show:function(a,c){$tooltip=this.element;$.contains(document.body,$tooltip[0])||$("body").append($tooltip);$tooltip.html(c);clearTimeout(this.hiding);
|
||||
delete this.hiding;var e=$(document).height()-$tooltip.outerHeight(),b=$(document).width()-$tooltip.outerWidth();$tooltip.css("left",Math.min(a.pageX+10,b-10));$tooltip.css("top",Math.min(a.pageY+25,e-10));$tooltip.show().addClass("show")},hide:function(){$tooltip=this.element;$tooltip.removeClass("show");this.hiding=setTimeout(function(){$tooltip.hide()},500)},element:$("<div>").attr("id","tooltip")},popup:{element:null,show:function(a){this.element=$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",
|
||||
function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{},Preview:{},Push:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{},"Terms & Conditions":{link:"http://mistserver.org/documentation#Legal"}}}}],
|
||||
buildMenu:function(){function a(a,c){var b=$("<a>").addClass("button");b.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in c.classes)b.addClass(c.classes[d]);"LTSonly"in c&&b.addClass("LTSonly");"link"in c?b.attr("href",c.link).attr("target","_blank"):"submenu"in c||b.click(function(c){UI.navto(a);c.stopPropagation()});return b}var c=UI.elements.menu,e;for(e in UI.menu){0<e&&c.append($("<br>"));for(var b in UI.menu[e]){var d=UI.menu[e][b],
|
||||
i=a(b,d);c.append(i);if("submenu"in d){var m=$("<span>").addClass("submenu");i.addClass("arrowdown").append(m);for(var f in d.submenu)m.append(a(f,d.submenu[f]))}}}e=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");c.after(e).after($("<div>").addClass("separator"))},buildUI:function(a){var c=
|
||||
$("<div>").addClass("input_container"),e;for(e in a){var b=a[e];if(b instanceof jQuery)c.append(b);else if("help"==b.type){var d=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(b.help));c.append(d);if("classes"in b)for(var i in b.classes)d.addClass(b.classes[i])}else if("text"==b.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(b.text)));else if("custom"==b.type)c.append(b.custom);else if("buttons"==b.type)for(i in d=
|
||||
$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&d.css(b.css),c.append(d),b.buttons){var m=b.buttons[i],f=$("<button>").text(m.label).data("opts",m);"css"in m&&f.css(m.css);d.append(f);switch(m.type){case "cancel":f.addClass("cancel").click(m["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),c=!1;a.find(".hasValidate").each(function(){if(c=$(this).data("validate")(this,!0))return!1});c||(a.find(".isSetting").each(function(){var a=
|
||||
$(this).getval(),c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete c.main[c.index],!0;c.main[c.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in b&&m.css(b.css);m.append($("<span>").addClass("label").html("label"in b?b.label+":":""));f=$("<span>").addClass("field_container");m.append(f);switch(b.type){case "password":d=
|
||||
$("<input>").attr("type","password");break;case "int":d=$("<input>").attr("type","number");"min"in b&&d.attr("min",b.min);"max"in b&&d.attr("max",b.min);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":d=$("<span>");break;case "debug":b.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"],
|
||||
[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":d=$("<select>");for(i in b.select){var p=$("<option>");"string"==typeof b.select[i]?p.text(b.select[i]):p.val(b.select[i][0]).text(b.select[i][1]);d.append(p)}break;case "textarea":d=
|
||||
$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":d=$("<input>").attr("type","checkbox");break;case "hidden":d=$("<input>").attr("type","hidden");m.hide();break;case "email":d=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":d=$("<input>").attr("type","text");"filetypes"in b&&d.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":d=$("<input>").attr("type","hidden");break;case "radioselect":d=
|
||||
$("<div>").addClass("radioselect");for(e in b.radioselect){var n=$("<input>").attr("type","radio").val(b.radioselect[e][0]).attr("name",b.label);("LTSonly"in b&&!mist.data.LTS||b.readonly)&&n.prop("disabled",!0);p=$("<label>").append(n).append($("<span>").html(b.radioselect[e][1]));d.append(p);if(2<b.radioselect[e].length)for(i in n=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),p.append(n),("LTSonly"in b&&!mist.data.LTS||b.readonly)&&n.prop("disabled",
|
||||
!0),b.radioselect[e][2])p=$("<option>"),n.append(p),b.radioselect[e][2][i]instanceof Array?p.val(b.radioselect[e][2][i][0]).html(b.radioselect[e][2][i][1]):p.html(b.radioselect[e][2][i])}break;case "checklist":d=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");d.append($controls).append($checklist);$controls.append($("<label>").text("All").prepend($("<input>").attr("type","checkbox").click(function(){$(this).is(":checked")?
|
||||
buildMenu:function(){function a(a,c){var b=$("<a>").addClass("button");b.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in c.classes)b.addClass(c.classes[d]);"LTSonly"in c&&b.addClass("LTSonly");"link"in c?b.attr("href",c.link).attr("target","_blank"):"submenu"in c||b.click(function(c){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),c.stopPropagation())});return b}var c=UI.elements.menu,e;for(e in UI.menu){0<e&&c.append($("<br>"));
|
||||
for(var b in UI.menu[e]){var d=UI.menu[e][b],i=a(b,d);c.append(i);if("submenu"in d){var m=$("<span>").addClass("submenu");i.addClass("arrowdown").append(m);for(var f in d.submenu)m.append(a(f,d.submenu[f]))}}}e=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");c.after(e).after($("<div>").addClass("separator"))},
|
||||
buildUI:function(a){var c=$("<div>").addClass("input_container"),e;for(e in a){var b=a[e];if(b instanceof jQuery)c.append(b);else if("help"==b.type){var d=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(b.help));c.append(d);if("classes"in b)for(var i in b.classes)d.addClass(b.classes[i])}else if("text"==b.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(b.text)));else if("custom"==b.type)c.append(b.custom);else if("buttons"==
|
||||
b.type)for(i in d=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&d.css(b.css),c.append(d),b.buttons){var m=b.buttons[i],f=$("<button>").text(m.label).data("opts",m);"css"in m&&f.css(m.css);d.append(f);switch(m.type){case "cancel":f.addClass("cancel").click(m["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),c=!1;a.find(".hasValidate").each(function(){if(c=$(this).data("validate")(this,!0))return!1});
|
||||
c||(a.find(".isSetting").each(function(){var a=$(this).getval(),c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete c.main[c.index],!0;c.main[c.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in b&&m.css(b.css);m.append($("<span>").addClass("label").html("label"in b?b.label+":":""));f=$("<span>").addClass("field_container");
|
||||
m.append(f);switch(b.type){case "password":d=$("<input>").attr("type","password");break;case "int":d=$("<input>").attr("type","number");"min"in b&&d.attr("min",b.min);"max"in b&&d.attr("max",b.min);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":d=$("<span>");break;case "debug":b.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"],
|
||||
[4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":d=$("<select>");for(i in b.select){var p=$("<option>");"string"==typeof b.select[i]?p.text(b.select[i]):p.val(b.select[i][0]).text(b.select[i][1]);
|
||||
d.append(p)}break;case "textarea":d=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":d=$("<input>").attr("type","checkbox");break;case "hidden":d=$("<input>").attr("type","hidden");m.hide();break;case "email":d=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":d=$("<input>").attr("type","text");"filetypes"in b&&d.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":d=$("<input>").attr("type",
|
||||
"hidden");break;case "radioselect":d=$("<div>").addClass("radioselect");for(e in b.radioselect){var n=$("<input>").attr("type","radio").val(b.radioselect[e][0]).attr("name",b.label);("LTSonly"in b&&!mist.data.LTS||b.readonly)&&n.prop("disabled",!0);p=$("<label>").append(n).append($("<span>").html(b.radioselect[e][1]));d.append(p);if(2<b.radioselect[e].length)for(i in n=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),p.append(n),("LTSonly"in
|
||||
b&&!mist.data.LTS||b.readonly)&&n.prop("disabled",!0),b.radioselect[e][2])p=$("<option>"),n.append(p),b.radioselect[e][2][i]instanceof Array?p.val(b.radioselect[e][2][i][0]).html(b.radioselect[e][2][i][1]):p.html(b.radioselect[e][2][i])}break;case "checklist":d=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");d.append($controls).append($checklist);$controls.append($("<label>").text("All").prepend($("<input>").attr("type","checkbox").click(function(){$(this).is(":checked")?
|
||||
$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!0):$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!1)})));for(e in b.checklist)"string"==typeof b.checklist[e]&&(b.checklist[e]=[b.checklist[e],b.checklist[e]]),$checklist.append($("<label>").text(b.checklist[e][1]).prepend($("<input>").attr("type","checkbox").attr("name",b.checklist[e][0])));break;case "DOMfield":d=b.DOMfield;break;default:d=$("<input>").attr("type","text")}d.addClass("field").data("opts",
|
||||
b);"pointer"in b&&d.attr("name",b.pointer.index);f.append(d);if("classes"in b)for(i in b.classes)d.addClass(b.classes[i]);"placeholder"in b&&d.attr("placeholder",b.placeholder);"default"in b&&d.attr("placeholder",b["default"]);"unit"in b&&f.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(d.attr("readonly","readonly"),d.click(function(){$(this).select()}));"qrcode"in b&&f.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()),c=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(c));c.qrcode({text:a,size:Math.min(c.width(),c.height())})})));"rows"in b&&d.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(f.addClass("LTSonly"),d.prop("disabled",!0));switch(b.type){case "browse":n=$("<div>").addClass("grouper").append(m);c.append(n);n=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});
|
||||
f.append(n);n.click(function(){function a(c){i.text("Loading..");mist.send(function(a){f.text(a.browse.path[0]);i.html(n.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var m=a.browse.subdirectories[c];i.append(n.clone(true).attr("title",f.text()+o+m).text(m))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var m=a.browse.files[c],l=f.text()+o+m,m=$("<a>").text(m).addClass("file").attr("title",
|
||||
l);i.append(m);if(p){var s=true,v;for(v in p)if(typeof p[v]!="undefined"&&mist.inputMatch(p[v],l)){s=false;break}s&&m.hide()}m.click(function(){var a=$(this).attr("title");d.setval(a);e.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field"),e=$(this),f=$("<span>").addClass("field"),m=$("<button>").text("Select this folder").on("keydown",function(a){a.stopPropagation()}),i=$("<div>").addClass("browse_contents"),n=$("<a>").addClass("folder"),
|
||||
l);i.append(m);if(p){var s=true,w;for(w in p)if(typeof p[w]!="undefined"&&mist.inputMatch(p[w],l)){s=false;break}s&&m.hide()}m.click(function(){var a=$(this).attr("title");d.setval(a);e.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field"),e=$(this),f=$("<span>").addClass("field"),m=$("<button>").text("Select this folder").on("keydown",function(a){a.stopPropagation()}),i=$("<div>").addClass("browse_contents"),n=$("<a>").addClass("folder"),
|
||||
p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(f).append(m))).append(i);m.click(function(){var a=f.text()+"/";d.setval(a);e.show();b.remove()});var o="/";mist.data.config.version.indexOf("indows")>-1&&(o="\\");n.click(function(){var c=f.text()+o+$(this).text();a(c)});c=d.getval();c=c.split(o);c.pop();c=c.join(o);e.hide();a(c)});break;case "geolimited":case "hostlimited":n=
|
||||
{field:d};n.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));n.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":n.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(e in UI.countrylist)n.prototype.append($("<option>").val(e).html(UI.countrylist[e]));break;case "hostlimited":n.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}n.prototype.on("change keyup",
|
||||
function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});n.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),c=[],b=false;a.values.children().each(function(){b=$(this).val();b!=""?c.push(b):$(this).remove()});a.values.append(a.prototype.clone(true));c.length>0?a.field.val($(this).val()+c.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&!mist.data.LTS&&(n.blackwhite.prop("disabled",!0),n.prototype.prop("disabled",
|
||||
|
@ -64,12 +64,12 @@ c)+", "+UI.format.time(a,c)},duration:function(a){var c=[0.001,1E3,60,60,24,7,1E
|
|||
b.hr).slice(-2),("0"+b.min).slice(-2),("0"+b.sec).slice(-2)+(b.ms?"."+b.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*c)/c;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var c=$("<span>");if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=
|
||||
typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");break;case 2:c.text("Standby").addClass("orange");break;default:c.text(a.online)}"error"in a&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},addUnit:function(a,c){var e=$("<span>").html(a);e.append($("<span>").addClass("unit").html(c));return e[0].innerHTML},bytes:function(a,
|
||||
c){var e="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=e[0];else{var b=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>b?unit=e[0]:(a/=Math.pow(1024,b),unit=e[b])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s":""))}},navto:function(a,c){var e=location.hash,b=e.split("@");b[0]=[mist.user.name,mist.user.host].join("&");b[1]=[a,c].join("&");"undefined"!=typeof screenlog&&screenlog.navto(b[1]);location.hash=b.join("@");location.hash==e&&$(window).trigger("hashchange")},showTab:function(a,
|
||||
c){var e,b,d=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))d.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else switch(e=UI.elements.menu.css("opacity","1").find(".button").filter(function(){if($(this).find(".plain").text()==a)return!0}),0<e.length&&(UI.elements.menu.find(".button.active").removeClass("active"),e.addClass("active")),UI.elements.secondary_menu.html(""),UI.interval.clear(),d.html($("<h2>").text(a)),a){case "Login":if(mist.user.loggedin){UI.navto("Overview");
|
||||
break}UI.elements.menu.css("opacity","0");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");d.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api",
|
||||
"default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"password"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.send(function(){UI.navto("Overview")})}}]}]));break;case "Create a new account":UI.elements.menu.css("visibility",
|
||||
"hidden");d.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));d.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,
|
||||
c){var e,b,d=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))d.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else switch(e=UI.elements.menu.removeClass("hide").find(".button").filter(function(){if($(this).find(".plain").text()==a)return!0}),0<e.length&&(UI.elements.menu.find(".button.active").removeClass("active"),e.addClass("active")),UI.elements.secondary_menu.html(""),UI.interval.clear(),d.html($("<h2>").text(a)),a){case "Login":if(mist.user.loggedin){UI.navto("Overview");
|
||||
break}UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");d.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api",
|
||||
"default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"password"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.send(function(){UI.navto("Overview")})}}]}]));break;case "Create a new account":UI.elements.menu.addClass("hide");
|
||||
d.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));d.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,
|
||||
index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,c){$(".match_password").not($(c)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"password"},classes:["match_password"]},{label:"Repeat password",type:"password",validate:["required",function(a,c){return a!=$(".match_password").not($(c)).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.password}})}}]}]));break;case "Account created":UI.elements.menu.css("visibility","hidden");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?"},
|
||||
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.password}})}}]}]));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 c=[],b;for(b in a.capabilities.connectors)if(a.capabilities.connectors[b].required)d.append('Could not enable protocol "'+b+'" because it has required settings.<br>');else{c.push({connector:b});d.append('Enabled protocol "'+
|
||||
b+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":var i=$("<span>").text("Loading.."),m=$("<span>"),f=$("<span>"),p=$("<span>");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:i,LTSonly:!0},{type:"span",label:"Server time",value:p},{type:"span",label:"Current streams",value:m},{type:"span",label:"Current connections",value:f},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",
|
||||
|
@ -80,51 +80,52 @@ g=function(){m.text(("active_streams"in mist.data?mist.data.active_streams?mist.
|
|||
typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");break}var h=$("<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("New protocol").click(function(){UI.navto("Edit Protocol")})).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(h));
|
||||
var k=function(){function a(c){var b=mist.data.capabilities.connectors[c.connector];if(!b)return"";var d=[],e=["required","optional"],f;for(f in e)for(var g in b[e[f]])c[g]&&c[g]!=""?d.push(g+": "+c[g]):b[e[f]][g]["default"]&&d.push(g+": "+b[e[f]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}h.html("");for(var c in mist.data.config.protocols){var b=mist.data.config.protocols[c];h.append($("<tr>").data("index",c).append($("<td>").text(b.connector)).append($("<td>").html(UI.format.status(b))).append($("<td>").html(a(b))).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.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};k();UI.interval.set(function(){mist.send(function(){k()})},
|
||||
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}var j=!1;""!=c&&0<=c&&(j=!0);var v={},q;for(q in mist.data.config.protocols)v[mist.data.config.protocols[q].connector]=1;var G=function(a){var b=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(b,o);d.push({type:"hidden",pointer:{main:o,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save",
|
||||
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}var j=!1;""!=c&&0<=c&&(j=!0);var w={},q;for(q in mist.data.config.protocols)w[mist.data.config.protocols[q].connector]=1;var F=function(a){var b=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(b,o);d.push({type:"hidden",pointer:{main:o,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save",
|
||||
"function":function(){if(j)mist.data.config.protocols[c]=o;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(o)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var e in b.deps){a=$("<li>").text(b.deps[e]+
|
||||
" ");$ul.append(a);typeof v[b.deps[e]]!="undefined"||typeof v[b.deps[e]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},v={};for(q in mist.data.config.protocols)v[mist.data.config.protocols[q].connector]=1;if(j){var r=mist.data.config.protocols[c],o=r;d.find("h2").append(' "'+r.connector+'"');d.append(G(r.connector))}else{d.html($("<h2>").text("New Protocol"));
|
||||
var o={},w=[];for(q in mist.data.capabilities.connectors)w.push([q,q]);var V=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:w,"function":function(){V.html(G($(this).getval()))}}])).append(V)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}h=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));e=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
|
||||
" ");$ul.append(a);typeof w[b.deps[e]]!="undefined"||typeof w[b.deps[e]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},w={};for(q in mist.data.config.protocols)w[mist.data.config.protocols[q].connector]=1;if(j){var r=mist.data.config.protocols[c],o=r;d.find("h2").append(' "'+r.connector+'"');d.append(F(r.connector))}else{d.html($("<h2>").text("New Protocol"));
|
||||
var o={},x=[];for(q in mist.data.capabilities.connectors)x.push([q,q]);var V=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:x,"function":function(){V.html(F($(this).getval()))}}])).append(V)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}h=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));e=$("<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(h);d.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Immidiately go to the stream preview or view the information available about the stream with the info button."}])).append($("<button>").text("New stream").click(function(){UI.navto("Edit Stream")})).append(e);
|
||||
e.stupidtable();var F=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;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=W(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;y[mist.data.active_streams[a]]=b}}b=Object.keys(y);b.sort();for(var c in b){var d=
|
||||
b[c],e;e=d in mist.data.streams?mist.data.streams[d]:y[d];var f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),g=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var D=mist.data.totals[d].all_protocols.clients,g=0;if(D.length){for(a in D)g=g+D[a][1];g=Math.round(g/D.length)}}f.html(UI.format.number(g));if(g==0&&e.online==1)e.online=2;g=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||
|
||||
!e.ischild)&&g.html($("<button>").text("Edit").click(function(){UI.navto("Edit Stream",$(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 "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));D=$("<span>").text(d);e.ischild&&D.css("padding-left","1em");var i=
|
||||
UI.format.status(e),j=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){i.html("");j="";f.html("")}h.append($("<tr>").data("index",d).html($("<td>").html(D).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(i)).append(f).append($("<td>").html(j)).append(g));
|
||||
a++}},{totals:a,active_streams:true})},y=$.extend(!0,{},mist.data.streams),W=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c};if(mist.data.LTS){var C=0,H=0;for(l in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[l].source)&&(y[l].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=c+"+"+a.browse.files[d];y[g]=W(g,mist.data.streams[c]);y[g].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[c].filesfound=true:mist.data.streams[c].filesfound=false;H++;if(C==H){mist.send(function(){F()},{active_streams:true});UI.interval.set(function(){F()},1E4)}},{browse:mist.data.streams[l].source},{stream:l}),C++);0==C&&(mist.send(function(){F()},
|
||||
{active_streams:!0}),UI.interval.set(function(){F()},3E4))}else mist.send(function(){F()},{active_streams:!0}),UI.interval.set(function(){F()},1E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}j=!1;""!=c&&(j=!0);j?(l=c,o=mist.data.streams[l],d.find("h2").append(' "'+l+'"')):(d.html($("<h2>").text("New Stream")),o={});l=[];for(q in mist.data.capabilities.inputs)l.push(mist.data.capabilities.inputs[q].source_match);
|
||||
var K=$("<div>");d.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:o,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",validate:["required"],filetypes:l,pointer:{main:o,index:"source"},help:'Set the stream source.<table><tr><td>VoD:</td><td>You can browse to the file or folder as a source or simply enter the path to the file.</td></tr><tr><td>Live:</td><td>You\'ll need to enter "push://IP" with the IP of the machine pushing towards MistServer.<br>You can use "push://" to accept any source.</td></tr><tr><td>(Pro only)</td><td>Use "push://(IP)@password" to set a password protection for pushes.</td></tr></table>If you\'re unsure how to set the source properly, please view our Live pushing guide at the tools section.',
|
||||
"function":function(){var a=$(this).val();if(a!=""){var b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)K.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{a=mist.data.capabilities.inputs[b];K.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,
|
||||
o);K.append(UI.buildUI(a))}}}},$("<br>"),{type:"custom",custom:K},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,
|
||||
e.stupidtable();var E=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,z,mist.data.streams);var a=0;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=W(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;z[mist.data.active_streams[a]]=b}}b=Object.keys(z);b.sort();for(var c in b){var d=
|
||||
b[c],e;e=d in mist.data.streams?mist.data.streams[d]:z[d];var f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),g=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var C=mist.data.totals[d].all_protocols.clients,g=0;if(C.length){for(a in C)g=g+C[a][1];g=Math.round(g/C.length)}}f.html(UI.format.number(g));if(g==0&&e.online==1)e.online=2;g=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||
|
||||
!e.ischild)&&g.html($("<button>").text("Edit").click(function(){UI.navto("Edit Stream",$(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 "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));C=$("<span>").text(d);e.ischild&&C.css("padding-left","1em");var i=
|
||||
UI.format.status(e),j=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){i.html("");j="";f.html("")}h.append($("<tr>").data("index",d).html($("<td>").html(C).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(i)).append(f).append($("<td>").html(j)).append(g));
|
||||
a++}},{totals:a,active_streams:true})},z=$.extend(!0,{},mist.data.streams),W=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c};if(mist.data.LTS){var B=0,G=0;for(l in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[l].source)&&(z[l].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=c+"+"+a.browse.files[d];z[g]=W(g,mist.data.streams[c]);z[g].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?z[c].filesfound=true:mist.data.streams[c].filesfound=false;G++;if(B==G){mist.send(function(){E()},{active_streams:true});UI.interval.set(function(){E()},1E4)}},{browse:mist.data.streams[l].source},{stream:l}),B++);0==B&&(mist.send(function(){E()},
|
||||
{active_streams:!0}),UI.interval.set(function(){E()},3E4))}else mist.send(function(){E()},{active_streams:!0}),UI.interval.set(function(){E()},1E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}j=!1;""!=c&&(j=!0);j?(l=c,o=mist.data.streams[l],d.find("h2").append(' "'+l+'"')):(d.html($("<h2>").text("New Stream")),o={});l=[];for(q in mist.data.capabilities.inputs)l.push(mist.data.capabilities.inputs[q].source_match);
|
||||
var J=$("<div>");d.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:o,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",validate:["required"],filetypes:l,pointer:{main:o,index:"source"},help:'Set the stream source.<table><tr><td>VoD:</td><td>You can browse to the file or folder as a source or simply enter the path to the file.</td></tr><tr><td>Live:</td><td>You\'ll need to enter "push://IP" with the IP of the machine pushing towards MistServer.<br>You can use "push://" to accept any source.</td></tr><tr><td>(Pro only)</td><td>Use "push://(IP)@password" to set a password protection for pushes.</td></tr></table>If you\'re unsure how to set the source properly, please view our Live pushing guide at the tools section.',
|
||||
"function":function(){var a=$(this).val();if(a!=""){var b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)J.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{a=mist.data.capabilities.inputs[b];J.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,
|
||||
o);J.append(UI.buildUI(a))}}}},$("<br>"),{type:"custom",custom:J},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,
|
||||
index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){if(!mist.data.streams)mist.data.streams={};mist.data.streams[o.name]=o;c!=o.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[o.name]=
|
||||
o;if(c!=o.name)a.deletestream=[c]}else a.streams=mist.data.streams;mist.send(function(){delete mist.data.streams[o.name].online;delete mist.data.streams[o.name].error;UI.navto("Streams")},a)}}]}]));break;case "Preview":if(""==c){d.append("Loading..");var N=function(b){var c={};b.sort();d.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:b,pointer:{main:c,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,c.stream)}}]}]));
|
||||
UI.elements.secondary_menu.html("").append($("<a>").addClass("button").addClass("active").text("Choose stream").click(function(){UI.navto("Preview")}));var e=$("<div>").addClass("preview_icons");d.append($("<span>").addClass("description").text("Or, click a stream from the list below.")).append(e);for(var g in b){var f=b[g],h="";if(f.indexOf("+")>-1){h=f.split("+");h=mist.data.streams[h[0]].source+h[1]}else h=mist.data.streams[f].source;e.append($("<button>").append($("<span>").text(f)).append($("<span>").addClass("description").text(h)).attr("title",
|
||||
f).attr("data-stream",f).click(function(){UI.navto("Preview",$(this).attr("data-stream"))}))}};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}H=C=0;w={};for(l in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[l].source)&&(mist.send(function(a,b){var c=b.stream,d;for(d in mist.data.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+mist.data.browse.files[d])&&(w[c+"+"+mist.data.browse.files[d]]=true);H++;C==H&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");b.length>1&&b[0]in mist.data.streams&&(w[mist.data.active_streams[a]]=true)}w=Object.keys(w);w=w.concat(Object.keys(mist.data.streams));w.sort();N(w)},{active_streams:true})},{browse:mist.data.streams[l].source},{stream:l}),
|
||||
C++);0==C&&mist.send(function(){var b=[],c;for(c in mist.data.active_streams){var e=mist.data.active_streams[c].split("+");e.length>1&&e[0]in mist.data.streams&&(b[mist.data.active_streams[c]]=true)}mist.data.streams&&(b=b.concat(Object.keys(mist.data.streams)));if(b.length==0)d.html($("<h2>").text(a)).append("Please set up a stream first.");else{b.sort();N(b)}},{active_streams:!0})}else N(Object.keys(mist.data.streams));break}d.find("h2").append(' of "'+c+'"');l=":8080";for(q in mist.data.config.protocols)if(r=
|
||||
mist.data.config.protocols[q],"HTTP"==r.connector||"HTTP.exe"==r.connector)l=r.port?":"+r.port:":8080";var E={},r=$("<span>").hide();E["Embed urls"]=r;d.append(r);e=mist.user.host;b=document.createElement("a");b.href=e;e=b.protocol+"//";b=b.hostname;var I=e+b+l+"/",x={autoplay:!0},L=function(a){var b=["div"],d='\n <script src="'+I+"embed_"+c+'.js"><\/script>\n';a.autoplay||b.push("data-noautoplay");a.forceprotocol&&a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');a.urlappend&&
|
||||
a.urlappend!=""&&b.push('data-urlappend="'+a.urlappend.replace(/\"/g,'\\"')+'"');return"<"+b.join(" ")+">"+d+"</div>"},X=$("<span>");r.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embedable script",type:"str",value:I+"embed_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:I+"info_"+c+".js",readonly:!0},{label:"Autodetect player",type:"str",value:I+c+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:L(x),rows:4,
|
||||
readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",value:!0,pointer:{main:x,index:"autoplay"},"function":function(){x.autoplay=$(this).getval();$(".embed_code").setval(L(x))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:x,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){x.forceprotocol=$(this).getval();$(".embed_code").setval(L(x))}},{label:"Video URL addition",
|
||||
type:"str",pointer:{main:x,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(){x.urlappend=$(this).getval();$(".embed_code").setval(L(x))}},$("<h3>").text("Protocol stream urls"),X]));l=$("<span>").append($("<h3>").text("Meta information")).hide();E["Meta information"]=l;var O=$("<span>");l.append(O);d.append(l);l=$("<span>").hide();E.Preview=l;d.append(l);var A=$("<div>").css({"float":"left",
|
||||
"margin-right":"1em",width:"100%"}).attr("data-forcesupportcheck",""),Y=$("<div>").css("float","left");l.append(A).append(Y);mist.stored.get().autoplay||A.attr("data-noautoplay","");var M=function(){A.text("Loading..");var a=document.createElement("script");a.src=I+"embed_"+c+".js";a.onerror=function(){A.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){M()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")A.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){M()}));
|
||||
else{var a=mistvideo[c],b=UI.buildUI([{label:"Protocol stream url",type:"str",readonly:true,value:a.embedded?a.embedded.url:"",qrcode:true},{label:"Autoplay (from now on)",type:"checkbox",value:mist.stored.get().autoplay,"function":function(){mist.stored.set("autoplay",$(this).getval()?1:0)}}]);b.find(".help_container").remove();A.append(b);var d=$("<table>").css("font-size","0.9em").html($("<thead>").html($("<tr>").html($("<th>")).append($("<th>").text("Type")).append($("<th>").text("Priority")).append($("<th>").text("Simul. tracks")).append($("<th>").html("Your browser<br>support"))));
|
||||
Y.html(d);b=$("<tbody>");d.append(b);var d=$(".embed_code_forceprotocol"),e=[];d.find(".clear").remove();for(var g in a.source){var f=a.source[g],h=f.type.split("/"),i=h[0];i.length<6&&(i=i.toUpperCase());switch(h.length){case 1:break;case 2:i=UI.format.capital(h[0])+" v"+h[1];if(h[0]=="flash")switch(h[1]){case "7":i="Progressive ("+i+")";break;case "10":i="RTMP ("+i+")";break;case "11":i="HDS ("+i+")"}break;case 3:switch(h[2]){case "vnd.apple.mpegurl":i=i+" HLS";break;case "vnd.ms-ss":i=i+" Smooth";
|
||||
break;case "mp2t":i=i+" TS";break;default:h[2].length<6&&(h[2]=h[2].toUpperCase());i=i+(" "+h[2]);h[1]!="video"&&(i=i+(" ("+h[1]+")"))}break;default:i=f.type}i=UI.format.capital(i);d.append($("<option>").text(i).val(f.type).addClass("clear"));e.push({label:i,type:"str",value:f.url,readonly:true,qrcode:true});h=$("<tr>");b.append(h);h.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){A.attr("data-forcetype",$(this).val()).html("Loading embed..");M()}).val(f.type))).append($("<td>").text(i)).append($("<td>").text(f.priority)).append($("<td>").text(f.simul_tracks+
|
||||
"/"+f.total_matches)).append($("<td>").text(f.browser_support?"yes":"no"));if(a.embedded&&a.embedded.type==f.type){h.css("outline","1px solid rgba(0,0,0,0.5)");h.find("input[type=radio]").prop("checked",true)}}X.html(UI.buildUI(e));var j;if(c in mistvideo)j=mistvideo[c].meta;if(j){a=[];a.push({label:"Type",type:"span",value:j.live?"Live":"Pre-recorded (VoD)"});"format"in j&&a.push({label:"Format",type:"span",value:j.format});j.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(j.buffer_window,
|
||||
"ms")});b={vheader:"Audio",labels:["Codec","Duration","Peak bitrate","Channels","Samplerate"],content:[]};g={vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate"],content:[]};d=Object.keys(j.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var l in d){e=d[l];f=j.tracks[e];switch(f.type){case "audio":b.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+
|
||||
UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz")]});break;case "video":g.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),
|
||||
UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps")]})}}j=UI.buildVheaderTable(b).css("width","auto");l=UI.buildVheaderTable(g).css("width","auto");a.push($("<span>").text("Tracks:"));a.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(j).append(l));O.html(UI.buildUI(a))}else O.html("No meta information available.")}};var b=$("<div>").addClass("video_container");A.html(b);b[0].appendChild(a)};M();var P=UI.elements.secondary_menu;P.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));
|
||||
l=["Preview","Embed urls","Meta information"];v=l[0];for(q in l)r=$("<a>").addClass("button").text(l[q]).click(function(){P.find(".active").removeClass("active");$(this).addClass("active");for(q in E)E[q].hide();E[$(this).text()].show()}),P.append(r),l[q]==v&&(r.addClass("active"),E[v].show());break;case "Push":var z=$("<div>").text("Loading..");d.append(z);mist.send(function(a){function b(a,c){var d=$("<span>");a.length>=4&&a[2]!=a[3]?d.append($("<span>").text(a[2])).append($("<span>").html("»").addClass("unit").css("margin",
|
||||
"0 0.5em")).append($("<span>").text(a[3])):d.append($("<span>").text(a[2]));return $("<tr>").append($("<td>").text(a[1])).append($("<td>").append(d.children())).append($("<td>").append($("<button>").text(c=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+a[1]+" to "+a[2])){var b=$(this).closest("tr");b.html($("<td colspan=99>").html($("<span>").addClass("red").text(c=="Automatic"?"Removing..":"Stopping..")));c=="Automatic"?
|
||||
mist.send(function(){b.remove()},{push_auto_remove:{stream:a[1],target:a[2]}}):mist.send(function(){function c(){setTimeout(function(){mist.send(function(d){var e=false;if("push_list"in d&&d.push_list&&d.push_list.length){var e=true,f;for(f in d.push_list)if(d.push_list[f][0]==a[0]){e=false;break}}else e=true;e?b.remove():c()},{push_list:1})},1E3)}c()},{push_stop:[a[0]]})}})))}z.html("");var c=a.push_settings;c||(c={});z.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},
|
||||
$("<h3>").text("Settings"),{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:c,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:c,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",
|
||||
label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:c})}}]}]));var d=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),e=d.clone();if("push_list"in a)for(var f in a.push_list)d.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)e.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));z.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push",
|
||||
"auto")}));e.find("tr").length==1?z.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):z.append(e);z.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));d.find("tr").length==1?z.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em")):z.append($("<button>").text("Stop all pushes").click(function(){var b=[],c;for(c in a.push_list)b.push(a.push_list[c][0]);
|
||||
if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){function 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(b.indexOf(c.push_list[e][0])==-1){d=false;break}}else d=true;d?UI.navto("Push"):a()},{push_list:1})},1E3)}a()},{push_stop:b});d.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append(d)},
|
||||
{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")},{capabilities:1});break}var t,Q=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var e=mist.data.capabilities.connectors[b];"push_urls"in e&&(a=a.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var f={};d.append(UI.buildUI([{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:f,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:["red"]}}],datalist:t,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.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>",
|
||||
f).attr("data-stream",f).click(function(){UI.navto("Preview",$(this).attr("data-stream"))}))}};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}G=B=0;x={};for(l in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[l].source)&&(mist.send(function(a,b){var c=b.stream,d;for(d in mist.data.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+mist.data.browse.files[d])&&(x[c+"+"+mist.data.browse.files[d]]=true);G++;B==G&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");b.length>1&&b[0]in mist.data.streams&&(x[mist.data.active_streams[a]]=true)}x=Object.keys(x);x=x.concat(Object.keys(mist.data.streams));x.sort();N(x)},{active_streams:true})},{browse:mist.data.streams[l].source},{stream:l}),
|
||||
B++);0==B&&mist.send(function(){var b=[],c;for(c in mist.data.active_streams){var e=mist.data.active_streams[c].split("+");e.length>1&&e[0]in mist.data.streams&&(b[mist.data.active_streams[c]]=true)}mist.data.streams&&(b=b.concat(Object.keys(mist.data.streams)));if(b.length==0)d.html($("<h2>").text(a)).append("Please set up a stream first.");else{b.sort();N(b)}},{active_streams:!0})}else N(Object.keys(mist.data.streams));break}d.find("h2").append(' of "'+c+'"');l=":8080";for(q in mist.data.config.protocols)if(r=
|
||||
mist.data.config.protocols[q],"HTTP"==r.connector||"HTTP.exe"==r.connector)l=r.port?":"+r.port:":8080";var D={},r=$("<span>").hide();D["Embed urls"]=r;d.append(r);e=mist.user.host;b=document.createElement("a");b.href=e;e=b.protocol+"//";b=b.hostname;var H=e+b+l+"/",y={autoplay:!0},K=function(a){var b=["div"],d='\n <script src="'+H+"embed_"+c+'.js"><\/script>\n';a.autoplay||b.push("data-noautoplay");a.forceprotocol&&a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');a.urlappend&&
|
||||
a.urlappend!=""&&b.push('data-urlappend="'+a.urlappend.replace(/\"/g,'\\"')+'"');return"<"+b.join(" ")+">"+d+"</div>"},X=$("<span>");r.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embedable script",type:"str",value:H+"embed_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:H+"info_"+c+".js",readonly:!0},{label:"Autodetect player",type:"str",value:H+c+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:K(y),rows:4,
|
||||
readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",value:!0,pointer:{main:y,index:"autoplay"},"function":function(){y.autoplay=$(this).getval();$(".embed_code").setval(K(y))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:y,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){y.forceprotocol=$(this).getval();$(".embed_code").setval(K(y))}},{label:"Video URL addition",
|
||||
type:"str",pointer:{main:y,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(){y.urlappend=$(this).getval();$(".embed_code").setval(K(y))}},$("<h3>").text("Protocol stream urls"),X]));l=$("<span>").append($("<h3>").text("Meta information")).hide();D["Meta information"]=l;var O=$("<span>");l.append(O);d.append(l);l=$("<span>").hide();D.Preview=l;d.append(l);var L=$("<div>").css({"float":"left",
|
||||
"margin-right":"1em",width:"100%"}),t=$("<div>").addClass("video_container").attr("data-forcesupportcheck","");L.html(t);var Y=$("<div>").css("float","left");l.append(L).append(Y);mist.stored.get().autoplay||t.attr("data-noautoplay","");var M=function(){t.text("Loading..");L.children(".input_container").remove();var a=document.createElement("script");a.src=H+"embed_"+c+".js";a.onerror=function(){t.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){M()}))};
|
||||
a.onload=function(){if(typeof mistvideo[c].error!="undefined")t.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){M()}));else{var a=mistvideo[c],b=UI.buildUI([{label:"Protocol stream url",type:"str",readonly:true,value:a.embedded?a.embedded.url:"",qrcode:true},{label:"Autoplay (from now on)",type:"checkbox",value:mist.stored.get().autoplay,"function":function(){mist.stored.set("autoplay",$(this).getval()?1:0)}}]);b.find(".help_container").remove();L.append(b);
|
||||
var d=$("<table>").css("font-size","0.9em").html($("<thead>").html($("<tr>").html($("<th>")).append($("<th>").text("Type")).append($("<th>").text("Priority")).append($("<th>").text("Simul. tracks")).append($("<th>").html("Your browser<br>support"))));Y.html(d);b=$("<tbody>");d.append(b);var d=$(".embed_code_forceprotocol"),e=[];d.find(".clear").remove();for(var g in a.source){var f=a.source[g],h=f.type.split("/"),i=h[0];i.length<6&&(i=i.toUpperCase());switch(h.length){case 1:break;case 2:i=UI.format.capital(h[0])+
|
||||
" v"+h[1];if(h[0]=="flash")switch(h[1]){case "7":i="Progressive ("+i+")";break;case "10":i="RTMP ("+i+")";break;case "11":i="HDS ("+i+")"}break;case 3:switch(h[2]){case "vnd.apple.mpegurl":i=i+" HLS";break;case "vnd.ms-ss":i=i+" Smooth";break;case "mp2t":i=i+" TS";break;default:h[2].length<6&&(h[2]=h[2].toUpperCase());i=i+(" "+h[2]);h[1]!="video"&&(i=i+(" ("+h[1]+")"))}break;default:i=f.type}i=UI.format.capital(i);d.append($("<option>").text(i).val(f.type).addClass("clear"));e.push({label:i,type:"str",
|
||||
value:f.url,readonly:true,qrcode:true});h=$("<tr>");b.append(h);h.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){t.attr("data-forcetype",$(this).val()).html("Loading embed..");M()}).val(f.type))).append($("<td>").text(i)).append($("<td>").text(f.priority)).append($("<td>").text(f.simul_tracks+"/"+f.total_matches)).append($("<td>").text(f.browser_support?"yes":"no"));if(a.embedded&&a.embedded.type==f.type){h.css("outline","1px solid rgba(0,0,0,0.5)");
|
||||
h.find("input[type=radio]").prop("checked",true)}}X.html(UI.buildUI(e));var j;if(c in mistvideo)j=mistvideo[c].meta;if(j){a=[];a.push({label:"Type",type:"span",value:j.live?"Live":"Pre-recorded (VoD)"});"format"in j&&a.push({label:"Format",type:"span",value:j.format});j.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(j.buffer_window,"ms")});b={vheader:"Audio",labels:["Codec","Duration","Peak bitrate","Channels","Samplerate"],content:[]};g={vheader:"Video",labels:["Codec","Duration",
|
||||
"Peak bitrate","Size","Framerate"],content:[]};d=Object.keys(j.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var l in d){e=d[l];f=j.tracks[e];switch(f.type){case "audio":b.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),
|
||||
"Hz")]});break;case "video":g.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps")]})}}j=UI.buildVheaderTable(b).css("width","auto");l=UI.buildVheaderTable(g).css("width","auto");a.push($("<span>").text("Tracks:"));
|
||||
a.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(j).append(l));O.html(UI.buildUI(a))}else O.html("No meta information available.")}};t.html("")[0].appendChild(a)};M();var P=UI.elements.secondary_menu;P.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));l=["Preview","Embed urls","Meta information"];w=l[0];for(q in l)r=$("<a>").addClass("button").text(l[q]).click(function(){P.find(".active").removeClass("active");
|
||||
$(this).addClass("active");for(q in D)D[q].hide();D[$(this).text()].show()}),P.append(r),l[q]==w&&(r.addClass("active"),D[w].show());break;case "Push":t=$("<div>").text("Loading..");d.append(t);mist.send(function(a){function b(a,c){var d=$("<span>");a.length>=4&&a[2]!=a[3]?d.append($("<span>").text(a[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(a[3])):d.append($("<span>").text(a[2]));return $("<tr>").append($("<td>").text(a[1])).append($("<td>").append(d.children())).append($("<td>").append($("<button>").text(c==
|
||||
"Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+a[1]+" to "+a[2])){var b=$(this).closest("tr");b.html($("<td colspan=99>").html($("<span>").addClass("red").text(c=="Automatic"?"Removing..":"Stopping..")));c=="Automatic"?mist.send(function(){b.remove()},{push_auto_remove:{stream:a[1],target:a[2]}}):mist.send(function(){function c(){setTimeout(function(){mist.send(function(d){var e=false;if("push_list"in d&&d.push_list&&
|
||||
d.push_list.length){var e=true,f;for(f in d.push_list)if(d.push_list[f][0]==a[0]){e=false;break}}else e=true;e?b.remove():c()},{push_list:1})},1E3)}c()},{push_stop:[a[0]]})}})))}t.html("");var c=a.push_settings;c||(c={});t.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},$("<h3>").text("Settings"),{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:c,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:c,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:c})}}]}]));var d=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),
|
||||
e=d.clone();if("push_list"in a)for(var f in a.push_list)d.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)e.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));t.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));e.find("tr").length==1?t.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):
|
||||
t.append(e);t.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));d.find("tr").length==1?t.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em")):t.append($("<button>").text("Stop all pushes").click(function(){var b=[],c;for(c in a.push_list)b.push(a.push_list[c][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){function 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(b.indexOf(c.push_list[e][0])==-1){d=false;break}}else d=true;d?UI.navto("Push"):a()},{push_list:1})},1E3)}a()},{push_stop:b});d.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append(d)},{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")},{capabilities:1});break}var u,Q=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var e=mist.data.capabilities.connectors[b];"push_urls"in e&&(a=a.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var f={};d.append(UI.buildUI([{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:f,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:["red"]}}],datalist:u,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.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>",
|
||||
pointer:{main:f,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[c=="auto"?"push_auto_add":"push_start"]=f;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
||||
mist.send(function(a){(t=a.active_streams)||(t=[]);var a=[],b;for(b in t)t[b].indexOf("+")!=-1&&a.push(t[b].replace(/\+.*/,"")+"+");t=t.concat(a);var c=0,d=0;for(b in mist.data.streams){t.push(b);if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){t.push(b+"+");mist.send(function(a,b){var e=b.stream,f;for(f in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||g.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,
|
||||
"/"+a.browse.files[f])&&t.push(e+"+"+a.browse.files[f]);d++;if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{active_streams:1}):(t=Object.keys(mist.data.streams),Q());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});h=$("<tbody>");e=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type",
|
||||
mist.send(function(a){(u=a.active_streams)||(u=[]);var a=[],b;for(b in u)u[b].indexOf("+")!=-1&&a.push(u[b].replace(/\+.*/,"")+"+");u=u.concat(a);var c=0,d=0;for(b in mist.data.streams){u.push(b);if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){u.push(b+"+");mist.send(function(a,b){var e=b.stream,f;for(f in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||g.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,
|
||||
"/"+a.browse.files[f])&&u.push(e+"+"+a.browse.files[f]);d++;if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Q()}},{active_streams:1}):(u=Object.keys(mist.data.streams),Q());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});h=$("<tbody>");e=$("<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(h);d.append(UI.buildUI([{type:"help",help:"Triggers are the system you can use 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(e);
|
||||
e.stupidtable();l=mist.data.config.triggers;for(q in l)for(r in l[q])h.append($("<tr>").attr("data-index",q+","+r).append($("<td>").text(q)).append($("<td>").text(l[q][r][2].join(", "))).append($("<td>").text(l[q][r][0])).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":"triggers"in mist.data.config||(mist.data.config.triggers={});c?(c=c.split(","),l=mist.data.config.triggers[c[0]][c[1]],o={triggeron:c[0],appliesto:l[2],url:l[0],async:l[1],"default":l[3]}):(d.html($("<h2>").text("New Trigger")),o={});d.append(UI.buildUI([{label:"Trigger on",
|
||||
|
@ -138,14 +139,14 @@ LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":fu
|
|||
{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var Z=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){R();Z.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(){R()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:Z,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})}));h=$("<tbody>").css("font-size",
|
||||
"0.9em");d.append($("<table>").append(h));var ba=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},R=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();h.html("");for(var b in a)h.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(ba(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align",
|
||||
"left")))}};R();break;case "Statistics":var B=$("<span>").text("Loading..");d.append(B);var o={},u=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},J={};for(q in mist.data.streams)J[q]=!0;for(q in mist.data.active_streams)J[mist.data.active_streams[q]]=!0;var J=Object.keys(J).sort(),S=[];for(q in mist.data.config.protocols)S.push(mist.data.config.protocols[q].connector);S.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:o,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(u).length+1)).closest("label").show()}else{var c=u[$(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")}}},{label:"Graph id",type:"str",pointer:{main:o,index:"id"},classes:["graph_id"],validate:[function(a){return a in
|
||||
u?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:o,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",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:o,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:",J],["protocol","The protocol:",S]],pointer:{main:o,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(o.graph=="new"){a=UI.plot.addGraph(o,b);u[a.id]=a;B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
|
||||
u[o.graph];var c=UI.plot.datatype.getOptions({datatype:o.datatype,origin:o.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(u)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=B.find("select.graph_ids");for(a in u){var e=UI.plot.addGraph(u[a],b);c.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in u[a].datasets){var h=UI.plot.datatype.getOptions({datatype:u[a].datasets[g].datatype,origin:u[a].datasets[g].origin});f.push(h)}e.datasets=f;u[e.id]=e}c.trigger("change");
|
||||
UI.plot.go(u);UI.interval.set(function(){UI.plot.go(u)},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..");break}var T=$("<table>"),U=$("<table>"),l={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(q in mist.data.capabilities.cpu)r=mist.data.capabilities.cpu[q],l.content.push({header:"CPU #"+(Number(q)+1),
|
||||
"left")))}};R();break;case "Statistics":var A=$("<span>").text("Loading..");d.append(A);var o={},v=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},I={};for(q in mist.data.streams)I[q]=!0;for(q in mist.data.active_streams)I[mist.data.active_streams[q]]=!0;var I=Object.keys(I).sort(),S=[];for(q in mist.data.config.protocols)S.push(mist.data.config.protocols[q].connector);S.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;A.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:o,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=A.find(".graph_xaxis"),b=A.find(".graph_id");
|
||||
if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(v).length+1)).closest("label").show()}else{var c=v[$(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")}}},{label:"Graph id",type:"str",pointer:{main:o,index:"id"},classes:["graph_id"],validate:[function(a){return a in
|
||||
v?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:o,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=A.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",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:o,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=A.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:",I],["protocol","The protocol:",S]],pointer:{main:o,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(o.graph=="new"){a=UI.plot.addGraph(o,b);v[a.id]=a;A.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
|
||||
v[o.graph];var c=UI.plot.datatype.getOptions({datatype:o.datatype,origin:o.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(v)}}]}]));var b=$("<div>").addClass("graph_container");d.append(b);var c=A.find("select.graph_ids");for(a in v){var e=UI.plot.addGraph(v[a],b);c.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in v[a].datasets){var h=UI.plot.datatype.getOptions({datatype:v[a].datasets[g].datatype,origin:v[a].datasets[g].origin});f.push(h)}e.datasets=f;v[e.id]=e}c.trigger("change");
|
||||
UI.plot.go(v);UI.interval.set(function(){UI.plot.go(v)},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..");break}var T=$("<table>"),U=$("<table>"),l={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(q in mist.data.capabilities.cpu)r=mist.data.capabilities.cpu[q],l.content.push({header:"CPU #"+(Number(q)+1),
|
||||
body:[r.model,UI.format.addUnit(UI.format.number(r.mhz),"MHz"),r.cores,r.threads]});var l=UI.buildVheaderTable(l),aa=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);T.replaceWith(a);T=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:" ",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);U.replaceWith(b);U=b};
|
||||
aa();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","auto").addClass("nolay").append($("<tr>").append($("<td>").append(T)).append($("<td>").append(U))).append($("<tr>").append($("<td>").append(l).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){aa()},{capabilities:true})},3E4);break;case "Email for Help":l=$.extend({},mist.data);
|
||||
|
@ -156,8 +157,8 @@ var mist={data:{},user:{name:"",password:"",host:location.origin+location.pathna
|
|||
error:function(b,d){delete mist.user.loggedin;if(!e.hide){switch(d){case "timeout":d=$("<i>").text("The connection timed out. ");break;case "abort":d=$("<i>").text("The connection was aborted. ");break;default:d=$("<i>").text(d+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(d).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,e)}))}UI.navto("Login")},
|
||||
success:function(b){log("Receive",$.extend(true,{},b),"as reply to",e.sendData);delete mist.user.loggedin;switch(b.authorize.status){case "OK":if("streams"in b)if(b.streams)if("incomplete list"in b.streams){delete b.streams["incomplete list"];$.extend(mist.data.streams,b.streams)}else mist.data.streams=b.streams;else mist.data.streams={};var d=$.extend({},b),f=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],p;for(p in d)f.indexOf(p)==-1&&delete d[p];$.extend(true,
|
||||
mist.data,d);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));b.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(b.log){d=b.log[b.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+
|
||||
UI.format.time(d[0])+" ["+d[1]+"] "+d[2])}if("totals"in b){d=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 i=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 p=0}else{m=m+c.interval[p][1]*1E3;c.interval[p][0]--;if(c.interval[p][0]<=0){p++;p<c.interval.length-1&&(i=i+2)}}if(i%2==1){d();i--}for(var G in c.data[f])e[c.fields[G]].push([m,
|
||||
c.data[f][G]]);if(i){d();i--}}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 b.totals)d(c.totals.streams,
|
||||
UI.format.time(d[0])+" ["+d[1]+"] "+d[2])}if("totals"in b){d=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 i=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 p=0}else{m=m+c.interval[p][1]*1E3;c.interval[p][0]--;if(c.interval[p][0]<=0){p++;p<c.interval.length-1&&(i=i+2)}}if(i%2==1){d();i--}for(var F in c.data[f])e[c.fields[F]].push([m,
|
||||
c.data[f][F]]);if(i){d();i--}}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 b.totals)d(c.totals.streams,
|
||||
c.totals.protocols,b.totals);else for(p in b.totals)d(c.totals[p].streams,c.totals[p].protocols,b.totals[p])}a&&a(b,e);break;case "CHALL":if(b.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=b.authorize.challenge;mist.send(a,c,e)}break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete c.authorize;
|
||||
mist.send(a,c,e);break;default:UI.navto("Login")}}};e.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){d.abort()}));var d=$.ajax(b)},inputMatch:function(a,c){if(typeof a=="undefined")return false;if(typeof a=="string"){var e=a.replace(/[^\w\s]/g,"\\$&"),e=e.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*"),e=RegExp("^"+e+"$","i");return e.test(c)}for(var b in a){e=a[b].replace(/[^\w\s]/g,
|
||||
"\\$&");e=e.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");e=RegExp("^"+e+"$","i");if(e.test(c))return true}return false},convertBuildOptions:function(a,c){var e=[],b=["required","optional"];"desc"in a&&e.push({type:"help",help:a.desc});for(var d in b)if(a[b[d]]){e.push($("<h4>").text(UI.format.capital(b[d])+" parameters"));for(var i in a[b[d]]){var m=a[b[d]][i],f={label:UI.format.capital(m.name),pointer:{main:c,index:i},validate:[]};b[d]=="required"&&!("default"in m)&&f.validate.push("required");
|
||||
|
|
28
lsp/mist.js
28
lsp/mist.js
|
@ -224,6 +224,7 @@ var UI = {
|
|||
}
|
||||
else if (!('submenu' in button)) {
|
||||
$button.click(function(e){
|
||||
if ($(this).closest('.menu').hasClass('hide')) { return; }
|
||||
UI.navto(j);
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
@ -1681,7 +1682,7 @@ var UI = {
|
|||
return;
|
||||
}
|
||||
|
||||
var $currbut = UI.elements.menu.css('opacity','1').find('.button').filter(function(){
|
||||
var $currbut = UI.elements.menu.removeClass('hide').find('.button').filter(function(){
|
||||
if ($(this).find('.plain').text() == tab) { return true; }
|
||||
});
|
||||
if ($currbut.length > 0) {
|
||||
|
@ -1702,7 +1703,7 @@ var UI = {
|
|||
UI.navto('Overview');
|
||||
return;
|
||||
}
|
||||
UI.elements.menu.css('opacity','0');
|
||||
UI.elements.menu.addClass('hide');
|
||||
UI.elements.connection.status.text('Disconnected').removeClass('green').addClass('red');
|
||||
$main.append(UI.buildUI([
|
||||
{
|
||||
|
@ -1748,7 +1749,7 @@ var UI = {
|
|||
]));
|
||||
break;
|
||||
case 'Create a new account':
|
||||
UI.elements.menu.css('visibility','hidden');
|
||||
UI.elements.menu.addClass('hide');
|
||||
$main.append(
|
||||
$('<p>').text('No account has been created yet in the MistServer at ').append(
|
||||
$('<i>').text(mist.user.host)
|
||||
|
@ -1824,7 +1825,7 @@ var UI = {
|
|||
}]));
|
||||
break;
|
||||
case 'Account created':
|
||||
UI.elements.menu.css('visibility','hidden');
|
||||
UI.elements.menu.addClass('hide');;
|
||||
$main.append(
|
||||
$('<p>').text('Your account has been created succesfully.')
|
||||
).append(UI.buildUI([
|
||||
|
@ -2999,22 +3000,25 @@ var UI = {
|
|||
'float': 'left',
|
||||
'margin-right': '1em',
|
||||
'width': '100%'
|
||||
}).attr('data-forcesupportcheck','');
|
||||
});
|
||||
var $c = $('<div>').addClass('video_container').attr('data-forcesupportcheck','');
|
||||
$video.html($c);
|
||||
var $protocols = $('<div>').css('float','left');
|
||||
$preview.append($video).append($protocols);
|
||||
|
||||
if (!mist.stored.get().autoplay) {
|
||||
$video.attr('data-noautoplay','');
|
||||
$c.attr('data-noautoplay','');
|
||||
}
|
||||
|
||||
function loadVideo() {
|
||||
$video.text('Loading..');
|
||||
$c.text('Loading..');
|
||||
$video.children('.input_container').remove();
|
||||
|
||||
// jQuery doesn't work -> use DOM magic
|
||||
var script = document.createElement('script');
|
||||
script.src = embedbase+'embed_'+other+'.js';
|
||||
script.onerror = function(){
|
||||
$video.html('Error loading "'+script.src+'".<br>').append(
|
||||
$c.html('Error loading "'+script.src+'".<br>').append(
|
||||
$('<button>').text('Try again').click(function(){
|
||||
loadVideo();
|
||||
})
|
||||
|
@ -3022,7 +3026,7 @@ var UI = {
|
|||
};
|
||||
script.onload = function(){
|
||||
if (typeof mistvideo[other].error != 'undefined') {
|
||||
$video.html(mistvideo[other].error+'<br>').append(
|
||||
$c.html(mistvideo[other].error+'<br>').append(
|
||||
$('<button>').text('Try again').click(function(){
|
||||
loadVideo();
|
||||
})
|
||||
|
@ -3139,7 +3143,7 @@ var UI = {
|
|||
$tr.html(
|
||||
$('<td>').html(
|
||||
$('<input>').attr('type','radio').attr('name','protocolforce').change(function(){
|
||||
$video.attr('data-forcetype',$(this).val()).html('Loading embed..');
|
||||
$c.attr('data-forcetype',$(this).val()).html('Loading embed..');
|
||||
loadVideo();
|
||||
}).val(source.type)
|
||||
)
|
||||
|
@ -3164,9 +3168,7 @@ var UI = {
|
|||
//meta information
|
||||
buildTrackinfo();
|
||||
};
|
||||
var $c = $('<div>').addClass('video_container')
|
||||
$video.html($c);
|
||||
$c[0].appendChild(script);
|
||||
$c.html('')[0].appendChild(script);
|
||||
}
|
||||
loadVideo();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue