LSP: bugfix: input type debug appears to have disappeared from convertBuildOptions
This commit is contained in:
parent
eee3595d46
commit
c1885a7a54
2 changed files with 157 additions and 151 deletions
302
lsp/minified.js
302
lsp/minified.js
|
@ -1,11 +1,11 @@
|
|||
var MD5=function(a){function b(a,b){var c,d,g,h,f;g=a&2147483648;h=b&2147483648;c=a&1073741824;d=b&1073741824;f=(a&1073741823)+(b&1073741823);return c&d?f^2147483648^g^h:c|d?f&1073741824?f^3221225472^g^h:f^1073741824^g^h:f^g^h}function c(a,c,d,g,h,f,e){a=b(a,b(b(c&d|~c&g,h),e));return b(a<<f|a>>>32-f,c)}function d(a,c,d,g,h,f,e){a=b(a,b(b(c&g|d&~g,h),e));return b(a<<f|a>>>32-f,c)}function f(a,c,d,g,h,f,e){a=b(a,b(b(c^d^g,h),e));return b(a<<f|a>>>32-f,c)}function i(a,c,d,g,h,f,e){a=b(a,b(b(d^(c|~g),
|
||||
h),e));return b(a<<f|a>>>32-f,c)}function m(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var e=[],t,o,l,x,j,g,h,k,e=a.replace(/\r\n/g,"\n"),a="";for(t=0;t<e.length;t++)o=e.charCodeAt(t),128>o?a+=String.fromCharCode(o):(127<o&&2048>o?a+=String.fromCharCode(o>>6|192):(a+=String.fromCharCode(o>>12|224),a+=String.fromCharCode(o>>6&63|128)),a+=String.fromCharCode(o&63|128));e=a;a=e.length;t=a+8;o=16*((t-t%64)/64+1);l=Array(o-1);for(j=x=0;j<a;)t=
|
||||
(j-j%4)/4,x=8*(j%4),l[t]|=e.charCodeAt(j)<<x,j++;t=(j-j%4)/4;l[t]|=128<<8*(j%4);l[o-2]=a<<3;l[o-1]=a>>>29;e=l;j=1732584193;g=4023233417;h=2562383102;k=271733878;for(a=0;a<e.length;a+=16)t=j,o=g,l=h,x=k,j=c(j,g,h,k,e[a+0],7,3614090360),k=c(k,j,g,h,e[a+1],12,3905402710),h=c(h,k,j,g,e[a+2],17,606105819),g=c(g,h,k,j,e[a+3],22,3250441966),j=c(j,g,h,k,e[a+4],7,4118548399),k=c(k,j,g,h,e[a+5],12,1200080426),h=c(h,k,j,g,e[a+6],17,2821735955),g=c(g,h,k,j,e[a+7],22,4249261313),j=c(j,g,h,k,e[a+8],7,1770035416),
|
||||
k=c(k,j,g,h,e[a+9],12,2336552879),h=c(h,k,j,g,e[a+10],17,4294925233),g=c(g,h,k,j,e[a+11],22,2304563134),j=c(j,g,h,k,e[a+12],7,1804603682),k=c(k,j,g,h,e[a+13],12,4254626195),h=c(h,k,j,g,e[a+14],17,2792965006),g=c(g,h,k,j,e[a+15],22,1236535329),j=d(j,g,h,k,e[a+1],5,4129170786),k=d(k,j,g,h,e[a+6],9,3225465664),h=d(h,k,j,g,e[a+11],14,643717713),g=d(g,h,k,j,e[a+0],20,3921069994),j=d(j,g,h,k,e[a+5],5,3593408605),k=d(k,j,g,h,e[a+10],9,38016083),h=d(h,k,j,g,e[a+15],14,3634488961),g=d(g,h,k,j,e[a+4],20,3889429448),
|
||||
j=d(j,g,h,k,e[a+9],5,568446438),k=d(k,j,g,h,e[a+14],9,3275163606),h=d(h,k,j,g,e[a+3],14,4107603335),g=d(g,h,k,j,e[a+8],20,1163531501),j=d(j,g,h,k,e[a+13],5,2850285829),k=d(k,j,g,h,e[a+2],9,4243563512),h=d(h,k,j,g,e[a+7],14,1735328473),g=d(g,h,k,j,e[a+12],20,2368359562),j=f(j,g,h,k,e[a+5],4,4294588738),k=f(k,j,g,h,e[a+8],11,2272392833),h=f(h,k,j,g,e[a+11],16,1839030562),g=f(g,h,k,j,e[a+14],23,4259657740),j=f(j,g,h,k,e[a+1],4,2763975236),k=f(k,j,g,h,e[a+4],11,1272893353),h=f(h,k,j,g,e[a+7],16,4139469664),
|
||||
g=f(g,h,k,j,e[a+10],23,3200236656),j=f(j,g,h,k,e[a+13],4,681279174),k=f(k,j,g,h,e[a+0],11,3936430074),h=f(h,k,j,g,e[a+3],16,3572445317),g=f(g,h,k,j,e[a+6],23,76029189),j=f(j,g,h,k,e[a+9],4,3654602809),k=f(k,j,g,h,e[a+12],11,3873151461),h=f(h,k,j,g,e[a+15],16,530742520),g=f(g,h,k,j,e[a+2],23,3299628645),j=i(j,g,h,k,e[a+0],6,4096336452),k=i(k,j,g,h,e[a+7],10,1126891415),h=i(h,k,j,g,e[a+14],15,2878612391),g=i(g,h,k,j,e[a+5],21,4237533241),j=i(j,g,h,k,e[a+12],6,1700485571),k=i(k,j,g,h,e[a+3],10,2399980690),
|
||||
h=i(h,k,j,g,e[a+10],15,4293915773),g=i(g,h,k,j,e[a+1],21,2240044497),j=i(j,g,h,k,e[a+8],6,1873313359),k=i(k,j,g,h,e[a+15],10,4264355552),h=i(h,k,j,g,e[a+6],15,2734768916),g=i(g,h,k,j,e[a+13],21,1309151649),j=i(j,g,h,k,e[a+4],6,4149444226),k=i(k,j,g,h,e[a+11],10,3174756917),h=i(h,k,j,g,e[a+2],15,718787259),g=i(g,h,k,j,e[a+9],21,3951481745),j=b(j,t),g=b(g,o),h=b(h,l),k=b(k,x);return(m(j)+m(g)+m(h)+m(k)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function b(b){var c=0,d;a(b).children("td,th").each(function(){if(c==t)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
|
||||
parseInt(Number(b));break;case "float":b=Number(b)}return b}var c=a(this),d=c.closest("table"),f=d.children("tbody"),i=f.children("tr"),m=c.attr("data-sort-type");if(m){var e=!0;c.hasClass("sorting-asc")&&(e=!1);var t=0;c.prevAll().each(function(){var b=a(this).attr("colspan");t+=b?Number(b):1});i.sort(function(a,c){var d=e?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});f.append(i);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(e?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(b){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host=
|
||||
var MD5=function(a){function b(a,b){var c,d,g,f,e;g=a&2147483648;f=b&2147483648;c=a&1073741824;d=b&1073741824;e=(a&1073741823)+(b&1073741823);return c&d?e^2147483648^g^f:c|d?e&1073741824?e^3221225472^g^f:e^1073741824^g^f:e^g^f}function c(a,c,d,g,f,e,h){a=b(a,b(b(c&d|~c&g,f),h));return b(a<<e|a>>>32-e,c)}function d(a,c,d,g,f,e,h){a=b(a,b(b(c&g|d&~g,f),h));return b(a<<e|a>>>32-e,c)}function e(a,c,d,g,f,e,h){a=b(a,b(b(c^d^g,f),h));return b(a<<e|a>>>32-e,c)}function j(a,c,d,g,f,e,h){a=b(a,b(b(d^(c|~g),
|
||||
f),h));return b(a<<e|a>>>32-e,c)}function m(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var h=[],t,o,l,x,i,g,f,k,h=a.replace(/\r\n/g,"\n"),a="";for(t=0;t<h.length;t++)o=h.charCodeAt(t),128>o?a+=String.fromCharCode(o):(127<o&&2048>o?a+=String.fromCharCode(o>>6|192):(a+=String.fromCharCode(o>>12|224),a+=String.fromCharCode(o>>6&63|128)),a+=String.fromCharCode(o&63|128));h=a;a=h.length;t=a+8;o=16*((t-t%64)/64+1);l=Array(o-1);for(i=x=0;i<a;)t=
|
||||
(i-i%4)/4,x=8*(i%4),l[t]|=h.charCodeAt(i)<<x,i++;t=(i-i%4)/4;l[t]|=128<<8*(i%4);l[o-2]=a<<3;l[o-1]=a>>>29;h=l;i=1732584193;g=4023233417;f=2562383102;k=271733878;for(a=0;a<h.length;a+=16)t=i,o=g,l=f,x=k,i=c(i,g,f,k,h[a+0],7,3614090360),k=c(k,i,g,f,h[a+1],12,3905402710),f=c(f,k,i,g,h[a+2],17,606105819),g=c(g,f,k,i,h[a+3],22,3250441966),i=c(i,g,f,k,h[a+4],7,4118548399),k=c(k,i,g,f,h[a+5],12,1200080426),f=c(f,k,i,g,h[a+6],17,2821735955),g=c(g,f,k,i,h[a+7],22,4249261313),i=c(i,g,f,k,h[a+8],7,1770035416),
|
||||
k=c(k,i,g,f,h[a+9],12,2336552879),f=c(f,k,i,g,h[a+10],17,4294925233),g=c(g,f,k,i,h[a+11],22,2304563134),i=c(i,g,f,k,h[a+12],7,1804603682),k=c(k,i,g,f,h[a+13],12,4254626195),f=c(f,k,i,g,h[a+14],17,2792965006),g=c(g,f,k,i,h[a+15],22,1236535329),i=d(i,g,f,k,h[a+1],5,4129170786),k=d(k,i,g,f,h[a+6],9,3225465664),f=d(f,k,i,g,h[a+11],14,643717713),g=d(g,f,k,i,h[a+0],20,3921069994),i=d(i,g,f,k,h[a+5],5,3593408605),k=d(k,i,g,f,h[a+10],9,38016083),f=d(f,k,i,g,h[a+15],14,3634488961),g=d(g,f,k,i,h[a+4],20,3889429448),
|
||||
i=d(i,g,f,k,h[a+9],5,568446438),k=d(k,i,g,f,h[a+14],9,3275163606),f=d(f,k,i,g,h[a+3],14,4107603335),g=d(g,f,k,i,h[a+8],20,1163531501),i=d(i,g,f,k,h[a+13],5,2850285829),k=d(k,i,g,f,h[a+2],9,4243563512),f=d(f,k,i,g,h[a+7],14,1735328473),g=d(g,f,k,i,h[a+12],20,2368359562),i=e(i,g,f,k,h[a+5],4,4294588738),k=e(k,i,g,f,h[a+8],11,2272392833),f=e(f,k,i,g,h[a+11],16,1839030562),g=e(g,f,k,i,h[a+14],23,4259657740),i=e(i,g,f,k,h[a+1],4,2763975236),k=e(k,i,g,f,h[a+4],11,1272893353),f=e(f,k,i,g,h[a+7],16,4139469664),
|
||||
g=e(g,f,k,i,h[a+10],23,3200236656),i=e(i,g,f,k,h[a+13],4,681279174),k=e(k,i,g,f,h[a+0],11,3936430074),f=e(f,k,i,g,h[a+3],16,3572445317),g=e(g,f,k,i,h[a+6],23,76029189),i=e(i,g,f,k,h[a+9],4,3654602809),k=e(k,i,g,f,h[a+12],11,3873151461),f=e(f,k,i,g,h[a+15],16,530742520),g=e(g,f,k,i,h[a+2],23,3299628645),i=j(i,g,f,k,h[a+0],6,4096336452),k=j(k,i,g,f,h[a+7],10,1126891415),f=j(f,k,i,g,h[a+14],15,2878612391),g=j(g,f,k,i,h[a+5],21,4237533241),i=j(i,g,f,k,h[a+12],6,1700485571),k=j(k,i,g,f,h[a+3],10,2399980690),
|
||||
f=j(f,k,i,g,h[a+10],15,4293915773),g=j(g,f,k,i,h[a+1],21,2240044497),i=j(i,g,f,k,h[a+8],6,1873313359),k=j(k,i,g,f,h[a+15],10,4264355552),f=j(f,k,i,g,h[a+6],15,2734768916),g=j(g,f,k,i,h[a+13],21,1309151649),i=j(i,g,f,k,h[a+4],6,4149444226),k=j(k,i,g,f,h[a+11],10,3174756917),f=j(f,k,i,g,h[a+2],15,718787259),g=j(g,f,k,i,h[a+9],21,3951481745),i=b(i,t),g=b(g,o),f=b(f,l),k=b(k,x);return(m(i)+m(g)+m(f)+m(k)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function b(b){var c=0,d;a(b).children("td,th").each(function(){if(c==t)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
|
||||
parseInt(Number(b));break;case "float":b=Number(b)}return b}var c=a(this),d=c.closest("table"),e=d.children("tbody"),j=e.children("tr"),m=c.attr("data-sort-type");if(m){var h=!0;c.hasClass("sorting-asc")&&(h=!1);var t=0;c.prevAll().each(function(){var b=a(this).attr("colspan");t+=b?Number(b):1});j.sort(function(a,c){var d=h?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});e.append(j);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(h?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(b){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host=
|
||||
a[1]));mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0});var c=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=c&&UI.elements.header.css("margin-right",-1*a+"px");c=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])});
|
||||
var MistVideoObject={},otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,b){this.vars[a]=b;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,b){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");
|
||||
this.opts={delay:b,callback:a};this.opts.id=setInterval(a,b)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",
|
||||
|
@ -21,61 +21,61 @@ clearTimeout(this.hiding);delete this.hiding;var c=$(document).height()-$tooltip
|
|||
"HLS (TS)";break;case "html5/application/vnd.apple.mpegurl;version=7":b="HLS (CMAF)";break;case "html5/video/webm":b="WebM";break;case "html5/video/mp4":b="MP4";break;case "dash/video/mp4":b="DASH";break;case "flash/11":b="HDS";break;case "flash/10":b="RTMP";break;case "flash/7":b="Progressive";break;case "html5/audio/mp3":b="MP3";break;case "html5/audio/wav":b="WAV";break;case "html5/video/mp2t":case "html5/video/mpeg":b="TS";break;case "html5/application/vnd.ms-sstr+xml":case "html5/application/vnd.ms-ss":b=
|
||||
"Smooth Streaming";break;case "html5/text/vtt":b="VTT Subtitles";break;case "html5/text/plain":b="SRT Subtitles";break;case "html5/text/javascript":b="JSON Subtitles";break;case "rtsp":b="RTSP";break;case "webrtc":b="WebRTC"}return b},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:{},General:{hiddenmenu:{"Edit variable":{},"Edit external writer":{}}},Protocols:{},Streams:{hiddenmenu:{Edit:{},Preview:{},Embed:{}}},Push:{},Triggers:{},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":{}}}}],buildMenu:function(){function a(a,b){var c=
|
||||
$("<a>").addClass("button");c.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in b.classes)c.addClass(b.classes[d]);"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),b.stopPropagation())});return c}var b=UI.elements.menu,c;for(c in UI.menu){0<c&&b.append($("<br>"));for(var d in UI.menu[c]){var f=UI.menu[c][d],i=a(d,f);b.append(i);if("submenu"in
|
||||
f){var m=$("<span>").addClass("submenu");i.addClass("arrowdown").append(m);for(var e in f.submenu)m.append(a(e,f.submenu[e]))}else if("hiddenmenu"in f)for(e in m=$("<span>").addClass("hiddenmenu"),i.append(m),f.hiddenmenu)m.append(a(e,f.hiddenmenu[e]))}}c=$("<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");
|
||||
$("<a>").addClass("button");c.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in b.classes)c.addClass(b.classes[d]);"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),b.stopPropagation())});return c}var b=UI.elements.menu,c;for(c in UI.menu){0<c&&b.append($("<br>"));for(var d in UI.menu[c]){var e=UI.menu[c][d],j=a(d,e);b.append(j);if("submenu"in
|
||||
e){var m=$("<span>").addClass("submenu");j.addClass("arrowdown").append(m);for(var h in e.submenu)m.append(a(h,e.submenu[h]))}else if("hiddenmenu"in e)for(h in m=$("<span>").addClass("hiddenmenu"),j.append(m),e.hiddenmenu)m.append(a(h,e.hiddenmenu[h]))}}c=$("<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");
|
||||
b.after(c).after($("<div>").addClass("separator"))},findInput:function(a){return this.findInOutput("inputs",a)},findOutput:function(a){return this.findInOutput("connectors",a)},findInOutput:function(a,b){if("capabilities"in mist.data){var c=!1,d=mist.data.capabilities[a];b in d&&(c=d[b]);b+".exe"in d&&(c=d[b+".exe"]);return c}throw"Request capabilities first";},buildUI:function(a){var b=$("<div>").addClass("input_container"),c;for(c in a){var d=a[c];if(d instanceof jQuery)b.append(d);else if("help"==
|
||||
d.type){var f=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));b.append(f);if("classes"in d)for(var i in d.classes)f.addClass(d.classes[i])}else if("text"==d.type)b.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)b.append(d.custom);else if("buttons"==d.type)for(i in f=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in d&&f.css(d.css),
|
||||
b.append(f),d.buttons){var m=d.buttons[i],e=$("<button>").text(m.label).data("opts",m);"css"in m&&e.css(m.css);if("classes"in m)for(var t in m.classes)e.addClass(m.classes[t]);f.append(e);switch(m.type){case "cancel":e.addClass("cancel").click(m["function"]);break;case "save":e.addClass("save").click(function(){var a=$(this).data("opts").preSave;a&&a.call(this);var b=$(this).closest(".input_container"),c=!1;b.find('.hasValidate:visible, input[type="hidden"].hasValidate').each(function(){if(c=$(this).data("validate")(this,
|
||||
!0))return!1});(a=$(this).data("opts").failedValidate)&&a.call(this);c||(b.find('.isSetting:visible, input[type="hidden"].isSetting').each(function(){var a=$(this).getval(),b=$(this).data("pointer");if(""===a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return b.main[b.index]=null,!0;b.main[b.index]=a;(a=$(this).data("opts").postSave)&&a.call(this)}),(a=$(this).data("opts")["function"])&&a(this))});break;default:e.click(m["function"])}}else{m=$("<label>").addClass("UIelement");
|
||||
b.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html("label"in d?d.label+":":""));if("classes"in d)for(t in d.classes)m.addClass(d.classes[t]);e=$("<span>").addClass("field_container");m.append(e);switch(d.type){case "password":f=$("<input>").attr("type","password");break;case "int":f=$("<input>").attr("type","number");"min"in d&&f.attr("min",d.min);"max"in d&&f.attr("max",d.max);"step"in d&&f.attr("step",d.step);"validate"in d?d.validate.push("int"):d.validate=["int"];
|
||||
break;case "span":f=$("<span>");break;case "debug":d.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":f=$("<select>");for(i in d.select){var o=$("<option>");"string"==typeof d.select[i]?o.text(d.select[i]):o.val(d.select[i][0]).text(d.select[i][1]);f.append(o)}break;case "textarea":f=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":f=$("<input>").attr("type","checkbox");break;case "hidden":f=$("<input>").attr("type","hidden");
|
||||
m.hide();break;case "email":f=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":f=$("<input>").attr("type","text");"filetypes"in d&&f.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":f=$("<input>").attr("type","hidden");break;case "radioselect":f=$("<div>").addClass("radioselect");for(c in d.radioselect){var l=$("<input>").attr("type","radio").val(d.radioselect[c][0]).attr("name",d.label);d.readonly&&l.prop("disabled",!0);o=
|
||||
$("<label>").append(l).append($("<span>").html(d.radioselect[c][1]));f.append(o);if(2<d.radioselect[c].length)for(i in l=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),o.append(l),d.readonly&&l.prop("disabled",!0),d.radioselect[c][2])o=$("<option>"),l.append(o),d.radioselect[c][2][i]instanceof Array?o.val(d.radioselect[c][2][i][0]).html(d.radioselect[c][2][i][1]):o.html(d.radioselect[c][2][i])}break;case "checklist":f=$("<div>").addClass("checkcontainer");
|
||||
$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");f.append($checklist);for(c in d.checklist)"string"==typeof d.checklist[c]&&(d.checklist[c]=[d.checklist[c],d.checklist[c]]),$checklist.append($("<label>").text(d.checklist[c][1]).prepend($("<input>").attr("type","checkbox").attr("name",d.checklist[c][0])));break;case "DOMfield":f=d.DOMfield;break;case "unix":f=$("<input>").attr("type","datetime-local").attr("step",1);d.unit=$("<button>").text("Now").click(function(){$(this).closest(".field_container").find(".field").setval((new Date).getTime()/
|
||||
1E3)});break;case "selectinput":f=$("<div>").addClass("selectinput");l=$("<select>");f.append(l);l.data("input",!1);for(c in d.selectinput)o=$("<option>"),l.append(o),"string"==typeof d.selectinput[c]?o.text(d.selectinput[c]):(o.text(d.selectinput[c][1]),"string"==typeof d.selectinput[c][0]?o.val(d.selectinput[c][0]):(o.val("CUSTOM"),l.data("input")||l.data("input",UI.buildUI([d.selectinput[c][0]]).children())));l.data("input")&&f.append(l.data("input"));l.change(function(){"CUSTOM"==$(this).val()?
|
||||
$(this).data("input").css("display","flex"):$(this).data("input").hide()});l.trigger("change");break;case "inputlist":f=$("<div>").addClass("inputlist");f.data("newitem",function(){var a;if("input"in d)a=UI.buildUI([d.input]).find(".field_container");else{var b=Object.assign({},d);delete b.validate;delete b.pointer;b.type="str";a=UI.buildUI([b]).find(".field_container")}a.removeClass("isSetting");a.addClass("listitem");var c=function(b){$(this).is(":last-child")?""!=$(this).find(".field").getval()?
|
||||
(b=a.clone().keyup(c),b.find(".field").setval(""),$(this).after(b)):8==b.which&&$(this).prev().find(".field").focus():""==$(this).find(".field").getval()&&(b=$(this).prev(),b.length||(b=$(this).next()),b.find(".field").focus(),$(this).remove())};a.keyup(c);return a});f.append(f.data("newitem"));break;case "sublist":f=$("<div>").addClass("sublist");l=$("<div>").addClass("curvals");l.append($("<span>").text("None."));var x=$("<div>").addClass("itemsettings"),j=$("<button>").text("New "+d.itemLabel),
|
||||
g=d.sublist,h=d,k=f,q=m;f.data("build",function(a,b){for(var c in h.saveas)c in a||delete h.saveas[c];h.saveas=Object.assign(h.saveas,a);c="New";"undefined"!=typeof b&&(c="Edit");c=UI.buildUI([$("<h4>").text(c+" "+h.itemLabel)].concat(g).concat([{label:"Save first",type:"str",classes:["onlyshowhelp"],validate:[function(){return{msg:"Did you want to save this "+h.itemLabel+"?",classes:["red"]}}]},{type:"buttons",buttons:[{label:"Cancel",type:"cancel","function":function(){x.html("");j.show();q.show()}},
|
||||
{label:"Save "+h.itemLabel,type:"save",preSave:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").hide()},failedValidate:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").show()},"function":function(){var a=k.getval(),c=Object.assign({},h.saveas),d;for(d in c)null===c[d]&&delete c[d];"undefined"==typeof b?a.push(c):a[b]=c;k.setval(a);x.html("");j.show();q.show()}}]}]));x.html(c);j.hide();q.hide()});var G=f;j.click(function(){G.data("build")({})});
|
||||
g.unshift({type:"str",label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+d.itemLabel+". It won't be used by MistServer.",pointer:{main:d.saveas,index:"x-LSP-name"}});f.data("savelist",[]);f.append(l).append(j);b.append(x);break;case "json":f=$("<textarea>").on("keydown",function(a){a.stopPropagation()}).on("keyup change",function(){this.style.height="";this.style.height=(this.scrollHeight?this.scrollHeight+20:14*this.value.split("\n").length+20)+"px"}).css("min-height",
|
||||
"3em");l=function(a,b){if(""!=$(b).val()&&null===a)return{msg:"Invalid json",classes:["red"]}};"validate"in d?d.validate.push(l):d.validate=[l];break;case "bitmask":f=$("<div>").addClass("bitmask");for(c in d.bitmask)f.append($("<label>").append($("<input>").attr("type","checkbox").attr("name","bitmask_"+("pointer"in d?d.pointer.index:"")).attr("value",d.bitmask[c][0]).addClass("field")).append($("<span>").text(d.bitmask[c][1])));m.attr("for","none");break;default:f=$("<input>").attr("type","text"),
|
||||
"maxlength"in d&&f.attr("maxlength",d.maxlength),"minlength"in d&&f.attr("minlength",d.minlength)}f.addClass("field").data("opts",d);"pointer"in d&&f.attr("name",d.pointer.index);e.append(f);if("classes"in d)for(i in d.classes)f.addClass(d.classes[i]);"placeholder"in d&&f.attr("placeholder",d.placeholder);"default"in d&&f.attr("placeholder",d["default"]);"unit"in d&&e.append($("<span>").addClass("unit").html(d.unit));"prefix"in d&&e.prepend($("<span>").addClass("unit").html(d.prefix));"readonly"in
|
||||
d&&(f.attr("readonly","readonly"),f.click(function(){$(this).select()}));"qrcode"in d&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in d&&document.queryCommandSupported("copy")&&
|
||||
e.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(b);
|
||||
alert("Failed to copy:\n"+a)}})));"rows"in d&&f.attr("rows",d.rows);if("dependent"in d)for(c in d.dependent)m.attr("data-dependent-"+c,d.dependent[c]);switch(d.type){case "browse":l=$("<div>").addClass("grouper").append(m);b.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});e.append(l);l.click(function(){function a(b){e.text("Loading..");mist.send(function(a){h.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");e.html(j.clone(true).text("..").attr("title",
|
||||
"Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var f=a.browse.subdirectories[b];e.append(j.clone(true).attr("title",h.text()+m+f).text(f))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var f=a.browse.files[b],l=h.text()+m+f,f=$("<a>").text(f).addClass("file").attr("title",l);e.append(f);if(k){var i=true,q;for(q in k)if(typeof k[q]!="undefined"&&mist.inputMatch(k[q],l)){i=false;break}i&&f.hide()}f.click(function(){var a=
|
||||
$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),f=$("<button>").text("Stop browsing").click(function(){g.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),h=$("<span>").addClass("field"),e=$("<div>").addClass("browse_contents"),j=$("<a>").addClass("folder"),k=d.data("filetypes");
|
||||
b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(h).append(f))).append(e);var m="/";mist.data.config.version.indexOf("indows")>-1&&(m="\\");j.click(function(){var b=h.text()+m+$(this).text();a(b)});b=d.getval();f=b.split("://");f.length>1&&(b=f[0]=="file"?f[1]:"");b=b.split(m);b.pop();b=b.join(m);g.hide();a(b)});break;case "geolimited":case "hostlimited":l={field:f};l.blackwhite=
|
||||
d.type){var e=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));b.append(e);if("classes"in d)for(var j in d.classes)e.addClass(d.classes[j])}else if("text"==d.type)b.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)b.append(d.custom);else if("buttons"==d.type)for(j in e=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in d&&e.css(d.css),
|
||||
b.append(e),d.buttons){var m=d.buttons[j],h=$("<button>").text(m.label).data("opts",m);"css"in m&&h.css(m.css);if("classes"in m)for(var t in m.classes)h.addClass(m.classes[t]);e.append(h);switch(m.type){case "cancel":h.addClass("cancel").click(m["function"]);break;case "save":h.addClass("save").click(function(){var a=$(this).data("opts").preSave;a&&a.call(this);var b=$(this).closest(".input_container"),c=!1;b.find('.hasValidate:visible, input[type="hidden"].hasValidate').each(function(){if(c=$(this).data("validate")(this,
|
||||
!0))return!1});(a=$(this).data("opts").failedValidate)&&a.call(this);c||(b.find('.isSetting:visible, input[type="hidden"].isSetting').each(function(){var a=$(this).getval(),b=$(this).data("pointer");if(""===a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return b.main[b.index]=null,!0;b.main[b.index]=a;(a=$(this).data("opts").postSave)&&a.call(this)}),(a=$(this).data("opts")["function"])&&a(this))});break;default:h.click(m["function"])}}else{m=$("<label>").addClass("UIelement");
|
||||
b.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html("label"in d?d.label+":":""));if("classes"in d)for(t in d.classes)m.addClass(d.classes[t]);h=$("<span>").addClass("field_container");m.append(h);switch(d.type){case "password":e=$("<input>").attr("type","password");break;case "int":e=$("<input>").attr("type","number");"min"in d&&e.attr("min",d.min);"max"in d&&e.attr("max",d.max);"step"in d&&e.attr("step",d.step);"validate"in d?d.validate.push("int"):d.validate=["int"];
|
||||
break;case "span":e=$("<span>");break;case "debug":d.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":e=$("<select>");for(j in d.select){var o=$("<option>");"string"==typeof d.select[j]?o.text(d.select[j]):o.val(d.select[j][0]).text(d.select[j][1]);e.append(o)}break;case "textarea":e=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":e=$("<input>").attr("type","checkbox");break;case "hidden":e=$("<input>").attr("type","hidden");
|
||||
m.hide();break;case "email":e=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":e=$("<input>").attr("type","text");"filetypes"in d&&e.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":e=$("<input>").attr("type","hidden");break;case "radioselect":e=$("<div>").addClass("radioselect");for(c in d.radioselect){var l=$("<input>").attr("type","radio").val(d.radioselect[c][0]).attr("name",d.label);d.readonly&&l.prop("disabled",!0);o=
|
||||
$("<label>").append(l).append($("<span>").html(d.radioselect[c][1]));e.append(o);if(2<d.radioselect[c].length)for(j in l=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),o.append(l),d.readonly&&l.prop("disabled",!0),d.radioselect[c][2])o=$("<option>"),l.append(o),d.radioselect[c][2][j]instanceof Array?o.val(d.radioselect[c][2][j][0]).html(d.radioselect[c][2][j][1]):o.html(d.radioselect[c][2][j])}break;case "checklist":e=$("<div>").addClass("checkcontainer");
|
||||
$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");e.append($checklist);for(c in d.checklist)"string"==typeof d.checklist[c]&&(d.checklist[c]=[d.checklist[c],d.checklist[c]]),$checklist.append($("<label>").text(d.checklist[c][1]).prepend($("<input>").attr("type","checkbox").attr("name",d.checklist[c][0])));break;case "DOMfield":e=d.DOMfield;break;case "unix":e=$("<input>").attr("type","datetime-local").attr("step",1);d.unit=$("<button>").text("Now").click(function(){$(this).closest(".field_container").find(".field").setval((new Date).getTime()/
|
||||
1E3)});break;case "selectinput":e=$("<div>").addClass("selectinput");l=$("<select>");e.append(l);l.data("input",!1);for(c in d.selectinput)o=$("<option>"),l.append(o),"string"==typeof d.selectinput[c]?o.text(d.selectinput[c]):(o.text(d.selectinput[c][1]),"string"==typeof d.selectinput[c][0]?o.val(d.selectinput[c][0]):(o.val("CUSTOM"),l.data("input")||l.data("input",UI.buildUI([d.selectinput[c][0]]).children())));l.data("input")&&e.append(l.data("input"));l.change(function(){"CUSTOM"==$(this).val()?
|
||||
$(this).data("input").css("display","flex"):$(this).data("input").hide()});l.trigger("change");break;case "inputlist":e=$("<div>").addClass("inputlist");e.data("newitem",function(){var a;if("input"in d)a=UI.buildUI([d.input]).find(".field_container");else{var b=Object.assign({},d);delete b.validate;delete b.pointer;b.type="str";a=UI.buildUI([b]).find(".field_container")}a.removeClass("isSetting");a.addClass("listitem");var c=function(b){$(this).is(":last-child")?""!=$(this).find(".field").getval()?
|
||||
(b=a.clone().keyup(c),b.find(".field").setval(""),$(this).after(b)):8==b.which&&$(this).prev().find(".field").focus():""==$(this).find(".field").getval()&&(b=$(this).prev(),b.length||(b=$(this).next()),b.find(".field").focus(),$(this).remove())};a.keyup(c);return a});e.append(e.data("newitem"));break;case "sublist":e=$("<div>").addClass("sublist");l=$("<div>").addClass("curvals");l.append($("<span>").text("None."));var x=$("<div>").addClass("itemsettings"),i=$("<button>").text("New "+d.itemLabel),
|
||||
g=d.sublist,f=d,k=e,q=m;e.data("build",function(a,b){for(var c in f.saveas)c in a||delete f.saveas[c];f.saveas=Object.assign(f.saveas,a);c="New";"undefined"!=typeof b&&(c="Edit");c=UI.buildUI([$("<h4>").text(c+" "+f.itemLabel)].concat(g).concat([{label:"Save first",type:"str",classes:["onlyshowhelp"],validate:[function(){return{msg:"Did you want to save this "+f.itemLabel+"?",classes:["red"]}}]},{type:"buttons",buttons:[{label:"Cancel",type:"cancel","function":function(){x.html("");i.show();q.show()}},
|
||||
{label:"Save "+f.itemLabel,type:"save",preSave:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").hide()},failedValidate:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").show()},"function":function(){var a=k.getval(),c=Object.assign({},f.saveas),d;for(d in c)null===c[d]&&delete c[d];"undefined"==typeof b?a.push(c):a[b]=c;k.setval(a);x.html("");i.show();q.show()}}]}]));x.html(c);i.hide();q.hide()});var G=e;i.click(function(){G.data("build")({})});
|
||||
g.unshift({type:"str",label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+d.itemLabel+". It won't be used by MistServer.",pointer:{main:d.saveas,index:"x-LSP-name"}});e.data("savelist",[]);e.append(l).append(i);b.append(x);break;case "json":e=$("<textarea>").on("keydown",function(a){a.stopPropagation()}).on("keyup change",function(){this.style.height="";this.style.height=(this.scrollHeight?this.scrollHeight+20:14*this.value.split("\n").length+20)+"px"}).css("min-height",
|
||||
"3em");l=function(a,b){if(""!=$(b).val()&&null===a)return{msg:"Invalid json",classes:["red"]}};"validate"in d?d.validate.push(l):d.validate=[l];break;case "bitmask":e=$("<div>").addClass("bitmask");for(c in d.bitmask)e.append($("<label>").append($("<input>").attr("type","checkbox").attr("name","bitmask_"+("pointer"in d?d.pointer.index:"")).attr("value",d.bitmask[c][0]).addClass("field")).append($("<span>").text(d.bitmask[c][1])));m.attr("for","none");break;default:e=$("<input>").attr("type","text"),
|
||||
"maxlength"in d&&e.attr("maxlength",d.maxlength),"minlength"in d&&e.attr("minlength",d.minlength)}e.addClass("field").data("opts",d);"pointer"in d&&e.attr("name",d.pointer.index);h.append(e);if("classes"in d)for(j in d.classes)e.addClass(d.classes[j]);"placeholder"in d&&e.attr("placeholder",d.placeholder);"default"in d&&e.attr("placeholder",d["default"]);"unit"in d&&h.append($("<span>").addClass("unit").html(d.unit));"prefix"in d&&h.prepend($("<span>").addClass("unit").html(d.prefix));"readonly"in
|
||||
d&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in d&&h.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in d&&document.queryCommandSupported("copy")&&
|
||||
h.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(b);
|
||||
alert("Failed to copy:\n"+a)}})));"rows"in d&&e.attr("rows",d.rows);if("dependent"in d)for(c in d.dependent)m.attr("data-dependent-"+c,d.dependent[c]);switch(d.type){case "browse":l=$("<div>").addClass("grouper").append(m);b.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});h.append(l);l.click(function(){function a(b){h.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");h.html(i.clone(true).text("..").attr("title",
|
||||
"Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var f=a.browse.subdirectories[b];h.append(i.clone(true).attr("title",e.text()+m+f).text(f))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var f=a.browse.files[b],l=e.text()+m+f,f=$("<a>").text(f).addClass("file").attr("title",l);h.append(f);if(k){var j=true,q;for(q in k)if(typeof k[q]!="undefined"&&mist.inputMatch(k[q],l)){j=false;break}j&&f.hide()}f.click(function(){var a=
|
||||
$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),f=$("<button>").text("Stop browsing").click(function(){g.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),h=$("<div>").addClass("browse_contents"),i=$("<a>").addClass("folder"),k=d.data("filetypes");
|
||||
b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(e).append(f))).append(h);var m="/";mist.data.config.version.indexOf("indows")>-1&&(m="\\");i.click(function(){var b=e.text()+m+$(this).text();a(b)});b=d.getval();f=b.split("://");f.length>1&&(b=f[0]=="file"?f[1]:"");b=b.split(m);b.pop();b=b.join(m);g.hide();a(b)});break;case "geolimited":case "hostlimited":l={field:e};l.blackwhite=
|
||||
$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));l.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":l.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(c in UI.countrylist)l.prototype.append($("<option>").val(c).html(UI.countrylist[c]));break;case "hostlimited":l.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}l.prototype.on("change keyup",
|
||||
function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});l.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=$(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});l.values.append(l.prototype.clone(!0));e.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in
|
||||
d&&(f.data("pointer",d.pointer).addClass("isSetting"),d.pointer.main&&(l=d.pointer.main[d.pointer.index],"undefined"!=l&&f.setval(l)));(""==f.getval()||null==f.getval()||!("pointer"in d))&&"value"in d&&f.setval(d.value);if("datalist"in d)for(c in l="datalist_"+c+MD5(f[0].outerHTML),f.attr("list",l),l=$("<datalist>").attr("id",l),e.append(l),d.datalist)l.append($("<option>").val(d.datalist[c]));e=$("<span>").addClass("help_container");m.append(e);"help"in d&&(e.append($("<span>").addClass("ih_balloon").html(d.help)),
|
||||
f.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in d){m=[];for(i in d.validate){l=d.validate[i];if("function"!=typeof l)switch(l){case "required":l=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":l=function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+
|
||||
function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});l.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=$(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});l.values.append(l.prototype.clone(!0));h.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in
|
||||
d&&(e.data("pointer",d.pointer).addClass("isSetting"),d.pointer.main&&(l=d.pointer.main[d.pointer.index],"undefined"!=l&&e.setval(l)));(""==e.getval()||null==e.getval()||!("pointer"in d))&&"value"in d&&e.setval(d.value);if("datalist"in d)for(c in l="datalist_"+c+MD5(e[0].outerHTML),e.attr("list",l),l=$("<datalist>").attr("id",l),h.append(l),d.datalist)l.append($("<option>").val(d.datalist[c]));h=$("<span>").addClass("help_container");m.append(h);"help"in d&&(h.append($("<span>").addClass("ih_balloon").html(d.help)),
|
||||
e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in d){m=[];for(j in d.validate){l=d.validate[j];if("function"!=typeof l)switch(l){case "required":l=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":l=function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+
|
||||
c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}};break;case "streamname":l=function(a,b){if(a!=""){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_\-\.]/g,"")!=a)return{msg:"Special characters (except for underscores (_), periods (.) and dashes (-)) are not allowed.",
|
||||
classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",classes:["red"]}}};break;case "streamname_with_wildcard":l=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=
|
||||
streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;case "streamname_with_wildcard_and_variables":l=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");
|
||||
streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_$]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",
|
||||
classes:["red"]}}};break;case "track_selector_parameter":l=function(){};break;case "track_selector":l=function(){};break;default:l=function(){}}m.push(l)}f.data("validate_functions",m).data("help_container",e).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(),d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var f in d){var h=d[f](c,a);if(h){$err=$("<span>").addClass("err_balloon").html(h.msg);
|
||||
for(var e in h.classes)$err.addClass(h.classes[e]);g.prepend($err);b&&$(a).focus();return typeof h=="object"&&"break"in h?h["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=f.getval()&&f.trigger("change")}"function"in d&&(f.on("change keyup",d["function"]),f.trigger("change"))}}b.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&
|
||||
b.length&&(b.trigger("click"),a.stopPropagation())});return b},buildVheaderTable:function(a){var b=$("<table>").css("margin","0.2em"),c=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];c.append($("<td>"));for(var f in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[f]?" ":a.labels[f]+":")));for(var i in a.content)for(f in c.append($("<td>").html(a.content[i].header)),a.content[i].body)d[f].append($("<td>").html(a.content[i].body[f]));
|
||||
b.append($("<tbody>").append(c).append(d));return b},plot:{addGraph:function(a,b){var c={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(c.elements.legend);c.elements.cont.append(c.elements.plot).append(c.elements.legend);b.append(c.elements.cont);return c},go:function(a){if(!(1>Object.keys(a).length)){var b={totals:[],clients:[]},c;for(c in a)for(var d in a[c].datasets){var f=
|
||||
a[c].datasets[d];switch(f.datatype){case "clients":case "upbps":case "downbps":case "perc_lost":case "perc_retrans":switch(f.origin[0]){case "total":b.totals.push({fields:[f.datatype],end:-15});break;case "stream":b.totals.push({fields:[f.datatype],streams:[f.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[f.datatype],protocols:[f.origin[1]],end:-15})}break;case "cpuload":case "memload":b.capabilities={}}}0==b.totals.length&&delete b.totals;0==b.clients.length&&delete b.clients;
|
||||
mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var f=[],o;for(o in c.datasets){var l=c.datasets[o];l.display&&(l.getdata(),l.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[l.yaxistype]),c.yaxes[l.yaxistype]=d.length),l.yaxis=c.yaxes[l.yaxistype],f.push(l))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,f,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,
|
||||
classes:["red"]}}};break;case "track_selector_parameter":l=function(){};break;case "track_selector":l=function(){};break;default:l=function(){}}m.push(l)}e.data("validate_functions",m).data("help_container",h).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(),d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var f in d){var e=d[f](c,a);if(e){$err=$("<span>").addClass("err_balloon").html(e.msg);
|
||||
for(var h in e.classes)$err.addClass(e.classes[h]);g.prepend($err);b&&$(a).focus();return typeof e=="object"&&"break"in e?e["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in d&&(e.on("change keyup",d["function"]),e.trigger("change"))}}b.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&
|
||||
b.length&&(b.trigger("click"),a.stopPropagation())});return b},buildVheaderTable:function(a){var b=$("<table>").css("margin","0.2em"),c=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];c.append($("<td>"));for(var e in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[e]?" ":a.labels[e]+":")));for(var j in a.content)for(e in c.append($("<td>").html(a.content[j].header)),a.content[j].body)d[e].append($("<td>").html(a.content[j].body[e]));
|
||||
b.append($("<tbody>").append(c).append(d));return b},plot:{addGraph:function(a,b){var c={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(c.elements.legend);c.elements.cont.append(c.elements.plot).append(c.elements.legend);b.append(c.elements.cont);return c},go:function(a){if(!(1>Object.keys(a).length)){var b={totals:[],clients:[]},c;for(c in a)for(var d in a[c].datasets){var e=
|
||||
a[c].datasets[d];switch(e.datatype){case "clients":case "upbps":case "downbps":case "perc_lost":case "perc_retrans":switch(e.origin[0]){case "total":b.totals.push({fields:[e.datatype],end:-15});break;case "stream":b.totals.push({fields:[e.datatype],streams:[e.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":b.capabilities={}}}0==b.totals.length&&delete b.totals;0==b.clients.length&&delete b.clients;
|
||||
mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var e=[],o;for(o in c.datasets){var l=c.datasets[o];l.display&&(l.getdata(),l.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[l.yaxistype]),c.yaxes[l.yaxistype]=d.length),l.yaxis=c.yaxes[l.yaxistype],e.push(l))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,e,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,
|
||||
borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",c).text("X").addClass("close").click(function(){var b=$(this).data("opts");if(confirm("Are you sure you want to remove "+
|
||||
b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var x=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var f=c.plot.getXAxes()[0],a=Math.min(f.max,a),a=Math.max(f.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var e in c.datasets){var j=" ";if(c.datasets[e].display){var f=UI.plot.yaxes[c.datasets[e].yaxistype].tickFormatter,
|
||||
l=c.datasets[e].data;if(a)for(var i in l){if(l[i][0]==a){j=f(l[i][1]);break}if(l[i][0]>a){if(i!=0){j=l[i];l=l[i-1];j=f(j[1]+(a-j[0])*(l[1]-j[1])/(l[0]-j[0]))}break}}else j=f(c.datasets[e].data[c.datasets[e].data.length-1][1])}b.eq(d).html(j);d++}};c.plot.getOptions();for(o in c.datasets)f=$("<input>").attr("type","checkbox").data("index",o).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")?a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=
|
||||
false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[o].display&&f.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(f).append($("<div>").addClass("series-color").css("background-color",c.datasets[o].color)).append(c.datasets[o].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",o).data("graph",c).click(function(){var b=$(this).data("index"),
|
||||
c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));x();var j=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=j){x(b.x);j=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",
|
||||
b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var x=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var e=c.plot.getXAxes()[0],a=Math.min(e.max,a),a=Math.max(e.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var h in c.datasets){var i=" ";if(c.datasets[h].display){var e=UI.plot.yaxes[c.datasets[h].yaxistype].tickFormatter,
|
||||
l=c.datasets[h].data;if(a)for(var j in l){if(l[j][0]==a){i=e(l[j][1]);break}if(l[j][0]>a){if(j!=0){i=l[j];l=l[j-1];i=e(i[1]+(a-i[0])*(l[1]-i[1])/(l[0]-i[0]))}break}}else i=e(c.datasets[h].data[c.datasets[h].data.length-1][1])}b.eq(d).html(i);d++}};c.plot.getOptions();for(o in c.datasets)e=$("<input>").attr("type","checkbox").data("index",o).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")?a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=
|
||||
false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[o].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",c.datasets[o].color)).append(c.datasets[o].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",o).data("graph",c).click(function(){var b=$(this).data("index"),
|
||||
c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));x();var i=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=i){x(b.x);i=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",
|
||||
c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1],c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",function(){x()})}}},b)}},save:function(a){var b={id:a.id,xaxis:a.xaxis,datasets:[]},c;for(c in a.datasets)b.datasets.push({origin:a.datasets[c].origin,
|
||||
datatype:a.datasets[c].datatype});a=mist.stored.get().graphs||{};a[b.id]=b;mist.stored.set("graphs",a)},del:function(a){var b=mist.stored.get().graphs||{};delete b[a];mist.stored.set("graphs",b)},datatype:{getOptions:function(a){var b=$.extend(!0,{},UI.plot.datatype.templates.general),c=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,c,a),a=$.extend(!0,b,a);switch(a.origin[0]){case "total":switch(a.datatype){case "cpuload":case "memload":break;default:a.label+=" (total)"}break;
|
||||
case "stream":case "protocol":a.label+=" ("+a.origin[1]+")"}var b=[],d;for(d in a.basecolor)c=a.basecolor[d],c+=50*(0.5-Math.random()),c=Math.round(c),c=Math.min(255,Math.max(0,c)),b.push(c);a.color="rgb("+b.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"",yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a=mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];
|
||||
return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-
|
||||
600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",yaxistype:"bytespersec",basecolor:[148,64,237]},perc_lost:{label:"Lost packages",yaxistype:"percentage",basecolor:[255,33,234]},perc_retrans:{label:"Re-transmitted packages",yaxistype:"percentage",
|
||||
basecolor:[0,0,255]}}},yaxes:{percentage:{name:"percentage",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,ticks:function(a){var b=
|
||||
0.3*Math.sqrt($(".graph").first().height()),b=(a.max-a.min)/b,c=Math.floor(Math.log(Math.abs(b))/Math.log(1024)),d=b/Math.pow(1024,c),f=-Math.floor(Math.log(d)/Math.LN10),i=a.tickDecimals;null!=i&&f>i&&(f=i);var m=Math.pow(10,-f),d=d/m,e;if(1.5>d)e=1;else if(3>d){if(e=2,2.25<d&&(null==i||f+1<=i))e=2.5,++f}else e=7.5>d?5:10;e=e*m*Math.pow(1024,c);null!=a.minTickSize&&e<a.minTickSize&&(e=a.minTickSize);a.delta=b;a.tickDecimals=Math.max(0,null!=i?i:f);a.tickSize=e;b=[];c=a.tickSize*Math.floor(a.min/
|
||||
a.tickSize);f=0;i=Number.NaN;do m=i,i=c+f*a.tickSize,b.push(i),++f;while(i<a.max&&i!=m);return b},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var c=$(this).data("dragstart"),d=c.ele.x-c.click.x+a.originalEvent.pageX,a=c.ele.y-
|
||||
c.click.y+a.originalEvent.pageY;$(this).css({opacity:1,top:a,left:d,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,b){var c=new Date(1E3*a),d=[];d.push(("0"+c.getHours()).slice(-2));d.push(("0"+c.getMinutes()).slice(-2));"short"!=b&&d.push(("0"+c.getSeconds()).slice(-2));return d.join(":")},date:function(a,b){var c=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),f=[];"long"==b&&f.push(d[c.getDay()]);f.push(("0"+c.getDate()).slice(-2));f.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[c.getMonth()]);
|
||||
"short"!=b&&f.push(c.getFullYear());return f.join(" ")},dateTime:function(a,b){return UI.format.date(a,b)+", "+UI.format.time(a,b)},duration:function(a){var b=[0.001,1E3,60,60,24,7,52,1E9],c="ms sec min hr day week year".split(" "),d={},f;for(f in c){var a=a/b[f],i=Math.round(a%b[Number(f)+1]);d[c[f]]=i;a-=i}var m;for(f=c.length-1;0<=f;f--)if(0<d[c[f]]){m=c[f];break}b=$("<span>");switch(m){case "year":b.append(UI.format.addUnit(d.year,"years, ")).append(UI.format.addUnit(d.week,"wks"));break;case "week":b.append(UI.format.addUnit(d.week,
|
||||
0.3*Math.sqrt($(".graph").first().height()),b=(a.max-a.min)/b,c=Math.floor(Math.log(Math.abs(b))/Math.log(1024)),d=b/Math.pow(1024,c),e=-Math.floor(Math.log(d)/Math.LN10),j=a.tickDecimals;null!=j&&e>j&&(e=j);var m=Math.pow(10,-e),d=d/m,h;if(1.5>d)h=1;else if(3>d){if(h=2,2.25<d&&(null==j||e+1<=j))h=2.5,++e}else h=7.5>d?5:10;h=h*m*Math.pow(1024,c);null!=a.minTickSize&&h<a.minTickSize&&(h=a.minTickSize);a.delta=b;a.tickDecimals=Math.max(0,null!=j?j:e);a.tickSize=h;b=[];c=a.tickSize*Math.floor(a.min/
|
||||
a.tickSize);e=0;j=Number.NaN;do m=j,j=c+e*a.tickSize,b.push(j),++e;while(j<a.max&&j!=m);return b},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var c=$(this).data("dragstart"),d=c.ele.x-c.click.x+a.originalEvent.pageX,a=c.ele.y-
|
||||
c.click.y+a.originalEvent.pageY;$(this).css({opacity:1,top:a,left:d,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,b){var c=new Date(1E3*a),d=[];d.push(("0"+c.getHours()).slice(-2));d.push(("0"+c.getMinutes()).slice(-2));"short"!=b&&d.push(("0"+c.getSeconds()).slice(-2));return d.join(":")},date:function(a,b){var c=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),e=[];"long"==b&&e.push(d[c.getDay()]);e.push(("0"+c.getDate()).slice(-2));e.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[c.getMonth()]);
|
||||
"short"!=b&&e.push(c.getFullYear());return e.join(" ")},dateTime:function(a,b){return UI.format.date(a,b)+", "+UI.format.time(a,b)},duration:function(a){var b=[0.001,1E3,60,60,24,7,52,1E9],c="ms sec min hr day week year".split(" "),d={},e;for(e in c){var a=a/b[e],j=Math.round(a%b[Number(e)+1]);d[c[e]]=j;a-=j}var m;for(e=c.length-1;0<=e;e--)if(0<d[c[e]]){m=c[e];break}b=$("<span>");switch(m){case "year":b.append(UI.format.addUnit(d.year,"years, ")).append(UI.format.addUnit(d.week,"wks"));break;case "week":b.append(UI.format.addUnit(d.week,
|
||||
"wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":b.append(UI.format.addUnit(d.day,"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:b.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+(d.ms?"."+d.ms:"")].join(":"))}return b[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var b=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*b)/b;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 b=$("<span>");if("undefined"==typeof a.online)return b.text("Unknown, checking.."),"undefined"!=typeof a.error&&b.text(a.error),b;switch(a.online){case -1:b.text("Enabling");break;case 0:b.text("Unavailable").addClass("red");break;case 1:b.text("Active").addClass("green");break;case 2:b.text("Standby").addClass("orange");break;default:b.text(a.online)}"error"in a&&b.text(a.error);return b},capital:function(a){return a.charAt(0).toUpperCase()+
|
||||
a.substring(1)},addUnit:function(a,b){var c=$("<span>").html(a);c.append($("<span>").addClass("unit").html(b));return c[0].innerHTML},bytes:function(a,b){var c="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=c[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=c[0]:(a/=Math.pow(1024,d),unit=c[d])}return UI.format.addUnit(UI.format.number(a),unit+(b?"/s":""))}},navto:function(a,b){var c=location.hash,d=c.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,b].join("&");
|
||||
|
@ -87,22 +87,22 @@ c.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"c
|
|||
return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"rawpassword"},classes:["match_password"]},{label:"Repeat password",type:"password",validate:["required",function(a,b){return a!=$(".match_password.field").not($(b)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",
|
||||
buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");c.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)c.append("Unable to enable all protocols as protocol settings already exist.<br>");else{c.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)c.append('Could not enable protocol "'+d+'" because it has required settings.<br>');else{b.push({connector:d});c.append('Enabled protocol "'+
|
||||
d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});c.append("Loading..");return}var f=$("<span>").text("Loading.."),i=$("<span>"),m=$("<span>").addClass("logs"),
|
||||
e=$("<span>"),t=$("<span>"),o=$("<span>").text("Unknown"),l=$("<span>"),x=$("<span>"),j=parseURL(mist.user.host),j=j.protocol+j.host+j.port,g={};c.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f},{type:"span",
|
||||
label:"Server time",value:t},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:""},{type:"span",label:"Active licenses",value:o},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:i},{type:"span",label:"Current connections",value:e},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:x},{type:"span",label:"Recent problems",
|
||||
d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});c.append("Loading..");return}var e=$("<span>").text("Loading.."),j=$("<span>"),m=$("<span>").addClass("logs"),
|
||||
h=$("<span>"),t=$("<span>"),o=$("<span>").text("Unknown"),l=$("<span>"),x=$("<span>"),i=parseURL(mist.user.host),i=i.protocol+i.host+i.port,g={};c.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:e},{type:"span",
|
||||
label:"Server time",value:t},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:""},{type:"span",label:"Active licenses",value:o},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:j},{type:"span",label:"Current connections",value:h},{type:"span",label:"Enabled protocols",value:l},{type:"span",label:"Disabled protocols",value:x},{type:"span",label:"Recent problems",
|
||||
value:m},$("<br>"),$("<h3>").text("Write config now"),{type:"help",help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"}},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},
|
||||
a)}}]}]));if(mist.data.LTS){var h=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in
|
||||
a&&h(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green");else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em",
|
||||
"margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target","_blank").text("Manual download");d[0].protocol="https:";f.append($("<div>").append(d))}c(a.log)}};h(mist.data);if("license"in mist.data.config){if("active_products"in mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var k=
|
||||
a)}}]}]));if(mist.data.LTS){var f=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");e.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");e.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}if(!a.update||!("uptodate"in a.update)){e.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in
|
||||
a&&f(a)},{checkupdate:true})},5E3)}else if(a.update.error)e.addClass("red").text(a.update.error);else if(a.update.uptodate)e.text("Your version is up to date.").addClass("green");else{if(a.update.progress){e.addClass("orange").removeClass("red").text("Updating..");b(a)}else{e.text("");e.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&e.append($("<button>").text("Rolling update").css({"font-size":"1em",
|
||||
"margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){e.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target","_blank").text("Manual download");d[0].protocol="https:";e.append($("<div>").append(d))}c(a.log)}};f(mist.data);if("license"in mist.data.config){if("active_products"in mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var k=
|
||||
$("<table>").css("text-indent","0");o.html(k);k.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(var q in mist.data.config.license.active_products){var G=mist.data.config.license.active_products[q];k.append($("<tr>").append($("<td>").append(G.name)).append($("<td>").append(G.updates_final?G.updates_final:"∞")).append($("<td>").append(G.use_final?G.use_final:
|
||||
"∞")).append($("<td>").append(G.amount?G.amount:"∞")))}}else o.text("None. ");o.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else f.text("");var Da=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){Ea()},a)},Ea=function(){i.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:
|
||||
"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";e.text(a);t.text(UI.format.dateTime(mist.data.config.time,"long"));m.html("");a=0;"license"in mist.data.config&&"user_msg"in mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>
|
||||
-1){a++;var d=$("<span>").addClass("content").addClass("red"),f=c[2].split("|");for(b in f)d.append($("<span>").text(f[b]));m.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&m.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];a.indexOf(d.connector)>-1||a.push(d.connector)}l.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);
|
||||
"∞")).append($("<td>").append(G.amount?G.amount:"∞")))}}else o.text("None. ");o.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else e.text("");var Da=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){Ea()},a)},Ea=function(){j.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:
|
||||
"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";h.text(a);t.text(UI.format.dateTime(mist.data.config.time,"long"));m.html("");a=0;"license"in mist.data.config&&"user_msg"in mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>
|
||||
-1){a++;var d=$("<span>").addClass("content").addClass("red"),e=c[2].split("|");for(b in e)d.append($("<span>").text(e[b]));m.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&m.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];a.indexOf(d.connector)>-1||a.push(d.connector)}l.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);
|
||||
x.text(c.length?c.join(", "):"None.")}else x.text("Loading..")};Da();Ea();UI.interval.set(Da,3E4);break;case "General":var M={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus,defaultStream:mist.data.config.defaultStream,trustedproxy:mist.data.config.trustedproxy},N={sessionViewerMode:mist.data.config.sessionViewerMode,sessionInputMode:mist.data.config.sessionInputMode,sessionOutputMode:mist.data.config.sessionOutputMode,
|
||||
sessionUnspecifiedMode:mist.data.config.sessionUnspecifiedMode,tknMode:mist.data.config.tknMode,sessionStreamInfoMode:mist.data.config.sessionStreamInfoMode},ea={location:"location"in mist.data.config?mist.data.config.location:{}},E={limit:""};"bandwidth"in mist.data&&(E=mist.data.bandwidth,null==E&&(E={}),E.limit||(E.limit=""));var Ga=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s"));
|
||||
c.html(UI.buildUI([$("<h2>").text("General settings"),{type:"help",help:"These are settings that apply to your MistServer instance in general."},{type:"str",label:"Human readable name",pointer:{main:M,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:M,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},
|
||||
{type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:M,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:M,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+j+"/PASSPHRASE or "+
|
||||
j+"/PASSPHRASE.json.",LTSonly:!0},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",pointer:{main:M,index:"trustedproxy"}},{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:M,index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",
|
||||
{type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:M,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:M,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+i+"/PASSPHRASE or "+
|
||||
i+"/PASSPHRASE.json.",LTSonly:!0},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",pointer:{main:M,index:"trustedproxy"}},{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:M,index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",
|
||||
LTSonly:!0},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(a){$(a).text("Saving..");mist.send(function(){UI.navto("General")},{config:M})}}]}]));c.append(UI.buildUI([$("<h3>").text("Sessions"),{type:"bitmask",label:"Bundle viewer sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:N,index:"sessionViewerMode"},help:"Change the way viewer connections are bundled into sessions.<br>Default: stream name, viewer IP and token"},{type:"bitmask",
|
||||
label:"Bundle input sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:N,index:"sessionInputMode"},help:"Change the way input connections are bundled into sessions.<br>Default: stream name, input IP, token and protocol"},{type:"bitmask",label:"Bundle output sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:N,index:"sessionOutputMode"},help:"Change the way output connections are bundled into sessions.<br>Default: stream name, output IP, token and protocol"},
|
||||
{type:"bitmask",label:"Bundle unspecified sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:N,index:"sessionUnspecifiedMode"},help:"Change the way unspecified connections are bundled into sessions.<br>Default: none"},{type:"select",label:"Treat HTTP-only sessions as",select:[[1,"A viewer session"],[2,"An output session: skip executing the USER_NEW and USER_END triggers"],[4,"A separate 'unspecified' session: skip executing the USER_NEW and USER_END triggers"],
|
||||
|
@ -120,71 +120,71 @@ b.append($("<tr>").addClass("uploader").attr("data-name",c).html($("<td>").text(
|
|||
b+"'?")&&mist.send(function(){UI.showTab("General")},{external_writer_remove:b})}))))}}else na.html("None configured.")},{external_writer_list:!0});break;case "Edit external writer":var z=!1;""!=b&&(z=!0);var Ia=function(){z?c.html($("<h2>").text("Edit external writer '"+b+"'")):c.html($("<h2>").text("New external writer"));var a={};if(mist.data.external_writer_list&&b in mist.data.external_writer_list){var d=mist.data.external_writer_list[b];a.name=d[0];a.cmdline=d[1];a.protocols=d[2]}c.append(UI.buildUI([{type:"str",
|
||||
label:"Human readable name",help:"A human readable name for the external writer.",validate:["required"],pointer:{main:a,index:"name"}},{type:"str",label:"Command line",help:"Command line for a local command (with optional arguments) which will write media data to the target.",validate:["required"],pointer:{main:a,index:"cmdline"}},{type:"inputlist",label:"URI protocols handled",help:"URI protocols which the external writer will be handling.",validate:["required",function(a){for(var b in a){var c=
|
||||
a[b];if(c.match(/^([a-z\d\+\-\.])+?$/)===null)return{classes:["red"],msg:"There was a problem with the protocol URI '"+$("<div>").text(c).html()+"':<br>A protocol URI may only contain lower case letters, digits, and the following special characters . + and -"}}}],input:{type:"str",unit:"://"},pointer:{main:a,index:"protocols"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={external_writer_add:a},
|
||||
d=null;b!=""&&b in mist.data.external_writer_list&&(d=mist.data.external_writer_list[b][0]);if(d!==null&&a.name!=d)c.external_writer_remove=d;mist.send(function(){UI.navto("General")},c)}}]}]))};"external_writer_list"in mist.data?Ia():mist.send(function(){Ia()},{external_writer_list:!0});break;case "Edit variable":z=!1;""!=b&&(z=!0);var Fa=function(a,d){z?c.html($("<h2>").text('Edit Variable "$'+b+'"')):c.html($("<h2>").text("New Variable"));var f=$("<div>");c.append(UI.buildUI([{type:"str",maxlength:31,
|
||||
d=null;b!=""&&b in mist.data.external_writer_list&&(d=mist.data.external_writer_list[b][0]);if(d!==null&&a.name!=d)c.external_writer_remove=d;mist.send(function(){UI.navto("General")},c)}}]}]))};"external_writer_list"in mist.data?Ia():mist.send(function(){Ia()},{external_writer_list:!0});break;case "Edit variable":z=!1;""!=b&&(z=!0);var Fa=function(a,d){z?c.html($("<h2>").text('Edit Variable "$'+b+'"')):c.html($("<h2>").text("New Variable"));var e=$("<div>");c.append(UI.buildUI([{type:"str",maxlength:31,
|
||||
label:"Variable name",prefix:"$",help:"What should the variable be called? A dollar sign will automatically be prepended.",pointer:{main:a,index:"name"},validate:["required",function(a){if(a.length&&a[0]=="$")return{msg:"The dollar sign will automatically be prepended. You don't need to type it here.",classes:["red"]};if(a.indexOf("{")!==-1||a.indexOf("}")!==-1||a.indexOf("$")!==-1)return{msg:'The following symbols are not permitted: "$ { }".',classes:["red"]}}]},{type:"select",label:"Type",help:"What kind of variable is this? It can either be a static value that you can enter below, or a dynamic one that is returned by a command.",
|
||||
select:[["value","Static value"],["command","Dynamic through command"]],value:"value",pointer:{main:d,index:"type"},"function":function(){var a=[$("Invalid variable type")];switch($(this).val()){case "value":a=[{type:"str",label:"Value",pointer:{main:d,index:"value"},help:"The static value that this variable should be replaced with. There is a character limit of 63 characters.",validate:["required"]}];break;case "command":a=[{type:"str",label:"Command",help:"The command that should be executed to retrieve the value for this variable.<br>For example:<br><code>/usr/bin/date +%A</code><br>There is a character limit of 511 characters.",
|
||||
validate:["required"],pointer:{main:d,index:"target"}},{type:"int",min:0,max:4294967295,"default":0,label:"Checking interval",unit:"s",help:"At what interval, in seconds, MistServer should execute the command and update the value.<br>To execute the command once when MistServer starts up (and then never update), set the interval to 0.",pointer:{main:d,index:"interval"}},{type:"int",min:0,max:4294967295,"default":1,label:"Wait time",unit:"s",help:"Specifies the maximum time, in seconds, MistServer should wait for data when executing the variable target. If set to 0 this variable takes on the same value as the interval.<br>MistServer only updates one variable at a time, so setting this value too high can block other variables from updating.",
|
||||
pointer:{main:d,index:"waitTime"}}]}f.html(UI.buildUI(a))}},f,{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={variable_add:a};switch(d.type){case "value":a.value=d.value;break;case "command":a.target=d.target;a.interval=d.interval;a.waitTime=d.waitTime}if(a.name!=b)c.variable_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};c.html("Loading..");z?mist.send(function(a){if(b in a.variable_list){a=
|
||||
pointer:{main:d,index:"waitTime"}}]}e.html(UI.buildUI(a))}},e,{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={variable_add:a};switch(d.type){case "value":a.value=d.value;break;case "command":a.target=d.target;a.interval=d.interval;a.waitTime=d.waitTime}if(a.name!=b)c.variable_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};c.html("Loading..");z?mist.send(function(a){if(b in a.variable_list){a=
|
||||
a.variable_list[b];Fa({name:b},typeof a=="string"?{value:a,type:"value"}:{target:a[0],interval:a[1],waitTime:a[4],type:"command"})}else c.append('Variable "$'+b+'" does not exist.')},{variable_list:!0}):Fa({},{});break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var F=$("<tbody>");c.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=
|
||||
[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n ";
|
||||
c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){if(mist.data.config.protocols===null)mist.data.config.protocols=[];for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear",
|
||||
"both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(F));var Ha=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],f=["required","optional"],w;for(w in f)for(var g in c[f[w]])b[g]&&b[g]!=""?d.push(g+": "+b[g]):c[f[w]][g]["default"]&&d.push(g+": "+c[f[w]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}
|
||||
"both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(F));var Ha=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],e=["required","optional"],w;for(w in e)for(var g in c[e[w]])b[g]&&b[g]!=""?d.push(g+": "+b[g]):c[e[w]][g]["default"]&&d.push(g+": "+c[e[w]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}
|
||||
F.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b],d=mist.data.capabilities.connectors[c.connector];F.append($("<tr>").data("index",b).append($("<td>").text(d&&d.friendly?d.friendly:c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=
|
||||
$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};Ha();UI.interval.set(function(){mist.send(function(){Ha()})},1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}z=
|
||||
!1;""!=b&&0<=b&&(z=!0);var V={};for(q in mist.data.config.protocols)V[mist.data.config.protocols[q].connector]=1;var Ja=function(a){var b=mist.data.capabilities.connectors[a],c=mist.convertBuildOptions(b,p);if(z)var d=$.extend({},p);c.push({type:"hidden",pointer:{main:p,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};z?a.updateprotocol=[d,p]:a.addprotocol=p;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel",
|
||||
"function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){k=$("<span>").text("Dependencies:");$ul=$("<ul>");k.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var f in b.deps){a=$("<li>").text(b.deps[f]+" ");$ul.append(a);typeof V[b.deps[f]]!="undefined"||typeof V[b.deps[f]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:k[0].innerHTML})}return UI.buildUI(c)},
|
||||
"function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){k=$("<span>").text("Dependencies:");$ul=$("<ul>");k.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)"))}c.unshift({type:"text",text:k[0].innerHTML})}return UI.buildUI(c)},
|
||||
V={};for(q in mist.data.config.protocols)V[mist.data.config.protocols[q].connector]=1;if(z){var s=mist.data.config.protocols[b],p=s;c.find("h2").append(' "'+s.connector+'"');c.append(Ja(s.connector))}else{c.html($("<h2>").text("New Protocol"));var p={},u=[["",""]];for(q in mist.data.capabilities.connectors)u.push([q,mist.data.capabilities.connectors[q].friendly?mist.data.capabilities.connectors[q].friendly:q]);var S=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:u,"function":function(){$(this).getval()!=
|
||||
""&&S.html(Ja($(this).getval()))}}])).append(S)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}var La=$("<button>"),O=$("<span>").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(La).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(O);
|
||||
""==b&&(g=mist.stored.get(),"viewmode"in g&&(b=g.viewmode));La.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var C=$.extend(!0,{},mist.data.streams),oa=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},pa=function(b,d,f){O.remove();switch(b){case "thumbnails":var g=$("<div>").addClass("preview_icons"),
|
||||
e;e=f||[];d.sort();d.unshift("");O.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();g.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(g);
|
||||
for(var h in d){var b=d[h],j="",k=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),l=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),f=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),
|
||||
Ka=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),r=$("<span>").addClass("image");if(b.indexOf("+")>-1){j=b.split("+");j=mist.data.streams[j[0]].source+j[1];l=k="";r.addClass("wildcard")}else{j=mist.data.streams[b].source;if(e.indexOf(b)>-1){Ka=f="";r.addClass("folder")}}g.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(r).append($("<span>").addClass("description").text(j)).append($("<span>").addClass("button_container").append(l).append(k).append(f).append(Ka)).attr("title",
|
||||
b).attr("data-stream",b))}break;default:var i=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(i);
|
||||
c.append(h);h.stupidtable();var m=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,C,mist.data.streams);var a=0;i.html("");d.sort();for(var b in d){var c=d[b],f;f=c in mist.data.streams?mist.data.streams[c]:C[c];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),w=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!=
|
||||
"undefined"){var e=mist.data.totals[c].all_protocols.clients,w=0;if(e.length){for(a in e)w=w+e[a][1];w=Math.round(w/e.length)}}g.html(UI.format.number(w));if(w==0&&f.online==1)f.online=2;w=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in f)||!f.ischild)&&w.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
|
||||
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)}}));e=$("<span>").text(f.name);f.ischild&&e.css("padding-left","1em");var h=UI.format.status(f),j=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),r=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in C[c]||f.online<0){h.html("");
|
||||
j="";g.html("");r=""}i.append($("<tr>").data("index",c).html($("<td>").html(e).attr("title",f.name=="..."?"The results were truncated":f.name).addClass("overflow_ellipsis")).append($("<td>").text(f.source).attr("title",f.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",f.online).html(h)).append(g).append($("<td>").css("white-space","nowrap").html(j).append(r)).append(w));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var q=
|
||||
0,Ma=0;for(e in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[e].source)){C[e].source=C[e].source+"*";C[e].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,f;a:for(f in a.browse.files){var g;for(g in mist.data.capabilities.inputs)if(!(g.indexOf("Buffer")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder")>=0||g.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[g].source_match,
|
||||
"/"+a.browse.files[f])){var w=c+"+"+a.browse.files[f];C[w]=oa(w,mist.data.streams[c]);C[w].source=mist.data.streams[c].source+a.browse.files[f];d++;if(d>=500){C[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?C[c].filesfound=true:mist.data.streams[c].filesfound=false;Ma++;if(q==Ma){mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});q++}}if(q==0){mist.send(function(){m()},
|
||||
{active_streams:true});UI.interval.set(function(){m()},5E3)}}else{mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}}};if(mist.data.LTS){var qa=0,Na=0,u={},Oa=[];for(g in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[g].source))Oa.push(g),mist.send(function(a,c){var d=c.stream,f=0,g;a:for(g in a.browse.files){var e;for(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[g])){u[d+"+"+a.browse.files[g]]=true;f++;if(f>=500){u[d+"+zzzzzzzzz"]=true;break a}}}Na++;qa==Na&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){u[mist.data.active_streams[a]]=true;C[mist.data.active_streams[a]]=oa(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);u=u.concat(Object.keys(mist.data.streams));
|
||||
""==b&&(g=mist.stored.get(),"viewmode"in g&&(b=g.viewmode));La.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var C=$.extend(!0,{},mist.data.streams),oa=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},pa=function(b,d,e){O.remove();switch(b){case "thumbnails":var g=$("<div>").addClass("preview_icons"),
|
||||
f;f=e||[];d.sort();d.unshift("");O.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();g.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(g);
|
||||
for(var h in d){var b=d[h],i="",k=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),l=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),e=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),
|
||||
Ka=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),r=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];l=k="";r.addClass("wildcard")}else{i=mist.data.streams[b].source;if(f.indexOf(b)>-1){Ka=e="";r.addClass("folder")}}g.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(r).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(l).append(k).append(e).append(Ka)).attr("title",
|
||||
b).attr("data-stream",b))}break;default:var j=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(j);
|
||||
c.append(h);h.stupidtable();var m=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,C,mist.data.streams);var a=0;j.html("");d.sort();for(var b in d){var c=d[b],e;e=c in mist.data.streams?mist.data.streams[c]:C[c];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),w=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!=
|
||||
"undefined"){var f=mist.data.totals[c].all_protocols.clients,w=0;if(f.length){for(a in f)w=w+f[a][1];w=Math.round(w/f.length)}}g.html(UI.format.number(w));if(w==0&&e.online==1)e.online=2;w=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||!e.ischild)&&w.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
|
||||
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)}}));f=$("<span>").text(e.name);e.ischild&&f.css("padding-left","1em");var h=UI.format.status(e),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),r=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in C[c]||e.online<0){h.html("");
|
||||
i="";g.html("");r=""}j.append($("<tr>").data("index",c).html($("<td>").html(f).attr("title",e.name=="..."?"The results were truncated":e.name).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(h)).append(g).append($("<td>").css("white-space","nowrap").html(i).append(r)).append(w));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var q=
|
||||
0,Ma=0;for(f in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[f].source)){C[f].source=C[f].source+"*";C[f].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,e;a:for(e in a.browse.files){var g;for(g in mist.data.capabilities.inputs)if(!(g.indexOf("Buffer")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder")>=0||g.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[g].source_match,
|
||||
"/"+a.browse.files[e])){var w=c+"+"+a.browse.files[e];C[w]=oa(w,mist.data.streams[c]);C[w].source=mist.data.streams[c].source+a.browse.files[e];d++;if(d>=500){C[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?C[c].filesfound=true:mist.data.streams[c].filesfound=false;Ma++;if(q==Ma){mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}},{browse:mist.data.streams[f].source},{stream:f});q++}}if(q==0){mist.send(function(){m()},
|
||||
{active_streams:true});UI.interval.set(function(){m()},5E3)}}else{mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}}};if(mist.data.LTS){var qa=0,Na=0,u={},Oa=[];for(g in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[g].source))Oa.push(g),mist.send(function(a,c){var d=c.stream,e=0,g;a:for(g in a.browse.files){var f;for(f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=
|
||||
0||f.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[g])){u[d+"+"+a.browse.files[g]]=true;e++;if(e>=500){u[d+"+zzzzzzzzz"]=true;break a}}}Na++;qa==Na&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){u[mist.data.active_streams[a]]=true;C[mist.data.active_streams[a]]=oa(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);u=u.concat(Object.keys(mist.data.streams));
|
||||
u.sort();pa(b,u,Oa)},{active_streams:true})},{browse:mist.data.streams[g].source},{stream:g}),qa++;0==qa&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){u[mist.data.active_streams[a]]=true;C[mist.data.active_streams[a]]=oa(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);mist.data.streams&&(u=u.concat(Object.keys(mist.data.streams)));u.sort();pa(b,u)},{active_streams:!0})}else pa(b,
|
||||
Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}z=!1;""!=b&&(z=!0);if(z){var Pa=b,p=mist.data.streams[Pa];c.find("h2").append(' "'+Pa+'"')}else c.html($("<h2>").text("New Stream")),p={};var Qa=[];for(q in mist.data.capabilities.inputs)Qa.push(mist.data.capabilities.inputs[q].source_match);var fa=$("<div>"),Ra=function(a){var c={};if(!mist.data.streams)mist.data.streams=
|
||||
{};mist.data.streams[p.name]=p;b!=p.name&&delete mist.data.streams[b];c.addstream={};c.addstream[p.name]=p;if(b!=p.name)c.deletestream=[b];if(p.stop_sessions&&b!=""){c.stop_sessions=b;delete p.stop_sessions}mist.send(function(){delete mist.data.streams[p.name].online;delete mist.data.streams[p.name].error;UI.navto(a,a=="Preview"?p.name:"")},c)},Sa=$("<style>").text("button.saveandpreview { display: none; }"),P=$("<span>"),ra=function(){var a=c.find("[name=name]").val();if(a){var b=parseURL(mist.user.host),
|
||||
d=c.find("[name=source]").val(),f=d.match(/@.*/);f&&(f=f[0].substring(1));var g=d.replace(/(?:.+?):\/\//,""),g=g.split("/"),g=g[0],g=g.split(":"),g=g[0];(d=d.match(/:\d+/))&&(d=d[0]);var e={},h=["RTMP","RTSP","RTMP.exe","RTSP.exe"],j;for(j in h)h[j]in mist.data.capabilities.connectors&&(e[h[j]]=mist.data.capabilities.connectors[h[j]].optional.port["default"]);var h={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},k;for(k in e){for(j in mist.data.config.protocols){var l=mist.data.config.protocols[j];
|
||||
if(l.connector==k){if("port"in l)e[k]=l.port;break}}e[k]=e[k]==h[k]?"":":"+e[k]}e.TS="";e["TS.exe"]="";P.find(".field").closest("label").hide();for(j in e){var r;k=d?d:e[j];switch(j){case "RTMP":case "RTMP.exe":r="rtmp://"+b.host+k+"/"+(f?f:"live")+"/";P.find(".field.RTMPurl").setval(r).closest("label").show();P.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();r=r+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":r="rtsp://"+b.host+k+"/"+(a==""?"STREAMNAME":a)+(f?
|
||||
"?pass="+f:"");break;case "TS":case "TS.exe":r="udp://"+(g==""?b.host:g)+k+"/"}P.find(".field."+j.replace(".exe","")).setval(r).closest("label").show()}}},Ta=$("<div>"),sa={},u=[],Ua=$("<div>");for(q in mist.data.capabilities.processes)u.push([q,mist.data.capabilities.processes[q].hrn?mist.data.capabilities.processes[q].hrn:mist.data.capabilities.processes[q].name]);if(u.length){var jb=[{label:"New process",type:"select",select:u,value:u[0][0],pointer:{main:sa,index:"process"},"function":function(){var a=
|
||||
d=c.find("[name=source]").val(),e=d.match(/@.*/);e&&(e=e[0].substring(1));var g=d.replace(/(?:.+?):\/\//,""),g=g.split("/"),g=g[0],g=g.split(":"),g=g[0];(d=d.match(/:\d+/))&&(d=d[0]);var f={},h=["RTMP","RTSP","RTMP.exe","RTSP.exe"],i;for(i in h)h[i]in mist.data.capabilities.connectors&&(f[h[i]]=mist.data.capabilities.connectors[h[i]].optional.port["default"]);var h={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},k;for(k in f){for(i in mist.data.config.protocols){var l=mist.data.config.protocols[i];
|
||||
if(l.connector==k){if("port"in l)f[k]=l.port;break}}f[k]=f[k]==h[k]?"":":"+f[k]}f.TS="";f["TS.exe"]="";P.find(".field").closest("label").hide();for(i in f){var r;k=d?d:f[i];switch(i){case "RTMP":case "RTMP.exe":r="rtmp://"+b.host+k+"/"+(e?e:"live")+"/";P.find(".field.RTMPurl").setval(r).closest("label").show();P.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();r=r+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":r="rtsp://"+b.host+k+"/"+(a==""?"STREAMNAME":a)+(e?
|
||||
"?pass="+e:"");break;case "TS":case "TS.exe":r="udp://"+(g==""?b.host:g)+k+"/"}P.find(".field."+i.replace(".exe","")).setval(r).closest("label").show()}}},Ta=$("<div>"),sa={},u=[],Ua=$("<div>");for(q in mist.data.capabilities.processes)u.push([q,mist.data.capabilities.processes[q].hrn?mist.data.capabilities.processes[q].hrn:mist.data.capabilities.processes[q].name]);if(u.length){var jb=[{label:"New process",type:"select",select:u,value:u[0][0],pointer:{main:sa,index:"process"},"function":function(){var a=
|
||||
$(this).getval();if(a!=null){var a=mist.data.capabilities.processes[a],b=[$("<h4>").text(a.name+" Process options")];Ua.html(UI.buildUI(b.concat(mist.convertBuildOptions(a,sa))))}}},Ua];Ta.append(UI.buildUI([$("<br>"),$("<h3>").text("Stream processes"),{label:"Stream processes",itemLabel:"stream process",type:"sublist",sublist:jb,saveas:sa,pointer:{main:p,index:"processes"}}]))}c.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:p,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},
|
||||
{label:"Source",type:"browse",filetypes:Qa,pointer:{main:p,index:"source"},help:"<p> Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified. </p> <table class=valigntop> <tr> <th colspan=3><b>File inputs</b></th> </tr> <tr> <th>File</th> <td> Linux/MacOS: /PATH/FILE<br> Windows: /cygdrive/DRIVE/PATH/FILE </td> <td> For file input please specify the proper path and file.<br> Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input. </td> </tr> <th> Folder </th> <td> Linux/MacOS: /PATH/<br> Windows: /cygdrive/DRIVE/PATH/ </td> <td> A folder stream makes all the recognised files in the selected folder available as a stream. </td> </tr> <tr><td colspan=3> </td></tr> <tr> <th colspan=3><b>Push inputs</b></th> </tr> <tr> <th>RTMP</th> <td>push://(IP)(@PASSWORD)</td> <td> IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br> PASSWORD is the application under which to push to MistServer, if it doesn't match the stream will be rejected. PASSWORD is MistServer Pro only. </td> </tr> <tr> <th>RTSP</th> <td>push://(IP)(@PASSWORD)</td> <td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td> </tr> <tr> <th>TS</th> <td>tsudp://(IP):PORT(/INTERFACE)</td> <td> IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br> PORT is the port you reserve for this stream on the chosen IP.<br> INTERFACE is the interface used, if left all interfaces will be used. </td> </tr> <tr><td colspan=3> </td></tr> <tr> <th colspan=3><b>Pull inputs</b></th> </tr> <tr> <th>DTSC</th> <td>dtsc://MISTSERVER_IP:PORT/(STREAMNAME)</td> <td>MISTSERVER_IP is the IP of another MistServer to pull from.<br> PORT is the DTSC port of the other MistServer. (default is 4200)<br> STREAMNAME is the name of the target stream on the other MistServer. If left empty, the name of this stream will be used. </td> </tr> <tr> <th>HLS</th> <td>http://URL/TO/STREAM.m3u8</td> <td>The URL where the HLS stream is available to MistServer.</td> </tr> <tr> <th>RTSP</th> <td>rtsp://(USER:PASSWORD@)IP(:PORT)(/path)</td> <td> USER:PASSWORD is the account used if authorization is required.<br> IP is the IP address used to pull this stream from.<br> PORT is the port used to connect through.<br> PATH is the path to be used to identify the correct stream. </td> </tr> </table>",
|
||||
"function":function(){var a=$(this).val();Sa.remove();P.html("");if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)fa.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];fa.html($("<h3>").text(b.name+" Input options"));
|
||||
var f=mist.convertBuildOptions(b,p);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&f.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:p,index:"always_on"}});fa.append(UI.buildUI(f));if(b.name=="Folder")c.append(Sa);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){d=[$("<br>"),$("<span>").text("Configure your source to push to:")];
|
||||
var e=mist.convertBuildOptions(b,p);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&e.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:p,index:"always_on"}});fa.append(UI.buildUI(e));if(b.name=="Folder")c.append(Sa);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){d=[$("<br>"),$("<span>").text("Configure your source to push to:")];
|
||||
switch(b.name){case "Buffer":case "Buffer.exe":d.push({label:"RTMP full url",type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});d.push({label:"RTMP url",type:"span",clipboard:true,readonly:true,classes:["RTMPurl"],help:"Use this RTMP url if your client also asks for a stream key"});d.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"});
|
||||
d.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});break;case "TS":case "TS.exe":a.charAt(0)=="/"?d=[]:d.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}P.html(UI.buildUI(d));ra()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",pointer:{main:p,index:"stop_sessions"}},P,$("<br>"),{type:"custom",custom:fa},Ta,{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},
|
||||
{type:"save",label:"Save","function":function(){Ra("Streams")}},{type:"save",label:"Save and Preview","function":function(){Ra("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){ra()});ra();break;case "Preview":""==b&&UI.navto("Streams");var Q=parseURL(mist.user.host),W=Q.protocol,T=Q.host,J=":8080",v=W+T+J+"/";for(q in mist.data.config.protocols)if(s=mist.data.config.protocols[q],"HTTP"==s.connector||"HTTP.exe"==s.connector){s.pubaddr&&s.pubaddr.length?"string"==
|
||||
typeof s.pubaddr?v=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(v=s.pubaddr[0].replace(/\/$/,"")+"/"):(J=s.port?":"+s.port:":8080",v=W+T+J+"/");break}var S=$("<div>").css({display:"flex","flex-flow":"row wrap","flex-shrink":1,"min-width":"auto"}),X="";-1==b.indexOf("+")&&(X=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(X).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",
|
||||
b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(S);var K=encodeURIComponent(b),Va=$("<div>").css("flex-shrink","1").css("min-width","auto").css("max-width","100%");S.append(Va);var Wa=$("<div>"),Y=$("<div>").text("Loading player..").css("max-width","100%").css("flex-shrink","1").css("min-width","auto"),ta=$("<div>").addClass("controls");Va.append(Y).append(Wa).append(ta);$("link#devcss").length||
|
||||
c.append($("<link>").attr("rel","stylesheet").attr("type","text/css").attr("href",v+"skins/dev.css").attr("id","devcss"));var Xa=function(){Wa.text("");var d=document.createElement("script");c.append(d);d.src=v+"player.js";d.onerror=function(){Y.html($("<p>").append('Failed to load <a href="'+v+'player.js">'+v+"player.js</a>.")).append($("<p>").append("Please check if you've activated the HTTP protocol, if your http port is blocked, or if you're trying to load HTTPS on an HTTP page.")).append($("<button>").text("Reload").css("display",
|
||||
"block").click(function(){Xa()}))};d.onload=function(){var f=b,g=function(){var a=MistVideoObject.reference;ta.html("");ta.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"],style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues",
|
||||
"block").click(function(){Xa()}))};d.onload=function(){var e=b,g=function(){var a=MistVideoObject.reference;ta.html("");ta.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"],style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues",
|
||||
style:{"max-width":"30em","flex-flow":"column nowrap"}},{type:"container",classes:["mistvideo-column","mistvideo-devcontrols"],children:[{type:"text",text:"Player control"},{type:"container",classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{"if":function(){return!(!this.player||!this.player.api)},then:{type:"button",title:"Reload the video source",label:"Reload video",onclick:function(){this.player.api.load()}}},{type:"button",title:"Build MistVideo again",label:"Reload player",
|
||||
onclick:function(){this.reload()}},{type:"button",title:"Switch to the next available player and source combination",label:"Try next combination",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},{type:"forceType"},{type:"forceSource"}]},{type:"log"}]}))};if(!(a!="Preview"||!b||b==""||f!=b)){Y[0].addEventListener("initialized",g);Y[0].addEventListener("initializeFailed",g);MistVideoObject.reference=mistPlay(f,{target:Y[0],host:v,skin:"dev",loop:true,MistVideoObject:MistVideoObject})}c[0].removeChild(d)};
|
||||
onclick:function(){this.reload()}},{type:"button",title:"Switch to the next available player and source combination",label:"Try next combination",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},{type:"forceType"},{type:"forceSource"}]},{type:"log"}]}))};if(!(a!="Preview"||!b||b==""||e!=b)){Y[0].addEventListener("initialized",g);Y[0].addEventListener("initializeFailed",g);MistVideoObject.reference=mistPlay(e,{target:Y[0],host:v,skin:"dev",loop:true,MistVideoObject:MistVideoObject})}c[0].removeChild(d)};
|
||||
MistVideoObject.reference={unload:function(){d.onload=function(){this.parentElement&&this.parentElement.removeChild(this)}}}};Xa();var ua=$("<div>").append($("<h3>").text("Meta information")),ga=$("<span>").text("Loading..");ua.append(ga);var Ya=$("<div>").addClass("process_info");ua.append(Ya);S.append(ua);if(""!=K){$.ajax({type:"GET",url:v+"json_"+K+".js",success:function(a){var b=function(a,b){return"maxbps"in a?UI.format.bytes(a[b],1):b=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},c=a.meta;if(!c||
|
||||
!c.tracks)ga.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(c.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language","Track index"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate",
|
||||
"Peak bitrate","Size","Framerate","Language","Track index","Has B-Frames"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},f=Object.keys(c.tracks);f.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});var g=1,e=1,h=1,j;for(j in f){var k=f[j],r=c.tracks[k];switch(r.type){case "audio":d.audio.content.push({header:"Track "+k.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/
|
||||
"Peak bitrate","Size","Framerate","Language","Track index","Has B-Frames"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},e=Object.keys(c.tracks);e.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});var g=1,f=1,h=1,i;for(i in e){var k=e[i],r=c.tracks[k];switch(r.type){case "audio":d.audio.content.push({header:"Track "+k.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/
|
||||
1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/1E3)+"</span>",b(r,"bps"),b(r,"maxbps"),r.channels,UI.format.addUnit(UI.format.number(r.rate),"Hz"),"language"in r?r.language:"unknown",g]});g++;break;case "video":d.video.content.push({header:"Track "+k.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/1E3)+"</span>",b(r,
|
||||
"bps"),b(r,"maxbps"),UI.format.addUnit(r.width,"x ")+UI.format.addUnit(r.height,"px"),UI.format.addUnit(UI.format.number(r.fpks/1E3),"fps"),"language"in r?r.language:"unknown",e,"bframes"in r?"yes":"no"]});e++;break;case "meta":case "subtitle":if(r.codec=="subtitle"||r.type=="subtitle"){d.subtitle.content.push({header:"Track "+k.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/
|
||||
1E3)+"</span>",b(r,"bps"),b(r,"maxbps"),"language"in r?r.language:"unknown",h]});h++}}}b=["audio","video","subtitle"];j=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(k in b)d[b[k]].content.length&&j.append(UI.buildVheaderTable(d[b[k]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(j);ga.html(UI.buildUI(a))}},error:function(){ga.html("Error while retrieving stream info.")}});var Za=function(){var a={proc_list:b};if(!mist.data.capabilities)a.capabilities=
|
||||
"bps"),b(r,"maxbps"),UI.format.addUnit(r.width,"x ")+UI.format.addUnit(r.height,"px"),UI.format.addUnit(UI.format.number(r.fpks/1E3),"fps"),"language"in r?r.language:"unknown",f,"bframes"in r?"yes":"no"]});f++;break;case "meta":case "subtitle":if(r.codec=="subtitle"||r.type=="subtitle"){d.subtitle.content.push({header:"Track "+k.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/
|
||||
1E3)+"</span>",b(r,"bps"),b(r,"maxbps"),"language"in r?r.language:"unknown",h]});h++}}}b=["audio","video","subtitle"];i=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(k in b)d[b[k]].content.length&&i.append(UI.buildVheaderTable(d[b[k]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(i);ga.html(UI.buildUI(a))}},error:function(){ga.html("Error while retrieving stream info.")}});var Za=function(){var a={proc_list:b};if(!mist.data.capabilities)a.capabilities=
|
||||
true;mist.send(function(a){if(a.proc_list){var b=$("<table>").css("width","auto"),c={"Process type:":function(a){return $("<b>").text(a.process)},"Source:":function(a){var b=$("<span>").text(a.source);a.source_tracks&&a.source_tracks.length&&b.append($("<span>").addClass("description").text(" track "+a.source_tracks.slice(0,-2).concat(a.source_tracks.slice(-2).join(" and ")).join(", ")));return b},"Sink:":function(a){var b=$("<span>").text(a.sink);a.sink_tracks&&a.sink_tracks.length&&b.append($("<span>").addClass("description").text(" track "+
|
||||
a.sink_tracks.slice(0,-2).concat(a.sink_tracks.slice(-2).join(" and ")).join(", ")));return b},"Active for:":function(a){var b=(new Date).setSeconds((new Date).getSeconds()-a.active_seconds);return $("<span>").append($("<span>").text(UI.format.duration(a.active_seconds))).append($("<span>").addClass("description").text(" since "+UI.format.time(b/1E3)))},"Pid:":function(a,b){return b},"Logs:":function(a){var b=$("<div>").text("None.");if(a.logs&&a.logs.length){b.html("").addClass("description").css({overflow:"auto",
|
||||
maxHeight:"6em",display:"flex",flexFlow:"column-reverse nowrap"});for(var c in a.logs){var d=a.logs[c];b.prepend($("<div>").append(UI.format.time(d[0])+" ["+d[1]+"] "+d[2]))}}return b},"Additional info:":function(a){var b;if(a.ainfo&&Object.keys(a.ainfo).length){b=$("<table>");for(var c in a.ainfo){var d=mist.data.capabilities.processes[a.process].ainfo[c];d||(d={name:c});b.append($("<tr>").append($("<th>").text(d.name+":")).append($("<td>").html(a.ainfo[c]).append(d.unit?$("<span>").addClass("unit").text(d.unit):
|
||||
"")))}}else b=$("<span>").addClass("description").text("N/A");return b}};Ya.html($("<h4>").text("Stream processes")).append(b);for(var d in c){var f=$("<tr>");b.append(f);f.append($("<th>").text(d).css("vertical-align","top"));for(var g in a.proc_list){$out=c[d](a.proc_list[g],g);f.append($("<td>").html($out).css("vertical-align","top"))}}}},a)};UI.interval.set(function(){Za()},5E3);Za()}break;case "Embed":""==b&&UI.navTo("Streams");X="";-1==b.indexOf("+")&&(X=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",
|
||||
"")))}}else b=$("<span>").addClass("description").text("N/A");return b}};Ya.html($("<h4>").text("Stream processes")).append(b);for(var d in c){var e=$("<tr>");b.append(e);e.append($("<th>").text(d).css("vertical-align","top"));for(var g in a.proc_list){$out=c[d](a.proc_list[g],g);e.append($("<td>").html($out).css("vertical-align","top"))}}}},a)};UI.interval.set(function(){Za()},5E3);Za()}break;case "Embed":""==b&&UI.navTo("Streams");X="";-1==b.indexOf("+")&&(X=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",
|
||||
b)}));c.html($("<div>").addClass("bigbuttons").append(X).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var Z=$("<span>");c.append(Z);var K=encodeURIComponent(b),Q=parseURL(mist.user.host),W=Q.protocol,T=Q.host,J=":8080",aa,ha={},v={http:W+T+J+"/"};for(q in mist.data.config.protocols)if(s=mist.data.config.protocols[q],
|
||||
"HTTP"==s.connector||"HTTP.exe"==s.connector)s.pubaddr?("string"==typeof s.pubaddr?v.http=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(v.http=s.pubaddr[0].replace(/\/$/,"")+"/"),ha.http=s.pubaddr):(J=s.port?":"+s.port:":8080",v.http=W+T+J+"/");else if("HTTPS"==s.connector||"HTTPS.exe"==s.connector)s.pubaddr&&s.pubaddr.length?("string"==typeof s.pubaddr?v.https=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(v.https=s.pubaddr[0].replace(/\/$/,"")+"/"),ha.https=s.pubaddr):(aa=s.port?":"+s.port:
|
||||
":4433",v.https="https://"+T+aa+"/");var R=v.http,D={http:v.http};"https"in v&&(D.https=v.https);if(otherhost.host||otherhost.https){R=(otherhost.https&&aa?"https://":"http://")+(otherhost.host?otherhost.host:Q.host)+(otherhost.https&&aa?aa:J)+"/";if(otherhost.host&&("http"in ha||(D.http=parseURL(D.http,{hostname:otherhost.host}).full),"https"in D&&!("https"in ha)))D.https=parseURL(D.https,{hostname:otherhost.host}).full;R=otherhost.https?D.https:D.http}var ba=!1,va={forcePlayer:"",forceType:"",controls:!0,
|
||||
autoplay:!0,loop:!1,muted:!1,fillSpace:!1,poster:"",urlappend:"",setTracks:{}},n=$.extend({},va),$a=UI.stored.getOpts();"embedoptions"in $a&&(n=$.extend(n,$a.embedoptions,!0),"object"!=typeof n.setTracks&&(n.setTracks={}));var ia={};switch(n.controls){case "stock":ia.controls="stock";break;case !0:ia.controls=1;break;case !1:ia.controls=0}var A=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}ba&&UI.stored.saveOpt("embedoptions",
|
||||
n);for(var c=b+"_",d=12,f="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+61);f=f+g}var c=c+f,d=['target: document.getElementById("'+c+'")'],e;for(e in n)e=="prioritize_type"?n[e]&&n[e]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[n[e]]]]})):e=="monitor_action"?n[e]&&n[e]!=""&&n[e]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'):
|
||||
n[e]!=va[e]&&(n[e]!=null&&(typeof n[e]!="object"||JSON.stringify(n[e])!=JSON.stringify(va[e])))&&d.push(e+": "+a(n[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+(otherhost.https?D.https:D.http)+K+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+b+'",{');e.push(" "+d.join(",\n "));e.push(" });");
|
||||
e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');if("https"in v&&parseURL(v.http).protocol!="https://"){e.push(' if (location.protocol == "https:") { p.src = "'+D.https+'player.js" } ');e.push(' else { p.src = "'+D.http+'player.js" } ')}else e.push(' p.src = "'+R+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>");
|
||||
e.push("</div>");return e.join("\n")},wa=$("<span>").text("Loading.."),ab=A(n),U=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),bb="";"https"in v&&(bb=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));Z.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type",
|
||||
n);for(var c=b+"_",d=12,e="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+61);e=e+g}var c=c+e,d=['target: document.getElementById("'+c+'")'],f;for(f in n)f=="prioritize_type"?n[f]&&n[f]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[n[f]]]]})):f=="monitor_action"?n[f]&&n[f]!=""&&n[f]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'):
|
||||
n[f]!=va[f]&&(n[f]!=null&&(typeof n[f]!="object"||JSON.stringify(n[f])!=JSON.stringify(va[f])))&&d.push(f+": "+a(n[f]));f=[];f.push('<div class="mistvideo" id="'+c+'">');f.push(" <noscript>");f.push(' <a href="'+(otherhost.https?D.https:D.http)+K+'.html" target="_blank">');f.push(" Click here to play this video");f.push(" </a>");f.push(" </noscript>");f.push(" <script>");f.push(" var a = function(){");f.push(' mistPlay("'+b+'",{');f.push(" "+d.join(",\n "));f.push(" });");
|
||||
f.push(" };");f.push(" if (!window.mistplayers) {");f.push(' var p = document.createElement("script");');if("https"in v&&parseURL(v.http).protocol!="https://"){f.push(' if (location.protocol == "https:") { p.src = "'+D.https+'player.js" } ');f.push(' else { p.src = "'+D.http+'player.js" } ')}else f.push(' p.src = "'+R+'player.js"');f.push(" document.head.appendChild(p);");f.push(" p.onload = a;");f.push(" }");f.push(" else { a(); }");f.push(" <\/script>");
|
||||
f.push("</div>");return f.join("\n")},wa=$("<span>").text("Loading.."),ab=A(n),U=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),bb="";"https"in v&&(bb=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));Z.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type",
|
||||
"text").addClass("field").val(otherhost.host?otherhost.host:Q.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=$(this).closest("label").find("input").val();UI.navto("Embed",b)}))))).append(bb)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:R+"json_"+K+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:R+"info_"+K+".js",readonly:!0,
|
||||
clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:R+K+".html",readonly:!0,qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:ab,rows:ab.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},
|
||||
$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},{label:"Prioritize type",type:"select",select:[["","Automatic"]],pointer:{main:n,index:"prioritize_type"},classes:["prioritize_type"],"function":function(){if(ba){n.prioritize_type=$(this).getval();$(".embed_code").setval(A(n))}},help:"Try to use this source type first, but full back to something else if it is not available."},
|
||||
|
@ -193,46 +193,46 @@ $("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help"
|
|||
$(".embed_code").setval(A(n))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:n,index:"loop"},"function":function(){n.loop=$(this).getval();$(".embed_code").setval(A(n))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:n,index:"muted"},"function":function(){n.muted=$(this).getval();$(".embed_code").setval(A(n))},help:"If the video should restart when the end is reached."},
|
||||
{label:"Fill available space",type:"checkbox",pointer:{main:n,index:"fillSpace"},"function":function(){n.fillSpace=$(this).getval();$(".embed_code").setval(A(n))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."},{label:"Poster",type:"str",pointer:{main:n,index:"poster"},"function":function(){n.poster=$(this).getval();$(".embed_code").setval(A(n))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",
|
||||
type:"str",pointer:{main:n,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(){n.urlappend=$(this).getval();$(".embed_code").setval(A(n))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:U,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:n,
|
||||
index:"monitor_action"},"function":function(){n.monitor_action=$(this).getval();$(".embed_code").setval(A(n))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),wa]));$.ajax({type:"GET",url:R+"json_"+K+".js",success:function(a){var b=[],c=Z.find(".field.forceType"),d=Z.find(".field.prioritize_type"),f;for(f in a.source){var e=a.source[f],g=UI.humanMime(e.type);b.push({label:g?g+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",
|
||||
value:e.url,readonly:true,qrcode:true,clipboard:true});g=UI.humanMime(e.type);if(c.children('option[value="'+e.type+'"]').length==0){c.append($("<option>").text(g?g+" ("+e.type+")":UI.format.capital(e.type)).val(e.type));d.append($("<option>").text(g?g+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}}c.val(n.forceType);d.val(n.prioritize_type);wa.html(UI.buildUI(b));U.html("");b={};for(f in a.meta.tracks){c=a.meta.tracks[f];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!=
|
||||
"video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){U.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){f=a[h];if(b[f]&&b[f].length){c=$("<select>").attr("data-type",f).css("flex-grow","1").change(function(){$(this).val()==""?delete n.setTracks[$(this).attr("data-type")]:n.setTracks[$(this).attr("data-type")]=
|
||||
$(this).val();$(".embed_code").setval(A(n))});U.append(c);f=="subtitle"?b[f].unshift(["","No "+f]):b[f].push([-1,"No "+f]);for(var j in b[f])c.append($("<option>").val(b[f][j][0]).text(b[f][j][1]));if(f in n.setTracks){c.val(n.setTracks[f]);if(c.val()==null){c.val("");delete n.setTracks[f];$(".embed_code").setval(A(n))}}}}}else U.closest("label").hide();ba=true},error:function(){wa.html("Error while retrieving stream info.");U.closest("label").hide();n.setTracks={}}});var ja=document.createElement("script");
|
||||
index:"monitor_action"},"function":function(){n.monitor_action=$(this).getval();$(".embed_code").setval(A(n))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),wa]));$.ajax({type:"GET",url:R+"json_"+K+".js",success:function(a){var b=[],c=Z.find(".field.forceType"),d=Z.find(".field.prioritize_type"),e;for(e in a.source){var f=a.source[e],g=UI.humanMime(f.type);b.push({label:g?g+" <span class=description>("+f.type+")</span>":UI.format.capital(f.type),type:"str",
|
||||
value:f.url,readonly:true,qrcode:true,clipboard:true});g=UI.humanMime(f.type);if(c.children('option[value="'+f.type+'"]').length==0){c.append($("<option>").text(g?g+" ("+f.type+")":UI.format.capital(f.type)).val(f.type));d.append($("<option>").text(g?g+" ("+f.type+")":UI.format.capital(f.type)).val(f.type))}}c.val(n.forceType);d.val(n.prioritize_type);wa.html(UI.buildUI(b));U.html("");b={};for(e in a.meta.tracks){c=a.meta.tracks[e];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!=
|
||||
"video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){U.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){e=a[h];if(b[e]&&b[e].length){c=$("<select>").attr("data-type",e).css("flex-grow","1").change(function(){$(this).val()==""?delete n.setTracks[$(this).attr("data-type")]:n.setTracks[$(this).attr("data-type")]=
|
||||
$(this).val();$(".embed_code").setval(A(n))});U.append(c);e=="subtitle"?b[e].unshift(["","No "+e]):b[e].push([-1,"No "+e]);for(var i in b[e])c.append($("<option>").val(b[e][i][0]).text(b[e][i][1]));if(e in n.setTracks){c.val(n.setTracks[e]);if(c.val()==null){c.val("");delete n.setTracks[e];$(".embed_code").setval(A(n))}}}}}else U.closest("label").hide();ba=true},error:function(){wa.html("Error while retrieving stream info.");U.closest("label").hide();n.setTracks={}}});var ja=document.createElement("script");
|
||||
ja.src=v.http+"player.js";document.head.appendChild(ja);ja.onload=function(){var a=Z.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};ja.onerror=function(){document.head.removeChild(this)};break;case "Push":var L=$("<div>").text("Loading..");c.append(L);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,
|
||||
e;for(e in c.push_list)if(a.indexOf(c.push_list[e][0])>-1){d=false;break}}else d=true;if(d)for(e in a)f.find("tr[data-pushid="+a[e]+"]").remove();else b()},{push_list:1})},1E3)}function c(e,g){var h=$("<span>"),j=$("<span>");if(g=="Automatic"&&e.length>=4){var k=function(a,b,c){a=""+("$"+a+" ");switch(Number(b)){case 0:a=a+"is true";break;case 1:a=a+"is false";break;case 2:a=a+("== "+c);break;case 3:a=a+("!= "+c);break;case 10:a=a+("> (numerical) "+c);break;case 11:a=a+(">= (numerical) "+c);break;
|
||||
case 12:a=a+("< (numerical) "+c);break;case 13:a=a+("<= (numerical) "+c);break;case 20:a=a+("> (lexical) "+c);break;case 21:a=a+(">= (lexical) "+c);break;case 22:a=a+("< (lexical) "+c);break;case 23:a=a+("<= (lexical) "+c);break;default:a=a+"comparison operator unknown"}return a};h.append($("<span>").text(e[2]));e[3]&&h.append($("<span>").text(", schedule on "+(new Date(e[3]*1E3)).toLocaleString()));e.length>=5&&e[4]&&h.append($("<span>").text(", complete on "+(new Date(e[4]*1E3)).toLocaleString()));
|
||||
e.length>=8&&e[5]&&h.append($("<span>").text(", starts if "+k(e[5],e[6],e[7])));e.length>=11&&e[8]&&h.append($("<span>").text(", stops if "+k(e[8],e[9],e[10])))}else e.length>=4&&e[2]!=e[3]?h.append($("<span>").text(e[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(e[3])):h.append($("<span>").text(e[2]));k=$("<td>").append($("<button>").text(g=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+
|
||||
" this push?\n"+e[1]+" to "+e[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(g=="Automatic"?"Removing..":"Stopping..")));if(g=="Automatic"){var c=e.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([e[0]])},{push_stop:[e[0]]})}}));if(g=="Automatic"){k.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));k.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+
|
||||
e[1]+" to "+e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var c=$(this);c.text("Stopping pushes..");var g=[],h;for(h in a.push_list)if(e[1]==a.push_list[h][1]&&e[2]==a.push_list[h][2]){g.push(a.push_list[h][0]);f.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(g)},{push_stop:g,push_settings:{wait:0}})}}))}else{if(e.length>=6){var l=
|
||||
e[5];j.append($("<div>").append("Active for: "+UI.format.duration(l.active_seconds))).append($("<div>").append("Data transfered: "+UI.format.bytes(l.bytes))).append($("<div>").append("Media time transfered: "+UI.format.duration(l.mediatime*0.001)));"pkt_retrans_count"in l&&j.append($("<div>").append("Packets retransmitted: "+UI.format.number(l.pkt_retrans_count||0)));"pkt_loss_count"in l&&j.append($("<div>").append("Packets lost: "+UI.format.number(l.pkt_loss_count||0)+" ("+UI.format.addUnit(UI.format.number(l.pkt_loss_perc||
|
||||
0),"%")+" over the last "+UI.format.addUnit(5,"s")+")"))}if(e.length>=5)for(var i in e[4]){l=e[4][i];j.append($("<div>").append(UI.format.time(l[0])+" ["+l[1]+"] "+l[2]))}}return $("<tr>").css("vertical-align","top").attr("data-pushid",e[0]).append($("<td>").text(e[1])).append($("<td>").append(h.children())).append($("<td>").addClass("logs").append(j.children())).append(k)}L.html(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."}]));
|
||||
var d=a.push_settings;d||(d={});var f=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>")).append($("<th>"))),e=f.clone();if("push_list"in a)for(var g in a.push_list)f.append(c(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list){var h=a.push_auto_list[g].slice();h.unshift(-1);e.append(c(h,"Automatic"))}L.append($("<h3>").text("Automatic push settings")).append(UI.buildUI([{label:"Delay before retry",unit:"s",type:"int",
|
||||
f;for(f in c.push_list)if(a.indexOf(c.push_list[f][0])>-1){d=false;break}}else d=true;if(d)for(f in a)e.find("tr[data-pushid="+a[f]+"]").remove();else b()},{push_list:1})},1E3)}function c(f,g){var h=$("<span>"),i=$("<span>");if(g=="Automatic"&&f.length>=4){var k=function(a,b,c){a=""+("$"+a+" ");switch(Number(b)){case 0:a=a+"is true";break;case 1:a=a+"is false";break;case 2:a=a+("== "+c);break;case 3:a=a+("!= "+c);break;case 10:a=a+("> (numerical) "+c);break;case 11:a=a+(">= (numerical) "+c);break;
|
||||
case 12:a=a+("< (numerical) "+c);break;case 13:a=a+("<= (numerical) "+c);break;case 20:a=a+("> (lexical) "+c);break;case 21:a=a+(">= (lexical) "+c);break;case 22:a=a+("< (lexical) "+c);break;case 23:a=a+("<= (lexical) "+c);break;default:a=a+"comparison operator unknown"}return a};h.append($("<span>").text(f[2]));f[3]&&h.append($("<span>").text(", schedule on "+(new Date(f[3]*1E3)).toLocaleString()));f.length>=5&&f[4]&&h.append($("<span>").text(", complete on "+(new Date(f[4]*1E3)).toLocaleString()));
|
||||
f.length>=8&&f[5]&&h.append($("<span>").text(", starts if "+k(f[5],f[6],f[7])));f.length>=11&&f[8]&&h.append($("<span>").text(", stops if "+k(f[8],f[9],f[10])))}else f.length>=4&&f[2]!=f[3]?h.append($("<span>").text(f[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(f[3])):h.append($("<span>").text(f[2]));k=$("<td>").append($("<button>").text(g=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+
|
||||
" this push?\n"+f[1]+" to "+f[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(g=="Automatic"?"Removing..":"Stopping..")));if(g=="Automatic"){var c=f.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([f[0]])},{push_stop:[f[0]]})}}));if(g=="Automatic"){k.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));k.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+
|
||||
f[1]+" to "+f[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var c=$(this);c.text("Stopping pushes..");var g=[],h;for(h in a.push_list)if(f[1]==a.push_list[h][1]&&f[2]==a.push_list[h][2]){g.push(a.push_list[h][0]);e.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(g)},{push_stop:g,push_settings:{wait:0}})}}))}else{if(f.length>=6){var l=
|
||||
f[5];i.append($("<div>").append("Active for: "+UI.format.duration(l.active_seconds))).append($("<div>").append("Data transfered: "+UI.format.bytes(l.bytes))).append($("<div>").append("Media time transfered: "+UI.format.duration(l.mediatime*0.001)));"pkt_retrans_count"in l&&i.append($("<div>").append("Packets retransmitted: "+UI.format.number(l.pkt_retrans_count||0)));"pkt_loss_count"in l&&i.append($("<div>").append("Packets lost: "+UI.format.number(l.pkt_loss_count||0)+" ("+UI.format.addUnit(UI.format.number(l.pkt_loss_perc||
|
||||
0),"%")+" over the last "+UI.format.addUnit(5,"s")+")"))}if(f.length>=5)for(var j in f[4]){l=f[4][j];i.append($("<div>").append(UI.format.time(l[0])+" ["+l[1]+"] "+l[2]))}}return $("<tr>").css("vertical-align","top").attr("data-pushid",f[0]).append($("<td>").text(f[1])).append($("<td>").append(h.children())).append($("<td>").addClass("logs").append(i.children())).append(k)}L.html(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."}]));
|
||||
var d=a.push_settings;d||(d={});var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>")).append($("<th>"))),f=e.clone();if("push_list"in a)for(var g in a.push_list)e.append(c(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list){var h=a.push_auto_list[g].slice();h.unshift(-1);f.append(c(h,"Automatic"))}L.append($("<h3>").text("Automatic push settings")).append(UI.buildUI([{label:"Delay before retry",unit:"s",type:"int",
|
||||
min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":3,pointer:{main:d,index:"wait"}},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"}},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}])).append($("<h3>").text("Automatic push settings")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push",
|
||||
"auto")}));e.find("tr").length==1?L.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):L.append(e);L.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(f.find("tr").length==1)L.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var e=[],h=[],j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),
|
||||
k=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(g in a.push_list){e.indexOf(a.push_list[g][1])==-1&&e.push(a.push_list[g][1]);h.indexOf(a.push_list[g][2])==-1&&h.push(a.push_list[g][2])}e.sort();h.sort();for(g in e)j.append($("<option>").text(e[g]));for(g in h)k.append($("<option>").text(h[g]));L.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},
|
||||
{push_stop:c});f.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(j).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(k).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=j.val(),d=k.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");
|
||||
var e={},g;for(g in a.push_list)if((c==""||a.push_list[g][1]==c)&&(d==""||a.push_list[g][2]==d))e[a.push_list[g][0]]=a.push_list[g];if(Object.keys(e).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(g in e)c=c+(e[g][1]+" to "+e[g][2]+"\n");if(confirm(c)){e=Object.keys(e);mist.send(function(){b(e)},{push_stop:e});for(g in e)f.find("tr[data-pushid="+e[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(f)}UI.interval.set(function(){mist.send(function(a){var b=
|
||||
f.find("tr").first();f.empty();f.append(b);for(var d in a.push_list)f.append(c(a.push_list[d]))},{push_list:1})},5E3)},{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)||!("variable_list"in mist.data)||!("external_writer_list"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1,variable_list:!0,external_writer_list:!0});return}var y,ka=function(a){var d=false,e=b.split("_");b=e[0];
|
||||
e.length==2&&(d=e[1]);if(d!==false&&typeof a=="undefined")mist.send(function(a){ka(a.push_auto_list[d])},{push_auto_list:1});else{var f=[],g=[],h={},j=[],k;for(k in mist.data.capabilities.connectors){e=mist.data.capabilities.connectors[k];if("push_urls"in e){h[k]=e.push_urls;for(var l in e.push_urls)e.push_urls[l][0]=="/"?f.push(e.push_urls[l]):g.push(e.push_urls[l])}}if(mist.data.external_writer_list)for(k in mist.data.external_writer_list){e=mist.data.external_writer_list[k];if(e.length>=3)for(l in e[2])j.push(e[2][l]+
|
||||
"://")}f.sort();g.sort();b=="auto"&&c.find("h2").text("Add automatic push");var i={params:{}},m=[];if(b=="auto"&&typeof a!="undefined"){i={stream:a[0],target:a[1],params:{}};l=i.target.split("?");if(l.length>1){m=l.pop();i.target=l.join("?");m=m.split("&");for(k in m){l=m[k].split("=");i.params[l.shift()]=l.join("=")}}if(a.length>=3)i.scheduletime=a[2]!=0?a[2]:null;if(a.length>=4)i.completetime=a[3]!=0?a[3]:null;if(a.length>=5)i.startVariableName=a[4]!=""?a[4]:null;if(a.length>=6)i.startVariableOperator=
|
||||
a[5]!=""?a[5]:null;if(a.length>=7)i.startVariableValue=a[6]!=""?a[6]:null;if(a.length>=8)i.endVariableName=a[7]!=""?a[7]:null;if(a.length>=9)i.endVariableOperator=a[8]!=""?a[8]:null;if(a.length>=10)i.endVariableValue=a[9]!=""?a[9]:null}var q=$("<div>").css("margin","1em 0"),n=$("<div>"),o;if(b=="auto"){n.css("margin","1em 0").html(UI.buildUI([{label:"This push should be active",help:"When 'based on server time' is selected, a start and/or end timestamp can be configured. When it's 'based on a variable', the push will be activated while the specified variable matches the specified value.",
|
||||
type:"select",select:[["time","Based on server time"],["variable","Based on a variable"]],value:i.startVariableName||i.endVariableName?"variable":"time",classes:["activewhen"],"function":function(){var a=n.find(".varbased").closest(".UIelement"),b=n.find(".timebased").closest(".UIelement");if($(this).getval()=="time"){a.hide();b.css("display","")}else{b.hide();a.css("display","");n.find('[name="startVariableOperator"]').trigger("change");n.find('[name="endVariableOperator"]').trigger("change")}}},
|
||||
$("<br>"),$("<span>").addClass("UIelement").append($("<h3>").text("Start the push").addClass("varbased")),{classes:["varbased"],label:"Use this variable",type:"str",help:"This variable should be used to determine if this push should be started.",prefix:"$",datalist:Object.keys(mist.data.variable_list||[]),pointer:{main:i,index:"startVariableName"}},{classes:["varbased"],label:"Comparison operator",type:"select",select:[[0,"is true"],[1,"is false"],[2,"=="],[3,"!="],[10,"> (numerical)"],[11,">= (numerical)"],
|
||||
[12,"< (numerical)"],[13,"<= (numerical)"],[20,"> (lexical)"],[21,">= (lexical)"],[22,"< (lexical)"],[23,"<= (lexical)"]],value:2,css:{display:"none"},help:"How would you like to compare this variable?",pointer:{main:i,index:"startVariableOperator"},"function":function(){var a=n.find('[name="startVariableValue"]').closest(".UIelement");Number($(this).getval())<2?a.hide():a.css("display","")}},{classes:["varbased"],label:"Variable value",type:"str",help:"The variable will be compared with this value to determine if this push should be started.<br>You can also enter another variable here!",
|
||||
datalist:Object.values(mist.data.variable_list||[]).map(function(a){return typeof a=="string"?a:a[3]}).concat(Object.keys(mist.data.variable_list||[]).map(function(a){return"$"+a})),pointer:{main:i,index:"startVariableValue"}},$("<span>").addClass("UIelement").append($("<h3>").text("Stop the push").addClass("varbased")),{classes:["varbased"],label:"Use this variable",type:"str",help:"This variable should be used to determine if this push should be stopped.<br>You can leave this field blank if you do not want to have a stop condition. (You can always stop the push manually)",
|
||||
prefix:"$",datalist:Object.keys(mist.data.variable_list||[]),pointer:{main:i,index:"endVariableName"}},{classes:["varbased"],label:"Comparison operator",type:"select",select:[[0,"is true"],[1,"is false"],[2,"=="],[3,"!="],[10,"> (numerical)"],[11,">= (numerical)"],[12,"< (numerical)"],[13,"<= (numerical)"],[20,"> (lexical)"],[21,">= (lexical)"],[22,"< (lexical)"],[23,"<= (lexical)"]],value:2,help:"How would you like to compare this variable?",pointer:{main:i,index:"endVariableOperator"},"function":function(){var a=
|
||||
n.find('[name="endVariableValue"]').closest(".UIelement");Number($(this).getval())<2?a.hide():a.css("display","")}},{classes:["varbased"],label:"Variable value",type:"str",help:"The variable will be compared with this value to determine if this push should be stopped.<br>You can also enter another variable here!",datalist:Object.values(mist.data.variable_list||[]).map(function(a){return typeof a=="string"?a:a[3]}).concat(Object.keys(mist.data.variable_list||[]).map(function(a){return"$"+a})),pointer:{main:i,
|
||||
index:"endVariableValue"}},{classes:["timebased"],type:"unix",label:"Start time",min:0,help:"The time where the push will become active. The default is to start immediately.",pointer:{main:i,index:"scheduletime"}},{classes:["timebased"],type:"unix",label:"End time",min:0,help:"The time where the push will stop. Defaults to never stop automatically.<br>Only makes sense for live streams.",pointer:{main:i,index:"completetime"}}],i));n.find(".activewhen").trigger("change")}k=[{label:"Stream name",type:"str",
|
||||
"auto")}));f.find("tr").length==1?L.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):L.append(f);L.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)L.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var f=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),
|
||||
k=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(g in a.push_list){f.indexOf(a.push_list[g][1])==-1&&f.push(a.push_list[g][1]);h.indexOf(a.push_list[g][2])==-1&&h.push(a.push_list[g][2])}f.sort();h.sort();for(g in f)i.append($("<option>").text(f[g]));for(g in h)k.append($("<option>").text(h[g]));L.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},
|
||||
{push_stop:c});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(k).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=k.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");
|
||||
var f={},g;for(g in a.push_list)if((c==""||a.push_list[g][1]==c)&&(d==""||a.push_list[g][2]==d))f[a.push_list[g][0]]=a.push_list[g];if(Object.keys(f).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(g in f)c=c+(f[g][1]+" to "+f[g][2]+"\n");if(confirm(c)){f=Object.keys(f);mist.send(function(){b(f)},{push_stop:f});for(g in f)e.find("tr[data-pushid="+f[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}UI.interval.set(function(){mist.send(function(a){var b=
|
||||
e.find("tr").first();e.empty();e.append(b);for(var d in a.push_list)e.append(c(a.push_list[d]))},{push_list:1})},5E3)},{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)||!("variable_list"in mist.data)||!("external_writer_list"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1,variable_list:!0,external_writer_list:!0});return}var y,ka=function(a){var d=false,f=b.split("_");b=f[0];
|
||||
f.length==2&&(d=f[1]);if(d!==false&&typeof a=="undefined")mist.send(function(a){ka(a.push_auto_list[d])},{push_auto_list:1});else{var e=[],g=[],h={},i=[],k;for(k in mist.data.capabilities.connectors){f=mist.data.capabilities.connectors[k];if("push_urls"in f){h[k]=f.push_urls;for(var l in f.push_urls)f.push_urls[l][0]=="/"?e.push(f.push_urls[l]):g.push(f.push_urls[l])}}if(mist.data.external_writer_list)for(k in mist.data.external_writer_list){f=mist.data.external_writer_list[k];if(f.length>=3)for(l in f[2])i.push(f[2][l]+
|
||||
"://")}e.sort();g.sort();b=="auto"&&c.find("h2").text("Add automatic push");var j={params:{}},m=[];if(b=="auto"&&typeof a!="undefined"){j={stream:a[0],target:a[1],params:{}};l=j.target.split("?");if(l.length>1){m=l.pop();j.target=l.join("?");m=m.split("&");for(k in m){l=m[k].split("=");j.params[l.shift()]=l.join("=")}}if(a.length>=3)j.scheduletime=a[2]!=0?a[2]:null;if(a.length>=4)j.completetime=a[3]!=0?a[3]:null;if(a.length>=5)j.startVariableName=a[4]!=""?a[4]:null;if(a.length>=6)j.startVariableOperator=
|
||||
a[5]!=""?a[5]:null;if(a.length>=7)j.startVariableValue=a[6]!=""?a[6]:null;if(a.length>=8)j.endVariableName=a[7]!=""?a[7]:null;if(a.length>=9)j.endVariableOperator=a[8]!=""?a[8]:null;if(a.length>=10)j.endVariableValue=a[9]!=""?a[9]:null}var q=$("<div>").css("margin","1em 0"),n=$("<div>"),o;if(b=="auto"){n.css("margin","1em 0").html(UI.buildUI([{label:"This push should be active",help:"When 'based on server time' is selected, a start and/or end timestamp can be configured. When it's 'based on a variable', the push will be activated while the specified variable matches the specified value.",
|
||||
type:"select",select:[["time","Based on server time"],["variable","Based on a variable"]],value:j.startVariableName||j.endVariableName?"variable":"time",classes:["activewhen"],"function":function(){var a=n.find(".varbased").closest(".UIelement"),b=n.find(".timebased").closest(".UIelement");if($(this).getval()=="time"){a.hide();b.css("display","")}else{b.hide();a.css("display","");n.find('[name="startVariableOperator"]').trigger("change");n.find('[name="endVariableOperator"]').trigger("change")}}},
|
||||
$("<br>"),$("<span>").addClass("UIelement").append($("<h3>").text("Start the push").addClass("varbased")),{classes:["varbased"],label:"Use this variable",type:"str",help:"This variable should be used to determine if this push should be started.",prefix:"$",datalist:Object.keys(mist.data.variable_list||[]),pointer:{main:j,index:"startVariableName"}},{classes:["varbased"],label:"Comparison operator",type:"select",select:[[0,"is true"],[1,"is false"],[2,"=="],[3,"!="],[10,"> (numerical)"],[11,">= (numerical)"],
|
||||
[12,"< (numerical)"],[13,"<= (numerical)"],[20,"> (lexical)"],[21,">= (lexical)"],[22,"< (lexical)"],[23,"<= (lexical)"]],value:2,css:{display:"none"},help:"How would you like to compare this variable?",pointer:{main:j,index:"startVariableOperator"},"function":function(){var a=n.find('[name="startVariableValue"]').closest(".UIelement");Number($(this).getval())<2?a.hide():a.css("display","")}},{classes:["varbased"],label:"Variable value",type:"str",help:"The variable will be compared with this value to determine if this push should be started.<br>You can also enter another variable here!",
|
||||
datalist:Object.values(mist.data.variable_list||[]).map(function(a){return typeof a=="string"?a:a[3]}).concat(Object.keys(mist.data.variable_list||[]).map(function(a){return"$"+a})),pointer:{main:j,index:"startVariableValue"}},$("<span>").addClass("UIelement").append($("<h3>").text("Stop the push").addClass("varbased")),{classes:["varbased"],label:"Use this variable",type:"str",help:"This variable should be used to determine if this push should be stopped.<br>You can leave this field blank if you do not want to have a stop condition. (You can always stop the push manually)",
|
||||
prefix:"$",datalist:Object.keys(mist.data.variable_list||[]),pointer:{main:j,index:"endVariableName"}},{classes:["varbased"],label:"Comparison operator",type:"select",select:[[0,"is true"],[1,"is false"],[2,"=="],[3,"!="],[10,"> (numerical)"],[11,">= (numerical)"],[12,"< (numerical)"],[13,"<= (numerical)"],[20,"> (lexical)"],[21,">= (lexical)"],[22,"< (lexical)"],[23,"<= (lexical)"]],value:2,help:"How would you like to compare this variable?",pointer:{main:j,index:"endVariableOperator"},"function":function(){var a=
|
||||
n.find('[name="endVariableValue"]').closest(".UIelement");Number($(this).getval())<2?a.hide():a.css("display","")}},{classes:["varbased"],label:"Variable value",type:"str",help:"The variable will be compared with this value to determine if this push should be stopped.<br>You can also enter another variable here!",datalist:Object.values(mist.data.variable_list||[]).map(function(a){return typeof a=="string"?a:a[3]}).concat(Object.keys(mist.data.variable_list||[]).map(function(a){return"$"+a})),pointer:{main:j,
|
||||
index:"endVariableValue"}},{classes:["timebased"],type:"unix",label:"Start time",min:0,help:"The time where the push will become active. The default is to start immediately.",pointer:{main:j,index:"scheduletime"}},{classes:["timebased"],type:"unix",label:"End time",min:0,help:"The time where the push will stop. Defaults to never stop automatically.<br>Only makes sense for live streams.",pointer:{main:j,index:"completetime"}}],j));n.find(".activewhen").trigger("change")}k=[{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:i,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["orange"],"break":false}}],datalist:y},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid push formats: <ul> <li>"+g.join("</li><li>")+"</li> </ul> Valid file formats: <ul> <li>"+f.join("</li><li>")+
|
||||
"</li> </ul> "+(j.length?"Additionally, the following protocols (from generic writers) may be used in combination with any of the above file formats:<ul><li>"+j.join("</li><li>")+"</li></ul>":"")+" Valid text replacements: <ul> <li>$stream - inserts the stream name used to push to MistServer</li> <li>$day - inserts the current day number</li><li>$month - inserts the current month number</li> <li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li> <li>$minute - inserts the minute timestamp the stream was received</li> <li>$seconds - inserts the seconds timestamp when the stream was received</li> <li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li> </ul>",
|
||||
pointer:{main:i,index:"target"},validate:["required",function(a){for(var b in g)if(mist.inputMatch(g[b],a))return false;for(b in f){if(mist.inputMatch(f[b],a))return false;for(var c in j)if(mist.inputMatch(j[c]+f[b].slice(1),a))return false}return{msg:"Does not match a valid target.<br>Valid push formats: <ul> <li>"+g.join("</li><li>")+"</li> </ul> Valid file formats: <ul> <li>"+f.join("</li><li>")+
|
||||
"</li> </ul> "+(j.length?"Additionally, the following protocols may be used in combination with any of the above file formats:<ul><li>"+j.join("</li><li>")+"</li></ul>":""),classes:["red"]}}],"function":function(){var a=false,b=$(this).getval();for(connector in h)for(var c in h[connector]){if(mist.inputMatch(h[connector][c],b)){a=connector;break}if(h[connector][c][0]=="/")for(var d in j)if(mist.inputMatch(j[d]+h[connector][c].slice(1),b)){a=connector;break}}if(a){q.html($("<h3>").text(mist.data.capabilities.connectors[a].friendly.replace("over HTTP",
|
||||
"")));o={};for(c in mist.data.capabilities.connectors[a].push_parameters){d=mist.data.capabilities.connectors[a].push_parameters[c];if(!d.prot_only||!(String().match&&b.match(/.+\:\/\/.+/)===null))d.file_only&&b[0]!="/"||(o[c]=d)}a={desc:mist.data.capabilities.connectors[a].desc.replace("over HTTP",""),optional:o,sort:"sort"};a=mist.convertBuildOptions(a,i.params);b=[];for(c in m){d=m[c].split("=");var e=d[0];e in o||b.push(e+(d.length>1?"="+d.slice(1).join("="):""))}a.push($("<br>"));a.push({type:"inputlist",
|
||||
label:"Custom url parameters",value:b,classes:["custom_url_parameters"],input:{type:"str",placeholder:"name=value",prefix:""},help:"Any custom url parameters not covered by the parameters configurable above.",pointer:{main:i,index:"custom_url_params"}});q.append(UI.buildUI(a))}else q.html($("<h4>").addClass("red").text("Unrecognized target.")).append($("<span>").text("Please edit the push target."))}},n,q];k.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},
|
||||
{type:"save",label:"Save",preSave:function(){delete i.startVariableName;delete i.startVariableOperator;delete i.startVariableValue;delete i.endVariableName;delete i.endVariableOperator;delete i.endVariableValue;delete i.completetime;delete i.scheduletime},"function":function(){var c=i.params,d;for(d in c)c[d]===null?delete c[d]:d in o||delete c[d];if(i.startVariableName||i.endVariableName){i.scheduletime=0;i.completetime=0}if(i.startVariableName===null){delete i.startVariableName;delete i.startVariableOperator;
|
||||
delete i.startVariableValue}if(i.endVariableName===null){delete i.endVariableName;delete i.endVariableOperator;delete i.endVariableValue}if(i.scheduletime)c.recstartunix=i.scheduletime;if(Object.keys(c).length||i.custom_url_params&&i.custom_url_params.length){var e="?",f=i.target.split("?");if(f.length>1){e="&";f=f[f.length-1];f=f.split("&");for(d in f){var g=f[d].split("=")[0];g in c&&delete c[g]}}if(Object.keys(c).length||i.custom_url_params&&i.custom_url_params.length){f=[];for(d in c)f.push(d+
|
||||
"="+c[d]);for(d in i.custom_url_params)f.push(i.custom_url_params[d]);e=e+f.join("&");i.target=i.target+e}}delete i.params;delete i.custom_url_params;c={};c[b=="auto"?"push_auto_add":"push_start"]=i;if(typeof a!="undefined"&&(a[0]!=i.stream||a[1]!=i.target))c.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},c)}}]});c.append(UI.buildUI(k))}};mist.data.LTS?mist.send(function(a){(y=a.active_streams)||(y=[]);var a=[],b;for(b in y)y[b].indexOf("+")!=-1&&a.push(y[b].replace(/\+.*/,"")+"+");y=
|
||||
y.concat(a);var c=0,d=0;for(b in mist.data.streams){y.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){y.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||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[f])&&y.push(e+"+"+a.browse.files[f]);d++;if(c==
|
||||
pointer:{main:j,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["orange"],"break":false}}],datalist:y},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid push formats: <ul> <li>"+g.join("</li><li>")+"</li> </ul> Valid file formats: <ul> <li>"+e.join("</li><li>")+
|
||||
"</li> </ul> "+(i.length?"Additionally, the following protocols (from generic writers) may be used in combination with any of the above file formats:<ul><li>"+i.join("</li><li>")+"</li></ul>":"")+" Valid text replacements: <ul> <li>$stream - inserts the stream name used to push to MistServer</li> <li>$day - inserts the current day number</li><li>$month - inserts the current month number</li> <li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li> <li>$minute - inserts the minute timestamp the stream was received</li> <li>$seconds - inserts the seconds timestamp when the stream was received</li> <li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li> </ul>",
|
||||
pointer:{main:j,index:"target"},validate:["required",function(a){for(var b in g)if(mist.inputMatch(g[b],a))return false;for(b in e){if(mist.inputMatch(e[b],a))return false;for(var c in i)if(mist.inputMatch(i[c]+e[b].slice(1),a))return false}return{msg:"Does not match a valid target.<br>Valid push formats: <ul> <li>"+g.join("</li><li>")+"</li> </ul> Valid file formats: <ul> <li>"+e.join("</li><li>")+
|
||||
"</li> </ul> "+(i.length?"Additionally, the following protocols may be used in combination with any of the above file formats:<ul><li>"+i.join("</li><li>")+"</li></ul>":""),classes:["red"]}}],"function":function(){var a=false,b=$(this).getval();for(connector in h)for(var c in h[connector]){if(mist.inputMatch(h[connector][c],b)){a=connector;break}if(h[connector][c][0]=="/")for(var d in i)if(mist.inputMatch(i[d]+h[connector][c].slice(1),b)){a=connector;break}}if(a){q.html($("<h3>").text(mist.data.capabilities.connectors[a].friendly.replace("over HTTP",
|
||||
"")));o={};for(c in mist.data.capabilities.connectors[a].push_parameters){d=mist.data.capabilities.connectors[a].push_parameters[c];if(!d.prot_only||!(String().match&&b.match(/.+\:\/\/.+/)===null))d.file_only&&b[0]!="/"||(o[c]=d)}a={desc:mist.data.capabilities.connectors[a].desc.replace("over HTTP",""),optional:o,sort:"sort"};a=mist.convertBuildOptions(a,j.params);b=[];for(c in m){d=m[c].split("=");var f=d[0];f in o||b.push(f+(d.length>1?"="+d.slice(1).join("="):""))}a.push($("<br>"));a.push({type:"inputlist",
|
||||
label:"Custom url parameters",value:b,classes:["custom_url_parameters"],input:{type:"str",placeholder:"name=value",prefix:""},help:"Any custom url parameters not covered by the parameters configurable above.",pointer:{main:j,index:"custom_url_params"}});q.append(UI.buildUI(a))}else q.html($("<h4>").addClass("red").text("Unrecognized target.")).append($("<span>").text("Please edit the push target."))}},n,q];k.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},
|
||||
{type:"save",label:"Save",preSave:function(){delete j.startVariableName;delete j.startVariableOperator;delete j.startVariableValue;delete j.endVariableName;delete j.endVariableOperator;delete j.endVariableValue;delete j.completetime;delete j.scheduletime},"function":function(){var c=j.params,d;for(d in c)c[d]===null?delete c[d]:d in o||delete c[d];if(j.startVariableName||j.endVariableName){j.scheduletime=0;j.completetime=0}if(j.startVariableName===null){delete j.startVariableName;delete j.startVariableOperator;
|
||||
delete j.startVariableValue}if(j.endVariableName===null){delete j.endVariableName;delete j.endVariableOperator;delete j.endVariableValue}if(j.scheduletime)c.recstartunix=j.scheduletime;if(Object.keys(c).length||j.custom_url_params&&j.custom_url_params.length){var f="?",e=j.target.split("?");if(e.length>1){f="&";e=e[e.length-1];e=e.split("&");for(d in e){var g=e[d].split("=")[0];g in c&&delete c[g]}}if(Object.keys(c).length||j.custom_url_params&&j.custom_url_params.length){e=[];for(d in c)e.push(d+
|
||||
"="+c[d]);for(d in j.custom_url_params)e.push(j.custom_url_params[d]);f=f+e.join("&");j.target=j.target+f}}delete j.params;delete j.custom_url_params;c={};c[b=="auto"?"push_auto_add":"push_start"]=j;if(typeof a!="undefined"&&(a[0]!=j.stream||a[1]!=j.target))c.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},c)}}]});c.append(UI.buildUI(k))}};mist.data.LTS?mist.send(function(a){(y=a.active_streams)||(y=[]);var a=[],b;for(b in y)y[b].indexOf("+")!=-1&&a.push(y[b].replace(/\+.*/,"")+"+");y=
|
||||
y.concat(a);var c=0,d=0;for(b in mist.data.streams){y.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){y.push(b+"+");mist.send(function(a,b){var f=b.stream,e;for(e in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||(g.indexOf("Folder")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&y.push(f+"+"+a.browse.files[e]);d++;if(c==
|
||||
d){y=y.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ka()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){y=y.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ka()}},{active_streams:1}):(y=Object.keys(mist.data.streams),ka());break;case "Triggers":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};var F=$("<tbody>"),cb=$("<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(F);c.append(UI.buildUI([{type:"help",help:"Triggers are a way to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(cb);
|
||||
cb.stupidtable();var xa=mist.data.config.triggers;for(q in xa)for(var db in xa[q]){var ya=triggerRewrite(xa[q][db]);F.append($("<tr>").attr("data-index",q+","+db).append($("<td>").text(q)).append($("<td>").text("streams"in ya?ya.streams.join(", "):"")).append($("<td>").text(ya.handler)).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");
|
||||
|
@ -246,15 +246,15 @@ pointer:{main:p,index:"async"}},{label:"Parameters",type:"str",help:$("<div>").t
|
|||
1);var a={handler:p.url,sync:p.async?true:false,streams:typeof p.appliesto=="undefined"?[]:p.appliesto,params:p.params,"default":p["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};p.triggeron in mist.data.config.triggers||(mist.data.config.triggers[p.triggeron]=[]);mist.data.config.triggers[p.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var gb=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");
|
||||
mist.send(function(){Aa();gb.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.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(){Aa()})},
|
||||
$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:gb,help:"Instantly refresh the table below."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));F=$("<tbody>").css("font-size","0.9em");c.append($("<table>").addClass("logs").append(F));var kb=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},
|
||||
Aa=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();F.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),e;for(e in d)c.append($("<span>").text(d[e]));F.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(kb(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};Aa();break;case "Statistics":var H=$("<span>").text("Loading..");
|
||||
Aa=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();F.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),f;for(f in d)c.append($("<span>").text(d[f]));F.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(kb(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};Aa();break;case "Statistics":var H=$("<span>").text("Loading..");
|
||||
c.append(H);var p={graph:"new"},B=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},da={};for(q in mist.data.streams)da[q]=!0;for(q in mist.data.active_streams)da[mist.data.active_streams[q]]=!0;var da=Object.keys(da).sort(),Ba=[];for(q in mist.data.config.protocols)Ba.push(mist.data.config.protocols[q].connector);Ba.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;H.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:p,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=H.find(".graph_xaxis"),b=H.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",
|
||||
false);b.setval("Graph "+(Object.keys(B).length+1)).closest("label").show()}else{var c=B[$(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:p,index:"id"},classes:["graph_id"],validate:[function(a){return a in B?{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:p,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=H.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"],["perc_lost","Lost packages"],["perc_retrans","Re-transmitted packages"]],pointer:{main:p,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=H.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:",da],["protocol","The protocol:",Ba]],pointer:{main:p,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(p.graph=="new"){a=UI.plot.addGraph(p,b);B[a.id]=a;H.find("input.graph_id").val("");
|
||||
H.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=B[p.graph];var c=UI.plot.datatype.getOptions({datatype:p.datatype,origin:p.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(B)}}]}]));var b=$("<div>").addClass("graph_container");c.append(b);var d=H.find("select.graph_ids");for(a in B){var e=UI.plot.addGraph(B[a],b);d.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in B[a].datasets){var h=UI.plot.datatype.getOptions({datatype:B[a].datasets[g].datatype,
|
||||
origin:B[a].datasets[g].origin});f.push(h)}e.datasets=f;B[e.id]=e}d.trigger("change");UI.plot.go(B);UI.interval.set(function(){UI.plot.go(B)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var Ca=$("<table>"),O=$("<table>"),hb={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(q in mist.data.capabilities.cpu){var la=
|
||||
H.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=B[p.graph];var c=UI.plot.datatype.getOptions({datatype:p.datatype,origin:p.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(B)}}]}]));var b=$("<div>").addClass("graph_container");c.append(b);var d=H.find("select.graph_ids");for(a in B){var f=UI.plot.addGraph(B[a],b);d.append($("<option>").text(f.id)).val(f.id);var e=[],g;for(g in B[a].datasets){var h=UI.plot.datatype.getOptions({datatype:B[a].datasets[g].datatype,
|
||||
origin:B[a].datasets[g].origin});e.push(h)}f.datasets=e;B[f.id]=f}d.trigger("change");UI.plot.go(B);UI.interval.set(function(){UI.plot.go(B)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var Ca=$("<table>"),O=$("<table>"),hb={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(q in mist.data.capabilities.cpu){var la=
|
||||
mist.data.capabilities.cpu[q];hb.content.push({header:"CPU #"+(Number(q)+1),body:[la.model,UI.format.addUnit(UI.format.number(la.mhz),"MHz"),la.cores,la.threads]})}var lb=UI.buildVheaderTable(hb),ib=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);Ca.replaceWith(a);Ca=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);O.replaceWith(b);O=b};ib();c.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(Ca)).append($("<td>").append(O))).append($("<tr>").append($("<td>").append(lb).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){ib()},
|
||||
|
@ -262,29 +262,29 @@ mist.data.capabilities.cpu[q];hb.content.push({header:"CPU #"+(Number(q)+1),body
|
|||
index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:p,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:p,index:"subject"}},{type:"hidden",value:"-",pointer:{main:p,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:p,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:I,pointer:{main:p,index:"configfile"}},{type:"buttons",buttons:[{type:"save",
|
||||
label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"https://mistserver.org/contact?skin=plain",data:p,success:function(a){a=$("<span>").html(a);a.find("script").remove();c.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:c.append($("<p>").text("This tab does not exist."))}c.find(".field").filter(function(){var a=$(this).getval();
|
||||
return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api";
|
||||
var mist={data:{},user:{name:"",password:"",host:host},send:function(a,b,c){var b=b||{},c=c||{},c=$.extend(true,{timeOut:3E4,sendData:b},c),d={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,d,b);log("Send",$.extend(true,{},b));var f={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:true,timeout:c.timeout*1E3,async:true,error:function(d,e,f){console.warn("connection failed :(",
|
||||
f);delete mist.user.loggedin;if(!c.hide){switch(e){case "timeout":e=$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append($("<span>").text(e)).append($("<a>").text("Send server request again").click(function(){mist.send(a,b,c)}))}UI.navto("Login")},
|
||||
success:function(f){log("Receive",$.extend(true,{},f),"as reply to",c.sendData);delete mist.user.loggedin;switch(f.authorize.status){case "OK":if("streams"in f)if(f.streams)if("incomplete list"in f.streams){delete f.streams["incomplete list"];$.extend(mist.data.streams,f.streams)}else mist.data.streams=f.streams;else mist.data.streams={};var e=$.extend({},f),i=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth","variable_list","external_writer_list"],
|
||||
o;for(o in e)i.indexOf(o)==-1&&delete e[o];if("bandwidth"in d&&!("bandwidth"in f))e.bandwidth=null;$.extend(mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));if(f.log){e=f.log[f.log.length-1];UI.elements.connection.msg.append($("<br>")).append($("<span>").text("Last log entry: "+
|
||||
UI.format.time(e[0])+" ["+e[1]+"] "+e[2]))}if("totals"in f){e=function(a,b,c){var d;d=function(){for(var a in c.fields)f[c.fields[a]].push([m,0])};var f={},e;for(e in c.fields)f[c.fields[e]]=[];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(e in c.data){if(e==0){m=c.start*1E3;var o=0}else{m=m+c.interval[o][1]*1E3;c.interval[o][0]--;if(c.interval[o][0]<=0){o++;o<c.interval.length-1&&(i=i+2)}}if(i%2==1){d();i--}for(var t in c.data[e])f[c.fields[t]].push([m,
|
||||
c.data[e][t]]);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=f;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in f.totals)e(b.totals.streams,
|
||||
b.totals.protocols,f.totals);else for(o in f.totals)e(b.totals[o].streams,b.totals[o].protocols,f.totals[o])}a&&a(f,c);break;case "CHALL":if(f.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=f.authorize.challenge;mist.send(a,b,c);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,
|
||||
name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete b.authorize;mist.send(a,b,c);break;default:UI.navto("Login")}}};c.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){i.abort()}));var i=$.ajax(f)},inputMatch:function(a,b){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var c in a){var d=
|
||||
a[c].replace(/[^\w\s]/g,"\\$&"),d=d.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+d+"(?:\\?[^\\?]*)?$","i").test(b))return true}return false},convertBuildOptions:function(a,b){function c(a,c,d){var e={label:UI.format.capital(d.name?d.name:c),pointer:{main:b,index:c},validate:[]};f[a]=="required"&&(!("default"in d)||d["default"]=="")&&e.validate.push("required");if("default"in d){e.placeholder=d["default"];if(d.type=="select")for(var i in d.select)if(d.select[i][0]==d["default"]){e.placeholder=
|
||||
d.select[i][1];break}}if("help"in d)e.help=d.help;if("unit"in d)e.unit=d.unit;if("placeholder"in d)e.placeholder=d.placeholder;if("type"in d)switch(d.type){case "int":e.type="int";if("max"in d)e.max=d.max;if("min"in d)e.min=d.min;break;case "uint":e.type="int";e.min=0;if("max"in d)e.max=d.max;if("min"in d)e.min=Math.max(e.min,d.min);break;case "radioselect":e.type="radioselect";e.radioselect=d.radioselect;break;case "select":e.type="select";e.select=d.select.slice(0);e.validate.indexOf("required")>=
|
||||
0&&e.select.unshift(["","placeholder"in e?"Default ("+e.placeholder+")":""]);break;case "sublist":e.type="sublist";e.saveas={};e.itemLabel=d.itemLabel;e.sublist=mist.convertBuildOptions(d,e.saveas);break;case "bool":e.type="checkbox";break;case "unixtime":e.type="unix";break;default:e.type="str"}else e.type="checkbox";if("format"in d)switch(d.format){case "set_or_unset":e.postSave=function(){var a=$(this).data("pointer");a.main[a.index]||delete a.main[a.index]}}"influences"in d?e["function"]=function(){var a=
|
||||
$(this).closest(".UIelement"),b=a.find("style");if(b.length)b=b[0];else{b=$("<style>").addClass("dependencies")[0];a.append(b)}b.innerHTML=".UIelement[data-dependent-"+c+"]:not([data-dependent-"+c+'~="'+$(this).getval()+'"]) { display: none; }\n';$(b).data("content",b.innerHTML);$("style.dependencies.hidden").each(function(){$(this).html($(this).data("content")).removeClass("hidden")});$(".UIelement:not(:visible) style.dependencies:not(.hidden)").each(function(){$(this).addClass("hidden");$(this).html("")})}:
|
||||
"disable"in d&&(e["function"]=function(){for(var a=$(this).closest(".input_container"),b=$(this).getval(),c=0;c<d.disable.length;c++){var e=a.find('.field[name="'+d.disable[c]+'"]').closest(".UIelement");if(e.length)b==""?e[0].style.display="":e.hide()}});if("dependent"in d)e.dependent=d.dependent;if("value"in d)e.value=d.value;if("validate"in d){e.validate=e.validate.concat(d.validate);if(d.validate.indexOf("track_selector_parameter")>-1)e.help="<div>"+d.help+"</div><p>Track selector parameters consist of a string value which may be any of the following:</p> <ul><li><code>selector,selector</code>: Selects the union of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,!selector</code>: Selects the difference of the given selectors. Specifically, all tracks part of the first selector that are not part of the second selector. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,selector</code>: Selects the intersection of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>none</code> or <code>-1</code>: Selects no tracks of this type.</li> <li><code>all</code> or <code>*</code>: Selects all tracks of this type.</li> <li>Any positive integer: Select this specific track ID. Does not apply if the given track ID does not exist or is of the wrong type. <strong>Does</strong> apply if the given track ID is incompatible with the currently active protocol or container format.</li> <li>ISO 639-1/639-3 language code: Select all tracks marked as the given language. Case insensitive.</li> <li>Codec string (e.g. <code>h264</code>): Select all tracks of the given codec. Case insensitive.</li> <li><code>highbps</code>, <code>maxbps</code> or <code>bestbps</code>: Select the track of this type with the highest bit rate.</li> <li><code>lowbps</code>, <code>minbps</code> or <code>worstbps</code>: Select the track of this type with the lowest bit rate.</li> <li><code>Xbps</code> or <code>Xkbps</code> or <code>Xmbps</code>: Select the single of this type which has a bit rate closest to the given number X. This number is in bits, not bytes.</li> <li><code>>Xbps</code> or <code>>Xkbps</code> or <code>>Xmbps</code>: Select all tracks of this type which have a bit rate greater than the given number X. This number is in bits, not bytes.</li> <li><code><Xbps</code> or <code><Xkbps</code> or <code><Xmbps</code>: Select all tracks of this type which have a bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>max<Xbps</code> or <code>max<Xkbps</code> or <code>max<Xmbps</code>: Select the one track of this type which has the highest bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>highres</code>, <code>maxres</code> or <code>bestres</code>: Select the track of this type with the highest pixel surface area. Only applied when the track type is video.</li> <li><code>lowres</code>, <code>minres</code> or <code>worstres</code>: Select the track of this type with the lowest pixel surface area. Only applied when the track type is video.</li> <li><code>XxY</code>: Select all tracks of this type with the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>~XxY</code>: Select the single track of this type closest to the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>>XxY</code>: Select all tracks of this type with a pixel surface area greater than X by Y pixels. Only applied when the track type is video.</li> <li><code><XxY</code>: Select all tracks of this type with a pixel surface area less than X by Y pixels. Only applied when the track type is video.</li> <li><code>720p</code>, <code>1080p</code>, <code>1440p</code>, <code>2k</code>, <code>4k</code>, <code>5k</code>, or <code>8k</code>: Select all tracks of this type with the given pixel surface area. Only applied when the track type is video.</li> <li><code>surround</code>, <code>mono</code>, <code>stereo</code>, <code>Xch</code>: Select all tracks of this type with the given channel count. The 'Xch' variant can use any positive integer for 'X'. Only applied when the track type is audio.</li></ul>";
|
||||
if(d.validate.indexOf("track_selector")>-1)e.help="<div>"+d.help+"</div><p>A track selector is at least one track type (audio, video or subtitle) combined with a track selector parameter. For example: <code>audio=none&video=maxres</code>.<p>Track selector parameters consist of a string value which may be any of the following:</p> <ul><li><code>selector,selector</code>: Selects the union of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,!selector</code>: Selects the difference of the given selectors. Specifically, all tracks part of the first selector that are not part of the second selector. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,selector</code>: Selects the intersection of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>none</code> or <code>-1</code>: Selects no tracks of this type.</li> <li><code>all</code> or <code>*</code>: Selects all tracks of this type.</li> <li>Any positive integer: Select this specific track ID. Does not apply if the given track ID does not exist or is of the wrong type. <strong>Does</strong> apply if the given track ID is incompatible with the currently active protocol or container format.</li> <li>ISO 639-1/639-3 language code: Select all tracks marked as the given language. Case insensitive.</li> <li>Codec string (e.g. <code>h264</code>): Select all tracks of the given codec. Case insensitive.</li> <li><code>highbps</code>, <code>maxbps</code> or <code>bestbps</code>: Select the track of this type with the highest bit rate.</li> <li><code>lowbps</code>, <code>minbps</code> or <code>worstbps</code>: Select the track of this type with the lowest bit rate.</li> <li><code>Xbps</code> or <code>Xkbps</code> or <code>Xmbps</code>: Select the single of this type which has a bit rate closest to the given number X. This number is in bits, not bytes.</li> <li><code>>Xbps</code> or <code>>Xkbps</code> or <code>>Xmbps</code>: Select all tracks of this type which have a bit rate greater than the given number X. This number is in bits, not bytes.</li> <li><code><Xbps</code> or <code><Xkbps</code> or <code><Xmbps</code>: Select all tracks of this type which have a bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>max<Xbps</code> or <code>max<Xkbps</code> or <code>max<Xmbps</code>: Select the one track of this type which has the highest bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>highres</code>, <code>maxres</code> or <code>bestres</code>: Select the track of this type with the highest pixel surface area. Only applied when the track type is video.</li> <li><code>lowres</code>, <code>minres</code> or <code>worstres</code>: Select the track of this type with the lowest pixel surface area. Only applied when the track type is video.</li> <li><code>XxY</code>: Select all tracks of this type with the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>~XxY</code>: Select the single track of this type closest to the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>>XxY</code>: Select all tracks of this type with a pixel surface area greater than X by Y pixels. Only applied when the track type is video.</li> <li><code><XxY</code>: Select all tracks of this type with a pixel surface area less than X by Y pixels. Only applied when the track type is video.</li> <li><code>720p</code>, <code>1080p</code>, <code>1440p</code>, <code>2k</code>, <code>4k</code>, <code>5k</code>, or <code>8k</code>: Select all tracks of this type with the given pixel surface area. Only applied when the track type is video.</li> <li><code>surround</code>, <code>mono</code>, <code>stereo</code>, <code>Xch</code>: Select all tracks of this type with the given channel count. The 'Xch' variant can use any positive integer for 'X'. Only applied when the track type is audio.</li></ul>"}return e}
|
||||
var d=[],f=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var i in f)if(a[f[i]]){d.push($("<h4>").text(UI.format.capital(f[i])+" parameters"));var m=Object.keys(a[f[i]]);"sort"in a&&m.sort(function(b,c){return(""+a[f[i]][b][a.sort]).localeCompare(a[f[i]][c][a.sort])});for(var e in m){var t=m[e],o=a[f[i]][t];if(Array.isArray(o))for(var l in o)d.push(c(i,t,o[l]));else d.push(c(i,t,o))}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,b){var c=
|
||||
var mist={data:{},user:{name:"",password:"",host:host},send:function(a,b,c){var b=b||{},c=c||{},c=$.extend(true,{timeOut:3E4,sendData:b},c),d={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,d,b);log("Send",$.extend(true,{},b));var e={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:true,timeout:c.timeout*1E3,async:true,error:function(d,e,j){console.warn("connection failed :(",
|
||||
j);delete mist.user.loggedin;if(!c.hide){switch(e){case "timeout":e=$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append($("<span>").text(e)).append($("<a>").text("Send server request again").click(function(){mist.send(a,b,c)}))}UI.navto("Login")},
|
||||
success:function(e){log("Receive",$.extend(true,{},e),"as reply to",c.sendData);delete mist.user.loggedin;switch(e.authorize.status){case "OK":if("streams"in e)if(e.streams)if("incomplete list"in e.streams){delete e.streams["incomplete list"];$.extend(mist.data.streams,e.streams)}else mist.data.streams=e.streams;else mist.data.streams={};var h=$.extend({},e),j=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth","variable_list","external_writer_list"],
|
||||
o;for(o in h)j.indexOf(o)==-1&&delete h[o];if("bandwidth"in d&&!("bandwidth"in e))h.bandwidth=null;$.extend(mist.data,h);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));if(e.log){h=e.log[e.log.length-1];UI.elements.connection.msg.append($("<br>")).append($("<span>").text("Last log entry: "+
|
||||
UI.format.time(h[0])+" ["+h[1]+"] "+h[2]))}if("totals"in e){h=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([m,0])};var e={},h;for(h in c.fields)e[c.fields[h]]=[];var j=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(h in c.data){if(h==0){m=c.start*1E3;var o=0}else{m=m+c.interval[o][1]*1E3;c.interval[o][0]--;if(c.interval[o][0]<=0){o++;o<c.interval.length-1&&(j=j+2)}}if(j%2==1){d();j--}for(var t in c.data[h])e[c.fields[t]].push([m,
|
||||
c.data[h][t]]);if(j){d();j--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in e.totals)h(b.totals.streams,
|
||||
b.totals.protocols,e.totals);else for(o in e.totals)h(b.totals[o].streams,b.totals[o].protocols,e.totals[o])}a&&a(e,c);break;case "CHALL":if(e.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=e.authorize.challenge;mist.send(a,b,c);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,
|
||||
name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete b.authorize;mist.send(a,b,c);break;default:UI.navto("Login")}}};c.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){j.abort()}));var j=$.ajax(e)},inputMatch:function(a,b){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var c in a){var d=
|
||||
a[c].replace(/[^\w\s]/g,"\\$&"),d=d.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+d+"(?:\\?[^\\?]*)?$","i").test(b))return true}return false},convertBuildOptions:function(a,b){function c(a,c,d){var f={label:UI.format.capital(d.name?d.name:c),pointer:{main:b,index:c},validate:[]};e[a]=="required"&&(!("default"in d)||d["default"]=="")&&f.validate.push("required");if("default"in d){f.placeholder=d["default"];if(d.type=="select")for(var h in d.select)if(d.select[h][0]==d["default"]){f.placeholder=
|
||||
d.select[h][1];break}}if("help"in d)f.help=d.help;if("unit"in d)f.unit=d.unit;if("placeholder"in d)f.placeholder=d.placeholder;if("type"in d)switch(d.type){case "int":f.type="int";if("max"in d)f.max=d.max;if("min"in d)f.min=d.min;break;case "uint":f.type="int";f.min=0;if("max"in d)f.max=d.max;if("min"in d)f.min=Math.max(f.min,d.min);break;case "radioselect":f.type="radioselect";f.radioselect=d.radioselect;break;case "select":f.type="select";f.select=d.select.slice(0);f.validate.indexOf("required")>=
|
||||
0&&f.select.unshift(["","placeholder"in f?"Default ("+f.placeholder+")":""]);break;case "sublist":f.type="sublist";f.saveas={};f.itemLabel=d.itemLabel;f.sublist=mist.convertBuildOptions(d,f.saveas);break;case "bool":f.type="checkbox";break;case "unixtime":f.type="unix";break;case "json":case "debug":case "inputlist":f.type=d.type;break;default:f.type="str"}else f.type="checkbox";if("format"in d)switch(d.format){case "set_or_unset":f.postSave=function(){var a=$(this).data("pointer");a.main[a.index]||
|
||||
delete a.main[a.index]}}"influences"in d?f["function"]=function(){var a=$(this).closest(".UIelement"),b=a.find("style");if(b.length)b=b[0];else{b=$("<style>").addClass("dependencies")[0];a.append(b)}b.innerHTML=".UIelement[data-dependent-"+c+"]:not([data-dependent-"+c+'~="'+$(this).getval()+'"]) { display: none; }\n';$(b).data("content",b.innerHTML);$("style.dependencies.hidden").each(function(){$(this).html($(this).data("content")).removeClass("hidden")});$(".UIelement:not(:visible) style.dependencies:not(.hidden)").each(function(){$(this).addClass("hidden");
|
||||
$(this).html("")})}:"disable"in d&&(f["function"]=function(){for(var a=$(this).closest(".input_container"),b=$(this).getval(),c=0;c<d.disable.length;c++){var e=a.find('.field[name="'+d.disable[c]+'"]').closest(".UIelement");if(e.length)b==""?e[0].style.display="":e.hide()}});if("dependent"in d)f.dependent=d.dependent;if("value"in d)f.value=d.value;if("validate"in d){f.validate=f.validate.concat(d.validate);if(d.validate.indexOf("track_selector_parameter")>-1)f.help="<div>"+d.help+"</div><p>Track selector parameters consist of a string value which may be any of the following:</p> <ul><li><code>selector,selector</code>: Selects the union of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,!selector</code>: Selects the difference of the given selectors. Specifically, all tracks part of the first selector that are not part of the second selector. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,selector</code>: Selects the intersection of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>none</code> or <code>-1</code>: Selects no tracks of this type.</li> <li><code>all</code> or <code>*</code>: Selects all tracks of this type.</li> <li>Any positive integer: Select this specific track ID. Does not apply if the given track ID does not exist or is of the wrong type. <strong>Does</strong> apply if the given track ID is incompatible with the currently active protocol or container format.</li> <li>ISO 639-1/639-3 language code: Select all tracks marked as the given language. Case insensitive.</li> <li>Codec string (e.g. <code>h264</code>): Select all tracks of the given codec. Case insensitive.</li> <li><code>highbps</code>, <code>maxbps</code> or <code>bestbps</code>: Select the track of this type with the highest bit rate.</li> <li><code>lowbps</code>, <code>minbps</code> or <code>worstbps</code>: Select the track of this type with the lowest bit rate.</li> <li><code>Xbps</code> or <code>Xkbps</code> or <code>Xmbps</code>: Select the single of this type which has a bit rate closest to the given number X. This number is in bits, not bytes.</li> <li><code>>Xbps</code> or <code>>Xkbps</code> or <code>>Xmbps</code>: Select all tracks of this type which have a bit rate greater than the given number X. This number is in bits, not bytes.</li> <li><code><Xbps</code> or <code><Xkbps</code> or <code><Xmbps</code>: Select all tracks of this type which have a bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>max<Xbps</code> or <code>max<Xkbps</code> or <code>max<Xmbps</code>: Select the one track of this type which has the highest bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>highres</code>, <code>maxres</code> or <code>bestres</code>: Select the track of this type with the highest pixel surface area. Only applied when the track type is video.</li> <li><code>lowres</code>, <code>minres</code> or <code>worstres</code>: Select the track of this type with the lowest pixel surface area. Only applied when the track type is video.</li> <li><code>XxY</code>: Select all tracks of this type with the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>~XxY</code>: Select the single track of this type closest to the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>>XxY</code>: Select all tracks of this type with a pixel surface area greater than X by Y pixels. Only applied when the track type is video.</li> <li><code><XxY</code>: Select all tracks of this type with a pixel surface area less than X by Y pixels. Only applied when the track type is video.</li> <li><code>720p</code>, <code>1080p</code>, <code>1440p</code>, <code>2k</code>, <code>4k</code>, <code>5k</code>, or <code>8k</code>: Select all tracks of this type with the given pixel surface area. Only applied when the track type is video.</li> <li><code>surround</code>, <code>mono</code>, <code>stereo</code>, <code>Xch</code>: Select all tracks of this type with the given channel count. The 'Xch' variant can use any positive integer for 'X'. Only applied when the track type is audio.</li></ul>";
|
||||
if(d.validate.indexOf("track_selector")>-1)f.help="<div>"+d.help+"</div><p>A track selector is at least one track type (audio, video or subtitle) combined with a track selector parameter. For example: <code>audio=none&video=maxres</code>.<p>Track selector parameters consist of a string value which may be any of the following:</p> <ul><li><code>selector,selector</code>: Selects the union of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,!selector</code>: Selects the difference of the given selectors. Specifically, all tracks part of the first selector that are not part of the second selector. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,selector</code>: Selects the intersection of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>none</code> or <code>-1</code>: Selects no tracks of this type.</li> <li><code>all</code> or <code>*</code>: Selects all tracks of this type.</li> <li>Any positive integer: Select this specific track ID. Does not apply if the given track ID does not exist or is of the wrong type. <strong>Does</strong> apply if the given track ID is incompatible with the currently active protocol or container format.</li> <li>ISO 639-1/639-3 language code: Select all tracks marked as the given language. Case insensitive.</li> <li>Codec string (e.g. <code>h264</code>): Select all tracks of the given codec. Case insensitive.</li> <li><code>highbps</code>, <code>maxbps</code> or <code>bestbps</code>: Select the track of this type with the highest bit rate.</li> <li><code>lowbps</code>, <code>minbps</code> or <code>worstbps</code>: Select the track of this type with the lowest bit rate.</li> <li><code>Xbps</code> or <code>Xkbps</code> or <code>Xmbps</code>: Select the single of this type which has a bit rate closest to the given number X. This number is in bits, not bytes.</li> <li><code>>Xbps</code> or <code>>Xkbps</code> or <code>>Xmbps</code>: Select all tracks of this type which have a bit rate greater than the given number X. This number is in bits, not bytes.</li> <li><code><Xbps</code> or <code><Xkbps</code> or <code><Xmbps</code>: Select all tracks of this type which have a bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>max<Xbps</code> or <code>max<Xkbps</code> or <code>max<Xmbps</code>: Select the one track of this type which has the highest bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>highres</code>, <code>maxres</code> or <code>bestres</code>: Select the track of this type with the highest pixel surface area. Only applied when the track type is video.</li> <li><code>lowres</code>, <code>minres</code> or <code>worstres</code>: Select the track of this type with the lowest pixel surface area. Only applied when the track type is video.</li> <li><code>XxY</code>: Select all tracks of this type with the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>~XxY</code>: Select the single track of this type closest to the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>>XxY</code>: Select all tracks of this type with a pixel surface area greater than X by Y pixels. Only applied when the track type is video.</li> <li><code><XxY</code>: Select all tracks of this type with a pixel surface area less than X by Y pixels. Only applied when the track type is video.</li> <li><code>720p</code>, <code>1080p</code>, <code>1440p</code>, <code>2k</code>, <code>4k</code>, <code>5k</code>, or <code>8k</code>: Select all tracks of this type with the given pixel surface area. Only applied when the track type is video.</li> <li><code>surround</code>, <code>mono</code>, <code>stereo</code>, <code>Xch</code>: Select all tracks of this type with the given channel count. The 'Xch' variant can use any positive integer for 'X'. Only applied when the track type is audio.</li></ul>"}return f}
|
||||
var d=[],e=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var j in e)if(a[e[j]]){d.push($("<h4>").text(UI.format.capital(e[j])+" parameters"));var m=Object.keys(a[e[j]]);"sort"in a&&m.sort(function(b,c){return(""+a[e[j]][b][a.sort]).localeCompare(a[e[j]][c][a.sort])});for(var h in m){var t=m[h],o=a[e[j]][t];if(Array.isArray(o))for(var l in o)d.push(c(j,t,o[l]));else d.push(c(j,t,o))}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,b){var c=
|
||||
this.get();c[a]=b;mist.send(function(){},{ui_settings:c})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}}
|
||||
$.fn.getval=function(){var a=$(this).data("opts"),b=$(this).val();if(a&&"type"in a)switch(a.type){case "int":b!=""&&(b=Number(b));break;case "span":b=$(this).html();break;case "debug":b=$(this).val()==""?null:Number($(this).val());break;case "checkbox":b=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){b=[];b.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&b.push(a.val())}else b="";break;case "checklist":b=
|
||||
[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){b.push($(this).attr("name"))});break;case "unix":b!=""&&(b=Math.round(new Date($(this).val())/1E3));break;case "selectinput":b=$(this).children("select").first().val();b=="CUSTOM"&&(b=$(this).children("label").first().find(".field_container").children().first().getval());break;case "inputlist":b=[];$(this).find(".field").each(function(){$(this).getval()!=""&&b.push($(this).getval())});break;case "sublist":b=$(this).data("savelist");
|
||||
break;case "json":try{b=JSON.parse($(this).val())}catch(c){b=null}break;case "bitmask":b=0;$(this).find("input").each(function(){$(this).prop("checked")&&(b=b+Number($(this).val()))})}return b};
|
||||
$.fn.setval=function(a){var b=$(this).data("opts");$(this).val(a);if(b&&"type"in b)switch(b.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":b=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";b.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),c;for(c in a)b.values.append(b.prototype.clone(true).val(a[c]));b.blackwhite.trigger("change");break;case "radioselect":if(typeof a==
|
||||
"undefined")return $(this);c=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&c.children("select").val(a[1]);break;case "checklist":b=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(c in a)b.filter('[name="'+a[c]+'"]').prop("checked",true);break;case "unix":if(typeof a!="undefined"&&a!=""&&a!==null){a=new Date(Math.round(a)*1E3);a.setMinutes(a.getMinutes()-a.getTimezoneOffset());a=a.toISOString();$(this).val(a.split("Z")[0])}break;
|
||||
case "selectinput":a===null&&(a="");var d=false;for(c in b.selectinput){var f;typeof b.selectinput[c]=="string"?f=b.selectinput[c]:typeof b.selectinput[c][0]=="string"&&(f=b.selectinput[c][0]);if(f==a){$(this).children("select").first().val(a);d=true;break}}if(!d){$(this).children("label").first().find(".field_container").children().first().setval(a);$(this).children("select").first().val("CUSTOM").trigger("change")}break;case "inputlist":typeof a=="string"&&(a=[a]);for(c in a){b=$(this).data("newitem")();
|
||||
b.find(".field").setval(a[c]);$(this).append(b)}$(this).append($(this).children().first());break;case "sublist":var i=$(this),b=$(this).children(".curvals");b.html("");if(a&&a.length)for(c in a){var d=$.extend(true,{},a[c]),m=function(a){for(var b in a)b.slice(0,6)=="x-LSP-"?delete a[b]:typeof a[b]=="object"&&m(a[b])};m(d);b.append($("<div>").addClass("subitem").append($("<span>").addClass("itemdetails").text(a[c]["x-LSP-name"]?a[c]["x-LSP-name"]:JSON.stringify(d)).attr("title",JSON.stringify(d,null,
|
||||
2))).append($("<button>").addClass("move").text("^").attr("title","Move item up").click(function(){var a=$(this).parent().index();if(a!=0){var b=i.getval();b.splice(a-1,0,b.splice(a,1)[0]);i.setval(b)}})).append($("<button>").text("Edit").click(function(){var a=$(this).parent().index(),b=$(this).closest(".field");b.data("build")(Object.assign({},b.getval()[a]),a)})).append($("<button>").text("x").attr("title","Remove item").click(function(a){var b=$(this).parent().index(),c=i.data("savelist");c.splice(b,
|
||||
1);i.setval(c);a.preventDefault()})))}else b.append("None.");i.data("savelist",a);break;case "json":$(this).val(a===null?"":JSON.stringify(a,null,2));break;case "bitmask":d=$(this).data("opts").bitmask;b=$(this).find("input");for(c in d){$el=b.eq(c);(a&d[c][0])==d[c][0]?$el.attr("checked","checked"):$el.removeAttr("checked")}}$(this).trigger("change");return $(this)};
|
||||
case "selectinput":a===null&&(a="");var d=false;for(c in b.selectinput){var e;typeof b.selectinput[c]=="string"?e=b.selectinput[c]:typeof b.selectinput[c][0]=="string"&&(e=b.selectinput[c][0]);if(e==a){$(this).children("select").first().val(a);d=true;break}}if(!d){$(this).children("label").first().find(".field_container").children().first().setval(a);$(this).children("select").first().val("CUSTOM").trigger("change")}break;case "inputlist":typeof a=="string"&&(a=[a]);for(c in a){b=$(this).data("newitem")();
|
||||
b.find(".field").setval(a[c]);$(this).append(b)}$(this).append($(this).children().first());break;case "sublist":var j=$(this),b=$(this).children(".curvals");b.html("");if(a&&a.length)for(c in a){var d=$.extend(true,{},a[c]),m=function(a){for(var b in a)b.slice(0,6)=="x-LSP-"?delete a[b]:typeof a[b]=="object"&&m(a[b])};m(d);b.append($("<div>").addClass("subitem").append($("<span>").addClass("itemdetails").text(a[c]["x-LSP-name"]?a[c]["x-LSP-name"]:JSON.stringify(d)).attr("title",JSON.stringify(d,null,
|
||||
2))).append($("<button>").addClass("move").text("^").attr("title","Move item up").click(function(){var a=$(this).parent().index();if(a!=0){var b=j.getval();b.splice(a-1,0,b.splice(a,1)[0]);j.setval(b)}})).append($("<button>").text("Edit").click(function(){var a=$(this).parent().index(),b=$(this).closest(".field");b.data("build")(Object.assign({},b.getval()[a]),a)})).append($("<button>").text("x").attr("title","Remove item").click(function(a){var b=$(this).parent().index(),c=j.data("savelist");c.splice(b,
|
||||
1);j.setval(c);a.preventDefault()})))}else b.append("None.");j.data("savelist",a);break;case "json":$(this).val(a===null?"":JSON.stringify(a,null,2));break;case "bitmask":d=$(this).data("opts").bitmask;b=$(this).find("input");for(c in d){$el=b.eq(c);(a&d[c][0])==d[c][0]?$el.attr("checked","checked"):$el.removeAttr("checked")}}$(this).trigger("change");return $(this)};
|
||||
function parseURL(a,b){var c=document.createElement("a");c.href=a;if(b)for(var d in b)c[d]=b[d];return{full:c.href,protocol:c.protocol+"//",host:c.hostname,port:c.port?":"+c.port:""}}function triggerRewrite(a){return typeof a=="object"&&typeof a.length=="undefined"?a:obj={handler:a[0],sync:a[1],streams:a[2],"default":a[3]}};
|
||||
|
|
|
@ -7955,6 +7955,12 @@ var mist = {
|
|||
obj.type = 'unix';
|
||||
break;
|
||||
}
|
||||
case 'json':
|
||||
case 'debug':
|
||||
case 'inputlist': {
|
||||
obj.type = ele.type;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
obj.type = 'str';
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue