Merge branch 'development' into LTS_development
This commit is contained in:
commit
5819e9cac8
5 changed files with 910 additions and 146 deletions
42
lsp/main.css
42
lsp/main.css
File diff suppressed because one or more lines are too long
260
lsp/minified.js
260
lsp/minified.js
|
@ -1,11 +1,11 @@
|
|||
var MD5=function(a){function c(a,c){var b,d,h,i,e;h=a&2147483648;i=c&2147483648;b=a&1073741824;d=c&1073741824;e=(a&1073741823)+(c&1073741823);return b&d?e^2147483648^h^i:b|d?e&1073741824?e^3221225472^h^i:e^1073741824^h^i:e^h^i}function b(a,b,d,h,i,e,g){a=c(a,c(c(b&d|~b&h,i),g));return c(a<<e|a>>>32-e,b)}function d(a,b,d,h,i,e,g){a=c(a,c(c(b&h|d&~h,i),g));return c(a<<e|a>>>32-e,b)}function f(a,b,d,h,i,e,g){a=c(a,c(c(b^d^h,i),g));return c(a<<e|a>>>32-e,b)}function l(a,b,d,h,i,e,g){a=c(a,c(c(d^(b|~h),
|
||||
i),g));return c(a<<e|a>>>32-e,b)}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=[],p,n,i,v,h,k,j,g,e=a.replace(/\r\n/g,"\n"),a="";for(p=0;p<e.length;p++)n=e.charCodeAt(p),128>n?a+=String.fromCharCode(n):(127<n&&2048>n?a+=String.fromCharCode(n>>6|192):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128)),a+=String.fromCharCode(n&63|128));e=a;a=e.length;p=a+8;n=16*((p-p%64)/64+1);i=Array(n-1);for(h=v=0;h<a;)p=
|
||||
(h-h%4)/4,v=8*(h%4),i[p]|=e.charCodeAt(h)<<v,h++;p=(h-h%4)/4;i[p]|=128<<8*(h%4);i[n-2]=a<<3;i[n-1]=a>>>29;e=i;h=1732584193;k=4023233417;j=2562383102;g=271733878;for(a=0;a<e.length;a+=16)p=h,n=k,i=j,v=g,h=b(h,k,j,g,e[a+0],7,3614090360),g=b(g,h,k,j,e[a+1],12,3905402710),j=b(j,g,h,k,e[a+2],17,606105819),k=b(k,j,g,h,e[a+3],22,3250441966),h=b(h,k,j,g,e[a+4],7,4118548399),g=b(g,h,k,j,e[a+5],12,1200080426),j=b(j,g,h,k,e[a+6],17,2821735955),k=b(k,j,g,h,e[a+7],22,4249261313),h=b(h,k,j,g,e[a+8],7,1770035416),
|
||||
g=b(g,h,k,j,e[a+9],12,2336552879),j=b(j,g,h,k,e[a+10],17,4294925233),k=b(k,j,g,h,e[a+11],22,2304563134),h=b(h,k,j,g,e[a+12],7,1804603682),g=b(g,h,k,j,e[a+13],12,4254626195),j=b(j,g,h,k,e[a+14],17,2792965006),k=b(k,j,g,h,e[a+15],22,1236535329),h=d(h,k,j,g,e[a+1],5,4129170786),g=d(g,h,k,j,e[a+6],9,3225465664),j=d(j,g,h,k,e[a+11],14,643717713),k=d(k,j,g,h,e[a+0],20,3921069994),h=d(h,k,j,g,e[a+5],5,3593408605),g=d(g,h,k,j,e[a+10],9,38016083),j=d(j,g,h,k,e[a+15],14,3634488961),k=d(k,j,g,h,e[a+4],20,3889429448),
|
||||
h=d(h,k,j,g,e[a+9],5,568446438),g=d(g,h,k,j,e[a+14],9,3275163606),j=d(j,g,h,k,e[a+3],14,4107603335),k=d(k,j,g,h,e[a+8],20,1163531501),h=d(h,k,j,g,e[a+13],5,2850285829),g=d(g,h,k,j,e[a+2],9,4243563512),j=d(j,g,h,k,e[a+7],14,1735328473),k=d(k,j,g,h,e[a+12],20,2368359562),h=f(h,k,j,g,e[a+5],4,4294588738),g=f(g,h,k,j,e[a+8],11,2272392833),j=f(j,g,h,k,e[a+11],16,1839030562),k=f(k,j,g,h,e[a+14],23,4259657740),h=f(h,k,j,g,e[a+1],4,2763975236),g=f(g,h,k,j,e[a+4],11,1272893353),j=f(j,g,h,k,e[a+7],16,4139469664),
|
||||
k=f(k,j,g,h,e[a+10],23,3200236656),h=f(h,k,j,g,e[a+13],4,681279174),g=f(g,h,k,j,e[a+0],11,3936430074),j=f(j,g,h,k,e[a+3],16,3572445317),k=f(k,j,g,h,e[a+6],23,76029189),h=f(h,k,j,g,e[a+9],4,3654602809),g=f(g,h,k,j,e[a+12],11,3873151461),j=f(j,g,h,k,e[a+15],16,530742520),k=f(k,j,g,h,e[a+2],23,3299628645),h=l(h,k,j,g,e[a+0],6,4096336452),g=l(g,h,k,j,e[a+7],10,1126891415),j=l(j,g,h,k,e[a+14],15,2878612391),k=l(k,j,g,h,e[a+5],21,4237533241),h=l(h,k,j,g,e[a+12],6,1700485571),g=l(g,h,k,j,e[a+3],10,2399980690),
|
||||
j=l(j,g,h,k,e[a+10],15,4293915773),k=l(k,j,g,h,e[a+1],21,2240044497),h=l(h,k,j,g,e[a+8],6,1873313359),g=l(g,h,k,j,e[a+15],10,4264355552),j=l(j,g,h,k,e[a+6],15,2734768916),k=l(k,j,g,h,e[a+13],21,1309151649),h=l(h,k,j,g,e[a+4],6,4149444226),g=l(g,h,k,j,e[a+11],10,3174756917),j=l(j,g,h,k,e[a+2],15,718787259),k=l(k,j,g,h,e[a+9],21,3951481745),h=c(h,p),k=c(k,n),j=c(j,i),g=c(g,v);return(m(h)+m(k)+m(j)+m(g)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(b){var c=0,d;a(b).children("td,th").each(function(){if(c==p)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 b=a(this),d=b.closest("table"),f=d.children("tbody"),l=f.children("tr"),m=b.attr("data-sort-type");if(m){var e=!0;b.hasClass("sorting-asc")&&(e=!1);var p=0;b.prevAll().each(function(){var b=a(this).attr("colspan");p+=b?Number(b):1});l.sort(function(a,b){var d=e?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});f.append(l);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");b.addClass(e?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),secondary_menu:$("nav.secondary_menu"),main:$("main"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();if(location.hash){var a=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 MD5=function(a){function c(a,c){var b,d,i,h,e;i=a&2147483648;h=c&2147483648;b=a&1073741824;d=c&1073741824;e=(a&1073741823)+(c&1073741823);return b&d?e^2147483648^i^h:b|d?e&1073741824?e^3221225472^i^h:e^1073741824^i^h:e^i^h}function b(a,b,d,i,h,e,f){a=c(a,c(c(b&d|~b&i,h),f));return c(a<<e|a>>>32-e,b)}function d(a,b,d,i,h,e,f){a=c(a,c(c(b&i|d&~i,h),f));return c(a<<e|a>>>32-e,b)}function g(a,b,d,i,h,e,f){a=c(a,c(c(b^d^i,h),f));return c(a<<e|a>>>32-e,b)}function k(a,b,d,i,h,e,f){a=c(a,c(c(d^(b|~i),
|
||||
h),f));return c(a<<e|a>>>32-e,b)}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=[],r,o,i,v,h,l,j,f,e=a.replace(/\r\n/g,"\n"),a="";for(r=0;r<e.length;r++)o=e.charCodeAt(r),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;r=a+8;o=16*((r-r%64)/64+1);i=Array(o-1);for(h=v=0;h<a;)r=
|
||||
(h-h%4)/4,v=8*(h%4),i[r]|=e.charCodeAt(h)<<v,h++;r=(h-h%4)/4;i[r]|=128<<8*(h%4);i[o-2]=a<<3;i[o-1]=a>>>29;e=i;h=1732584193;l=4023233417;j=2562383102;f=271733878;for(a=0;a<e.length;a+=16)r=h,o=l,i=j,v=f,h=b(h,l,j,f,e[a+0],7,3614090360),f=b(f,h,l,j,e[a+1],12,3905402710),j=b(j,f,h,l,e[a+2],17,606105819),l=b(l,j,f,h,e[a+3],22,3250441966),h=b(h,l,j,f,e[a+4],7,4118548399),f=b(f,h,l,j,e[a+5],12,1200080426),j=b(j,f,h,l,e[a+6],17,2821735955),l=b(l,j,f,h,e[a+7],22,4249261313),h=b(h,l,j,f,e[a+8],7,1770035416),
|
||||
f=b(f,h,l,j,e[a+9],12,2336552879),j=b(j,f,h,l,e[a+10],17,4294925233),l=b(l,j,f,h,e[a+11],22,2304563134),h=b(h,l,j,f,e[a+12],7,1804603682),f=b(f,h,l,j,e[a+13],12,4254626195),j=b(j,f,h,l,e[a+14],17,2792965006),l=b(l,j,f,h,e[a+15],22,1236535329),h=d(h,l,j,f,e[a+1],5,4129170786),f=d(f,h,l,j,e[a+6],9,3225465664),j=d(j,f,h,l,e[a+11],14,643717713),l=d(l,j,f,h,e[a+0],20,3921069994),h=d(h,l,j,f,e[a+5],5,3593408605),f=d(f,h,l,j,e[a+10],9,38016083),j=d(j,f,h,l,e[a+15],14,3634488961),l=d(l,j,f,h,e[a+4],20,3889429448),
|
||||
h=d(h,l,j,f,e[a+9],5,568446438),f=d(f,h,l,j,e[a+14],9,3275163606),j=d(j,f,h,l,e[a+3],14,4107603335),l=d(l,j,f,h,e[a+8],20,1163531501),h=d(h,l,j,f,e[a+13],5,2850285829),f=d(f,h,l,j,e[a+2],9,4243563512),j=d(j,f,h,l,e[a+7],14,1735328473),l=d(l,j,f,h,e[a+12],20,2368359562),h=g(h,l,j,f,e[a+5],4,4294588738),f=g(f,h,l,j,e[a+8],11,2272392833),j=g(j,f,h,l,e[a+11],16,1839030562),l=g(l,j,f,h,e[a+14],23,4259657740),h=g(h,l,j,f,e[a+1],4,2763975236),f=g(f,h,l,j,e[a+4],11,1272893353),j=g(j,f,h,l,e[a+7],16,4139469664),
|
||||
l=g(l,j,f,h,e[a+10],23,3200236656),h=g(h,l,j,f,e[a+13],4,681279174),f=g(f,h,l,j,e[a+0],11,3936430074),j=g(j,f,h,l,e[a+3],16,3572445317),l=g(l,j,f,h,e[a+6],23,76029189),h=g(h,l,j,f,e[a+9],4,3654602809),f=g(f,h,l,j,e[a+12],11,3873151461),j=g(j,f,h,l,e[a+15],16,530742520),l=g(l,j,f,h,e[a+2],23,3299628645),h=k(h,l,j,f,e[a+0],6,4096336452),f=k(f,h,l,j,e[a+7],10,1126891415),j=k(j,f,h,l,e[a+14],15,2878612391),l=k(l,j,f,h,e[a+5],21,4237533241),h=k(h,l,j,f,e[a+12],6,1700485571),f=k(f,h,l,j,e[a+3],10,2399980690),
|
||||
j=k(j,f,h,l,e[a+10],15,4293915773),l=k(l,j,f,h,e[a+1],21,2240044497),h=k(h,l,j,f,e[a+8],6,1873313359),f=k(f,h,l,j,e[a+15],10,4264355552),j=k(j,f,h,l,e[a+6],15,2734768916),l=k(l,j,f,h,e[a+13],21,1309151649),h=k(h,l,j,f,e[a+4],6,4149444226),f=k(f,h,l,j,e[a+11],10,3174756917),j=k(j,f,h,l,e[a+2],15,718787259),l=k(l,j,f,h,e[a+9],21,3951481745),h=c(h,r),l=c(l,o),j=c(j,i),f=c(f,v);return(m(h)+m(l)+m(j)+m(f)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(b){var c=0,d;a(b).children("td,th").each(function(){if(c==r)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 b=a(this),d=b.closest("table"),g=d.children("tbody"),k=g.children("tr"),m=b.attr("data-sort-type");if(m){var e=!0;b.hasClass("sorting-asc")&&(e=!1);var r=0;b.prevAll().each(function(){var b=a(this).attr("colspan");r+=b?Number(b):1});k.sort(function(a,b){var d=e?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});g.append(k);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");b.addClass(e?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),secondary_menu:$("nav.secondary_menu"),main:$("main"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();if(location.hash){var a=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})});
|
||||
$(window).on("hashchange",function(){var a=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 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,c){this.vars[a]=c;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,c){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");this.opts={delay:c,callback:a};
|
||||
this.opts.id=setInterval(a,c)}},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",BQ:"Bonaire, Sint Eustatius and Saba",
|
||||
|
@ -18,131 +18,141 @@ RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barthélemy",SH
|
|||
ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan, Province of China",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",
|
||||
UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela, Bolivarian Republic of",VN:"Viet Nam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},tooltip:{show:function(a,c){$tooltip=this.element;$.contains(document.body,$tooltip[0])||$("body").append($tooltip);$tooltip.html(c);clearTimeout(this.hiding);
|
||||
delete this.hiding;var b=$(document).height()-$tooltip.outerHeight(),d=$(document).width()-$tooltip.outerWidth();$tooltip.css("left",Math.min(a.pageX+10,d-10));$tooltip.css("top",Math.min(a.pageY+25,b-10));$tooltip.show().addClass("show")},hide:function(){$tooltip=this.element;$tooltip.removeClass("show");this.hiding=setTimeout(function(){$tooltip.hide()},500)},element:$("<div>").attr("id","tooltip")},popup:{element:null,show:function(a){this.element=$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",
|
||||
function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{},Preview:{},Limits:{LTSonly:!0},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/wiki/Category:Guides"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/wiki/Mistserver_Changelog"},"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{},"Terms & Conditions":{link:"http://mistserver.org/wiki/Mistserver_license"}}}}],
|
||||
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]);"LTSonly"in b&&c.addClass("LTSonly");"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){UI.navto(a);b.stopPropagation()});return c}var c=UI.elements.menu,b;for(b in UI.menu){0<b&&c.append($("<br>"));for(var d in UI.menu[b]){var f=UI.menu[b][d],
|
||||
l=a(d,f);c.append(l);if("submenu"in f){var m=$("<span>").addClass("submenu");l.addClass("arrowdown").append(m);for(var e in f.submenu)m.append(a(e,f.submenu[e]))}}}b=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");c.after(b).after($("<div>").addClass("separator"))},buildUI:function(a){var c=
|
||||
$("<div>").addClass("input_container"),b;for(b in a){var d=a[b];if(d instanceof jQuery)c.append(d);else if("help"==d.type){var f=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));c.append(f);if("classes"in d)for(var l in d.classes)f.addClass(d.classes[l])}else if("text"==d.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)c.append(d.custom);else if("buttons"==d.type)for(l in f=
|
||||
$("<span>").addClass("button_container"),"css"in d&&f.css(d.css),c.append(f),d.buttons){var m=d.buttons[l],e=$("<button>").text(m.label).data("opts",m);"css"in m&&e.css(m.css);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).closest(".input_container"),b=!1;a.find(".hasValidate").each(function(){if(b=$(this).data("validate")(this,!0))return!1});b||(a.find(".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 delete b.main[b.index],!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:e.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html(d.label+":"));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.min);"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(l in d.select){var p=$("<option>");"string"==typeof d.select[l]?p.text(d.select[l]):p.val(d.select[l][0]).text(d.select[l][1]);f.append(p)}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(b in d.radioselect){var n=
|
||||
$("<input>").attr("type","radio").val(d.radioselect[b][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&n.prop("disabled",!0);p=$("<label>").append(n).append($("<span>").html(d.radioselect[b][1]));f.append(p);if(2<d.radioselect[b].length)for(l in n=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),p.append(n),("LTSonly"in d&&!mist.data.LTS||d.readonly)&&n.prop("disabled",!0),d.radioselect[b][2])p=$("<option>"),n.append(p),
|
||||
d.radioselect[b][2][l]instanceof Array?p.val(d.radioselect[b][2][l][0]).html(d.radioselect[b][2][l][1]):p.html(d.radioselect[b][2][l])}break;default:f=$("<input>").attr("type","text")}f.addClass("field").data("opts",d);e.append(f);if("classes"in d)for(l in d.classes)f.addClass(d.classes[l]);"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));"readonly"in d&&(f.attr("readonly","readonly"),
|
||||
f.click(function(){$(this).select()}));"qrcode"in d&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").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())})})));"rows"in d&&f.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(e.addClass("LTSonly"),f.prop("disabled",!0));
|
||||
switch(d.type){case "browse":n=$("<div>").addClass("grouper").append(m);c.append(n);n=$("<button>").text("Browse");e.append(n);n.click(function(){function a(b){m.text("Loading..");mist.send(function(a){g.text(a.browse.path[0]);m.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var i=a.browse.subdirectories[b];m.append(l.clone(true).attr("title",g.text()+p+i).text(i))}}if(a.browse.files){a.browse.files.sort();
|
||||
for(b in a.browse.files){var i=a.browse.files[b],f=g.text()+p+i,i=$("<a>").text(i).addClass("file").attr("title",f);m.append(i);if(n){var v=true,r;for(r in n)if(typeof n[r]!="undefined"&&mist.inputMatch(n[r],f)){v=false;break}v&&i.hide()}i.click(function(){var a=$(this).attr("title");d.setval(a);e.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field"),e=$(this),g=$("<span>").addClass("field"),f=$("<button>").text("Select this folder"),
|
||||
m=$("<div>").addClass("browse_contents"),l=$("<a>").addClass("folder"),n=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(g).append(f))).append(m);f.click(function(){var a=g.text()+"/";d.setval(a);e.show();c.remove()});var p="/";mist.data.config.version.indexOf("indows")>-1&&(p="\\");l.click(function(){var b=g.text()+p+$(this).text();a(b)});b=d.getval();b=
|
||||
b.split(p);b.pop();b=b.join(p);e.hide();a(b)});break;case "geolimited":case "hostlimited":n={field:f};n.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));n.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":n.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(b in UI.countrylist)n.prototype.append($("<option>").val(b).html(UI.countrylist[b]));break;case "hostlimited":n.prototype=
|
||||
$("<input>").attr("type","text").attr("placeholder","type a host")}n.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});n.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=$(this).val();c!=""?b.push(c):$(this).remove()});a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});
|
||||
"LTSonly"in d&&!mist.data.LTS&&(n.blackwhite.prop("disabled",!0),n.prototype.prop("disabled",!0));n.values.append(n.prototype.clone(!0));e.data("subUI",n).addClass("limit_list").append(n.blackwhite).append(n.values)}"pointer"in d&&(f.data("pointer",d.pointer).addClass("isSetting"),e=d.pointer.main[d.pointer.index],"undefined"!=e&&f.setval(e));"value"in d&&f.setval(d.value);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(l in d.validate){n=d.validate[l];if("function"!=typeof n)switch(n){case "required":n=function(a){return a==""?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":n=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"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":n=function(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) are not allowed.",classes:["red"]}};
|
||||
break;default:n=function(){}}m.push(n)}f.data("validate_functions",m).data("help_container",e).data("validate",function(a,b){var c=$(a).getval(),d=$(a).data("validate_functions"),e=$(a).data("help_container");e.find(".err_balloon").remove();for(var g in d){var f=d[g](c,a);if(f){$err=$("<span>").addClass("err_balloon").html(f.msg);for(var m in f.classes)$err.addClass(f.classes[m]);e.prepend($err);b&&$(a).focus();return 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"))}}c.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").trigger("click");break;case 27:$(this).find("button.cancel").trigger("click")}});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),b=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];b.append($("<td>"));
|
||||
for(var f in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[f]?" ":a.labels[f]+":")));for(var l in a.content)for(f in b.append($("<td>").html(a.content[l].header)),a.content[l].body)d[f].append($("<td>").html(a.content[l].body[f]));c.append($("<tbody>").append(b).append(d));return c},buildLimits:function(a,c,b){function d(a,d){var e=$("<tbody>"),h;for(h in a){var f=$("<tr>");f.data("pointer",d.concat(h));var j="";switch(d[0]){case "server":j="The entire server";break;case "stream":j=
|
||||
'The stream "'+d[1]+'"'}f.append($("<td>").addClass("applies_to").text(j));var j=a[h].name,g=a[h].value;switch(a[h].name){case "kbps_max":j="Maximum bandwidth";g=UI.format.bytes(g,!0);break;case "users":j="Maximum connected users";g=UI.format.number(g);break;case "geo":var j="Geolimited",m=g,g="<span class=unit>["+("-"==g.charAt(0)?"Blacklist":"Whitelist")+"]</span> ",m=m.substr(1).split(" "),l=[],p;for(p in m){var o=UI.countrylist[m[p]];l.push("undefined"==typeof o?m[p]:o)}g+=l.join(", ");break;
|
||||
case "host":j="Hostlimited",m=g,g="<span class=unit>["+("-"==g.charAt(0)?"Blacklist":"Whitelist")+"]</span> ",m=m.substr(1).split(" "),g+=m.join(", ")}f.append($("<td>").text(a[h].type).addClass("kind")).append($("<td>").text(j).addClass("type")).append($("<td>").html(g).addClass("value")).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Limit",$(this).closest("tr").data("pointer").join("^"));UI.returnTab=[c,b]})).append($("<button>").text("Delete").click(function(){var a=
|
||||
$(this).closest("tr"),d="Are you sure you want to delete the "+a.find(".kind").text()+" "+a.find(".type").text()+" limit for "+a.find(".applies_to").text()+"?";if(confirm(d)){var a=a.data("pointer"),d=a[a.length-1],e={};switch(a[0]){case "server":mist.data.config.limits.splice(d,1);e={config:mist.data.config};break;case "stream":mist.data.streams[a[1]].limits.splice(d,1),1==mist.data.LTS?(d={},d[a[1]]=mist.data.streams[a[1]],e={addstream:d}):e={streams:mist.data.streams}}mist.send(function(){UI.navto(c,
|
||||
b)},e)}})));e.append(f)}return e.children()}var f=$("<div>"),l=$("<table>");f.append(l);var m=$("<tr>").append($("<th>").text("Kind").attr("data-sort-type","string")).append($("<th>").text("Type").attr("data-sort-type","string")).append($("<th>").text("Value")).append($("<th>"));a instanceof Array?a={noapply:a}:m.prepend($("<th>").text("Applies to").attr("data-sort-type","string").addClass("sorting-asc").addClass("applies_to"));l.append($("<thead>").append(m));m=$("<tbody>");l.append(m);for(var e in a)switch(e){case "server":m.append(d(a[e],
|
||||
["server"]));break;case "streams":for(var p in a[e])m.append(d(a[e][p],["stream",p]))}f.prepend($("<button>").text("New limit").click(function(){UI.navto("Edit Limit");UI.returnTab=[c,b]}));0<m.children().length?l.stupidtable():(l.remove(),f.append($("<span>").text("No limits set.")));return f.children()},plot:{addGraph:function(a,c){var b={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend")}};b.elements.cont.append(b.elements.plot).append(b.elements.legend);
|
||||
c.append(b.elements.cont);return b},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},b;for(b in a)for(var d in a[b].datasets){var f=a[b].datasets[d];switch(f.datatype){case "clients":case "upbps":case "downbps":switch(f.origin[0]){case "total":c.totals.push({fields:[f.datatype]});break;case "stream":c.totals.push({fields:[f.datatype],streams:[f.origin[1]]});break;case "protocol":c.totals.push({fields:[f.datatype],protocols:[f.origin[1]]})}break;case "cpuload":case "memload":c.capabilities=
|
||||
{}}}0==c.totals.length&&delete c.totals;0==c.clients.length&&delete c.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=[],n;for(n in c.datasets){var i=c.datasets[n];i.display&&(i.getdata(),i.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[i.yaxistype]),c.yaxes[i.yaxistype]=d.length),i.yaxis=c.yaxes[i.yaxistype],f.push(i))}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,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}}});d=$("<div>").addClass("legend-list").addClass("checklist");c.elements.legend.html($("<h3>").text(c.id)).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)}})).append(d);c.plot.getOptions();for(n in c.datasets)f=$("<input>").attr("type","checkbox").data("index",n).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[n].display&&f.attr("checked","checked"),d.append($("<label>").html(f).append($("<div>").addClass("series-color").css("background-color",
|
||||
c.datasets[n].color)).append(c.datasets[n].label).append($("<button>").text("X").addClass("close").data("index",n).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)}}})));c.elements.plot.on("plothover",function(a,b,c){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()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},b;for(b in a.datasets)c.datasets.push({origin:a.datasets[b].origin,datatype:a.datasets[b].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general),b=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),
|
||||
a=$.extend(!0,b,a),a=$.extend(!0,c,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 c=[],d;for(d in a.basecolor)b=a.basecolor[d],b+=50*(0.5-Math.random()),b=Math.round(b),b=Math.min(255,Math.max(0,b)),c.push(b);a.color="rgb("+c.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 load",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,Math.min(100,mist.data.capabilities.load.one/
|
||||
this.cores)]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!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]}}},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 c=0.3*Math.sqrt($(".graph").first().height()),c=(a.max-a.min)/c,b=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),d=c/Math.pow(1024,b),f=-Math.floor(Math.log(d)/Math.LN10),l=a.tickDecimals;null!=l&&f>l&&(f=l);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==l||f+1<=l))e=2.5,++f}else e=7.5>d?5:10;e=e*m*Math.pow(1024,b);null!=a.minTickSize&&e<a.minTickSize&&(e=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=l?l:f);a.tickSize=e;c=[];b=a.tickSize*
|
||||
Math.floor(a.min/a.tickSize);f=0;l=Number.NaN;do m=l,l=b+f*a.tickSize,c.push(l),++f;while(l<a.max&&l!=m);return c},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},format:{time:function(a,c){var b=new Date(1E3*a),d=[];d.push(("0"+b.getHours()).slice(-2));d.push(("0"+b.getMinutes()).slice(-2));"short"!=c&&d.push(("0"+b.getSeconds()).slice(-2));return d.join(":")},date:function(a,c){var b=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),f=[];"long"==c&&f.push(d[b.getDay()]);
|
||||
f.push(("0"+b.getDate()).slice(-2));f.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[b.getMonth()]);"short"!=c&&f.push(b.getFullYear());return f.join(" ")},dateTime:function(a,c){return UI.format.date(a,c)+", "+UI.format.time(a,c)},duration:function(a){var c=[0.001,1E3,60,60,24,7,1E9],b="ms sec min hr day week".split(" "),d={},f;for(f in b){var a=a/c[f],l=Math.round(a%c[Number(f)+1]);d[b[f]]=l;a-=l}var m;for(f=b.length-1;0<=f;f--)if(0<d[b[f]]){m=b[f];break}c=$("<span>");switch(m){case "week":c.append(UI.format.addUnit(d.week,
|
||||
"wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":c.append(UI.format.addUnit(d.day,"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:c.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+(d.ms?"."+d.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*c)/c;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=
|
||||
number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var c=$("<span>");if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");break;case 2:c.text("Inactive").addClass("orange");break;default:c.text(a.online)}"undefined"!=typeof a.error&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+
|
||||
a.substring(1)},addUnit:function(a,c){var b=$("<span>").html(a);b.append($("<span>").addClass("unit").html(c));return b[0].innerHTML},bytes:function(a,c){var b="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=b[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=b[0]:(a/=Math.pow(1024,d),unit=b[d])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s":""))}},navto:function(a,c){var b=location.hash,d=b.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,c].join("&");
|
||||
location.hash=d.join("@");location.hash==b&&$(window).trigger("hashchange")},showTab:function(a,c){var b=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))b.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else{var d=UI.elements.menu.css("visibility","visible").find(".button").filter(function(){if($(this).find(".plain").text()==a)return!0});0<d.length&&(UI.elements.menu.find(".button.active").removeClass("active"),d.addClass("active"));UI.elements.secondary_menu.html("");
|
||||
UI.interval.clear();b.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");break}UI.elements.menu.css("visibility","hidden");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");b.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},
|
||||
function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{},Preview:{},Limits:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/wiki/Category:Guides"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/wiki/Mistserver_Changelog"},"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{},"Terms & Conditions":{link:"http://mistserver.org/wiki/Mistserver_license"}}}}],
|
||||
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]);"LTSonly"in b&&c.addClass("LTSonly");"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){UI.navto(a);b.stopPropagation()});return c}var c=UI.elements.menu,b;for(b in UI.menu){0<b&&c.append($("<br>"));for(var d in UI.menu[b]){var g=UI.menu[b][d],
|
||||
k=a(d,g);c.append(k);if("submenu"in g){var m=$("<span>").addClass("submenu");k.addClass("arrowdown").append(m);for(var e in g.submenu)m.append(a(e,g.submenu[e]))}}}b=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");c.after(b).after($("<div>").addClass("separator"))},buildUI:function(a){var c=
|
||||
$("<div>").addClass("input_container"),b;for(b in a){var d=a[b];if(d instanceof jQuery)c.append(d);else if("help"==d.type){var g=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));c.append(g);if("classes"in d)for(var k in d.classes)g.addClass(d.classes[k])}else if("text"==d.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)c.append(d.custom);else if("buttons"==d.type)for(k in g=
|
||||
$("<span>").addClass("button_container"),"css"in d&&g.css(d.css),c.append(g),d.buttons){var m=d.buttons[k],e=$("<button>").text(m.label).data("opts",m);"css"in m&&e.css(m.css);g.append(e);switch(m.type){case "cancel":e.addClass("cancel").click(m["function"]);break;case "save":e.addClass("save").click(function(){var a=$(this).closest(".input_container"),b=!1;a.find(".hasValidate").each(function(){if(b=$(this).data("validate")(this,!0))return!1});b||(a.find(".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 delete b.main[b.index],!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:e.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html(d.label+":"));e=$("<span>").addClass("field_container");m.append(e);switch(d.type){case "password":g=$("<input>").attr("type","password");
|
||||
break;case "int":g=$("<input>").attr("type","number");"min"in d&&g.attr("min",d.min);"max"in d&&g.attr("max",d.min);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":g=$("<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":g=$("<select>");for(k in d.select){var r=$("<option>");"string"==typeof d.select[k]?r.text(d.select[k]):r.val(d.select[k][0]).text(d.select[k][1]);g.append(r)}break;case "textarea":g=$("<textarea>").on("keydown",function(a){a.stopPropagation()});
|
||||
break;case "checkbox":g=$("<input>").attr("type","checkbox");break;case "hidden":g=$("<input>").attr("type","hidden");m.hide();break;case "email":g=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":g=$("<input>").attr("type","text");"filetypes"in d&&g.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":g=$("<input>").attr("type","hidden");break;case "radioselect":g=$("<div>").addClass("radioselect");for(b in d.radioselect){var o=
|
||||
$("<input>").attr("type","radio").val(d.radioselect[b][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&o.prop("disabled",!0);r=$("<label>").append(o).append($("<span>").html(d.radioselect[b][1]));g.append(r);if(2<d.radioselect[b].length)for(k in o=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),r.append(o),("LTSonly"in d&&!mist.data.LTS||d.readonly)&&o.prop("disabled",!0),d.radioselect[b][2])r=$("<option>"),o.append(r),
|
||||
d.radioselect[b][2][k]instanceof Array?r.val(d.radioselect[b][2][k][0]).html(d.radioselect[b][2][k][1]):r.html(d.radioselect[b][2][k])}break;case "checklist":g=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");g.append($controls).append($checklist);$controls.append($("<label>").text("All").prepend($("<input>").attr("type","checkbox").click(function(){$(this).is(":checked")?$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",
|
||||
!0):$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!1)})));for(b in d.checklist)"string"==typeof d.checklist[b]&&(d.checklist[b]=[d.checklist[b],d.checklist[b]]),$checklist.append($("<label>").text(d.checklist[b][1]).prepend($("<input>").attr("type","checkbox").attr("name",d.checklist[b][0])));break;default:g=$("<input>").attr("type","text")}g.addClass("field").data("opts",d);e.append(g);if("classes"in d)for(k in d.classes)g.addClass(d.classes[k]);"placeholder"in d&&
|
||||
g.attr("placeholder",d.placeholder);"default"in d&&g.attr("placeholder",d["default"]);"unit"in d&&e.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(g.attr("readonly","readonly"),g.click(function(){$(this).select()}));"qrcode"in d&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").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())})})));"rows"in d&&g.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(e.addClass("LTSonly"),g.prop("disabled",!0));switch(d.type){case "browse":o=$("<div>").addClass("grouper").append(m);c.append(o);o=$("<button>").text("Browse");e.append(o);o.click(function(){function a(b){m.text("Loading..");mist.send(function(a){f.text(a.browse.path[0]);m.html(k.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();
|
||||
for(var b in a.browse.subdirectories){var i=a.browse.subdirectories[b];m.append(k.clone(true).attr("title",f.text()+o+i).text(i))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var i=a.browse.files[b],g=f.text()+o+i,i=$("<a>").text(i).addClass("file").attr("title",g);m.append(i);if(n){var q=true,v;for(v in n)if(typeof n[v]!="undefined"&&mist.inputMatch(n[v],g)){q=false;break}q&&i.hide()}i.click(function(){var a=$(this).attr("title");d.setval(a);e.show();c.remove()})}}},{browse:b})}
|
||||
var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field"),e=$(this),f=$("<span>").addClass("field"),g=$("<button>").text("Select this folder"),m=$("<div>").addClass("browse_contents"),k=$("<a>").addClass("folder"),n=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(f).append(g))).append(m);g.click(function(){var a=f.text()+
|
||||
"/";d.setval(a);e.show();c.remove()});var o="/";mist.data.config.version.indexOf("indows")>-1&&(o="\\");k.click(function(){var b=f.text()+o+$(this).text();a(b)});b=d.getval();b=b.split(o);b.pop();b=b.join(o);e.hide();a(b)});break;case "geolimited":case "hostlimited":o={field:g};o.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));o.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":o.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));
|
||||
for(b in UI.countrylist)o.prototype.append($("<option>").val(b).html(UI.countrylist[b]));break;case "hostlimited":o.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}o.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});o.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=$(this).val();c!=""?b.push(c):$(this).remove()});
|
||||
a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in d&&!mist.data.LTS&&(o.blackwhite.prop("disabled",!0),o.prototype.prop("disabled",!0));o.values.append(o.prototype.clone(!0));e.data("subUI",o).addClass("limit_list").append(o.blackwhite).append(o.values)}"pointer"in d&&(g.data("pointer",d.pointer).addClass("isSetting"),e=d.pointer.main[d.pointer.index],"undefined"!=e&&g.setval(e));"value"in d&&g.setval(d.value);
|
||||
e=$("<span>").addClass("help_container");m.append(e);"help"in d&&(e.append($("<span>").addClass("ih_balloon").html(d.help)),g.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in d){m=[];for(k in d.validate){o=d.validate[k];if("function"!=typeof o)switch(o){case "required":o=function(a){return a==""?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":o=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"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":o=function(a,b){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) are not allowed.",classes:["red"]};if(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;default:o=function(){}}m.push(o)}g.data("validate_functions",m).data("help_container",e).data("validate",function(a,b){var c=$(a).getval(),d=$(a).data("validate_functions"),
|
||||
e=$(a).data("help_container");e.find(".err_balloon").remove();for(var f in d){var g=d[f](c,a);if(g){$err=$("<span>").addClass("err_balloon").html(g.msg);for(var m in g.classes)$err.addClass(g.classes[m]);e.prepend($err);b&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=g.getval()&&g.trigger("change")}"function"in d&&(g.on("change keyup",d["function"]),g.trigger("change"))}}c.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").trigger("click");
|
||||
break;case 27:$(this).find("button.cancel").trigger("click")}});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),b=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];b.append($("<td>"));for(var g in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[g]?" ":a.labels[g]+":")));for(var k in a.content)for(g in b.append($("<td>").html(a.content[k].header)),a.content[k].body)d[g].append($("<td>").html(a.content[k].body[g]));
|
||||
c.append($("<tbody>").append(b).append(d));return c},buildLimits:function(a,c,b){function d(a,d){var e=$("<tbody>"),h;for(h in a){var g=$("<tr>");g.data("pointer",d.concat(h));var j="";switch(d[0]){case "server":j="The entire server";break;case "stream":j='The stream "'+d[1]+'"'}g.append($("<td>").addClass("applies_to").text(j));var j=a[h].name,f=a[h].value;switch(a[h].name){case "kbps_max":j="Maximum bandwidth";f=UI.format.bytes(f,!0);break;case "users":j="Maximum connected users";f=UI.format.number(f);
|
||||
break;case "geo":var j="Geolimited",m=f,f="<span class=unit>["+("-"==f.charAt(0)?"Blacklist":"Whitelist")+"]</span> ",m=m.substr(1).split(" "),k=[],p;for(p in m){var n=UI.countrylist[m[p]];k.push("undefined"==typeof n?m[p]:n)}f+=k.join(", ");break;case "host":j="Hostlimited",m=f,f="<span class=unit>["+("-"==f.charAt(0)?"Blacklist":"Whitelist")+"]</span> ",m=m.substr(1).split(" "),f+=m.join(", ")}g.append($("<td>").text(a[h].type).addClass("kind")).append($("<td>").text(j).addClass("type")).append($("<td>").html(f).addClass("value")).append($("<td>").css("text-align",
|
||||
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Limit",$(this).closest("tr").data("pointer").join("^"));UI.returnTab=[c,b]})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr"),d="Are you sure you want to delete the "+a.find(".kind").text()+" "+a.find(".type").text()+" limit for "+a.find(".applies_to").text()+"?";if(confirm(d)){var a=a.data("pointer"),d=a[a.length-1],e={};switch(a[0]){case "server":mist.data.config.limits.splice(d,1);e={config:mist.data.config};
|
||||
break;case "stream":mist.data.streams[a[1]].limits.splice(d,1),1==mist.data.LTS?(d={},d[a[1]]=mist.data.streams[a[1]],e={addstream:d}):e={streams:mist.data.streams}}mist.send(function(){UI.navto(c,b)},e)}})));e.append(g)}return e.children()}var g=$("<div>"),k=$("<table>");g.append(k);var m=$("<tr>").append($("<th>").text("Kind").attr("data-sort-type","string")).append($("<th>").text("Type").attr("data-sort-type","string")).append($("<th>").text("Value")).append($("<th>"));a instanceof Array?a={noapply:a}:
|
||||
m.prepend($("<th>").text("Applies to").attr("data-sort-type","string").addClass("sorting-asc").addClass("applies_to"));k.append($("<thead>").append(m));m=$("<tbody>");k.append(m);for(var e in a)switch(e){case "server":m.append(d(a[e],["server"]));break;case "streams":for(var r in a[e])m.append(d(a[e][r],["stream",r]))}g.prepend($("<button>").text("New limit").click(function(){UI.navto("Edit Limit");UI.returnTab=[c,b]}));0<m.children().length?k.stupidtable():(k.remove(),g.append($("<span>").text("No limits set.")));
|
||||
return g.children()},plot:{addGraph:function(a,c){var b={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend")}};b.elements.cont.append(b.elements.plot).append(b.elements.legend);c.append(b.elements.cont);return b},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},b;for(b in a)for(var d in a[b].datasets){var g=a[b].datasets[d];switch(g.datatype){case "clients":case "upbps":case "downbps":switch(g.origin[0]){case "total":c.totals.push({fields:[g.datatype]});
|
||||
break;case "stream":c.totals.push({fields:[g.datatype],streams:[g.origin[1]]});break;case "protocol":c.totals.push({fields:[g.datatype],protocols:[g.origin[1]]})}break;case "cpuload":case "memload":c.capabilities={}}}0==c.totals.length&&delete c.totals;0==c.clients.length&&delete c.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 g=[],o;for(o in c.datasets){var i=
|
||||
c.datasets[o];i.display&&(i.getdata(),i.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[i.yaxistype]),c.yaxes[i.yaxistype]=d.length),i.yaxis=c.yaxes[i.yaxistype],g.push(i))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,g,{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)"]}}});d=$("<div>").addClass("legend-list").addClass("checklist");c.elements.legend.html($("<h3>").text(c.id)).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)}})).append(d);c.plot.getOptions();for(o in c.datasets)g=$("<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&&g.attr("checked","checked"),d.append($("<label>").html(g).append($("<div>").addClass("series-color").css("background-color",c.datasets[o].color)).append(c.datasets[o].label).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)}}})));c.elements.plot.on("plothover",function(a,b,c){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()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},b;for(b in a.datasets)c.datasets.push({origin:a.datasets[b].origin,datatype:a.datasets[b].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];
|
||||
mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general),b=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,b,a),a=$.extend(!0,c,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 c=[],d;for(d in a.basecolor)b=a.basecolor[d],b+=50*(0.5-Math.random()),b=Math.round(b),b=Math.min(255,
|
||||
Math.max(0,b)),c.push(b);a.color="rgb("+c.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 load",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<
|
||||
1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,Math.min(100,mist.data.capabilities.load.one/this.cores)]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!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]}}},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 c=0.3*Math.sqrt($(".graph").first().height()),c=(a.max-a.min)/c,b=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),d=c/Math.pow(1024,b),g=-Math.floor(Math.log(d)/Math.LN10),k=a.tickDecimals;null!=k&&g>k&&(g=k);var m=Math.pow(10,-g),d=d/m,e;if(1.5>d)e=1;else if(3>d){if(e=2,2.25<d&&(null==k||g+1<=k))e=2.5,++g}else e=7.5>
|
||||
d?5:10;e=e*m*Math.pow(1024,b);null!=a.minTickSize&&e<a.minTickSize&&(e=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=k?k:g);a.tickSize=e;c=[];b=a.tickSize*Math.floor(a.min/a.tickSize);g=0;k=Number.NaN;do m=k,k=b+g*a.tickSize,c.push(k),++g;while(k<a.max&&k!=m);return c},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},format:{time:function(a,c){var b=new Date(1E3*a),d=[];d.push(("0"+b.getHours()).slice(-2));d.push(("0"+b.getMinutes()).slice(-2));"short"!=c&&d.push(("0"+
|
||||
b.getSeconds()).slice(-2));return d.join(":")},date:function(a,c){var b=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),g=[];"long"==c&&g.push(d[b.getDay()]);g.push(("0"+b.getDate()).slice(-2));g.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[b.getMonth()]);"short"!=c&&g.push(b.getFullYear());return g.join(" ")},dateTime:function(a,c){return UI.format.date(a,c)+", "+UI.format.time(a,c)},duration:function(a){var c=[0.001,1E3,60,60,24,7,1E9],b="ms sec min hr day week".split(" "),
|
||||
d={},g;for(g in b){var a=a/c[g],k=Math.round(a%c[Number(g)+1]);d[b[g]]=k;a-=k}var m;for(g=b.length-1;0<=g;g--)if(0<d[b[g]]){m=b[g];break}c=$("<span>");switch(m){case "week":c.append(UI.format.addUnit(d.week,"wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":c.append(UI.format.addUnit(d.day,"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:c.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+(d.ms?"."+d.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||
|
||||
0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*c)/c;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var c=$("<span>");if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");
|
||||
break;case 2:c.text("Inactive").addClass("orange");break;default:c.text(a.online)}"undefined"!=typeof a.error&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},addUnit:function(a,c){var b=$("<span>").html(a);b.append($("<span>").addClass("unit").html(c));return b[0].innerHTML},bytes:function(a,c){var b="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=b[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=b[0]:(a/=Math.pow(1024,d),
|
||||
unit=b[d])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s":""))}},navto:function(a,c){var b=location.hash,d=b.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,c].join("&");location.hash=d.join("@");location.hash==b&&$(window).trigger("hashchange")},showTab:function(a,c){var b=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))b.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else{var d=UI.elements.menu.css("visibility","visible").find(".button").filter(function(){if($(this).find(".plain").text()==
|
||||
a)return!0});0<d.length&&(UI.elements.menu.find(".button.active").removeClass("active"),d.addClass("active"));UI.elements.secondary_menu.html("");UI.interval.clear();b.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");break}UI.elements.menu.css("visibility","hidden");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");b.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},
|
||||
{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"password"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.send(function(){UI.navto("Overview")})}}]}]));
|
||||
break;case "Create a new account":UI.elements.menu.css("visibility","hidden");b.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));b.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",
|
||||
pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,b){$(".match_password").not($(b)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"password"},classes:["match_password"]},{label:"Repeat password",type:"password",validate:["required",function(a,b){return a!=$(".match_password").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.password}})}}]}]));break;case "Account created":UI.elements.menu.css("visibility","hidden");b.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)b.append("Unable to enable all protocols as protocol settings already exist.<br>");else{b.append("Retrieving available protocols..<br>");mist.send(function(a){var c=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)b.append('Could not enable protocol "'+d+'" because it has required settings.<br>');else{c.push({connector:d});b.append('Enabled protocol "'+
|
||||
d+'".<br>')}b.append("Saving protocol settings..<br>");mist.send(function(){b.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":var f=$("<span>").text("Loading.."),l=$("<span>"),m=$("<span>"),e=$("<span>");b.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
|
||||
{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,LTSonly:!0},{type:"span",label:"Server time",value:e},{type:"span",label:"Current streams",value:l},{type:"span",label:"Current connections",value:m},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You???ll still need to set host name within your network yourself."},{type:"debug",
|
||||
d+'".<br>')}b.append("Saving protocol settings..<br>");mist.send(function(){b.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":var g=$("<span>").text("Loading.."),k=$("<span>"),m=$("<span>"),e=$("<span>");b.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:g,LTSonly:!0},{type:"span",label:"Server time",value:e},{type:"span",label:"Current streams",value:k},{type:"span",label:"Current connections",value:m},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You???ll still need to set host name within your network yourself."},{type:"debug",
|
||||
label:"Debug level",pointer:{main:mist.data.config,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:"checkbox",label:"Force JSON file save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don???t forget to press save after ticking the box."},
|
||||
{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var p=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?f.addClass("red").text(a.error):a.uptodate?f.text("Your version is up to date.").addClass("green"):f.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){mist.send(function(){UI.navto("Overview")},
|
||||
{autoupdate:true})})):f.text("Unknown")};if(!mist.stored.get().update||864E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var n=mist.stored.get().update||{};n.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,n,a.update));p()},{checkupdate:!0})}else p()}else f.text("");var i=function(){mist.send(function(){v()},{totals:{fields:["clients"],start:-10},active_streams:true})},v=function(){l.text(("active_streams"in mist.data?mist.data.active_streams?
|
||||
{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var r=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?g.addClass("red").text(a.error):a.uptodate?g.text("Your version is up to date.").addClass("green"):g.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){mist.send(function(){UI.navto("Overview")},
|
||||
{autoupdate:true})})):g.text("Unknown")};if(!mist.stored.get().update||864E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var o=mist.stored.get().update||{};o.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,o,a.update));r()},{checkupdate:!0})}else r()}else g.text("");var i=function(){mist.send(function(){v()},{totals:{fields:["clients"],start:-10},active_streams:true})},v=function(){k.text(("active_streams"in mist.data?mist.data.active_streams?
|
||||
mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");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..";m.text(a);e.text(UI.format.dateTime(mist.data.config.time,"long"))};i();v();UI.interval.set(i,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},
|
||||
{capabilities:!0});b.append("Loading..");break}var h=$("<tbody>");b.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")})).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(h));
|
||||
var k=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],e=["required","optional"],f;for(f in e)for(var g in c[e[f]])b[g]&&b[g]!=""?d.push(g+": "+b[g]):c[e[f]][g]["default"]&&d.push(g+": "+c[e[f]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}h.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];h.append($("<tr>").data("index",b).append($("<td>").text(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.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};k();UI.interval.set(function(){mist.send(function(){k()})},
|
||||
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}var j=!1;""!=c&&0<=c&&(j=!0);var g={},r;for(r in mist.data.config.protocols)g[mist.data.config.protocols[r].connector]=1;var O=function(a){var b=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(b,o);d.push({type:"hidden",pointer:{main:o,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save",
|
||||
"function":function(){if(j)mist.data.config.protocols[c]=o;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(o)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var e in b.deps){a=$("<li>").text(b.deps[e]+
|
||||
" ");$ul.append(a);typeof g[b.deps[e]]!="undefined"||typeof g[b.deps[e]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},g={};for(r in mist.data.config.protocols)g[mist.data.config.protocols[r].connector]=1;if(j){var q=mist.data.config.protocols[c],o=q;b.find("h2").append(' "'+q.connector+'"');b.append(O(q.connector))}else{b.html($("<h2>").text("New Protocol"));
|
||||
var o={},t=[];for(r in mist.data.capabilities.connectors)t.push([r,r]);var P=$("<span>");b.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){P.html(O($(this).getval()))}}])).append(P)}break;case "Streams":if(!("capabilities"in mist.data)){b.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}h=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));q=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
|
||||
"string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(h);b.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Immidiately go to the stream preview or view the information available about the stream with the info button."}])).append($("<button>").text("New stream").click(function(){UI.navto("Edit Stream")})).append(q);
|
||||
q.stupidtable();var C=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-10});mist.send(function(){var a=0;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=Q(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;y[mist.data.active_streams[a]]=b}}b=Object.keys(y);b.sort();for(var c in b){var d=b[c],e=y[d],f=$("<td>").css("text-align",
|
||||
"right").html($("<span>").addClass("description").text("Loading..")),g=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){g=mist.data.totals[d].all_protocols.clients;g=g.length?g[g.length-1][1]:0}f.html(UI.format.number(g));if(g==0&&e.online==1)e.online=2;g=$("<td>").css("text-align","right").css("white-space","nowrap");e.ischild||g.html($("<button>").text("Edit").click(function(){UI.navto("Edit Stream",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=
|
||||
$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));var i=$("<span>").text(d);e.ischild&&i.css("padding-left","1em");h.append($("<tr>").data("index",d).html($("<td>").html(i).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width",
|
||||
"20em")).append($("<td>").data("sort-value",e.online).html(UI.format.status(e))).append(f).append($("<td>").html($("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}))).append(g));a++}},{totals:a,active_streams:true})},y=$.extend(!0,{},mist.data.streams),Q=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c};if(mist.data.LTS){var z=0,D=0;for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||
|
||||
mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&&(y[i].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=c+"+"+a.browse.files[d];y[g]=Q(g,mist.data.streams[c]);y[g].source=mist.data.streams[c].source+a.browse.files[d]}D++;if(z==D){mist.send(function(){C()},
|
||||
{active_streams:true});UI.interval.set(function(){C()},3E4)}},{browse:mist.data.streams[i].source},{stream:i}),z++);0==z&&(mist.send(function(){C()},{active_streams:!0}),UI.interval.set(function(){C()},3E4))}else mist.send(function(){C()},{active_streams:!0}),UI.interval.set(function(){C()},3E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}j=!1;""!=c&&(j=!0);j?(q=c,o=mist.data.streams[q],
|
||||
b.find("h2").append(' "'+q+'"')):(b.html($("<h2>").text("New Stream")),o={});i=[];for(r in mist.data.capabilities.inputs)i.push(mist.data.capabilities.inputs[r].source_match);var E=$("<div>");b.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:o,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",validate:["required"],filetypes:i,pointer:{main:o,index:"source"},help:'Set the stream source.<br>VoD: You can browse to the file or folder as a source or simply enter the path to the file.<br>Live: You???ll need to enter "push://IP" with the IP of the machine pushing towards MistServer. You can use "push://" to accept any source.<br>Pro only: use "push://(IP)@password" to set a password protection for pushes.<br>If you\'re unsure how to set the source properly please view our Live pushing guide at the tools section.',
|
||||
"function":function(){var a=$(this).val(),b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)E.html($("<h3>").text("Unrecognized input")).append($("<span>").text("Please edit the stream source."));else{a=mist.data.capabilities.inputs[b];E.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,o);E.append(UI.buildUI(a))}}},$("<br>"),
|
||||
{type:"custom",custom:E},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:o,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:o,index:"contentkey"}},{type:"text",
|
||||
text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){if(!mist.data.streams)mist.data.streams={};mist.data.streams[o.name]=o;c!=o.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[o.name]=o;if(c!=o.name)a.deletestream=
|
||||
[c]}else a.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},a)}}]}]));j&&(i={streams:{}},i.streams[q]=mist.data.streams[q].limits,b.append($("<h3>").text("Limits")).append(UI.buildLimits(i,a,c)));break;case "Preview":if(""==c){b.append("Loading..");var H=function(c){var d={};c.sort();b.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:c,pointer:{main:d,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,
|
||||
d.stream)}}]}]));UI.elements.secondary_menu.html("").append($("<a>").addClass("button").addClass("active").text("Choose stream").click(function(){UI.navto("Preview")}))};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}D=z=0;t={};for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&&
|
||||
(mist.send(function(a,b){var c=b.stream,d;for(d in mist.data.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+mist.data.browse.files[d])&&(t[c+"+"+mist.data.browse.files[d]]=true);D++;z==D&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");b.length>1&&b[0]in mist.data.streams&&(t[mist.data.active_streams[a]]=true)}t=Object.keys(t);
|
||||
t=t.concat(Object.keys(mist.data.streams));t.sort();H(t)},{active_streams:true})},{browse:mist.data.streams[i].source},{stream:i}),z++);0==z&&mist.send(function(){var c=[],d;for(d in mist.data.active_streams){var e=mist.data.active_streams[d].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[d]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)b.html($("<h2>").text(a)).append("Please set up a stream first.");else{c.sort();H(c)}},{active_streams:!0})}else H(Object.keys(mist.data.streams));
|
||||
break}b.find("h2").append(' of "'+c+'"');i=":8080";for(r in mist.data.config.protocols)if(q=mist.data.config.protocols[r],"HTTP"==q.connector||"HTTP.exe"==q.connector)i=q.port?":"+q.port:":8080";var A={},q=$("<span>").hide();A["Embed urls"]=q;b.append(q);var d="",R=mist.user.host.match(/(https?)\:\/\/([^:\/]+)\:(\d+)?/i);null!=R&&(d=R[2]);var F="http://"+d+i+"/",B={},I=function(a){var b=["div"],d='\n <script src="'+F+"embed_"+c+'.js"><\/script>\n';a.autoplay&&b.push("data-autoplay");a.forceprotocol&&
|
||||
a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');return"<"+b.join(" ")+">"+d+"</div>"},S=$("<span>");q.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embed url",type:"str",value:F+"embed_"+c+".js",readonly:!0,qrcode:!0},{label:"Info url",type:"str",value:F+"info_"+c+".js",qrcode:!0,readonly:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:I(B),rows:4,readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",
|
||||
0),{label:"Autoplay",type:"checkbox",pointer:{main:B,index:"autoplay"},"function":function(){B.autoplay=$(this).getval();$(".embed_code").setval(I(B))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:B,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){B.forceprotocol=$(this).getval();$(".embed_code").setval(I(B))}},$("<h3>").text("Protocol stream urls"),S]));i=$("<span>").append($("<h3>").text("Meta information")).hide();A["Meta information"]=
|
||||
i;var J=$("<span>");i.append(J);b.append(i);var T=function(){var a;if(c in mist.data.streams)a=mist.data.streams[c].meta;if(a){var b=[];b.push({label:"Type",type:"span",value:a.live?"Live":"Pre-recorded (VoD)"});"format"in a&&b.push({label:"Format",type:"span",value:a.format});a.live&&b.push({label:"Buffer window",type:"span",value:UI.format.addUnit(a.buffer_window,"ms")});var d={vheader:"Audio",labels:["Codec","Duration","Average bitrate","Channels","Samplerate"],content:[]},e={vheader:"Video",labels:["Codec",
|
||||
"Duration","Average bitrate","Size","Framerate"],content:[]},g=Object.keys(a.tracks);g.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var f in g){var h=g[f],i=a.tracks[h];switch(i.type){case "audio":d.content.push({header:"Track "+h.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",UI.format.bytes(i.bps,1),i.channels,UI.format.addUnit(UI.format.number(i.rate),
|
||||
"Hz")]});break;case "video":e.content.push({header:"Track "+h.split("_").pop(),body:[i.codec,UI.format.duration((i.lastms-i.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(i.firstms/1E3)+" to "+UI.format.duration(i.lastms/1E3)+"</span>",UI.format.bytes(i.bps,1),UI.format.addUnit(i.width,"x ")+UI.format.addUnit(i.height,"px"),UI.format.addUnit(UI.format.number(i.fpks/1E3),"fps")]})}}a=UI.buildVheaderTable(d).css("width","auto");e=UI.buildVheaderTable(e).css("width","auto");b.push($("<span>").text("Tracks:"));
|
||||
b.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(a).append(e));J.html(UI.buildUI(b))}else J.html("No meta information available.")};T();c in mist.data.streams&&!("meta"in mist.data.streams[c])&&mist.send(function(){T()});i=$("<span>").hide();A.Preview=i;b.append(i);var w=$("<div>").css("float","left").css("margin-right","1em").attr("data-forcesupportcheck",""),U=$("<div>").css("float","left");i.append(w).append(U);mist.stored.get().autoplay&&
|
||||
w.attr("data-autoplay","");var G=function(){w.text("Loading..");var a=document.createElement("script");a.src=F+"embed_"+c+".js";a.onerror=function(){w.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){G()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")w.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){G()}));else{var a=mistvideo[c],b=UI.buildUI([{label:"Protocol stream url",type:"str",readonly:true,
|
||||
value:a.embedded?a.embedded.url:"",qrcode:true},{label:"Autoplay (from now on)",type:"checkbox",value:mist.stored.get().autoplay,"function":function(){mist.stored.set("autoplay",$(this).getval()?1:0)}}]);b.find(".help_container").remove();w.append(b);var d=$("<table>").css("font-size","0.9em").html($("<thead>").html($("<tr>").html($("<th>")).append($("<th>").text("Type")).append($("<th>").text("Priority")).append($("<th>").text("Simul. tracks")).append($("<th>").html("Your browser<br>support"))));
|
||||
U.html(d);b=$("<tbody>");d.append(b);var d=$(".embed_code_forceprotocol"),e=[];d.find(".clear").remove();for(var g in a.source){var f=a.source[g],i=f.type.split("/"),h=i[0];h.length<6&&(h=h.toUpperCase());switch(i.length){case 1:break;case 2:h=UI.format.capital(i[0])+" v"+i[1];if(i[0]=="flash")switch(i[1]){case "7":h="Progressive ("+h+")";break;case "10":h="RTMP ("+h+")";break;case "11":h="HDS ("+h+")"}break;case 3:switch(i[2]){case "vnd.apple.mpegurl":h=h+" HLS";break;case "vnd.ms-ss":h=h+" Smooth";
|
||||
break;case "mp2t":h=h+" TS";break;default:i[2].length<6&&(i[2]=i[2].toUpperCase());h=h+(" "+i[2]);i[1]!="video"&&(h=h+(" ("+i[1]+")"))}break;default:h=f.type}h=UI.format.capital(h);d.append($("<option>").text(h).val(f.type).addClass("clear"));e.push({label:h,type:"str",value:f.url,readonly:true,qrcode:true});i=$("<tr>");b.append(i);i.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){w.attr("data-forcetype",$(this).val()).html("Loading embed..");G()}).val(f.type))).append($("<td>").text(h)).append($("<td>").text(f.priority)).append($("<td>").text(f.simul_tracks+
|
||||
"/"+f.total_matches)).append($("<td>").text(f.browser_support?"yes":"no"));if(a.embedded&&a.embedded.type==f.type){i.css("outline","1px solid rgba(0,0,0,0.5)");i.find("input[type=radio]").prop("checked",true)}}S.html(UI.buildUI(e))}};w.html("")[0].appendChild(a)};G();var K=UI.elements.secondary_menu;K.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));i=["Preview","Embed urls","Meta information"];g=i[0];
|
||||
for(r in i)q=$("<a>").addClass("button").text(i[r]).click(function(){K.find(".active").removeClass("active");$(this).addClass("active");for(r in A)A[r].hide();A[$(this).text()].show()}),K.append(q),i[r]==g&&(q.addClass("active"),A[g].show());break;case "Limits":b.append(UI.buildUI([{type:"help",help:"Here you can see an overview of all the limits you currently have. Limits are an LTS only feature and you can simply add new limits by selecting new, by selecting edit you can edit the existing limit, by selecting delete you can delete the existing limit."}]));
|
||||
i={server:mist.data.config.limits,streams:{}};for(r in mist.data.streams)"limits"in mist.data.streams[r]&&(i.streams[r]=mist.data.streams[r].limits);b.append(UI.buildLimits(i,a,c));break;case "Edit Limit":j=!1;""!=c&&(j=!0);o={};i=[{type:"help",help:"Here you can set the limit specifications, soft limits only warn while hard limits restrict access. Please feel free to set up limits according to your preferences."}];"Overview"==UI.returnTab[0]&&(UI.returnTab=["Limits"]);if(j){q=c.split("^");d=a;switch(q[0]){case "server":o=
|
||||
mist.data.config.limits[q[1]];d="For the entire server";break;case "stream":o=mist.data.streams[q[1]].limits[q[2]],d='For the stream "'+q[1]+'"'}i.push({type:"text",text:d})}else{b.html($("<h2>").text("New limit"));var x=[];for(r in mist.data.streams)x.push(r);t=[["server","The entire server"],["stream","The stream:",x]];q={label:"Applies to",type:"radioselect",radioselect:t,pointer:{main:o,index:"applies_to"},LTSonly:!0,validate:["required"]};"Edit Stream"==UI.returnTab[0]&&UI.returnTab[1]&&(q.value=
|
||||
["stream",UI.returnTab[1]],q.readonly=!0);i.push(q)}var i=i.concat([$("<br>"),{label:"Kind",type:"select",select:[["soft","Soft"],["hard","Hard"]],pointer:{main:o,index:"type"},help:"The server will not allow a hard limit to be passed. A soft limit can be used to set alerts.",LTSonly:!0,validate:["required"]},{label:"Value",pointer:{main:o,index:"value"},classes:["limit_value"],LTSonly:!0},{label:"Type",type:"select",select:[["kbps_max","Maximum bandwidth"],["users","Maximum connected users"],["geo",
|
||||
"Geo limited"],["host","Host limited"]],pointer:{main:o,index:"name"},LTSonly:!0,validate:["required"],classes:["limit_type"],"function":function(){var a=$(this).getval(),b=$(this).closest(".input_container").find(".limit_value"),c=b.closest("label"),b=b.data("opts");delete b.type;delete b.min;delete b.unit;b.validate=["required"];switch(a){case "kbps_max":b.type="int";b.min=1;b.unit="bytes/s";break;case "users":b.type="int";b.min=1;break;case "geo":b.type="geolimited";break;case "host":b.type="hostlimited"}a=
|
||||
UI.buildUI([b]);c.replaceWith(a.children())}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto(UI.returnTab[0],UI.returnTab[1])}},{type:"save",label:"Save","function":function(){var a={};if(j){var b=c.split("^");switch(b[0]){case "server":a={config:{limits:mist.data.config.limits}};break;case "stream":if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}else{b=o.applies_to;delete o.applies_to;switch(b[0]){case "server":if(!mist.data.config.limits)mist.data.config.limits=
|
||||
[];mist.data.config.limits.push(o);a={config:{limits:mist.data.config.limits}};break;case "stream":if(typeof mist.data.streams[b[1]].limits=="undefined")mist.data.streams[b[1]].limits=[];mist.data.streams[b[1]].limits.push(o);if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}mist.send(function(){UI.navto(UI.returnTab[0],UI.returnTab[1])},a)}}]}]),u=UI.buildUI(i);b.append(u);u.find(".limit_type").closest("label").after(u.find(".limit_value").closest("label"));
|
||||
u.find(".limit_type").trigger("change");break;case "Logs":b.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(){clearInterval(UI.interval);UI.interval.set(function(){mist.send(function(){V()})},$(this).val()*
|
||||
1E3)}}]));b.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));h=$("<tbody>").css("font-size","0.9em");b.append($("<table>").append(h));var X=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},V=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();h.html("");for(var b in a)h.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],
|
||||
"long")).css("white-space","nowrap")).append($("<td>").html(X(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align","left")))}};V();break;case "Statistics":u=$("<span>").text("Loading..");b.append(u);var o={},s=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},x={};for(r in mist.data.streams)x[r]=!0;for(r in mist.data.active_streams)x[mist.data.active_streams[r]]=!0;var x=Object.keys(x).sort(),L=[];for(r in mist.data.config.protocols)L.push(mist.data.config.protocols[r].connector);
|
||||
L.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;u.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new",
|
||||
"New graph"]],pointer:{main:o,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=u.find(".graph_xaxis"),b=u.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(s).length+1)).closest("label").show()}else{var c=s[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&
|
||||
a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:o,index:"id"},classes:["graph_id"],validate:[function(a){return a in s?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"],["coords","Geographical"]],pointer:{main:o,index:"xaxis"},classes:["graph_xaxis"],"function":function(){$s=u.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 load"],["memload","Memory load"],["coords",
|
||||
"Client location"]],pointer:{main:o,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=u.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:",x],["protocol",
|
||||
"The protocol:",L]],pointer:{main:o,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(o.graph=="new"){a=UI.plot.addGraph(o,c);s[a.id]=a;u.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=s[o.graph];var b=UI.plot.datatype.getOptions({datatype:o.datatype,origin:o.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(s)}}]}]));var c=$("<div>").addClass("graph_container");
|
||||
b.append(c);var d=u.find("select.graph_ids");for(a in s){var e=UI.plot.addGraph(s[a],c);d.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in s[a].datasets){var h=UI.plot.datatype.getOptions({datatype:s[a].datasets[g].datatype,origin:s[a].datasets[g].origin});f.push(h)}e.datasets=f;s[e.id]=e}d.trigger("change");UI.plot.go(s);UI.interval.set(function(){UI.plot.go(s)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},
|
||||
{capabilities:!0});b.append("Loading..");break}var M=$("<table>"),N=$("<table>"),i={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(r in mist.data.capabilities.cpu)q=mist.data.capabilities.cpu[r],i.content.push({header:"CPU #"+(Number(r)+1),body:[q.model,UI.format.addUnit(UI.format.number(q.mhz),"MHz"),q.cores,q.threads]});var i=UI.buildVheaderTable(i),W=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);M.replaceWith(a);M=a;b={vheader:"Load average",
|
||||
labels:["1 minute","5 minutes","15 minutes",""],content:[{header:" ",body:[UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100),""]}]};b=UI.buildVheaderTable(b);N.replaceWith(b);N=b};W();b.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(M)).append($("<td>").append(N))).append($("<tr>").append($("<td>").append(i).attr("colspan",
|
||||
2))));UI.interval.set(function(){mist.send(function(){W()},{capabilities:true})},3E4);break;case "Email for Help":i=$.extend({},mist.data);delete i.statistics;delete i.totals;delete i.clients;delete i.capabilities;i=JSON.stringify(i);i="Version: "+mist.data.config.version+"\n\nConfig:\n"+i;o={};b.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},{type:"str",label:"Your name",
|
||||
validate:["required"],pointer:{main:o,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:o,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:o,index:"subject"}},{type:"hidden",value:"-",pointer:{main:o,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:o,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:i,pointer:{main:o,index:"configfile"}},
|
||||
{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact_us?skin=plain",data:o,success:function(a){a=$("<span>").html(a);a.find("script").remove();b.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;UI.navto("Login");break;default:b.append($("<p>").text("This tab does not exist."))}}}},mist={data:{},user:{name:"",password:"",
|
||||
host:"http://"+(location.hostname?location.hostname:"localhost")+":4242/api"},send:function(a,c,b){var c=c||{},b=b||{},b=$.extend(!0,{timeout:30,sendData:c},b),d={authorize:{password:mist.user.authstring?MD5(MD5(mist.user.password)+mist.user.authstring):"",username:mist.user.name}};$.extend(!0,d,c);log("Send",$.extend(!0,{},c));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:!0,timeout:1E3*b.timeout,async:!0,error:function(d,f){delete mist.user.loggedin;
|
||||
if(!b.hide){switch(f){case "timeout":f=$("<i>").text("The connection timed out. ");break;case "abort":f=$("<i>").text("The connection was aborted. ");break;default:f=$("<i>").text(f+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(f).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,b)}))}UI.navto("Login")},success:function(d){log("Receive",$.extend(!0,
|
||||
{},d),"as reply to",b.sendData);delete mist.user.loggedin;switch(d.authorize.status){case "OK":$.extend(!0,mist.data,d);mist.data.streams=d.streams;mist.data.config.protocols=d.config.protocols;mist.data.config.limits=d.config.limits;mist.user.loggedin=!0;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));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){var f=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(f[0])+" ["+f[1]+"] "+f[2])}if("totals"in d)if(f=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([g,0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var j=0,g;if(c.data){600>c.end-c.start?(g=1E3*(c.end-600),d(),g=1E3*c.start,d()):g=1E3*c.start;
|
||||
for(f in c.data){if(0==f){g=1E3*c.start;var l=0}else g+=1E3*c.interval[l][1],c.interval[l][0]--,0>=c.interval[l][0]&&(l++,l<c.interval.length-1&&(j=2));1==j&&(d(),j--);for(var m in c.data[f])e[c.fields[m]].push([g,c.data[f][m]]);j&&(d(),j--)}5<mist.data.config.time-c.end&&(d(),g=1E3*mist.data.config.time,d())}else g=1E3*(mist.data.config.time-600),d(),g=1E3*mist.data.config.time,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={},"fields"in d.totals)f(c.totals.streams,c.totals.protocols,d.totals);else for(var e in d.totals)f(c.totals[e].streams,c.totals[e].protocols,d.totals[e]);a&&a(d,b);break;case "CHALL":d.authorize.challenge==mist.user.authstring?(""!=mist.user.password&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red"),UI.navto("Login")):
|
||||
""==mist.user.password?UI.navto("Login"):(mist.user.authstring=d.authorize.challenge,mist.send(a,c,b));break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete c.authorize;mist.send(a,c,b);break;default:UI.navto("Login")}}};b.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){f.abort()}));var f=$.ajax(d)},inputMatch:function(a,c){if("undefined"==typeof a)return!1;
|
||||
var b=a.replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");return RegExp("^"+b+"$","i").test(c)},convertBuildOptions:function(a,c){var b=[],d=["required","optional"];"desc"in a&&b.push({type:"help",help:a.desc});for(var f in d)if(a[d[f]]){b.push($("<h4>").text(UI.format.capital(d[f])+" parameters"));for(var l in a[d[f]]){var m=a[d[f]][l],e={label:UI.format.capital(m.name),pointer:{main:c,index:l},validate:[]};"required"==d[f]&&!("default"in m)&&e.validate.push("required");
|
||||
var l=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],e=["required","optional"],g;for(g in e)for(var f in c[e[g]])b[f]&&b[f]!=""?d.push(f+": "+b[f]):c[e[g]][f]["default"]&&d.push(f+": "+c[e[g]][f]["default"]);return $("<span>").addClass("description").text(d.join(", "))}h.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];h.append($("<tr>").data("index",b).append($("<td>").text(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.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};l();UI.interval.set(function(){mist.send(function(){l()})},
|
||||
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}var j=!1;""!=c&&0<=c&&(j=!0);var f={},q;for(q in mist.data.config.protocols)f[mist.data.config.protocols[q].connector]=1;var P=function(a){var b=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(b,n);d.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save",
|
||||
"function":function(){if(j)mist.data.config.protocols[c]=n;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(n)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var e in b.deps){a=$("<li>").text(b.deps[e]+
|
||||
" ");$ul.append(a);typeof f[b.deps[e]]!="undefined"||typeof f[b.deps[e]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},f={};for(q in mist.data.config.protocols)f[mist.data.config.protocols[q].connector]=1;if(j){var p=mist.data.config.protocols[c],n=p;b.find("h2").append(' "'+p.connector+'"');b.append(P(p.connector))}else{b.html($("<h2>").text("New Protocol"));
|
||||
var n={},t=[];for(q in mist.data.capabilities.connectors)t.push([q,q]);var Q=$("<span>");b.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){Q.html(P($(this).getval()))}}])).append(Q)}break;case "Streams":if(!("capabilities"in mist.data)){b.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}h=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));p=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
|
||||
"string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(h);b.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Immidiately go to the stream preview or view the information available about the stream with the info button."}])).append($("<button>").text("New stream").click(function(){UI.navto("Edit Stream")})).append(p);
|
||||
p.stupidtable();var D=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-10});mist.send(function(){$.extend(true,x,mist.data.streams);var a=0;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=R(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;x[mist.data.active_streams[a]]=b}}b=Object.keys(x);b.sort();for(var c in b){var d=
|
||||
b[c],e=x[d],g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){f=mist.data.totals[d].all_protocols.clients;f=f.length?f[f.length-1][1]:0}g.html(UI.format.number(f));if(f==0&&e.online==1)e.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");e.ischild||f.html($("<button>").text("Edit").click(function(){UI.navto("Edit Stream",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=
|
||||
$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));var i=$("<span>").text(d);e.ischild&&i.css("padding-left","1em");var j=UI.format.status(e),k=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){j.html("");k="";g.html("")}h.append($("<tr>").data("index",
|
||||
d).html($("<td>").html(i).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(j)).append(g).append($("<td>").html(k)).append(f));a++}},{totals:a,active_streams:true})},x=$.extend(!0,{},mist.data.streams),R=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c};if(mist.data.LTS){var A=
|
||||
0,E=0;for(i in mist.data.streams)p=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(p.source_match,mist.data.streams[i].source)&&(x[i].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=c+"+"+a.browse.files[d];x[g]=R(g,mist.data.streams[c]);
|
||||
x[g].source=mist.data.streams[c].source+a.browse.files[d]}a.browse.files.length?x[c].filesfound=true:mist.data.streams[c].filesfound=false;E++;if(A==E){mist.send(function(){D()},{active_streams:true});UI.interval.set(function(){D()},3E4)}},{browse:mist.data.streams[i].source},{stream:i}),A++);0==A&&(mist.send(function(){D()},{active_streams:!0}),UI.interval.set(function(){D()},3E4))}else mist.send(function(){D()},{active_streams:!0}),UI.interval.set(function(){D()},3E4);break;case "Edit Stream":if("undefined"==
|
||||
typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}j=!1;""!=c&&(j=!0);j?(p=c,n=mist.data.streams[p],b.find("h2").append(' "'+p+'"')):(b.html($("<h2>").text("New Stream")),n={});i=[];for(q in mist.data.capabilities.inputs)i.push(mist.data.capabilities.inputs[q].source_match);var F=$("<div>");b.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:n,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},
|
||||
{label:"Source",type:"browse",validate:["required"],filetypes:i,pointer:{main:n,index:"source"},help:'Set the stream source.<table><tr><td>VoD:</td><td>You can browse to the file or folder as a source or simply enter the path to the file.</td></tr><tr><td>Live:</td><td>You\'ll need to enter "push://IP" with the IP of the machine pushing towards MistServer.<br>You can use "push://" to accept any source.</td></tr><tr><td>(Pro only)</td><td>Use "push://(IP)@password" to set a password protection for pushes.</td></tr></table>If you\'re unsure how to set the source properly, please view our Live pushing guide at the tools section.',
|
||||
"function":function(){var a=$(this).val(),b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)F.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{a=mist.data.capabilities.inputs[b];F.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,
|
||||
n);F.append(UI.buildUI(a))}}},$("<br>"),{type:"custom",custom:F},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:n,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:n,
|
||||
index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:n,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:n,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;c!=n.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[n.name]=
|
||||
n;if(c!=n.name)a.deletestream=[c]}else a.streams=mist.data.streams;mist.send(function(){delete mist.data.streams[n.name].online;delete mist.data.streams[n.name].error;UI.navto("Streams")},a)}}]}]));j&&(i={streams:{}},i.streams[p]=mist.data.streams[p].limits,b.append($("<h3>").text("Limits")).append(UI.buildLimits(i,a,c)));break;case "Preview":if(""==c){b.append("Loading..");var I=function(c){var d={};c.sort();b.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:c,
|
||||
pointer:{main:d,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,d.stream)}}]}]));UI.elements.secondary_menu.html("").append($("<a>").addClass("button").addClass("active").text("Choose stream").click(function(){UI.navto("Preview")}));var e=$("<div>").addClass("preview_icons");b.append($("<span>").addClass("description").text("Or, click a stream from the list below.")).append(e);for(var g in c){var f=c[g],i="";if(f.indexOf("+")>-1){i=f.split("+");i=
|
||||
mist.data.streams[i[0]].source+i[1]}else i=mist.data.streams[f].source;e.append($("<button>").append($("<span>").text(f)).append($("<span>").addClass("description").text(i)).attr("title",f).attr("data-stream",f).click(function(){UI.navto("Preview",$(this).attr("data-stream"))}))}};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}E=A=0;t={};for(i in mist.data.streams)p=mist.data.capabilities.inputs.Folder||
|
||||
mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(p.source_match,mist.data.streams[i].source)&&(mist.send(function(a,b){var c=b.stream,d;for(d in mist.data.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+mist.data.browse.files[d])&&(t[c+"+"+mist.data.browse.files[d]]=true);E++;A==E&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");
|
||||
b.length>1&&b[0]in mist.data.streams&&(t[mist.data.active_streams[a]]=true)}t=Object.keys(t);t=t.concat(Object.keys(mist.data.streams));t.sort();I(t)},{active_streams:true})},{browse:mist.data.streams[i].source},{stream:i}),A++);0==A&&mist.send(function(){var c=[],d;for(d in mist.data.active_streams){var e=mist.data.active_streams[d].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[d]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)b.html($("<h2>").text(a)).append("Please set up a stream first.");
|
||||
else{c.sort();I(c)}},{active_streams:!0})}else I(Object.keys(mist.data.streams));break}b.find("h2").append(' of "'+c+'"');i=":8080";for(q in mist.data.config.protocols)if(p=mist.data.config.protocols[q],"HTTP"==p.connector||"HTTP.exe"==p.connector)i=p.port?":"+p.port:":8080";var B={},p=$("<span>").hide();B["Embed urls"]=p;b.append(p);var w="",d=mist.user.host.match(/(https?)\:\/\/([^:\/]+)\:(\d+)?/i);null!=d&&(w=d[2]);var G="http://"+w+i+"/",C={},J=function(a){var b=["div"],d='\n <script src="'+
|
||||
G+"embed_"+c+'.js"><\/script>\n';a.autoplay&&b.push("data-autoplay");a.forceprotocol&&a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');return"<"+b.join(" ")+">"+d+"</div>"},S=$("<span>");p.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embed url",type:"str",value:G+"embed_"+c+".js",readonly:!0,qrcode:!0},{label:"Info url",type:"str",value:G+"info_"+c+".js",qrcode:!0,readonly:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:J(C),rows:4,
|
||||
readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",pointer:{main:C,index:"autoplay"},"function":function(){C.autoplay=$(this).getval();$(".embed_code").setval(J(C))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:C,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){C.forceprotocol=$(this).getval();$(".embed_code").setval(J(C))}},$("<h3>").text("Protocol stream urls"),
|
||||
S]));i=$("<span>").append($("<h3>").text("Meta information")).hide();B["Meta information"]=i;var K=$("<span>");i.append(K);b.append(i);i=$("<span>").hide();B.Preview=i;b.append(i);var y=$("<div>").css("float","left").css("margin-right","1em").attr("data-forcesupportcheck",""),T=$("<div>").css("float","left");i.append(y).append(T);mist.stored.get().autoplay&&y.attr("data-autoplay","");var H=function(){y.text("Loading..");var a=document.createElement("script");a.src=G+"embed_"+c+".js";a.onerror=function(){y.html('Error loading "'+
|
||||
a.src+'".<br>').append($("<button>").text("Try again").click(function(){H()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")y.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){H()}));else{var a=mistvideo[c],b=UI.buildUI([{label:"Protocol stream url",type:"str",readonly:true,value:a.embedded?a.embedded.url:"",qrcode:true},{label:"Autoplay (from now on)",type:"checkbox",value:mist.stored.get().autoplay,"function":function(){mist.stored.set("autoplay",
|
||||
$(this).getval()?1:0)}}]);b.find(".help_container").remove();y.append(b);var d=$("<table>").css("font-size","0.9em").html($("<thead>").html($("<tr>").html($("<th>")).append($("<th>").text("Type")).append($("<th>").text("Priority")).append($("<th>").text("Simul. tracks")).append($("<th>").html("Your browser<br>support"))));T.html(d);b=$("<tbody>");d.append(b);var d=$(".embed_code_forceprotocol"),e=[];d.find(".clear").remove();for(var g in a.source){var f=a.source[g],i=f.type.split("/"),h=i[0];h.length<
|
||||
6&&(h=h.toUpperCase());switch(i.length){case 1:break;case 2:h=UI.format.capital(i[0])+" v"+i[1];if(i[0]=="flash")switch(i[1]){case "7":h="Progressive ("+h+")";break;case "10":h="RTMP ("+h+")";break;case "11":h="HDS ("+h+")"}break;case 3:switch(i[2]){case "vnd.apple.mpegurl":h=h+" HLS";break;case "vnd.ms-ss":h=h+" Smooth";break;case "mp2t":h=h+" TS";break;default:i[2].length<6&&(i[2]=i[2].toUpperCase());h=h+(" "+i[2]);i[1]!="video"&&(h=h+(" ("+i[1]+")"))}break;default:h=f.type}h=UI.format.capital(h);
|
||||
d.append($("<option>").text(h).val(f.type).addClass("clear"));e.push({label:h,type:"str",value:f.url,readonly:true,qrcode:true});i=$("<tr>");b.append(i);i.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){y.attr("data-forcetype",$(this).val()).html("Loading embed..");H()}).val(f.type))).append($("<td>").text(h)).append($("<td>").text(f.priority)).append($("<td>").text(f.simul_tracks+"/"+f.total_matches)).append($("<td>").text(f.browser_support?"yes":
|
||||
"no"));if(a.embedded&&a.embedded.type==f.type){i.css("outline","1px solid rgba(0,0,0,0.5)");i.find("input[type=radio]").prop("checked",true)}}S.html(UI.buildUI(e));var j;if(c in mistvideo)j=mistvideo[c].meta;if(j){a=[];a.push({label:"Type",type:"span",value:j.live?"Live":"Pre-recorded (VoD)"});"format"in j&&a.push({label:"Format",type:"span",value:j.format});j.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(j.buffer_window,"ms")});b={vheader:"Audio",labels:["Codec","Duration",
|
||||
"Average bitrate","Channels","Samplerate"],content:[]};g={vheader:"Video",labels:["Codec","Duration","Average bitrate","Size","Framerate"],content:[]};d=Object.keys(j.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var k in d){e=d[k];f=j.tracks[e];switch(f.type){case "audio":b.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/
|
||||
1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz")]});break;case "video":g.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps")]})}}j=UI.buildVheaderTable(b).css("width",
|
||||
"auto");k=UI.buildVheaderTable(g).css("width","auto");a.push($("<span>").text("Tracks:"));a.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(j).append(k));K.html(UI.buildUI(a))}else K.html("No meta information available.")}};y.html("")[0].appendChild(a)};H();var L=UI.elements.secondary_menu;L.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));
|
||||
i=["Preview","Embed urls","Meta information"];f=i[0];for(q in i)p=$("<a>").addClass("button").text(i[q]).click(function(){L.find(".active").removeClass("active");$(this).addClass("active");for(q in B)B[q].hide();B[$(this).text()].show()}),L.append(p),i[q]==f&&(p.addClass("active"),B[f].show());break;case "Limits":b.append(UI.buildUI([{type:"help",help:"Here you can see an overview of all the limits you currently have. Limits are an LTS only feature and you can simply add new limits by selecting new, by selecting edit you can edit the existing limit, by selecting delete you can delete the existing limit."}]));
|
||||
i={server:mist.data.config.limits,streams:{}};for(q in mist.data.streams)"limits"in mist.data.streams[q]&&(i.streams[q]=mist.data.streams[q].limits);b.append(UI.buildLimits(i,a,c));break;case "Edit Limit":j=!1;""!=c&&(j=!0);n={};i=[{type:"help",help:"Here you can set the limit specifications, soft limits only warn while hard limits restrict access. Please feel free to set up limits according to your preferences."}];"Overview"==UI.returnTab[0]&&(UI.returnTab=["Limits"]);if(j){p=c.split("^");w=a;switch(p[0]){case "server":n=
|
||||
mist.data.config.limits[p[1]];w="For the entire server";break;case "stream":n=mist.data.streams[p[1]].limits[p[2]],w='For the stream "'+p[1]+'"'}i.push({type:"text",text:w})}else{b.html($("<h2>").text("New limit"));var z=[];for(q in mist.data.streams)z.push(q);t=[["server","The entire server"],["stream","The stream:",z]];p={label:"Applies to",type:"radioselect",radioselect:t,pointer:{main:n,index:"applies_to"},LTSonly:!0,validate:["required"]};"Edit Stream"==UI.returnTab[0]&&UI.returnTab[1]&&(p.value=
|
||||
["stream",UI.returnTab[1]],p.readonly=!0);i.push(p)}var i=i.concat([$("<br>"),{label:"Kind",type:"select",select:[["soft","Soft"],["hard","Hard"]],pointer:{main:n,index:"type"},help:"The server will not allow a hard limit to be passed. A soft limit can be used to set alerts.",LTSonly:!0,validate:["required"]},{label:"Value",pointer:{main:n,index:"value"},classes:["limit_value"],LTSonly:!0},{label:"Type",type:"select",select:[["kbps_max","Maximum bandwidth"],["users","Maximum connected users"],["geo",
|
||||
"Geo limited"],["host","Host limited"]],pointer:{main:n,index:"name"},LTSonly:!0,validate:["required"],classes:["limit_type"],"function":function(){var a=$(this).getval(),b=$(this).closest(".input_container").find(".limit_value"),c=b.closest("label"),b=b.data("opts");delete b.type;delete b.min;delete b.unit;b.validate=["required"];switch(a){case "kbps_max":b.type="int";b.min=1;b.unit="bytes/s";break;case "users":b.type="int";b.min=1;break;case "geo":b.type="geolimited";break;case "host":b.type="hostlimited"}a=
|
||||
UI.buildUI([b]);c.replaceWith(a.children())}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto(UI.returnTab[0],UI.returnTab[1])}},{type:"save",label:"Save","function":function(){var a={};if(j){var b=c.split("^");switch(b[0]){case "server":a={config:{limits:mist.data.config.limits}};break;case "stream":if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}else{b=n.applies_to;delete n.applies_to;switch(b[0]){case "server":if(!mist.data.config.limits)mist.data.config.limits=
|
||||
[];mist.data.config.limits.push(n);a={config:{limits:mist.data.config.limits}};break;case "stream":if(typeof mist.data.streams[b[1]].limits=="undefined")mist.data.streams[b[1]].limits=[];mist.data.streams[b[1]].limits.push(n);if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}mist.send(function(){UI.navto(UI.returnTab[0],UI.returnTab[1])},a)}}]}]),u=UI.buildUI(i);b.append(u);u.find(".limit_type").closest("label").after(u.find(".limit_value").closest("label"));
|
||||
u.find(".limit_type").trigger("change");break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});h=$("<tbody>");p=$("<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("Execute URL").attr("data-sort-type","string")).append($("<th>")))).append(h);b.append(UI.buildUI([{type:"help",help:"Balder verzin iets leuks"}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(p);
|
||||
p.stupidtable();i=mist.data.config.triggers;for(q in i)for(w in i[q])h.append($("<tr>").attr("data-index",q+","+w).append($("<td>").text(q)).append($("<td>").text(i[q][w][2].join(", "))).append($("<td>").text(i[q][w][0])).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});c?(c=c.split(","),i=mist.data.config.triggers[c[0]][c[1]],
|
||||
n={triggeron:c[0],appliesto:i[2],url:i[0],async:i[1],"default":i[3]}):(b.html($("<h2>").text("New Trigger")),n={});b.append(UI.buildUI([{type:"help",help:"Balder verzin iets leuks"},{label:"Trigger on",pointer:{main:n,index:"triggeron"},help:"Balder verzin iets leuks",type:"select",select:[["SYSTEM_START","server boot"],["SYSTEM_STOP","server exit"],["SYSTEM_CONFIG","config changed"],["SYSTEM_LOG","log line logged"],["OUTPUT_ADD","new output configured"],["OUTPUT_CONFIG","output config changed"],
|
||||
["OUTPUT_REMOVE","deleted output in config"],["STREAM_ADD","new stream configured"],["STREAM_CONFIG","stream config changed"],["STREAM_REMOVE","stream config deleted"],["STREAM_LOAD","stream input loaded in memory"],["STREAM_UNLOAD","stream input unloaded from memory"],["STREAM_TRACK_ADD","added track to stream; ie: push/multi"],["STREAM_TRACK_REMOVE","removed track from stream"],["CONN_OPEN","new connection"],["CONN_CLOSE","connection closed"],["CONN_PLAY","before play start, includes limits status"],
|
||||
["CONN_STOP","play end, but no disconnect yet"]],LTSonly:!0},{label:"Applies to",pointer:{main:n,index:"appliesto"},help:"Balder verzin iets leuks (none checked = all are checked)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Excecute URL",help:"Balder verzin iets leuks",pointer:{main:n,index:"url"},validate:["required"],type:"str",LTSonly:!0},{label:"Asynchronous",type:"checkbox",help:"Balder verzin iets leuks",pointer:{main:n,index:"async"},LTSonly:!0},
|
||||
{label:"Default return on error",type:"str",help:"Balder verzin iets leuks (synchronous only)",pointer:{main:n,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a=[n.url,n.async?true:false,typeof n.appliesto!="undefined"?n.appliesto:[]];typeof n["default"]!="undefined"&&a.push(n["default"]);n.triggeron in mist.data.config.triggers||
|
||||
(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));break;case "Logs":b.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(){clearInterval(UI.interval);UI.interval.set(function(){mist.send(function(){U()})},$(this).val()*1E3)}}]));b.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));h=$("<tbody>").css("font-size","0.9em");b.append($("<table>").append(h));var W=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},U=function(){var a=
|
||||
mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();h.html("");for(var b in a)h.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(W(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align","left")))}};U();break;case "Statistics":u=$("<span>").text("Loading..");b.append(u);var n={},s=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},z={};for(q in mist.data.streams)z[q]=
|
||||
!0;for(q in mist.data.active_streams)z[mist.data.active_streams[q]]=!0;var z=Object.keys(z).sort(),M=[];for(q in mist.data.config.protocols)M.push(mist.data.config.protocols[q].connector);M.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;u.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:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=u.find(".graph_xaxis"),b=u.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(s).length+1)).closest("label").show()}else{var c=s[$(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:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in s?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"],["coords","Geographical"]],pointer:{main:n,index:"xaxis"},classes:["graph_xaxis"],
|
||||
"function":function(){$s=u.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 load"],["memload","Memory load"],["coords","Client location"]],pointer:{main:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=u.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:",z],["protocol","The protocol:",M]],pointer:{main:n,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(n.graph=="new"){a=UI.plot.addGraph(n,c);s[a.id]=a;u.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=s[n.graph];var b=UI.plot.datatype.getOptions({datatype:n.datatype,
|
||||
origin:n.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(s)}}]}]));var c=$("<div>").addClass("graph_container");b.append(c);var d=u.find("select.graph_ids");for(a in s){var e=UI.plot.addGraph(s[a],c);d.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in s[a].datasets){var i=UI.plot.datatype.getOptions({datatype:s[a].datasets[g].datatype,origin:s[a].datasets[g].origin});f.push(i)}e.datasets=f;s[e.id]=e}d.trigger("change");UI.plot.go(s);UI.interval.set(function(){UI.plot.go(s)},1E4)},
|
||||
{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});b.append("Loading..");break}var N=$("<table>"),O=$("<table>"),i={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(q in mist.data.capabilities.cpu)p=mist.data.capabilities.cpu[q],i.content.push({header:"CPU #"+(Number(q)+1),body:[p.model,UI.format.addUnit(UI.format.number(p.mhz),"MHz"),
|
||||
p.cores,p.threads]});var i=UI.buildVheaderTable(i),V=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);N.replaceWith(a);N=a;b={vheader:"Load average",labels:["1 minute","5 minutes","15 minutes",""],content:[{header:" ",body:[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};V();b.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(N)).append($("<td>").append(O))).append($("<tr>").append($("<td>").append(i).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){V()},{capabilities:true})},3E4);break;case "Email for Help":i=$.extend({},mist.data);delete i.statistics;delete i.totals;delete i.clients;delete i.capabilities;i=JSON.stringify(i);i="Version: "+mist.data.config.version+"\n\nConfig:\n"+i;n={};b.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},
|
||||
{type:"str",label:"Your name",validate:["required"],pointer:{main:n,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:n,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:n,index:"subject"}},{type:"hidden",value:"-",pointer:{main:n,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:n,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:i,
|
||||
pointer:{main:n,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact_us?skin=plain",data:n,success:function(a){a=$("<span>").html(a);a.find("script").remove();b.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;UI.navto("Login");break;default:b.append($("<p>").text("This tab does not exist."))}}}},mist=
|
||||
{data:{},user:{name:"",password:"",host:"http://"+(location.hostname?location.hostname:"localhost")+":4242/api"},send:function(a,c,b){var c=c||{},b=b||{},b=$.extend(!0,{timeout:30,sendData:c},b),d={authorize:{password:mist.user.authstring?MD5(MD5(mist.user.password)+mist.user.authstring):"",username:mist.user.name}};$.extend(!0,d,c);log("Send",$.extend(!0,{},c));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:!0,timeout:1E3*b.timeout,async:!0,error:function(d,
|
||||
g){delete mist.user.loggedin;if(!b.hide){switch(g){case "timeout":g=$("<i>").text("The connection timed out. ");break;case "abort":g=$("<i>").text("The connection was aborted. ");break;default:g=$("<i>").text(g+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(g).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,b)}))}UI.navto("Login")},success:function(d){log("Receive",
|
||||
$.extend(!0,{},d),"as reply to",b.sendData);delete mist.user.loggedin;switch(d.authorize.status){case "OK":$.extend(!0,mist.data,d);mist.data.streams=d.streams;mist.data.config.protocols=d.config.protocols;mist.data.config.limits=d.config.limits;mist.user.loggedin=!0;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));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){var g=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(g[0])+" ["+g[1]+"] "+g[2])}if("totals"in d)if(g=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([f,0])};var e={},g;for(g in c.fields)e[c.fields[g]]=[];var j=0,f;if(c.data){600>c.end-c.start?(f=1E3*(c.end-600),d(),f=1E3*c.start,d()):f=1E3*c.start;
|
||||
for(g in c.data){if(0==g){f=1E3*c.start;var k=0}else f+=1E3*c.interval[k][1],c.interval[k][0]--,0>=c.interval[k][0]&&(k++,k<c.interval.length-1&&(j=2));1==j&&(d(),j--);for(var m in c.data[g])e[c.fields[m]].push([f,c.data[g][m]]);j&&(d(),j--)}5<mist.data.config.time-c.end&&(d(),f=1E3*mist.data.config.time,d())}else f=1E3*(mist.data.config.time-600),d(),f=1E3*mist.data.config.time,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={},"fields"in d.totals)g(c.totals.streams,c.totals.protocols,d.totals);else for(var e in d.totals)g(c.totals[e].streams,c.totals[e].protocols,d.totals[e]);a&&a(d,b);break;case "CHALL":d.authorize.challenge==mist.user.authstring?(""!=mist.user.password&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red"),UI.navto("Login")):
|
||||
""==mist.user.password?UI.navto("Login"):(mist.user.authstring=d.authorize.challenge,mist.send(a,c,b));break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete c.authorize;mist.send(a,c,b);break;default:UI.navto("Login")}}};b.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){g.abort()}));var g=$.ajax(d)},inputMatch:function(a,c){if("undefined"==typeof a)return!1;
|
||||
var b=a.replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");return RegExp("^"+b+"$","i").test(c)},convertBuildOptions:function(a,c){var b=[],d=["required","optional"];"desc"in a&&b.push({type:"help",help:a.desc});for(var g in d)if(a[d[g]]){b.push($("<h4>").text(UI.format.capital(d[g])+" parameters"));for(var k in a[d[g]]){var m=a[d[g]][k],e={label:UI.format.capital(m.name),pointer:{main:c,index:k},validate:[]};"required"==d[g]&&!("default"in m)&&e.validate.push("required");
|
||||
"default"in m&&(e.placeholder=m["default"]);"help"in m&&(e.help=m.help);"unit"in m&&(e.unit=m.unit);switch(m.type){case "int":e.type="int";break;case "uint":e.type="int";e.min=0;break;case "debug":e.type="debug";break;case "select":e.type="select",e.select=m.select;default:e.type="str"}b.push(e)}}return b},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var b=this.get();b[a]=c;mist.send(function(){},{ui_settings:b})},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"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent(),a.length?(c=[],c.push(a.children("input[type=radio]").val()),a=a.children("select"),a.length&&c.push(a.val())):c=""}return c};
|
||||
$.fn.getval=function(){var a=$(this).data("opts"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();a.length?(c=[],c.push(a.children("input[type=radio]").val()),a=a.children("select"),a.length&&c.push(a.val())):c="";break;case "checklist":c=[],$(this).find(".checklist input[type=checkbox]:checked").each(function(){c.push($(this).attr("name"))}),
|
||||
c.length==a.checklist.length&&(c=[])}return c};
|
||||
$.fn.setval=function(a){var c=$(this).data("opts");$(this).val(a);if(c&&"type"in c)switch(c.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":c=$(this).closest(".field_container").data("subUI");if("undefined"==typeof a||0==a.length)a="-";c.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),b;for(b in a)c.values.append(c.prototype.clone(!0).val(a[b]));c.blackwhite.trigger("change");break;case "radioselect":if("undefined"==
|
||||
typeof a)return $(this);b=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",!0).parent();1<a.length&&b.children("select").val(a[1])}$(this).trigger("change");return $(this)};
|
||||
typeof a)return $(this);b=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",!0).parent();1<a.length&&b.children("select").val(a[1]);break;case "checklist":for(b in c=$(this).find(".checklist input[type=checkbox]"),a)c.filter('[name="'+a[b]+'"]').prop("checked",!0)}$(this).trigger("change");return $(this)};
|
||||
|
|
324
lsp/mist.js
324
lsp/mist.js
|
@ -173,6 +173,9 @@ var UI = {
|
|||
Limits: {
|
||||
LTSonly: true
|
||||
},
|
||||
'Triggers': {
|
||||
LTSonly: false
|
||||
},
|
||||
Logs: {},
|
||||
Statistics: {},
|
||||
'Server Stats': {}
|
||||
|
@ -492,6 +495,34 @@ var UI = {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case 'checklist':
|
||||
$field = $('<div>').addClass('checkcontainer');
|
||||
$controls = $('<div>').addClass('controls');
|
||||
$checklist = $('<div>').addClass('checklist');
|
||||
$field.append($controls).append($checklist);
|
||||
$controls.append(
|
||||
$('<label>').text('All').prepend(
|
||||
$('<input>').attr('type','checkbox').click(function(){
|
||||
if ($(this).is(':checked')) {
|
||||
$(this).closest('.checkcontainer').find('input[type=checkbox]').prop('checked',true);
|
||||
}
|
||||
else {
|
||||
$(this).closest('.checkcontainer').find('input[type=checkbox]').prop('checked',false);
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
for (var i in e.checklist) {
|
||||
if (typeof e.checklist[i] == 'string') {
|
||||
e.checklist[i] = [e.checklist[i], e.checklist[i]];
|
||||
}
|
||||
$checklist.append(
|
||||
$('<label>').text(e.checklist[i][1]).prepend(
|
||||
$('<input>').attr('type','checkbox').attr('name',e.checklist[i][0])
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$field = $('<input>').attr('type','text');
|
||||
}
|
||||
|
@ -813,6 +844,16 @@ var UI = {
|
|||
classes: ['red']
|
||||
};
|
||||
}
|
||||
//check for duplicate stream names
|
||||
if (val in mist.data.streams) {
|
||||
//check that we're not simply editing the stream
|
||||
if ($(me).data('pointer').main.name != val) {
|
||||
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;
|
||||
default:
|
||||
|
@ -2336,24 +2377,31 @@ var UI = {
|
|||
);
|
||||
}
|
||||
|
||||
var streamnamelabel = $('<span>').text(streamname);
|
||||
var $streamnamelabel = $('<span>').text(streamname);
|
||||
if (stream.ischild) {
|
||||
streamnamelabel.css('padding-left','1em');
|
||||
$streamnamelabel.css('padding-left','1em');
|
||||
}
|
||||
var $online = UI.format.status(stream);
|
||||
var $preview = $('<button>').text('Preview').click(function(){
|
||||
UI.navto('Preview',$(this).closest('tr').data('index'));
|
||||
});
|
||||
if (stream.filesfound) {
|
||||
$online.html('');
|
||||
$preview = '';
|
||||
$viewers.html('');
|
||||
}
|
||||
$tbody.append(
|
||||
$('<tr>').data('index',streamname).html(
|
||||
$('<td>').html(streamnamelabel).attr('title',streamname).addClass('overflow_ellipsis')
|
||||
$('<td>').html($streamnamelabel).attr('title',streamname).addClass('overflow_ellipsis')
|
||||
).append(
|
||||
$('<td>').text(stream.source).attr('title',stream.source).addClass('description').addClass('overflow_ellipsis').css('max-width','20em')
|
||||
).append(
|
||||
$('<td>').data('sort-value',stream.online).html(UI.format.status(stream))
|
||||
$('<td>').data('sort-value',stream.online).html($online)
|
||||
).append(
|
||||
$viewers
|
||||
).append(
|
||||
$('<td>').html(
|
||||
$('<button>').text('Preview').click(function(){
|
||||
UI.navto('Preview',$(this).closest('tr').data('index'));
|
||||
})
|
||||
$preview
|
||||
)
|
||||
).append(
|
||||
$buttons
|
||||
|
@ -2373,6 +2421,7 @@ var UI = {
|
|||
});
|
||||
}
|
||||
mist.send(function(){
|
||||
$.extend(true,allstreams,mist.data.streams);
|
||||
buildStreamTable();
|
||||
},{
|
||||
totals: totals,
|
||||
|
@ -2412,6 +2461,12 @@ var UI = {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (d.browse.files.length) {
|
||||
allstreams[s].filesfound = true;
|
||||
}
|
||||
else {
|
||||
mist.data.streams[s].filesfound = false;
|
||||
}
|
||||
browsecomplete++;
|
||||
if (browserequests == browsecomplete) {
|
||||
mist.send(function(){
|
||||
|
@ -2498,7 +2553,7 @@ var UI = {
|
|||
main: saveas,
|
||||
index: 'source'
|
||||
},
|
||||
help: 'Set the stream source.<br>VoD: You can browse to the file or folder as a source or simply enter the path to the file.<br>Live: You???ll need to enter "push://IP" with the IP of the machine pushing towards MistServer. You can use "push://" to accept any source.<br>Pro only: use "push://(IP)@password" to set a password protection for pushes.<br>If you\'re unsure how to set the source properly please view our Live pushing guide at the tools section.',
|
||||
help: 'Set the stream source.<table><tr><td>VoD:</td><td>You can browse to the file or folder as a source or simply enter the path to the file.</td></tr><tr><td>Live:</td><td>You\'ll need to enter "push://IP" with the IP of the machine pushing towards MistServer.<br>You can use "push://" to accept any source.</td></tr><tr><td>(Pro only)</td><td>Use "push://(IP)@password" to set a password protection for pushes.</td></tr></table>If you\'re unsure how to set the source properly, please view our Live pushing guide at the tools section.',
|
||||
'function': function(){
|
||||
var source = $(this).val();
|
||||
var type = null;
|
||||
|
@ -2511,9 +2566,9 @@ var UI = {
|
|||
}
|
||||
if (type === null) {
|
||||
$inputoptions.html(
|
||||
$('<h3>').text('Unrecognized input')
|
||||
$('<h3>').text('Unrecognized input').addClass('red')
|
||||
).append(
|
||||
$('<span>').text('Please edit the stream source.')
|
||||
$('<span>').text('Please edit the stream source.').addClass('red')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -2599,8 +2654,11 @@ var UI = {
|
|||
send.streams = mist.data.streams;
|
||||
}
|
||||
mist.send(function(){
|
||||
delete mist.data.streams[saveas.name].online;
|
||||
delete mist.data.streams[saveas.name].error;
|
||||
UI.navto('Streams');
|
||||
},send)
|
||||
},send);
|
||||
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -2651,7 +2709,32 @@ var UI = {
|
|||
$('<a>').addClass('button').addClass('active').text('Choose stream').click(function(){
|
||||
UI.navto('Preview');
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
var $shortcuts = $('<div>').addClass('preview_icons');
|
||||
$main.append(
|
||||
$('<span>').addClass('description').text('Or, click a stream from the list below.')
|
||||
).append($shortcuts);
|
||||
for (var i in select) {
|
||||
var streamname = select[i];
|
||||
var source = '';
|
||||
if (streamname.indexOf('+') > -1) {
|
||||
var streambits = streamname.split('+');
|
||||
source = mist.data.streams[streambits[0]].source+streambits[1];
|
||||
}
|
||||
else {
|
||||
source = mist.data.streams[streamname].source;
|
||||
}
|
||||
$shortcuts.append(
|
||||
$('<button>').append(
|
||||
$('<span>').text(streamname)
|
||||
).append(
|
||||
$('<span>').addClass('description').text(source)
|
||||
).attr('title',streamname).attr('data-stream',streamname).click(function(){
|
||||
UI.navto('Preview',$(this).attr('data-stream'));
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (mist.data.LTS) {
|
||||
|
@ -2830,8 +2913,8 @@ var UI = {
|
|||
$main.append($trackinfo);
|
||||
function buildTrackinfo() {
|
||||
var meta;
|
||||
if (other in mist.data.streams) {
|
||||
meta = mist.data.streams[other].meta;
|
||||
if (other in mistvideo) {
|
||||
meta = mistvideo[other].meta;
|
||||
}
|
||||
if (!meta) {
|
||||
$tracktable.html('No meta information available.');
|
||||
|
@ -2917,13 +3000,6 @@ var UI = {
|
|||
);
|
||||
$tracktable.html(UI.buildUI(build));
|
||||
}
|
||||
buildTrackinfo();
|
||||
if ((other in mist.data.streams) && (!('meta' in mist.data.streams[other]))) {
|
||||
//try to refresh the meta information
|
||||
mist.send(function(){
|
||||
buildTrackinfo();
|
||||
});
|
||||
}
|
||||
|
||||
//embedded video
|
||||
var $preview = $('<span>').hide();
|
||||
|
@ -3090,6 +3166,9 @@ var UI = {
|
|||
$protocolurls.html(
|
||||
UI.buildUI(buildurls)
|
||||
);
|
||||
|
||||
//meta information
|
||||
buildTrackinfo();
|
||||
};
|
||||
$video.html('')[0].appendChild(script);
|
||||
}
|
||||
|
@ -3340,6 +3419,194 @@ var UI = {
|
|||
);
|
||||
$UI.find('.limit_type').trigger('change');
|
||||
|
||||
break;
|
||||
case 'Triggers':
|
||||
if (!('triggers' in mist.data.config)) {
|
||||
mist.data.config.triggers = {};
|
||||
}
|
||||
|
||||
var $tbody = $('<tbody>');
|
||||
var $table = $('<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('Execute URL').attr('data-sort-type','string')
|
||||
).append(
|
||||
$('<th>')
|
||||
)
|
||||
)
|
||||
).append($tbody);
|
||||
|
||||
$main.append(
|
||||
UI.buildUI([{
|
||||
type: 'help',
|
||||
help: 'Balder verzin iets leuks'
|
||||
}])
|
||||
).append(
|
||||
$('<button>').text('New trigger').click(function(){
|
||||
UI.navto('Edit Trigger');
|
||||
})
|
||||
).append($table);
|
||||
$table.stupidtable();
|
||||
|
||||
var triggers = mist.data.config.triggers
|
||||
for (var i in triggers) {
|
||||
for (var j in triggers[i]) {
|
||||
$tbody.append(
|
||||
$('<tr>').attr('data-index',i+','+j).append(
|
||||
$('<td>').text(i)
|
||||
).append(
|
||||
$('<td>').text(triggers[i][j][2].join(', '))
|
||||
).append(
|
||||
$('<td>').text(triggers[i][j][0])
|
||||
).append(
|
||||
$('<td>').html(
|
||||
$('<button>').text('Edit').click(function(){
|
||||
UI.navto('Edit Trigger',$(this).closest('tr').attr('data-index'));
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'Edit Trigger':
|
||||
if (!('triggers' in mist.data.config)) {
|
||||
mist.data.config.triggers = {};
|
||||
}
|
||||
if (!other) {
|
||||
//new
|
||||
$main.html(
|
||||
$('<h2>').text('New Trigger')
|
||||
);
|
||||
var saveas = {};
|
||||
}
|
||||
else {
|
||||
//editing
|
||||
other = other.split(',');
|
||||
var source = mist.data.config.triggers[other[0]][other[1]];
|
||||
var saveas = {
|
||||
triggeron: other[0],
|
||||
appliesto: source[2],
|
||||
url: source[0],
|
||||
async: source[1],
|
||||
'default': source[3]
|
||||
};
|
||||
}
|
||||
|
||||
$main.append(UI.buildUI([{
|
||||
type: 'help',
|
||||
help: 'Balder verzin iets leuks'
|
||||
},{
|
||||
label: 'Trigger on',
|
||||
pointer: {
|
||||
main: saveas,
|
||||
index: 'triggeron'
|
||||
},
|
||||
help: 'Balder verzin iets leuks',
|
||||
type: 'select',
|
||||
select: [
|
||||
['SYSTEM_START', 'server boot'],
|
||||
['SYSTEM_STOP', 'server exit'],
|
||||
['SYSTEM_CONFIG', 'config changed'],
|
||||
['SYSTEM_LOG', 'log line logged'],
|
||||
['OUTPUT_ADD', 'new output configured'],
|
||||
['OUTPUT_CONFIG', 'output config changed'],
|
||||
['OUTPUT_REMOVE', 'deleted output in config'],
|
||||
['STREAM_ADD', 'new stream configured'],
|
||||
['STREAM_CONFIG', 'stream config changed'],
|
||||
['STREAM_REMOVE', 'stream config deleted'],
|
||||
['STREAM_LOAD', 'stream input loaded in memory'],
|
||||
['STREAM_UNLOAD', 'stream input unloaded from memory'],
|
||||
['STREAM_TRACK_ADD', 'added track to stream; ie: push/multi'],
|
||||
['STREAM_TRACK_REMOVE', 'removed track from stream'],
|
||||
['CONN_OPEN', 'new connection'],
|
||||
['CONN_CLOSE', 'connection closed'],
|
||||
['CONN_PLAY', 'before play start, includes limits status'],
|
||||
['CONN_STOP', 'play end, but no disconnect yet']
|
||||
],
|
||||
LTSonly: true
|
||||
},{
|
||||
label: 'Applies to',
|
||||
pointer: {
|
||||
main: saveas,
|
||||
index: 'appliesto'
|
||||
},
|
||||
help: 'Balder verzin iets leuks (none checked = all are checked)',
|
||||
type: 'checklist',
|
||||
checklist: Object.keys(mist.data.streams),
|
||||
LTSonly: true
|
||||
},$('<br>'),{
|
||||
label: 'Excecute URL',
|
||||
help: 'Balder verzin iets leuks',
|
||||
pointer: {
|
||||
main: saveas,
|
||||
index: 'url'
|
||||
},
|
||||
validate: ['required'],
|
||||
type: 'str',
|
||||
LTSonly: true
|
||||
},{
|
||||
label: 'Asynchronous',
|
||||
type: 'checkbox',
|
||||
help: 'Balder verzin iets leuks',
|
||||
pointer: {
|
||||
main: saveas,
|
||||
index: 'async'
|
||||
},
|
||||
LTSonly: true
|
||||
},{
|
||||
label: 'Default return on error',
|
||||
type: 'str',
|
||||
help: 'Balder verzin iets leuks (synchronous only)',
|
||||
pointer: {
|
||||
main: saveas,
|
||||
index: 'default'
|
||||
},
|
||||
LTSonly: true
|
||||
},{
|
||||
type: 'buttons',
|
||||
buttons: [
|
||||
{
|
||||
type: 'cancel',
|
||||
label: 'Cancel',
|
||||
'function': function(){
|
||||
UI.navto('Triggers');
|
||||
}
|
||||
},{
|
||||
type: 'save',
|
||||
label: 'Save',
|
||||
'function': function(){
|
||||
if (other) {
|
||||
//remove the old setting
|
||||
mist.data.config.triggers[other[0]].splice(other[1],1);
|
||||
}
|
||||
|
||||
var newtrigger = [
|
||||
saveas.url,
|
||||
(saveas.async ? true : false),
|
||||
(typeof saveas.appliesto != 'undefined' ? saveas.appliesto : [])
|
||||
];
|
||||
if (typeof saveas['default'] != 'undefined') {
|
||||
newtrigger.push(saveas['default']);
|
||||
}
|
||||
if (!(saveas.triggeron in mist.data.config.triggers)) {
|
||||
mist.data.config.triggers[saveas.triggeron] = [];
|
||||
}
|
||||
mist.data.config.triggers[saveas.triggeron].push(newtrigger);
|
||||
|
||||
mist.send(function(){
|
||||
UI.navto('Triggers');
|
||||
},{config: mist.data.config});
|
||||
}
|
||||
}
|
||||
]
|
||||
}]));
|
||||
|
||||
break;
|
||||
case 'Logs':
|
||||
|
||||
|
@ -4204,6 +4471,15 @@ $.fn.getval = function(){
|
|||
val = '';
|
||||
}
|
||||
break;
|
||||
case 'checklist':
|
||||
val = [];
|
||||
$(this).find('.checklist input[type=checkbox]:checked').each(function(){
|
||||
val.push($(this).attr('name'));
|
||||
});
|
||||
if (val.length == opts.checklist.length) {
|
||||
val = [];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
|
@ -4242,6 +4518,12 @@ $.fn.setval = function(val){
|
|||
$l.children('select').val(val[1]);
|
||||
}
|
||||
break;
|
||||
case 'checklist':
|
||||
var $inputs = $(this).find('.checklist input[type=checkbox]');
|
||||
for (i in val) {
|
||||
$inputs.filter('[name="'+val[i]+'"]').prop('checked',true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$(this).trigger('change');
|
||||
|
|
381
lsp/newembed.js
Normal file
381
lsp/newembed.js
Normal file
|
@ -0,0 +1,381 @@
|
|||
if (typeof mistplayers == 'undefined') {
|
||||
//no need to define this if it's already there
|
||||
|
||||
var mistplayers = {};
|
||||
|
||||
//create prototype with empty functions the player should have, so that any that have not been defined return false
|
||||
function MistPlayer() {
|
||||
|
||||
//return true if this player is to be used for this mimetype
|
||||
this.formimetype = function (fullmimetype){ return false; };
|
||||
|
||||
this.name = 'Generic player';
|
||||
|
||||
//mimetype: e.g. 'video/mp4'; that is withouth the html5, flash, or whatever first part.
|
||||
this.supported = function(mimetype){ return false; };
|
||||
|
||||
/*
|
||||
shape of build options:
|
||||
{
|
||||
container: html DOM element,
|
||||
width: (int) video width,
|
||||
height: (int) video height,
|
||||
name: (string) the stream name,
|
||||
src: (string) the video source string,
|
||||
mimetype: (string) the mimetype,
|
||||
islive: (boolean) whether or not this is a live video,
|
||||
autoplay: (boolean) whether or not to enable autoplay
|
||||
}
|
||||
*/
|
||||
this.build = function(options){ return false; };
|
||||
|
||||
//creates the player element, including custom functions
|
||||
this.element = function(tag){
|
||||
var ele = document.createElement(tag);
|
||||
ele.mistplay = function(){ return false; };
|
||||
ele.mistpause = function(){ return false; };
|
||||
|
||||
//(double) value: 0 for muted, 1 for max
|
||||
ele.mistsetvolume = function(value){ return false; };
|
||||
//return the current position, in seconds
|
||||
ele.mistposition = function(){ return false; };
|
||||
|
||||
return ele;
|
||||
};
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
//ADD AVAILABLE PLAYERS TO THE MISTPLAYERS OBJECT//
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
////HTML5////////////////////////////////////////////
|
||||
var html5 = new MistPlayer();
|
||||
mistplayers.html5 = html5;
|
||||
html5.name = 'HTML5 video element';
|
||||
html5.formimetype = function(fullmimetype){
|
||||
var t = fullmimetype.split('/');
|
||||
return ((t[0] == 'html5') && (t[1] == 'video'));
|
||||
};
|
||||
html5.supported = function(mimetype) {
|
||||
var support = false;
|
||||
try {
|
||||
var v = document.createElement('video');
|
||||
if ((v) && (v.canPlayType(mimetype) != "")) {
|
||||
support = v.canPlayType(mimetype);
|
||||
}
|
||||
} catch(e){}
|
||||
return support;
|
||||
}
|
||||
html5.build = function(options){
|
||||
var ele = this.element('video');
|
||||
|
||||
ele.setAttribute('width',options.width);
|
||||
ele.setAttribute('height',options.height);
|
||||
ele.setAttribute('src',encodeURI(options.src));
|
||||
ele.setAttribute('controls','controls');
|
||||
|
||||
if (options.autoplay) {
|
||||
ele.setAttribute('autoplay','controls');
|
||||
}
|
||||
|
||||
ele.mistplay = function(){
|
||||
this.play();
|
||||
};
|
||||
ele.mistpause = function(){
|
||||
this.pause();
|
||||
};
|
||||
ele.mistsetvolume = function(value){
|
||||
this.volume = value;
|
||||
};
|
||||
ele.mistposition = function(){
|
||||
return this.currentTime;
|
||||
}
|
||||
|
||||
options.container.appendChild(ele);
|
||||
return ele;
|
||||
}
|
||||
|
||||
////FLASH////////////////////////////////////////////
|
||||
var flash = new MistPlayer();
|
||||
mistplayers.flash = flash;
|
||||
flash.name = 'Flash object';
|
||||
flash.formimetype = function(fullmimetype){
|
||||
var t = fullmimetype.split('/');
|
||||
return (t[0] == 'flash');
|
||||
};
|
||||
flash.supported = function(mimetype) {
|
||||
|
||||
var version = 0;
|
||||
try {
|
||||
// check in the mimeTypes
|
||||
version = navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin.description.replace(/([^0-9\.])/g, '').split('.')[0];
|
||||
} catch(e){}
|
||||
try {
|
||||
// for our special friend IE
|
||||
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable("$version").replace(/([^0-9\,])/g, '').split(',')[0];
|
||||
} catch(e){}
|
||||
version = parseInt(version);
|
||||
|
||||
return version >= parseInt(mimetype);
|
||||
}
|
||||
flash.build = function(options){
|
||||
var ele = this.element('object');
|
||||
ele.setAttribute('id',options.name);
|
||||
ele.setAttribute('width',options.width);
|
||||
ele.setAttribute('height',options.height);
|
||||
|
||||
//set flashvars
|
||||
var flashvars = {
|
||||
src: encodeURIComponent(options.src),
|
||||
controlBarMode: 'floating',
|
||||
initialBufferTime: 5,
|
||||
expandedBufferTime: 5,
|
||||
minContinuousPlaybackTime: 3
|
||||
};
|
||||
//set param elements
|
||||
var params = {
|
||||
movie: 'http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf',
|
||||
flashvars: [],
|
||||
allowFullScreen: 'true',
|
||||
allowscriptaccess: 'always',
|
||||
wmode: 'direct'
|
||||
};
|
||||
if (options.autoplay) {
|
||||
params.autoPlay = 'true';
|
||||
flashvars.autoPlay = 'true';
|
||||
}
|
||||
if (options.islive) {
|
||||
flashvars.streamType = 'live';
|
||||
}
|
||||
if (parseInt(options.mimetype) >= 10) {
|
||||
params.movie = 'http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf';
|
||||
}
|
||||
for (var i in flashvars) {
|
||||
params.flashvars.push(i+'='+flashvars[i]);
|
||||
}
|
||||
params.flashvars = params.flashvars.join('&');
|
||||
for (var i in params) {
|
||||
var param = document.createElement('param');
|
||||
ele.appendChild(param);
|
||||
param.setAttribute('name',i);
|
||||
param.setAttribute('value',params[i]);
|
||||
}
|
||||
|
||||
var embed = document.createElement('embed');
|
||||
embed.setAttribute('name',options.name);
|
||||
embed.setAttribute('src',params.movie);
|
||||
embed.setAttribute('type','application/x-shockwave-flash');
|
||||
embed.setAttribute('allowscriptaccess','always');
|
||||
embed.setAttribute('allowfullscreen','true');
|
||||
embed.setAttribute('width',options.width);
|
||||
embed.setAttribute('height',options.height);
|
||||
embed.setAttribute('flashvars',params.flashvars);
|
||||
ele.appendChild(embed);
|
||||
|
||||
options.container.appendChild(ele);
|
||||
return ele;
|
||||
}
|
||||
|
||||
////SILVERLIGHT//////////////////////////////////////
|
||||
var silverlight = new MistPlayer();
|
||||
mistplayers.silverlight = silverlight;
|
||||
silverlight.name = 'Silverlight';
|
||||
silverlight.formimetype = function(fullmimetype){
|
||||
return (fullmimetype == 'silverlight');
|
||||
};
|
||||
silverlight.supported = function(mimetype) {
|
||||
var plugin;
|
||||
|
||||
try {
|
||||
// check in the mimeTypes
|
||||
plugin = navigator.plugins["Silverlight Plug-In"];
|
||||
return !!plugin;
|
||||
} catch(e){}
|
||||
try {
|
||||
// for our special friend IE
|
||||
plugin = new ActiveXObject('AgControl.AgControl');
|
||||
return true;
|
||||
} catch(e){}
|
||||
|
||||
return false;
|
||||
}
|
||||
silverlight.build = function(options){
|
||||
var ele = this.element('object');
|
||||
|
||||
ele.setAttribute('data','data:application/x-silverlight,'); //yes that comma needs to be there
|
||||
ele.setAttribute('type','application/x-silverlight');
|
||||
ele.setAttribute('width',options.width);
|
||||
ele.setAttribute('height',options.height);
|
||||
|
||||
var params = {
|
||||
source: encodeURI(options.src),
|
||||
onerror: 'onSilverlightError',
|
||||
autoUpgrade: 'true',
|
||||
background: 'black',
|
||||
enableHtmlAccess: 'true',
|
||||
minRuntimeVersion: '3.0.40624.0',
|
||||
initparams: []
|
||||
};
|
||||
var initparams = {
|
||||
autoload: 'false',
|
||||
enablecaptions: 'true',
|
||||
joinLive: 'true',
|
||||
muted: 'false',
|
||||
playlist: document.createElement('playList')
|
||||
};
|
||||
if (options.autoplay) {
|
||||
initparams.autoplay = 'true';
|
||||
}
|
||||
var playitems = document.createElement('playListItems');
|
||||
initparams.playlist.appendChild(playitems);
|
||||
var playitem = document.createElement('playListItem');
|
||||
playitems.appendChild(playitem);
|
||||
playitems.setAttribute('mediaSource',encodeURI(options.src));
|
||||
playitems.setAttribute('adaptiveStreaming','true');
|
||||
initparams.playlist = initparams.playlist.outerHTML;
|
||||
|
||||
for (var i in initparams) {
|
||||
params.initparams.push(i+'='+initparams[i]);
|
||||
}
|
||||
params.initparams = params.initparams.join(',');
|
||||
for (var i in params) {
|
||||
var param = document.createElement('param');
|
||||
ele.appendChild(param);
|
||||
param.setAttribute('name',i);
|
||||
param.setAttribute('value',params[i]);
|
||||
}
|
||||
|
||||
ele.innerHTML += '<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /></a>';
|
||||
|
||||
options.container.appendChild(ele);
|
||||
return ele;
|
||||
}
|
||||
|
||||
} //end of player definitions
|
||||
|
||||
function mistembed(streamname) {
|
||||
|
||||
function findPlayer(fullmimetype) {
|
||||
for (var i in mistplayers) {
|
||||
if (mistplayers[i].formimetype(fullmimetype)) {
|
||||
return mistplayers[i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var video = mistvideo[streamname];
|
||||
container = document.createElement('div'),
|
||||
scripts = document.getElementsByTagName('script'),
|
||||
me = scripts[scripts.length - 1];
|
||||
|
||||
if (me.parentNode.hasAttribute('data-forcetype')) {
|
||||
var forceType = me.parentNode.getAttribute('data-forcetype');
|
||||
}
|
||||
if (me.parentNode.hasAttribute('data-forcesupportcheck')) {
|
||||
var forceSupportCheck = true;
|
||||
}
|
||||
if (me.parentNode.hasAttribute('data-autoplay')) {
|
||||
var autoplay = true;
|
||||
}
|
||||
|
||||
// create the container
|
||||
me.parentNode.insertBefore(container, me);
|
||||
// set the class to 'mistvideo'
|
||||
container.setAttribute('class', 'mistvideo');
|
||||
// remove script tag
|
||||
me.parentNode.removeChild(me);
|
||||
|
||||
if(video.error) {
|
||||
// there was an error; display it
|
||||
container.innerHTML = '<strong>Error: '+video.error+'</strong>';
|
||||
}
|
||||
else if ((typeof video.source == 'undefined') || (video.source.length < 1)) {
|
||||
// no stream sources
|
||||
container.innerHTML = '<strong>Error: no protocols found</strong>';
|
||||
}
|
||||
else {
|
||||
// no error, and sources found. Check the video types and output the best
|
||||
// available video player.
|
||||
|
||||
var foundPlayer = false;
|
||||
|
||||
for (var i in video.source) {
|
||||
if ((forceType) && (video.source[i].type.indexOf(forceType) < 0)) {
|
||||
video.source[i].rejected = 'This source type is not the one being forced.';
|
||||
continue;
|
||||
}
|
||||
|
||||
var player = findPlayer(video.source[i].type);
|
||||
var shortmime = video.source[i].type.split('/');
|
||||
shortmime.shift();
|
||||
shortmime = shortmime.join('/');
|
||||
video.source[i].browser_support = false;
|
||||
|
||||
if (player) {
|
||||
var support = player.supported(shortmime);
|
||||
if ((support) || (forceType)) {
|
||||
//either the player is supported by the browser, or this source type is being enforced
|
||||
|
||||
video.source[i].browser_support = Boolean(support);
|
||||
if (foundPlayer === false) {
|
||||
foundPlayer = {
|
||||
protocol: video.source[i],
|
||||
player: player,
|
||||
shortmime: shortmime
|
||||
};
|
||||
}
|
||||
if (!forceSupportCheck) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
video.source[i].rejected = 'The player for this source type ('+player.name+') is not supported by your browser.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
video.source[i].rejected = 'No compatible player found for this source type.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundPlayer) {
|
||||
// we support this kind of video, so build it.
|
||||
|
||||
//calculations for the size
|
||||
videowidth = video.width || 250;
|
||||
videoheight = video.height || 250;
|
||||
var ratio;
|
||||
var containerwidth = parseInt(container.scrollWidth);
|
||||
var containerheight = parseInt(container.scrollHeight);
|
||||
if(videowidth > containerwidth && containerwidth > 0) {
|
||||
ratio = videowidth / containerwidth;
|
||||
videowidth /= ratio;
|
||||
videoheight /= ratio;
|
||||
}
|
||||
if(videoheight > containerheight && containerheight > 0) {
|
||||
ratio = videoheight / containerheight;
|
||||
videowidth /= ratio;
|
||||
videoheight /= ratio;
|
||||
}
|
||||
|
||||
video.embedded = foundPlayer.player.build({
|
||||
container: container,
|
||||
width: videowidth,
|
||||
height: videoheight,
|
||||
src: foundPlayer.protocol.url,
|
||||
name: streamname,
|
||||
mimetype: foundPlayer.shortmime,
|
||||
islive: (video.type == 'live'),
|
||||
autoplay: autoplay
|
||||
});
|
||||
|
||||
return foundPlayer.protocol.type;
|
||||
}
|
||||
else {
|
||||
// of all the source types given, none was supported (eg. no flash and HTML5 video). Display error
|
||||
container.innerHTML = '<strong>No support for any player found</strong>';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
49
lsp/test_newembed.html
Normal file
49
lsp/test_newembed.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Test the stream embedding</title>
|
||||
<style></style>
|
||||
<script src=plugins/jquery.js></script>
|
||||
<!--<script src='../src/embed.js'></script>-->
|
||||
<script src='newembed.js'></script>
|
||||
<script>
|
||||
var embed_settings = {};
|
||||
$(function(){
|
||||
$('button#embed').click(function(){
|
||||
$('#embedcontainer, #button_container').html('');
|
||||
|
||||
var streamName = $('input[name=streamName]').val();
|
||||
var embedtype = $('input[name=force]').val();
|
||||
|
||||
var info = document.createElement('script');
|
||||
info.src = 'http://localhost:8080/info_'+streamName+'.js';
|
||||
document.getElementById('embedcontainer').appendChild(info);
|
||||
info.onload = function(){
|
||||
if (embedtype == '') {
|
||||
$('#embedcontainer').removeAttr('data-forcetype');
|
||||
}
|
||||
else {
|
||||
$('#embedcontainer').attr('data-forcetype',embedtype);
|
||||
}
|
||||
$('#embedcontainer').append(
|
||||
$('<div>').text('Embedded: '+mistembed(streamName))
|
||||
);
|
||||
console.log(mistvideo[streamName]);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<label>
|
||||
Enter the streamname: <input type=text value=bunny name=streamName>
|
||||
</label><br>
|
||||
<label>
|
||||
Force embed type: <input type=text name=force> (blank for auto)
|
||||
</label><br>
|
||||
<button id=embed>Embed</button>
|
||||
<div id=button_container></div>
|
||||
<div id=embedcontainer style="width: 100%; height: 35em;" data-forcesupportcheck data-autoplay>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue