LSP: updates to push parameters

Includes:
 - new buildUI element option 'postSave'
 - new buildUI element option 'prefix'
 - validation 'track_selector_parameter' and 'track_selector' in convertBuildOptions now expand help text
 - new element option 'disable' in convertBuildOptions
 - new element type 'bool' in convertBuildOptions (equals checkbox)
 - new element type 'unixtime' in convertBuildOptions
 - new element option 'format' in convertBuildOptions
 - UI for scheduling automated pushes based on variables
 - MistServer: sorting of capabilities.push_parameters
 - Prevent an empty (null) variable_list to break adding automatic pushes
 - automatic push config: start and stop if conditions
 - Fix LSP to hide endVariableValue on boolean expression
 - Remove references to current evaluation in LSP
 - Also remove the start variable requirement from the frontend
 - allow endVariabbles without startVariables, bugfix variable value hint
 - push target url parameters: dump 'leftover' params in a custom params field; added customizable inputlist inputs
 - autopushes: when the variable settings are not set, they are '', not 0. Also trigger onchange of comparison operator fields when the edit page loads so the variable value fields are shown or hidden properly.
 - autopush tab onchange maar nu goed (?) fixup pl0x
 - autopush: there's fun and joy in making Jaron do multiple fixups
 - autopush tab: not my fault Balder asks one change at a time D:
This commit is contained in:
Cat 2022-10-05 16:42:13 +02:00 committed by Thulinma
parent c7211b23c1
commit c66d236e58
5 changed files with 659 additions and 314 deletions

View file

@ -734,47 +734,56 @@ void Util::Config::addStandardPushCapabilities(JSON::Value &cap){
pp["audio"]["help"] = "Override which audio tracks of the stream should be selected"; pp["audio"]["help"] = "Override which audio tracks of the stream should be selected";
pp["audio"]["type"] = "string"; pp["audio"]["type"] = "string";
pp["audio"]["validate"][0u] = "track_selector"; pp["audio"]["validate"][0u] = "track_selector";
pp["audio"]["sort"] = "aa";
pp["video"]["name"] = "Video track(s)"; pp["video"]["name"] = "Video track(s)";
pp["video"]["help"] = "Override which video tracks of the stream should be selected"; pp["video"]["help"] = "Override which video tracks of the stream should be selected";
pp["video"]["type"] = "string"; pp["video"]["type"] = "string";
pp["video"]["validate"][0u] = "track_selector"; pp["video"]["validate"][0u] = "track_selector";
pp["video"]["sort"] = "ab";
pp["subtitle"]["name"] = "Subtitle track(s)"; pp["subtitle"]["name"] = "Subtitle track(s)";
pp["subtitle"]["help"] = "Override which subtitle tracks of the stream should be selected"; pp["subtitle"]["help"] = "Override which subtitle tracks of the stream should be selected";
pp["subtitle"]["type"] = "string"; pp["subtitle"]["type"] = "string";
pp["subtitle"]["validate"].append("track_selector"); pp["subtitle"]["validate"].append("track_selector");
pp["subtitle"]["sort"] = "ac";
pp["rate"]["name"] = "Playback rate"; pp["rate"]["name"] = "Playback rate";
pp["rate"]["help"] = "Multiplier for the playback speed rate, or 0 to not limit"; pp["rate"]["help"] = "Multiplier for the playback speed rate, or 0 to not limit";
pp["rate"]["type"] = "int"; pp["rate"]["type"] = "int";
pp["rate"]["default"] = "1"; pp["rate"]["default"] = "1";
pp["rate"]["sort"] = "ba";
pp["realtime"]["name"] = "Don't speed up output"; pp["realtime"]["name"] = "Don't speed up output";
pp["realtime"]["help"] = "If set to any value, removes the rate override to unlimited normally applied to push outputs"; pp["realtime"]["help"] = "If set to any value, removes the rate override to unlimited normally applied to push outputs";
pp["realtime"]["type"] = "bool"; pp["realtime"]["type"] = "bool";
pp["realtime"]["format"] = "set_or_unset"; pp["realtime"]["format"] = "set_or_unset";
pp["realtime"]["sort"] = "bb";
pp["unmask"]["name"] = "Unmask tracks"; pp["unmask"]["name"] = "Unmask tracks";
pp["unmask"]["help"] = "If set to any value, removes any applied track masking before selecting tracks, acting as if no mask was applied at all"; pp["unmask"]["help"] = "If set to any value, removes any applied track masking before selecting tracks, acting as if no mask was applied at all";
pp["unmask"]["type"] = "bool"; pp["unmask"]["type"] = "bool";
pp["unmask"]["format"] = "set_or_unset"; pp["unmask"]["format"] = "set_or_unset";
pp["unmask"]["sort"] = "bc";
pp["waittrackcount"]["name"] = "Wait for GOP count"; pp["waittrackcount"]["name"] = "Wait for GOP count";
pp["waittrackcount"]["help"] = "Before starting, wait until this number of GOPs is available in the main selected track"; pp["waittrackcount"]["help"] = "Before starting, wait until this number of GOPs is available in the main selected track";
pp["waittrackcount"]["type"] = "int"; pp["waittrackcount"]["type"] = "int";
pp["waittrackcount"]["default"] = 2; pp["waittrackcount"]["default"] = 2;
pp["waittrackcount"]["sort"] = "bd";
pp["maxwaittrackms"]["name"] = "Max buffer duration for GOP count wait"; pp["maxwaittrackms"]["name"] = "Max buffer duration for GOP count wait";
pp["maxwaittrackms"]["help"] = "When waiting for GOPs on the main track, give up when this much data is available in the main track buffer"; pp["maxwaittrackms"]["help"] = "When waiting for GOPs on the main track, give up when this much data is available in the main track buffer";
pp["maxwaittrackms"]["type"] = "int"; pp["maxwaittrackms"]["type"] = "int";
pp["maxwaittrackms"]["default"] = "5s, or 120s when using a non-default GOP count"; pp["maxwaittrackms"]["default"] = "5s, or 120s when using a non-default GOP count";
pp["maxwaittrackms"]["unit"] = "ms"; pp["maxwaittrackms"]["unit"] = "ms";
pp["maxwaittrackms"]["sort"] = "be";
pp["append"]["name"] = "Append to file"; pp["append"]["name"] = "Append to file";
pp["append"]["help"] = "If set to any value, will (if possible) append to an existing file, rather than overwriting it"; pp["append"]["help"] = "If set to any value, will (if possible) append to an existing file, rather than overwriting it";
pp["append"]["type"] = "bool"; pp["append"]["type"] = "bool";
pp["append"]["format"] = "set_or_unset"; pp["append"]["format"] = "set_or_unset";
pp["append"]["sort"] = "bf";
pp["pushdelay"]["name"] = "Push delay"; pp["pushdelay"]["name"] = "Push delay";
pp["pushdelay"]["help"] = "Ensures the stream is always delayed by at least this many seconds. Internally overrides the \"realtime\" and \"start\" parameters"; pp["pushdelay"]["help"] = "Ensures the stream is always delayed by at least this many seconds. Internally overrides the \"realtime\" and \"start\" parameters";
@ -782,11 +791,13 @@ void Util::Config::addStandardPushCapabilities(JSON::Value &cap){
pp["pushdelay"]["unit"] = "s"; pp["pushdelay"]["unit"] = "s";
pp["pushdelay"]["disable"].append("realtime"); pp["pushdelay"]["disable"].append("realtime");
pp["pushdelay"]["disable"].append("start"); pp["pushdelay"]["disable"].append("start");
pp["pushdelay"]["sort"] = "bg";
pp["split"]["name"] = "Split interval"; pp["split"]["name"] = "Split interval";
pp["split"]["help"] = "Performs a gapless restart of the recording every this may seconds. Always aligns to the next keyframe after this duration, to ensure each recording is fully playable"; pp["split"]["help"] = "Performs a gapless restart of the recording every this may seconds. Always aligns to the next keyframe after this duration, to ensure each recording is fully playable";
pp["split"]["type"] = "int"; pp["split"]["type"] = "int";
pp["split"]["unit"] = "s"; pp["split"]["unit"] = "s";
pp["split"]["sort"] = "bh";
pp["duration"]["name"] = "Duration of push"; pp["duration"]["name"] = "Duration of push";
pp["duration"]["help"] = "How much media time to push, in seconds. Internally overrides \"recstop\""; pp["duration"]["help"] = "How much media time to push, in seconds. Internally overrides \"recstop\"";
@ -794,18 +805,21 @@ void Util::Config::addStandardPushCapabilities(JSON::Value &cap){
pp["duration"]["unit"] = "s"; pp["duration"]["unit"] = "s";
pp["duration"]["disable"].append("recstop"); pp["duration"]["disable"].append("recstop");
pp["duration"]["disable"].append("stop"); pp["duration"]["disable"].append("stop");
pp["duration"]["sort"] = "bi";
pp["stop"]["name"] = "Media timestamp to stop at"; pp["stop"]["name"] = "Media timestamp to stop at";
pp["stop"]["help"] = "What internal media timestamp to stop at"; pp["stop"]["help"] = "What internal media timestamp to stop at";
pp["stop"]["type"] = "int"; pp["stop"]["type"] = "int";
pp["stop"]["unit"] = "s"; pp["stop"]["unit"] = "s";
pp["stop"]["prot_only"] = true; pp["stop"]["prot_only"] = true;
pp["stop"]["sort"] = "bk";
pp["start"]["name"] = "Media timestamp to start from"; pp["start"]["name"] = "Media timestamp to start from";
pp["start"]["help"] = "What internal media timestamp to start from"; pp["start"]["help"] = "What internal media timestamp to start from";
pp["start"]["type"] = "int"; pp["start"]["type"] = "int";
pp["start"]["unit"] = "s"; pp["start"]["unit"] = "s";
pp["start"]["prot_only"] = true; pp["start"]["prot_only"] = true;
pp["start"]["sort"] = "bl";
pp["stopunix"]["name"] = "Unix timestamp to stop at"; pp["stopunix"]["name"] = "Unix timestamp to stop at";
pp["stopunix"]["help"] = "What unix timestamp to stop at"; pp["stopunix"]["help"] = "What unix timestamp to stop at";
@ -813,6 +827,7 @@ void Util::Config::addStandardPushCapabilities(JSON::Value &cap){
pp["stopunix"]["unit"] = "s"; pp["stopunix"]["unit"] = "s";
pp["stopunix"]["prot_only"] = true; pp["stopunix"]["prot_only"] = true;
pp["stopunix"]["disable"].append("stop"); pp["stopunix"]["disable"].append("stop");
pp["stopunix"]["sort"] = "bm";
pp["startunix"]["name"] = "Unix timestamp to start from"; pp["startunix"]["name"] = "Unix timestamp to start from";
pp["startunix"]["help"] = "What unix timestamp to start from"; pp["startunix"]["help"] = "What unix timestamp to start from";
@ -820,18 +835,21 @@ void Util::Config::addStandardPushCapabilities(JSON::Value &cap){
pp["startunix"]["unit"] = "s"; pp["startunix"]["unit"] = "s";
pp["startunix"]["prot_only"] = true; pp["startunix"]["prot_only"] = true;
pp["startunix"]["disable"].append("start"); pp["startunix"]["disable"].append("start");
pp["startunix"]["sort"] = "bn";
pp["recstop"]["name"] = "Media timestamp to stop at"; pp["recstop"]["name"] = "Media timestamp to stop at";
pp["recstop"]["help"] = "What internal media timestamp to stop at"; pp["recstop"]["help"] = "What internal media timestamp to stop at";
pp["recstop"]["type"] = "int"; pp["recstop"]["type"] = "int";
pp["recstop"]["unit"] = "s"; pp["recstop"]["unit"] = "s";
pp["recstop"]["file_only"] = true; pp["recstop"]["file_only"] = true;
pp["recstop"]["sort"] = "bo";
pp["recstart"]["name"] = "Media timestamp to start from"; pp["recstart"]["name"] = "Media timestamp to start from";
pp["recstart"]["help"] = "What internal media timestamp to start from"; pp["recstart"]["help"] = "What internal media timestamp to start from";
pp["recstart"]["type"] = "int"; pp["recstart"]["type"] = "int";
pp["recstart"]["unit"] = "s"; pp["recstart"]["unit"] = "s";
pp["recstart"]["file_only"] = true; pp["recstart"]["file_only"] = true;
pp["recstart"]["sort"] = "bp";
pp["recstopunix"]["name"] = "Unix timestamp to stop at"; pp["recstopunix"]["name"] = "Unix timestamp to stop at";
pp["recstopunix"]["help"] = "What unix timestamp to stop at"; pp["recstopunix"]["help"] = "What unix timestamp to stop at";
@ -839,6 +857,7 @@ void Util::Config::addStandardPushCapabilities(JSON::Value &cap){
pp["recstopunix"]["unit"] = "s"; pp["recstopunix"]["unit"] = "s";
pp["recstopunix"]["file_only"] = true; pp["recstopunix"]["file_only"] = true;
pp["recstopunix"]["disable"].append("recstop"); pp["recstopunix"]["disable"].append("recstop");
pp["recstopunix"]["sort"] = "bq";
pp["recstartunix"]["name"] = "Unix timestamp to start from"; pp["recstartunix"]["name"] = "Unix timestamp to start from";
pp["recstartunix"]["help"] = "What unix timestamp to start from"; pp["recstartunix"]["help"] = "What unix timestamp to start from";
@ -846,6 +865,7 @@ void Util::Config::addStandardPushCapabilities(JSON::Value &cap){
pp["recstartunix"]["unit"] = "s"; pp["recstartunix"]["unit"] = "s";
pp["recstartunix"]["file_only"] = true; pp["recstartunix"]["file_only"] = true;
pp["recstartunix"]["disable"].append("recstart"); pp["recstartunix"]["disable"].append("recstart");
pp["recstartunix"]["sort"] = "br";
} }

View file

@ -654,29 +654,6 @@ input[type=radio] {
display: none; display: none;
} }
.LTSonly {
overflow: hidden;
position: relative;
outline: 1px solid rgba(0,0,0,0.2);
}
td.LTSonly { outline: none; }
.LTSonly:after {
content: 'Pro';
font-size: 0.8em;
text-align: center;
white-space: nowrap;
position: absolute;
right: -3em;
top: 0.2em;
width: 8em;
transform: rotate(25deg);
height: 1.5em;
box-shadow: -0.2em 0.2em 0.5em rgba(0,0,0,0.2);
outline: 1px solid rgba(0,0,0,0.2);
color: rgba(255,255,255,0.8);
background-image: linear-gradient(to top,rgb(71, 184, 93),rgb(63, 139, 78));
text-shadow: -0.2em 0.2em 0.5em rgba(0,0,0,0.2);
}
[disabled] { [disabled] {
opacity: 0.75; opacity: 0.75;
} }
@ -980,6 +957,18 @@ button.return:before {
.mistvideo-column { .mistvideo-column {
flex-direction: column; flex-direction: column;
} }
.UIelement .inputlist .field_container {
margin-bottom: 0.2em;
}
.UIelement.custom_url_parameters .field_container .field_container .unit:before {
content: "&";
width: 0.8em;
display: block;
text-align: center;
}
.UIelement.custom_url_parameters .field_container .field_container:first-child .unit:before {
content: "?";
}
@font-face { @font-face {
font-family: Latin Modern Sans; font-family: Latin Modern Sans;

View file

@ -1,11 +1,11 @@
var MD5=function(a){function b(a,b){var c,d,f,e,g;f=a&2147483648;e=b&2147483648;c=a&1073741824;d=b&1073741824;g=(a&1073741823)+(b&1073741823);return c&d?g^2147483648^f^e:c|d?g&1073741824?g^3221225472^f^e:g^1073741824^f^e:g^f^e}function c(a,c,d,f,g,e,h){a=b(a,b(b(c&d|~c&f,g),h));return b(a<<e|a>>>32-e,c)}function d(a,c,d,f,e,g,h){a=b(a,b(b(c&f|d&~f,e),h));return b(a<<g|a>>>32-g,c)}function e(a,c,d,f,g,e,h){a=b(a,b(b(c^d^f,g),h));return b(a<<e|a>>>32-e,c)}function l(a,c,d,f,e,g,h){a=b(a,b(b(d^(c|~f), var MD5=function(a){function b(a,b){var c,d,g,i,f;g=a&2147483648;i=b&2147483648;c=a&1073741824;d=b&1073741824;f=(a&1073741823)+(b&1073741823);return c&d?f^2147483648^g^i:c|d?f&1073741824?f^3221225472^g^i:f^1073741824^g^i:f^g^i}function c(a,c,d,g,i,f,e){a=b(a,b(b(c&d|~c&g,i),e));return b(a<<f|a>>>32-f,c)}function d(a,c,d,g,i,f,e){a=b(a,b(b(c&g|d&~g,i),e));return b(a<<f|a>>>32-f,c)}function f(a,c,d,g,i,f,e){a=b(a,b(b(c^d^g,i),e));return b(a<<f|a>>>32-f,c)}function l(a,c,d,g,i,f,e){a=b(a,b(b(d^(c|~g),
e),h));return b(a<<g|a>>>32-g,c)}function n(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var h=[],t,m,k,w,i,f,g,j,h=a.replace(/\r\n/g,"\n"),a="";for(t=0;t<h.length;t++)m=h.charCodeAt(t),128>m?a+=String.fromCharCode(m):(127<m&&2048>m?a+=String.fromCharCode(m>>6|192):(a+=String.fromCharCode(m>>12|224),a+=String.fromCharCode(m>>6&63|128)),a+=String.fromCharCode(m&63|128));h=a;a=h.length;t=a+8;m=16*((t-t%64)/64+1);k=Array(m-1);for(i=w=0;i<a;)t= i),e));return b(a<<f|a>>>32-f,c)}function m(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var e=[],t,o,k,x,h,g,i,j,e=a.replace(/\r\n/g,"\n"),a="";for(t=0;t<e.length;t++)o=e.charCodeAt(t),128>o?a+=String.fromCharCode(o):(127<o&&2048>o?a+=String.fromCharCode(o>>6|192):(a+=String.fromCharCode(o>>12|224),a+=String.fromCharCode(o>>6&63|128)),a+=String.fromCharCode(o&63|128));e=a;a=e.length;t=a+8;o=16*((t-t%64)/64+1);k=Array(o-1);for(h=x=0;h<a;)t=
(i-i%4)/4,w=8*(i%4),k[t]|=h.charCodeAt(i)<<w,i++;t=(i-i%4)/4;k[t]|=128<<8*(i%4);k[m-2]=a<<3;k[m-1]=a>>>29;h=k;i=1732584193;f=4023233417;g=2562383102;j=271733878;for(a=0;a<h.length;a+=16)t=i,m=f,k=g,w=j,i=c(i,f,g,j,h[a+0],7,3614090360),j=c(j,i,f,g,h[a+1],12,3905402710),g=c(g,j,i,f,h[a+2],17,606105819),f=c(f,g,j,i,h[a+3],22,3250441966),i=c(i,f,g,j,h[a+4],7,4118548399),j=c(j,i,f,g,h[a+5],12,1200080426),g=c(g,j,i,f,h[a+6],17,2821735955),f=c(f,g,j,i,h[a+7],22,4249261313),i=c(i,f,g,j,h[a+8],7,1770035416), (h-h%4)/4,x=8*(h%4),k[t]|=e.charCodeAt(h)<<x,h++;t=(h-h%4)/4;k[t]|=128<<8*(h%4);k[o-2]=a<<3;k[o-1]=a>>>29;e=k;h=1732584193;g=4023233417;i=2562383102;j=271733878;for(a=0;a<e.length;a+=16)t=h,o=g,k=i,x=j,h=c(h,g,i,j,e[a+0],7,3614090360),j=c(j,h,g,i,e[a+1],12,3905402710),i=c(i,j,h,g,e[a+2],17,606105819),g=c(g,i,j,h,e[a+3],22,3250441966),h=c(h,g,i,j,e[a+4],7,4118548399),j=c(j,h,g,i,e[a+5],12,1200080426),i=c(i,j,h,g,e[a+6],17,2821735955),g=c(g,i,j,h,e[a+7],22,4249261313),h=c(h,g,i,j,e[a+8],7,1770035416),
j=c(j,i,f,g,h[a+9],12,2336552879),g=c(g,j,i,f,h[a+10],17,4294925233),f=c(f,g,j,i,h[a+11],22,2304563134),i=c(i,f,g,j,h[a+12],7,1804603682),j=c(j,i,f,g,h[a+13],12,4254626195),g=c(g,j,i,f,h[a+14],17,2792965006),f=c(f,g,j,i,h[a+15],22,1236535329),i=d(i,f,g,j,h[a+1],5,4129170786),j=d(j,i,f,g,h[a+6],9,3225465664),g=d(g,j,i,f,h[a+11],14,643717713),f=d(f,g,j,i,h[a+0],20,3921069994),i=d(i,f,g,j,h[a+5],5,3593408605),j=d(j,i,f,g,h[a+10],9,38016083),g=d(g,j,i,f,h[a+15],14,3634488961),f=d(f,g,j,i,h[a+4],20,3889429448), j=c(j,h,g,i,e[a+9],12,2336552879),i=c(i,j,h,g,e[a+10],17,4294925233),g=c(g,i,j,h,e[a+11],22,2304563134),h=c(h,g,i,j,e[a+12],7,1804603682),j=c(j,h,g,i,e[a+13],12,4254626195),i=c(i,j,h,g,e[a+14],17,2792965006),g=c(g,i,j,h,e[a+15],22,1236535329),h=d(h,g,i,j,e[a+1],5,4129170786),j=d(j,h,g,i,e[a+6],9,3225465664),i=d(i,j,h,g,e[a+11],14,643717713),g=d(g,i,j,h,e[a+0],20,3921069994),h=d(h,g,i,j,e[a+5],5,3593408605),j=d(j,h,g,i,e[a+10],9,38016083),i=d(i,j,h,g,e[a+15],14,3634488961),g=d(g,i,j,h,e[a+4],20,3889429448),
i=d(i,f,g,j,h[a+9],5,568446438),j=d(j,i,f,g,h[a+14],9,3275163606),g=d(g,j,i,f,h[a+3],14,4107603335),f=d(f,g,j,i,h[a+8],20,1163531501),i=d(i,f,g,j,h[a+13],5,2850285829),j=d(j,i,f,g,h[a+2],9,4243563512),g=d(g,j,i,f,h[a+7],14,1735328473),f=d(f,g,j,i,h[a+12],20,2368359562),i=e(i,f,g,j,h[a+5],4,4294588738),j=e(j,i,f,g,h[a+8],11,2272392833),g=e(g,j,i,f,h[a+11],16,1839030562),f=e(f,g,j,i,h[a+14],23,4259657740),i=e(i,f,g,j,h[a+1],4,2763975236),j=e(j,i,f,g,h[a+4],11,1272893353),g=e(g,j,i,f,h[a+7],16,4139469664), h=d(h,g,i,j,e[a+9],5,568446438),j=d(j,h,g,i,e[a+14],9,3275163606),i=d(i,j,h,g,e[a+3],14,4107603335),g=d(g,i,j,h,e[a+8],20,1163531501),h=d(h,g,i,j,e[a+13],5,2850285829),j=d(j,h,g,i,e[a+2],9,4243563512),i=d(i,j,h,g,e[a+7],14,1735328473),g=d(g,i,j,h,e[a+12],20,2368359562),h=f(h,g,i,j,e[a+5],4,4294588738),j=f(j,h,g,i,e[a+8],11,2272392833),i=f(i,j,h,g,e[a+11],16,1839030562),g=f(g,i,j,h,e[a+14],23,4259657740),h=f(h,g,i,j,e[a+1],4,2763975236),j=f(j,h,g,i,e[a+4],11,1272893353),i=f(i,j,h,g,e[a+7],16,4139469664),
f=e(f,g,j,i,h[a+10],23,3200236656),i=e(i,f,g,j,h[a+13],4,681279174),j=e(j,i,f,g,h[a+0],11,3936430074),g=e(g,j,i,f,h[a+3],16,3572445317),f=e(f,g,j,i,h[a+6],23,76029189),i=e(i,f,g,j,h[a+9],4,3654602809),j=e(j,i,f,g,h[a+12],11,3873151461),g=e(g,j,i,f,h[a+15],16,530742520),f=e(f,g,j,i,h[a+2],23,3299628645),i=l(i,f,g,j,h[a+0],6,4096336452),j=l(j,i,f,g,h[a+7],10,1126891415),g=l(g,j,i,f,h[a+14],15,2878612391),f=l(f,g,j,i,h[a+5],21,4237533241),i=l(i,f,g,j,h[a+12],6,1700485571),j=l(j,i,f,g,h[a+3],10,2399980690), g=f(g,i,j,h,e[a+10],23,3200236656),h=f(h,g,i,j,e[a+13],4,681279174),j=f(j,h,g,i,e[a+0],11,3936430074),i=f(i,j,h,g,e[a+3],16,3572445317),g=f(g,i,j,h,e[a+6],23,76029189),h=f(h,g,i,j,e[a+9],4,3654602809),j=f(j,h,g,i,e[a+12],11,3873151461),i=f(i,j,h,g,e[a+15],16,530742520),g=f(g,i,j,h,e[a+2],23,3299628645),h=l(h,g,i,j,e[a+0],6,4096336452),j=l(j,h,g,i,e[a+7],10,1126891415),i=l(i,j,h,g,e[a+14],15,2878612391),g=l(g,i,j,h,e[a+5],21,4237533241),h=l(h,g,i,j,e[a+12],6,1700485571),j=l(j,h,g,i,e[a+3],10,2399980690),
g=l(g,j,i,f,h[a+10],15,4293915773),f=l(f,g,j,i,h[a+1],21,2240044497),i=l(i,f,g,j,h[a+8],6,1873313359),j=l(j,i,f,g,h[a+15],10,4264355552),g=l(g,j,i,f,h[a+6],15,2734768916),f=l(f,g,j,i,h[a+13],21,1309151649),i=l(i,f,g,j,h[a+4],6,4149444226),j=l(j,i,f,g,h[a+11],10,3174756917),g=l(g,j,i,f,h[a+2],15,718787259),f=l(f,g,j,i,h[a+9],21,3951481745),i=b(i,t),f=b(f,m),g=b(g,k),j=b(j,w);return(n(i)+n(f)+n(g)+n(j)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function b(b){var c=0,d;a(b).children("td,th").each(function(){if(c==t)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(n){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b= i=l(i,j,h,g,e[a+10],15,4293915773),g=l(g,i,j,h,e[a+1],21,2240044497),h=l(h,g,i,j,e[a+8],6,1873313359),j=l(j,h,g,i,e[a+15],10,4264355552),i=l(i,j,h,g,e[a+6],15,2734768916),g=l(g,i,j,h,e[a+13],21,1309151649),h=l(h,g,i,j,e[a+4],6,4149444226),j=l(j,h,g,i,e[a+11],10,3174756917),i=l(i,j,h,g,e[a+2],15,718787259),g=l(g,i,j,h,e[a+9],21,3951481745),h=b(h,t),g=b(g,o),i=b(i,k),j=b(j,x);return(m(h)+m(g)+m(i)+m(j)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function b(b){var c=0,d;a(b).children("td,th").each(function(){if(c==t)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
parseInt(Number(b));break;case "float":b=Number(b)}return b}var c=a(this),d=c.closest("table"),e=d.children("tbody"),l=e.children("tr"),n=c.attr("data-sort-type");if(n){var h=!0;c.hasClass("sorting-asc")&&(h=!1);var t=0;c.prevAll().each(function(){var b=a(this).attr("colspan");t+=b?Number(b):1});l.sort(function(a,c){var d=h?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});e.append(l);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(h?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(b){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host= parseInt(Number(b));break;case "float":b=Number(b)}return b}var c=a(this),d=c.closest("table"),f=d.children("tbody"),l=f.children("tr"),m=c.attr("data-sort-type");if(m){var e=!0;c.hasClass("sorting-asc")&&(e=!1);var t=0;c.prevAll().each(function(){var b=a(this).attr("colspan");t+=b?Number(b):1});l.sort(function(a,c){var d=e?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});f.append(l);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(e?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(b){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host=
a[1]));mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0});var c=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=c&&UI.elements.header.css("margin-right",-1*a+"px");c=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])}); a[1]));mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0});var c=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=c&&UI.elements.header.css("margin-right",-1*a+"px");c=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])});
var MistVideoObject={},otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,b){this.vars[a]=b;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,b){this.opts&&log("[interval]","Set called on interval, but an interval is already active."); var MistVideoObject={},otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,b){this.vars[a]=b;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,b){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");
this.opts={delay:b,callback:a};this.opts.id=setInterval(a,b)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"&Aring;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", this.opts={delay:b,callback:a};this.opts.id=setInterval(a,b)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"&Aring;land Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",
@ -21,246 +21,260 @@ clearTimeout(this.hiding);delete this.hiding;var c=$(document).height()-$tooltip
"HLS (TS)";break;case "html5/application/vnd.apple.mpegurl;version=7":b="HLS (CMAF)";break;case "html5/video/webm":b="WebM";break;case "html5/video/mp4":b="MP4";break;case "dash/video/mp4":b="DASH";break;case "flash/11":b="HDS";break;case "flash/10":b="RTMP";break;case "flash/7":b="Progressive";break;case "html5/audio/mp3":b="MP3";break;case "html5/audio/wav":b="WAV";break;case "html5/video/mp2t":case "html5/video/mpeg":b="TS";break;case "html5/application/vnd.ms-sstr+xml":case "html5/application/vnd.ms-ss":b= "HLS (TS)";break;case "html5/application/vnd.apple.mpegurl;version=7":b="HLS (CMAF)";break;case "html5/video/webm":b="WebM";break;case "html5/video/mp4":b="MP4";break;case "dash/video/mp4":b="DASH";break;case "flash/11":b="HDS";break;case "flash/10":b="RTMP";break;case "flash/7":b="Progressive";break;case "html5/audio/mp3":b="MP3";break;case "html5/audio/wav":b="WAV";break;case "html5/video/mp2t":case "html5/video/mpeg":b="TS";break;case "html5/application/vnd.ms-sstr+xml":case "html5/application/vnd.ms-ss":b=
"Smooth Streaming";break;case "html5/text/vtt":b="VTT Subtitles";break;case "html5/text/plain":b="SRT Subtitles";break;case "html5/text/javascript":b="JSON Subtitles";break;case "rtsp":b="RTSP";break;case "webrtc":b="WebRTC"}return b},popup:{element:null,show:function(a){this.element=$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}}, "Smooth Streaming";break;case "html5/text/vtt":b="VTT Subtitles";break;case "html5/text/plain":b="SRT Subtitles";break;case "html5/text/javascript":b="JSON Subtitles";break;case "rtsp":b="RTSP";break;case "webrtc":b="WebRTC"}return b},popup:{element:null,show:function(a){this.element=$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},
menu:[{Overview:{},General:{},Protocols:{},Streams:{hiddenmenu:{Edit:{},Preview:{},Embed:{}}},Push:{},Triggers:{},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{}}}}],buildMenu:function(){function a(a,b){var c=$("<a>").addClass("button");c.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a)); menu:[{Overview:{},General:{},Protocols:{},Streams:{hiddenmenu:{Edit:{},Preview:{},Embed:{}}},Push:{},Triggers:{},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{}}}}],buildMenu:function(){function a(a,b){var c=$("<a>").addClass("button");c.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));
for(var d in b.classes)c.addClass(b.classes[d]);"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),b.stopPropagation())});return c}var b=UI.elements.menu,c;for(c in UI.menu){0<c&&b.append($("<br>"));for(var d in UI.menu[c]){var e=UI.menu[c][d],l=a(d,e);b.append(l);if("submenu"in e){var n=$("<span>").addClass("submenu");l.addClass("arrowdown").append(n);for(var h in e.submenu)n.append(a(h,e.submenu[h]))}else if("hiddenmenu"in for(var d in b.classes)c.addClass(b.classes[d]);"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){$(this).closest(".menu").hasClass("hide")||(UI.navto(a),b.stopPropagation())});return c}var b=UI.elements.menu,c;for(c in UI.menu){0<c&&b.append($("<br>"));for(var d in UI.menu[c]){var f=UI.menu[c][d],l=a(d,f);b.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]))}else if("hiddenmenu"in
e)for(h in n=$("<span>").addClass("hiddenmenu"),l.append(n),e.hiddenmenu)n.append(a(h,e.hiddenmenu[h]))}}c=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");b.after(c).after($("<div>").addClass("separator"))},findInput:function(a){return this.findInOutput("inputs",a)},findOutput:function(a){return this.findInOutput("connectors", f)for(e in m=$("<span>").addClass("hiddenmenu"),l.append(m),f.hiddenmenu)m.append(a(e,f.hiddenmenu[e]))}}c=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");b.after(c).after($("<div>").addClass("separator"))},findInput:function(a){return this.findInOutput("inputs",a)},findOutput:function(a){return this.findInOutput("connectors",
a)},findInOutput:function(a,b){if("capabilities"in mist.data){var c=!1,d=mist.data.capabilities[a];b in d&&(c=d[b]);b+".exe"in d&&(c=d[b+".exe"]);return c}throw"Request capabilities first";},buildUI:function(a){var b=$("<div>").addClass("input_container"),c;for(c in a){var d=a[c];if(d instanceof jQuery)b.append(d);else if("help"==d.type){var e=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));b.append(e);if("classes"in d)for(var l in d.classes)e.addClass(d.classes[l])}else if("text"== a)},findInOutput:function(a,b){if("capabilities"in mist.data){var c=!1,d=mist.data.capabilities[a];b in d&&(c=d[b]);b+".exe"in d&&(c=d[b+".exe"]);return c}throw"Request capabilities first";},buildUI:function(a){var b=$("<div>").addClass("input_container"),c;for(c in a){var d=a[c];if(d instanceof jQuery)b.append(d);else if("help"==d.type){var f=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));b.append(f);if("classes"in d)for(var l in d.classes)f.addClass(d.classes[l])}else if("text"==
d.type)b.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)b.append(d.custom);else if("buttons"==d.type)for(l in e=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in d&&e.css(d.css),b.append(e),d.buttons){var n=d.buttons[l],h=$("<button>").text(n.label).data("opts",n);"css"in n&&h.css(n.css);if("classes"in n)for(var t in n.classes)h.addClass(n.classes[t]);e.append(h);switch(n.type){case "cancel":h.addClass("cancel").click(n["function"]); d.type)b.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)b.append(d.custom);else if("buttons"==d.type)for(l in f=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in d&&f.css(d.css),b.append(f),d.buttons){var m=d.buttons[l],e=$("<button>").text(m.label).data("opts",m);"css"in m&&e.css(m.css);if("classes"in m)for(var t in m.classes)e.addClass(m.classes[t]);f.append(e);switch(m.type){case "cancel":e.addClass("cancel").click(m["function"]);
break;case "save":h.addClass("save").click(function(){var a=$(this).data("opts").preSave;a&&a.call(this);var b=$(this).closest(".input_container"),c=!1;b.find('.hasValidate:visible, input[type="hidden"].hasValidate').each(function(){if(c=$(this).data("validate")(this,!0))return!1});(a=$(this).data("opts").failedValidate)&&a.call(this);c||(b.find('.isSetting:visible, input[type="hidden"].isSetting').each(function(){var a=$(this).getval(),b=$(this).data("pointer");if(""===a)if("default"in $(this).data("opts"))a= break;case "save":e.addClass("save").click(function(){var a=$(this).data("opts").preSave;a&&a.call(this);var b=$(this).closest(".input_container"),c=!1;b.find('.hasValidate:visible, input[type="hidden"].hasValidate').each(function(){if(c=$(this).data("validate")(this,!0))return!1});(a=$(this).data("opts").failedValidate)&&a.call(this);c||(b.find('.isSetting:visible, input[type="hidden"].isSetting').each(function(){var a=$(this).getval(),b=$(this).data("pointer");if(""===a)if("default"in $(this).data("opts"))a=
$(this).data("opts")["default"];else return b.main[b.index]=null,!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:h.click(n["function"])}}else{n=$("<label>").addClass("UIelement");b.append(n);"css"in d&&n.css(d.css);n.append($("<span>").addClass("label").html("label"in d?d.label+":":""));if("classes"in d)for(t in d.classes)n.addClass(d.classes[t]);h=$("<span>").addClass("field_container");n.append(h);switch(d.type){case "password":e=$("<input>").attr("type","password"); $(this).data("opts")["default"];else return b.main[b.index]=null,!0;b.main[b.index]=a;(a=$(this).data("opts").postSave)&&a.call(this)}),(a=$(this).data("opts")["function"])&&a(this))});break;default:e.click(m["function"])}}else{m=$("<label>").addClass("UIelement");b.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html("label"in d?d.label+":":""));if("classes"in d)for(t in d.classes)m.addClass(d.classes[t]);e=$("<span>").addClass("field_container");m.append(e);switch(d.type){case "password":f=
break;case "int":e=$("<input>").attr("type","number");"min"in d&&e.attr("min",d.min);"max"in d&&e.attr("max",d.max);"step"in d&&e.attr("step",d.step);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":e=$("<span>");break;case "debug":d.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"], $("<input>").attr("type","password");break;case "int":f=$("<input>").attr("type","number");"min"in d&&f.attr("min",d.min);"max"in d&&f.attr("max",d.max);"step"in d&&f.attr("step",d.step);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":f=$("<span>");break;case "debug":d.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"],
[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":e=$("<select>");for(l in d.select){var m=$("<option>");"string"==typeof d.select[l]?m.text(d.select[l]):m.val(d.select[l][0]).text(d.select[l][1]);e.append(m)}break;case "textarea":e= [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 o=$("<option>");"string"==typeof d.select[l]?o.text(d.select[l]):o.val(d.select[l][0]).text(d.select[l][1]);f.append(o)}break;case "textarea":f=
$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":e=$("<input>").attr("type","checkbox");break;case "hidden":e=$("<input>").attr("type","hidden");n.hide();break;case "email":e=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":e=$("<input>").attr("type","text");"filetypes"in d&&e.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":e=$("<input>").attr("type","hidden");break;case "radioselect":e= $("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":f=$("<input>").attr("type","checkbox");break;case "hidden":f=$("<input>").attr("type","hidden");m.hide();break;case "email":f=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":f=$("<input>").attr("type","text");"filetypes"in d&&f.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":f=$("<input>").attr("type","hidden");break;case "radioselect":f=
$("<div>").addClass("radioselect");for(c in d.radioselect){var k=$("<input>").attr("type","radio").val(d.radioselect[c][0]).attr("name",d.label);d.readonly&&k.prop("disabled",!0);m=$("<label>").append(k).append($("<span>").html(d.radioselect[c][1]));e.append(m);if(2<d.radioselect[c].length)for(l in k=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),m.append(k),d.readonly&&k.prop("disabled",!0),d.radioselect[c][2])m=$("<option>"),k.append(m), $("<div>").addClass("radioselect");for(c in d.radioselect){var k=$("<input>").attr("type","radio").val(d.radioselect[c][0]).attr("name",d.label);d.readonly&&k.prop("disabled",!0);o=$("<label>").append(k).append($("<span>").html(d.radioselect[c][1]));f.append(o);if(2<d.radioselect[c].length)for(l in k=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),o.append(k),d.readonly&&k.prop("disabled",!0),d.radioselect[c][2])o=$("<option>"),k.append(o),
d.radioselect[c][2][l]instanceof Array?m.val(d.radioselect[c][2][l][0]).html(d.radioselect[c][2][l][1]):m.html(d.radioselect[c][2][l])}break;case "checklist":e=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");e.append($checklist);for(c in d.checklist)"string"==typeof d.checklist[c]&&(d.checklist[c]=[d.checklist[c],d.checklist[c]]),$checklist.append($("<label>").text(d.checklist[c][1]).prepend($("<input>").attr("type","checkbox").attr("name", d.radioselect[c][2][l]instanceof Array?o.val(d.radioselect[c][2][l][0]).html(d.radioselect[c][2][l][1]):o.html(d.radioselect[c][2][l])}break;case "checklist":f=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");f.append($checklist);for(c in d.checklist)"string"==typeof d.checklist[c]&&(d.checklist[c]=[d.checklist[c],d.checklist[c]]),$checklist.append($("<label>").text(d.checklist[c][1]).prepend($("<input>").attr("type","checkbox").attr("name",
d.checklist[c][0])));break;case "DOMfield":e=d.DOMfield;break;case "unix":e=$("<input>").attr("type","datetime-local").attr("step",1);d.unit=$("<button>").text("Now").click(function(){$(this).closest(".field_container").find(".field").setval((new Date).getTime()/1E3)});break;case "selectinput":e=$("<div>").addClass("selectinput");k=$("<select>");e.append(k);k.data("input",!1);for(c in d.selectinput)m=$("<option>"),k.append(m),"string"==typeof d.selectinput[c]?m.text(d.selectinput[c]):(m.text(d.selectinput[c][1]), d.checklist[c][0])));break;case "DOMfield":f=d.DOMfield;break;case "unix":f=$("<input>").attr("type","datetime-local").attr("step",1);d.unit=$("<button>").text("Now").click(function(){$(this).closest(".field_container").find(".field").setval((new Date).getTime()/1E3)});break;case "selectinput":f=$("<div>").addClass("selectinput");k=$("<select>");f.append(k);k.data("input",!1);for(c in d.selectinput)o=$("<option>"),k.append(o),"string"==typeof d.selectinput[c]?o.text(d.selectinput[c]):(o.text(d.selectinput[c][1]),
"string"==typeof d.selectinput[c][0]?m.val(d.selectinput[c][0]):(m.val("CUSTOM"),k.data("input")||k.data("input",UI.buildUI([d.selectinput[c][0]]).children())));k.data("input")&&e.append(k.data("input"));k.change(function(){"CUSTOM"==$(this).val()?$(this).data("input").css("display","flex"):$(this).data("input").hide()});k.trigger("change");break;case "inputlist":e=$("<div>").addClass("inputlist");e.data("newitem",function(){var a=$("<input>").attr("type","text").addClass("listitem");d.readonly&& "string"==typeof d.selectinput[c][0]?o.val(d.selectinput[c][0]):(o.val("CUSTOM"),k.data("input")||k.data("input",UI.buildUI([d.selectinput[c][0]]).children())));k.data("input")&&f.append(k.data("input"));k.change(function(){"CUSTOM"==$(this).val()?$(this).data("input").css("display","flex"):$(this).data("input").hide()});k.trigger("change");break;case "inputlist":f=$("<div>").addClass("inputlist");f.data("newitem",function(){var a;if("input"in d)a=UI.buildUI([d.input]).find(".field_container");else{var b=
a.prop("disabled",!0);var b=function(c){$(this).is(":last-child")?""!=$(this).val()?$(this).after(a.clone().keyup(b).val("")):8==c.which&&$(this).prev().focus():""==$(this).val()&&($(this).next().focus(),$(this).remove())};a.keyup(b);return a});e.append(e.data("newitem"));break;case "sublist":e=$("<div>").addClass("sublist");k=$("<div>").addClass("curvals");k.append($("<span>").text("None."));var w=$("<div>").addClass("itemsettings"),i=$("<button>").text("New "+d.itemLabel),f=d.sublist,g=d,j=e,r= Object.assign({},d);b.type="str";a=UI.buildUI([b]).find(".field_container")}a.addClass("listitem");var c=function(b){$(this).is(":last-child")?""!=$(this).find(".field").getval()?(b=a.clone().keyup(c),b.find(".field").setval(""),$(this).after(b)):8==b.which&&$(this).prev().find(".field").focus():""==$(this).find(".field").getval()&&(b=$(this).prev(),b.length||(b=$(this).next()),b.find(".field").focus(),$(this).remove())};a.keyup(c);return a});f.append(f.data("newitem"));break;case "sublist":f=$("<div>").addClass("sublist");
n;e.data("build",function(a,b){for(var c in g.saveas)c in a||delete g.saveas[c];g.saveas=Object.assign(g.saveas,a);c="New";"undefined"!=typeof b&&(c="Edit");c=UI.buildUI([$("<h4>").text(c+" "+g.itemLabel)].concat(f).concat([{label:"Save first",type:"str",classes:["onlyshowhelp"],validate:[function(){return{msg:"Did you want to save this "+g.itemLabel+"?",classes:["red"]}}]},{type:"buttons",buttons:[{label:"Cancel",type:"cancel","function":function(){w.html("");i.show();r.show()}},{label:"Save "+g.itemLabel, k=$("<div>").addClass("curvals");k.append($("<span>").text("None."));var x=$("<div>").addClass("itemsettings"),h=$("<button>").text("New "+d.itemLabel),g=d.sublist,i=d,j=f,q=m;f.data("build",function(a,b){for(var c in i.saveas)c in a||delete i.saveas[c];i.saveas=Object.assign(i.saveas,a);c="New";"undefined"!=typeof b&&(c="Edit");c=UI.buildUI([$("<h4>").text(c+" "+i.itemLabel)].concat(g).concat([{label:"Save first",type:"str",classes:["onlyshowhelp"],validate:[function(){return{msg:"Did you want to save this "+
type:"save",preSave:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").hide()},failedValidate:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").show()},"function":function(){var a=j.getval(),c=Object.assign({},g.saveas),d;for(d in c)null===c[d]&&delete c[d];"undefined"==typeof b?a.push(c):a[b]=c;j.setval(a);w.html("");i.show();r.show()}}]}]));w.html(c);i.hide();r.hide()});var F=e;i.click(function(){F.data("build")({})});f.unshift({type:"str", i.itemLabel+"?",classes:["red"]}}]},{type:"buttons",buttons:[{label:"Cancel",type:"cancel","function":function(){x.html("");h.show();q.show()}},{label:"Save "+i.itemLabel,type:"save",preSave:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").hide()},failedValidate:function(){$(this).closest(".input_container").find(".onlyshowhelp").closest("label").show()},"function":function(){var a=j.getval(),c=Object.assign({},i.saveas),d;for(d in c)null===c[d]&&delete c[d];"undefined"==
label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+d.itemLabel+". It won't be used by MistServer.",pointer:{main:d.saveas,index:"x-LSP-name"}});e.data("savelist",[]);e.append(k).append(i);b.append(w);break;case "json":e=$("<textarea>").on("keydown",function(a){a.stopPropagation()}).on("keyup change",function(){this.style.height="";this.style.height=(this.scrollHeight?this.scrollHeight+20:14*this.value.split("\n").length+20)+"px"}).css("min-height","3em");k=function(a, typeof b?a.push(c):a[b]=c;j.setval(a);x.html("");h.show();q.show()}}]}]));x.html(c);h.hide();q.hide()});var G=f;h.click(function(){G.data("build")({})});g.unshift({type:"str",label:"Human readable name",placeholder:"none",help:"A convenient name to describe this "+d.itemLabel+". It won't be used by MistServer.",pointer:{main:d.saveas,index:"x-LSP-name"}});f.data("savelist",[]);f.append(k).append(h);b.append(x);break;case "json":f=$("<textarea>").on("keydown",function(a){a.stopPropagation()}).on("keyup change",
b){if(""!=$(b).val()&&null===a)return{msg:"Invalid json",classes:["red"]}};"validate"in d?d.validate.push(k):d.validate=[k];break;case "bitmask":e=$("<div>").addClass("bitmask");for(c in d.bitmask)e.append($("<label>").append($("<input>").attr("type","checkbox").attr("name","bitmask_"+("pointer"in d?d.pointer.index:"")).attr("value",d.bitmask[c][0]).addClass("field")).append($("<span>").text(d.bitmask[c][1])));n.attr("for","none");break;default:e=$("<input>").attr("type","text"),"maxlength"in d&& function(){this.style.height="";this.style.height=(this.scrollHeight?this.scrollHeight+20:14*this.value.split("\n").length+20)+"px"}).css("min-height","3em");k=function(a,b){if(""!=$(b).val()&&null===a)return{msg:"Invalid json",classes:["red"]}};"validate"in d?d.validate.push(k):d.validate=[k];break;case "bitmask":f=$("<div>").addClass("bitmask");for(c in d.bitmask)f.append($("<label>").append($("<input>").attr("type","checkbox").attr("name","bitmask_"+("pointer"in d?d.pointer.index:"")).attr("value",
e.attr("maxlength",d.maxlength),"minlength"in d&&e.attr("minlength",d.minlength)}e.addClass("field").data("opts",d);"pointer"in d&&e.attr("name",d.pointer.index);h.append(e);if("classes"in d)for(l in d.classes)e.addClass(d.classes[l]);"placeholder"in d&&e.attr("placeholder",d.placeholder);"default"in d&&e.attr("placeholder",d["default"]);"unit"in d&&h.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in d&& d.bitmask[c][0]).addClass("field")).append($("<span>").text(d.bitmask[c][1])));m.attr("for","none");break;default:f=$("<input>").attr("type","text"),"maxlength"in d&&f.attr("maxlength",d.maxlength),"minlength"in d&&f.attr("minlength",d.minlength)}f.addClass("field").data("opts",d);"pointer"in d&&f.attr("name",d.pointer.index);e.append(f);if("classes"in d)for(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"]);
h.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in d&&document.queryCommandSupported("copy")&&h.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown", "unit"in d&&e.append($("<span>").addClass("unit").html(d.unit));"prefix"in d&&e.prepend($("<span>").addClass("unit").html(d.prefix));"readonly"in d&&(f.attr("readonly","readonly"),f.click(function(){$(this).select()}));"qrcode"in d&&e.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));
function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);var f=$(this);setTimeout(function(){f.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in d&&e.attr("rows",d.rows);if("dependent"in b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in d&&document.queryCommandSupported("copy")&&e.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");
d)for(c in d.dependent)n.attr("data-dependent-"+c,d.dependent[c]);switch(d.type){case "browse":k=$("<div>").addClass("grouper").append(n);b.append(k);k=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});h.append(k);k.click(function(){function a(b){h.text("Loading..");mist.send(function(a){e.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");h.html(i.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort(); document.body.removeChild(b);var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in d&&f.attr("rows",d.rows);if("dependent"in d)for(c in d.dependent)m.attr("data-dependent-"+c,d.dependent[c]);switch(d.type){case "browse":k=$("<div>").addClass("grouper").append(m);b.append(k);k=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});e.append(k);k.click(function(){function a(b){e.text("Loading..");mist.send(function(a){i.text(a.browse.path[0]);
for(var b in a.browse.subdirectories){var g=a.browse.subdirectories[b];h.append(i.clone(true).attr("title",e.text()+n+g).text(g))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var g=a.browse.files[b],k=e.text()+n+g,g=$("<a>").text(g).addClass("file").attr("title",k);h.append(g);if(j){var l=true,m;for(m in j)if(typeof j[m]!="undefined"&&mist.inputMatch(j[m],k)){l=false;break}l&&g.hide()}g.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity", mist.data.LTS&&d.setval(a.browse.path[0]+"/");e.html(h.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var f=a.browse.subdirectories[b];e.append(h.clone(true).attr("title",i.text()+m+f).text(f))}}if(a.browse.files){a.browse.files.sort();for(b in a.browse.files){var f=a.browse.files[b],k=i.text()+m+f,f=$("<a>").text(f).addClass("file").attr("title",k);e.append(f);if(j){var l=true,q;for(q in j)if(typeof j[q]!=
1);f.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),f=$(this),g=$("<button>").text("Stop browsing").click(function(){f.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),e=$("<span>").addClass("field"),h=$("<div>").addClass("browse_contents"),i=$("<a>").addClass("folder"),j=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(e).append(g))).append(h); "undefined"&&mist.inputMatch(j[q],k)){l=false;break}l&&f.hide()}f.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),f=$("<button>").text("Stop browsing").click(function(){g.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),i=$("<span>").addClass("field"),
var n="/";mist.data.config.version.indexOf("indows")>-1&&(n="\\");i.click(function(){var b=e.text()+n+$(this).text();a(b)});b=d.getval();g=b.split("://");g.length>1&&(b=g[0]=="file"?g[1]:"");b=b.split(n);b.pop();b=b.join(n);f.hide();a(b)});break;case "geolimited":case "hostlimited":k={field:e};k.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));k.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":k.prototype= e=$("<div>").addClass("browse_contents"),h=$("<a>").addClass("folder"),j=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(i).append(f))).append(e);var m="/";mist.data.config.version.indexOf("indows")>-1&&(m="\\");h.click(function(){var b=i.text()+m+$(this).text();a(b)});b=d.getval();f=b.split("://");f.length>1&&(b=f[0]=="file"?f[1]:"");b=b.split(m);b.pop();
$("<select>").append($("<option>").val("").text("[Select a country]"));for(c in UI.countrylist)k.prototype.append($("<option>").val(c).html(UI.countrylist[c]));break;case "hostlimited":k.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}k.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});k.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c= b=b.join(m);g.hide();a(b)});break;case "geolimited":case "hostlimited":k={field:f};k.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));k.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":k.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(c in UI.countrylist)k.prototype.append($("<option>").val(c).html(UI.countrylist[c]));break;case "hostlimited":k.prototype=$("<input>").attr("type",
$(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")});k.values.append(k.prototype.clone(!0));h.data("subUI",k).addClass("limit_list").append(k.blackwhite).append(k.values)}"pointer"in d&&(e.data("pointer",d.pointer).addClass("isSetting"),d.pointer.main&&(k=d.pointer.main[d.pointer.index],"undefined"!=k&&e.setval(k)));(""==e.getval()||null==e.getval())&&"value"in d&&e.setval(d.value); "text").attr("placeholder","type a host")}k.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});k.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")});k.values.append(k.prototype.clone(!0));
if("datalist"in d)for(c in k="datalist_"+c+MD5(e[0].outerHTML),e.attr("list",k),k=$("<datalist>").attr("id",k),h.append(k),d.datalist)k.append($("<option>").val(d.datalist[c]));h=$("<span>").addClass("help_container");n.append(h);"help"in d&&(h.append($("<span>").addClass("ih_balloon").html(d.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in d){n=[];for(l in d.validate){k= e.data("subUI",k).addClass("limit_list").append(k.blackwhite).append(k.values)}"pointer"in d&&(f.data("pointer",d.pointer).addClass("isSetting"),d.pointer.main&&(k=d.pointer.main[d.pointer.index],"undefined"!=k&&f.setval(k)));(""==f.getval()||null==f.getval()||!("pointer"in d))&&"value"in d&&f.setval(d.value);if("datalist"in d)for(c in k="datalist_"+c+MD5(f[0].outerHTML),f.attr("list",k),k=$("<datalist>").attr("id",k),e.append(k),d.datalist)k.append($("<option>").val(d.datalist[c]));e=$("<span>").addClass("help_container");
d.validate[l];if("function"!=typeof k)switch(k){case "required":k=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":k=function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}};break;case "streamname":k=function(a,b){if(a!=""){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.", 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){k=d.validate[l];if("function"!=typeof k)switch(k){case "required":k=function(a){return a==""||a==null?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":k=function(a,b){var c=$(b).data("opts");
classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_\-\.]/g,"")!=a)return{msg:"Special characters (except for underscores (_), periods (.) and dashes (-)) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",classes:["red"]}}};break; if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}};break;case "streamname":k=function(a,b){if(a!=""){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_\-\.]/g,"")!=a)return{msg:"Special characters (except for underscores (_), periods (.) and dashes (-)) are not allowed.",
case "streamname_with_wildcard":k=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.", classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",classes:["red"]}}};break;case "streamname_with_wildcard":k=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=
classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;case "streamname_with_wildcard_and_variables":k=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.", streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;case "streamname_with_wildcard_and_variables":k=function(a){if(a!=""){streampart=a.split("+");var b=streampart.slice(1).join("+");
classes:["red"]};if(streampart.replace(/[^\da-z_$]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",classes:["red"]}}};break;default:k=function(){}}n.push(k)}e.data("validate_functions",n).data("help_container",h).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(), streampart=streampart[0];if(!isNaN(streampart.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(streampart.toLowerCase()!=streampart)return{msg:"Uppercase letters are not allowed in a stream name.",classes:["red"]};if(streampart.replace(/[^\da-z_$]/g,"")!=streampart)return{msg:"Special characters (except for underscores) are not allowed in a stream name.",classes:["red"]};if(streampart!=a&&b.replace(/[\00|\0|\/]/g,"")!=b)return{msg:"Slashes or null bytes are not allowed in wildcards.",
d=$(a).data("validate_functions"),f=$(a).data("help_container");f.find(".err_balloon").remove();for(var g in d){var e=d[g](c,a);if(e){$err=$("<span>").addClass("err_balloon").html(e.msg);for(var h in e.classes)$err.addClass(e.classes[h]);f.prepend($err);b&&$(a).focus();return typeof e=="object"&&"break"in e?e["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in d&&(e.on("change keyup", classes:["red"]}}};break;case "track_selector_parameter":k=function(){};break;case "track_selector":k=function(){};break;default:k=function(){}}m.push(k)}f.data("validate_functions",m).data("help_container",e).data("validate",function(a,b){if($(a).is(":visible")||$(a).is('input[type="hidden"]')){var c=$(a).getval(),d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var f in d){var i=d[f](c,a);if(i){$err=$("<span>").addClass("err_balloon").html(i.msg);
d["function"]),e.trigger("change"))}}b.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&b.length&&(b.trigger("click"),a.stopPropagation())});return b},buildVheaderTable:function(a){var b=$("<table>").css("margin","0.2em"),c=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];c.append($("<td>"));for(var e in a.labels)d.push($("<tr>").append($("<td>").html(""== for(var e in i.classes)$err.addClass(i.classes[e]);g.prepend($err);b&&$(a).focus();return typeof i=="object"&&"break"in i?i["break"]:true}}return false}}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=f.getval()&&f.trigger("change")}"function"in d&&(f.on("change keyup",d["function"]),f.trigger("change"))}}b.on("keydown",function(a){var b=!1;switch(a.which){case 13:b=$(this).find("button.save").first();break;case 27:b=$(this).find("button.cancel").first()}b&&
a.labels[e]?"&nbsp;":a.labels[e]+":")));for(var l in a.content)for(e in c.append($("<td>").html(a.content[l].header)),a.content[l].body)d[e].append($("<td>").html(a.content[l].body[e]));b.append($("<tbody>").append(c).append(d));return b},plot:{addGraph:function(a,b){var c={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(c.elements.legend);c.elements.cont.append(c.elements.plot).append(c.elements.legend); b.length&&(b.trigger("click"),a.stopPropagation())});return b},buildVheaderTable:function(a){var b=$("<table>").css("margin","0.2em"),c=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),d=[];c.append($("<td>"));for(var f in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[f]?"&nbsp;":a.labels[f]+":")));for(var l in a.content)for(f in c.append($("<td>").html(a.content[l].header)),a.content[l].body)d[f].append($("<td>").html(a.content[l].body[f]));
b.append(c.elements.cont);return c},go:function(a){if(!(1>Object.keys(a).length)){var b={totals:[],clients:[]},c;for(c in a)for(var d in a[c].datasets){var e=a[c].datasets[d];switch(e.datatype){case "clients":case "upbps":case "downbps":case "perc_lost":case "perc_retrans":switch(e.origin[0]){case "total":b.totals.push({fields:[e.datatype],end:-15});break;case "stream":b.totals.push({fields:[e.datatype],streams:[e.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[e.datatype],protocols:[e.origin[1]], b.append($("<tbody>").append(c).append(d));return b},plot:{addGraph:function(a,b){var c={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(c.elements.legend);c.elements.cont.append(c.elements.plot).append(c.elements.legend);b.append(c.elements.cont);return c},go:function(a){if(!(1>Object.keys(a).length)){var b={totals:[],clients:[]},c;for(c in a)for(var d in a[c].datasets){var f=
end:-15})}break;case "cpuload":case "memload":b.capabilities={}}}0==b.totals.length&&delete b.totals;0==b.clients.length&&delete b.clients;mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var e=[],m;for(m in c.datasets){var k=c.datasets[m];k.display&&(k.getdata(),k.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[k.yaxistype]),c.yaxes[k.yaxistype]=d.length),k.yaxis=c.yaxes[k.yaxistype], a[c].datasets[d];switch(f.datatype){case "clients":case "upbps":case "downbps":case "perc_lost":case "perc_retrans":switch(f.origin[0]){case "total":b.totals.push({fields:[f.datatype],end:-15});break;case "stream":b.totals.push({fields:[f.datatype],streams:[f.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[f.datatype],protocols:[f.origin[1]],end:-15})}break;case "cpuload":case "memload":b.capabilities={}}}0==b.totals.length&&delete b.totals;0==b.clients.length&&delete b.clients;
e.push(k))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,e,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts", mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var f=[],o;for(o in c.datasets){var k=c.datasets[o];k.display&&(k.getdata(),k.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[k.yaxistype]),c.yaxes[k.yaxistype]=d.length),k.yaxis=c.yaxes[k.yaxistype],f.push(k))}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,
c).text("X").addClass("close").click(function(){var b=$(this).data("opts");if(confirm("Are you sure you want to remove "+b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var w=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var e=c.plot.getXAxes()[0],a=Math.min(e.max,a),a=Math.max(e.min, borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",c).text("X").addClass("close").click(function(){var b=$(this).data("opts");if(confirm("Are you sure you want to remove "+
a);b.eq(0).html(UI.format.time(a/1E3))}for(var h in c.datasets){var i="&nbsp;";if(c.datasets[h].display){var e=UI.plot.yaxes[c.datasets[h].yaxistype].tickFormatter,k=c.datasets[h].data;if(a)for(var l in k){if(k[l][0]==a){i=e(k[l][1]);break}if(k[l][0]>a){if(l!=0){i=k[l];k=k[l-1];i=e(i[1]+(a-i[0])*(k[1]-i[1])/(k[0]-i[0]))}break}}else i=e(c.datasets[h].data[c.datasets[h].data.length-1][1])}b.eq(d).html(i);d++}};c.plot.getOptions();for(m in c.datasets)e=$("<input>").attr("type","checkbox").data("index", b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var x=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a=="undefined")b.eq(0).html("Latest:");else{var f=c.plot.getXAxes()[0],a=Math.min(f.max,a),a=Math.max(f.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var e in c.datasets){var h="&nbsp;";if(c.datasets[e].display){var f=UI.plot.yaxes[c.datasets[e].yaxistype].tickFormatter,
m).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[m].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",c.datasets[m].color)).append(c.datasets[m].label))).append($("<td>").css("padding-right","2em").css("text-align", k=c.datasets[e].data;if(a)for(var l in k){if(k[l][0]==a){h=f(k[l][1]);break}if(k[l][0]>a){if(l!=0){h=k[l];k=k[l-1];h=f(h[1]+(a-h[0])*(k[1]-h[1])/(k[0]-h[0]))}break}}else h=f(c.datasets[e].data[c.datasets[e].data.length-1][1])}b.eq(d).html(h);d++}};c.plot.getOptions();for(o in c.datasets)f=$("<input>").attr("type","checkbox").data("index",o).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")?a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=
"right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",m).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); false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[o].display&&f.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(f).append($("<div>").addClass("series-color").css("background-color",c.datasets[o].color)).append(c.datasets[o].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",o).data("graph",c).click(function(){var b=$(this).data("index"),
b={};b[c.id]=c;UI.plot.go(b)}}}))));w();var i=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=i){w(b.x);i=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1], c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));x();var h=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=h){x(b.x);h=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",
c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",function(){w()})}}},b)}},save:function(a){var b={id:a.id,xaxis:a.xaxis,datasets:[]},c;for(c in a.datasets)b.datasets.push({origin:a.datasets[c].origin,datatype:a.datasets[c].datatype});a=mist.stored.get().graphs||{};a[b.id]=b;mist.stored.set("graphs",a)},del:function(a){var b=mist.stored.get().graphs||{};delete b[a];mist.stored.set("graphs",b)},datatype:{getOptions:function(a){var b=$.extend(!0,{},UI.plot.datatype.templates.general), c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1],c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",function(){x()})}}},b)}},save:function(a){var b={id:a.id,xaxis:a.xaxis,datasets:[]},c;for(c in a.datasets)b.datasets.push({origin:a.datasets[c].origin,
c=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,c,a),a=$.extend(!0,b,a);switch(a.origin[0]){case "total":switch(a.datatype){case "cpuload":case "memload":break;default:a.label+=" (total)"}break;case "stream":case "protocol":a.label+=" ("+a.origin[1]+")"}var b=[],d;for(d in a.basecolor)c=a.basecolor[d],c+=50*(0.5-Math.random()),c=Math.round(c),c=Math.min(255,Math.max(0,c)),b.push(c);a.color="rgb("+b.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"", datatype:a.datasets[c].datatype});a=mist.stored.get().graphs||{};a[b.id]=b;mist.stored.set("graphs",a)},del:function(a){var b=mist.stored.get().graphs||{};delete b[a];mist.stored.set("graphs",b)},datatype:{getOptions:function(a){var b=$.extend(!0,{},UI.plot.datatype.templates.general),c=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,c,a),a=$.extend(!0,b,a);switch(a.origin[0]){case "total":switch(a.datatype){case "cpuload":case "memload":break;default:a.label+=" (total)"}break;
yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a=mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time, case "stream":case "protocol":a.label+=" ("+a.origin[1]+")"}var b=[],d;for(d in a.basecolor)c=a.basecolor[d],c+=50*(0.5-Math.random()),c=Math.round(c),c=Math.min(255,Math.max(0,c)),b.push(c);a.color="rgb("+b.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"",yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a=mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];
mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down", return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-
yaxistype:"bytespersec",basecolor:[148,64,237]},perc_lost:{label:"Lost packages",yaxistype:"percentage",basecolor:[255,33,234]},perc_retrans:{label:"Re-transmitted packages",yaxistype:"percentage",basecolor:[0,0,255]}}},yaxes:{percentage:{name:"percentage",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)}, 600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",yaxistype:"bytespersec",basecolor:[148,64,237]},perc_lost:{label:"Lost packages",yaxistype:"percentage",basecolor:[255,33,234]},perc_retrans:{label:"Re-transmitted packages",yaxistype:"percentage",
tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,ticks:function(a){var b=0.3*Math.sqrt($(".graph").first().height()),b=(a.max-a.min)/b,c=Math.floor(Math.log(Math.abs(b))/Math.log(1024)),d=b/Math.pow(1024,c),e=-Math.floor(Math.log(d)/Math.LN10),l=a.tickDecimals;null!=l&&e>l&&(e=l);var n=Math.pow(10,-e),d=d/n,h;if(1.5>d)h=1;else if(3>d){if(h=2,2.25<d&&(null==l||e+1<=l))h=2.5,++e}else h=7.5> basecolor:[0,0,255]}}},yaxes:{percentage:{name:"percentage",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,ticks:function(a){var b=
d?5:10;h=h*n*Math.pow(1024,c);null!=a.minTickSize&&h<a.minTickSize&&(h=a.minTickSize);a.delta=b;a.tickDecimals=Math.max(0,null!=l?l:e);a.tickSize=h;b=[];c=a.tickSize*Math.floor(a.min/a.tickSize);e=0;l=Number.NaN;do n=l,l=c+e*a.tickSize,b.push(l),++e;while(l<a.max&&l!=n);return b},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX, 0.3*Math.sqrt($(".graph").first().height()),b=(a.max-a.min)/b,c=Math.floor(Math.log(Math.abs(b))/Math.log(1024)),d=b/Math.pow(1024,c),f=-Math.floor(Math.log(d)/Math.LN10),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,c);null!=a.minTickSize&&e<a.minTickSize&&(e=a.minTickSize);a.delta=b;a.tickDecimals=Math.max(0,null!=l?l:f);a.tickSize=e;b=[];c=a.tickSize*Math.floor(a.min/
y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var c=$(this).data("dragstart"),d=c.ele.x-c.click.x+a.originalEvent.pageX,a=c.ele.y-c.click.y+a.originalEvent.pageY;$(this).css({opacity:1,top:a,left:d,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,b){var c=new Date(1E3*a),d=[];d.push(("0"+c.getHours()).slice(-2));d.push(("0"+c.getMinutes()).slice(-2));"short"!=b&&d.push(("0"+c.getSeconds()).slice(-2));return d.join(":")}, a.tickSize);f=0;l=Number.NaN;do m=l,l=c+f*a.tickSize,b.push(l),++f;while(l<a.max&&l!=m);return b},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var c=$(this).data("dragstart"),d=c.ele.x-c.click.x+a.originalEvent.pageX,a=c.ele.y-
date:function(a,b){var c=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),e=[];"long"==b&&e.push(d[c.getDay()]);e.push(("0"+c.getDate()).slice(-2));e.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[c.getMonth()]);"short"!=b&&e.push(c.getFullYear());return e.join(" ")},dateTime:function(a,b){return UI.format.date(a,b)+", "+UI.format.time(a,b)},duration:function(a){var b=[0.001,1E3,60,60,24,7,52,1E9],c="ms sec min hr day week year".split(" "),d={},e;for(e in c){var a=a/b[e], c.click.y+a.originalEvent.pageY;$(this).css({opacity:1,top:a,left:d,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,b){var c=new Date(1E3*a),d=[];d.push(("0"+c.getHours()).slice(-2));d.push(("0"+c.getMinutes()).slice(-2));"short"!=b&&d.push(("0"+c.getSeconds()).slice(-2));return d.join(":")},date:function(a,b){var c=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),f=[];"long"==b&&f.push(d[c.getDay()]);f.push(("0"+c.getDate()).slice(-2));f.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[c.getMonth()]);
l=Math.round(a%b[Number(e)+1]);d[c[e]]=l;a-=l}var n;for(e=c.length-1;0<=e;e--)if(0<d[c[e]]){n=c[e];break}b=$("<span>");switch(n){case "year":b.append(UI.format.addUnit(d.year,"years, ")).append(UI.format.addUnit(d.week,"wks"));break;case "week":b.append(UI.format.addUnit(d.week,"wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":b.append(UI.format.addUnit(d.day,"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:b.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+ "short"!=b&&f.push(c.getFullYear());return f.join(" ")},dateTime:function(a,b){return UI.format.date(a,b)+", "+UI.format.time(a,b)},duration:function(a){var b=[0.001,1E3,60,60,24,7,52,1E9],c="ms sec min hr day week year".split(" "),d={},f;for(f in c){var a=a/b[f],l=Math.round(a%b[Number(f)+1]);d[c[f]]=l;a-=l}var m;for(f=c.length-1;0<=f;f--)if(0<d[c[f]]){m=c[f];break}b=$("<span>");switch(m){case "year":b.append(UI.format.addUnit(d.year,"years, ")).append(UI.format.addUnit(d.week,"wks"));break;case "week":b.append(UI.format.addUnit(d.week,
(d.ms?"."+d.ms:"")].join(":"))}return b[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var b=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*b)/b;if(1E4<=a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var b=$("<span>");if("undefined"==typeof a.online)return b.text("Unknown, checking.."),"undefined"!=typeof a.error&&b.text(a.error),b;switch(a.online){case -1:b.text("Enabling"); "wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":b.append(UI.format.addUnit(d.day,"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:b.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+(d.ms?"."+d.ms:"")].join(":"))}return b[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var b=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*b)/b;if(1E4<=a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=
break;case 0:b.text("Unavailable").addClass("red");break;case 1:b.text("Active").addClass("green");break;case 2:b.text("Standby").addClass("orange");break;default:b.text(a.online)}"error"in a&&b.text(a.error);return b},capital:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},addUnit:function(a,b){var c=$("<span>").html(a);c.append($("<span>").addClass("unit").html(b));return c[0].innerHTML},bytes:function(a,b){var c="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=c[0];else{var d=Math.floor(Math.log(Math.abs(a))/ number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var b=$("<span>");if("undefined"==typeof a.online)return b.text("Unknown, checking.."),"undefined"!=typeof a.error&&b.text(a.error),b;switch(a.online){case -1:b.text("Enabling");break;case 0:b.text("Unavailable").addClass("red");break;case 1:b.text("Active").addClass("green");break;case 2:b.text("Standby").addClass("orange");break;default:b.text(a.online)}"error"in a&&b.text(a.error);return b},capital:function(a){return a.charAt(0).toUpperCase()+
Math.log(1024));0>d?unit=c[0]:(a/=Math.pow(1024,d),unit=c[d])}return UI.format.addUnit(UI.format.number(a),unit+(b?"/s":""))}},navto:function(a,b){var c=location.hash,d=c.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,b].join("&");"undefined"!=typeof screenlog&&screenlog.navto(d[1]);location.hash=d.join("@");location.hash==c&&$(window).trigger("hashchange")},showTab:function(a,b){var c=UI.elements.main;if(mist.user.loggedin){if(!("ui_settings"in mist.data)){c.html("Loading.."); a.substring(1)},addUnit:function(a,b){var c=$("<span>").html(a);c.append($("<span>").addClass("unit").html(b));return c[0].innerHTML},bytes:function(a,b){var c="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=c[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=c[0]:(a/=Math.pow(1024,d),unit=c[d])}return UI.format.addUnit(UI.format.number(a),unit+(b?"/s":""))}},navto:function(a,b){var c=location.hash,d=c.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,b].join("&");
mist.send(function(){UI.showTab(a,b)},{ui_settings:!0});return}mist.data.config.serverid&&(document.title=mist.data.config.serverid+" - MistServer MI")}var d=UI.elements.menu.removeClass("hide").find('.plain:contains("'+a+'")').closest(".button");0<d.length&&(UI.elements.menu.find(".button.active").removeClass("active"),d.addClass("active"));MistVideoObject&&MistVideoObject.reference&&MistVideoObject.reference.unload();UI.interval.clear();c.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview"); "undefined"!=typeof screenlog&&screenlog.navto(d[1]);location.hash=d.join("@");location.hash==c&&$(window).trigger("hashchange")},showTab:function(a,b){var c=UI.elements.main;if(mist.user.loggedin){if(!("ui_settings"in mist.data)){c.html("Loading..");mist.send(function(){UI.showTab(a,b)},{ui_settings:!0});return}mist.data.config.serverid&&(document.title=mist.data.config.serverid+" - MistServer MI")}var d=UI.elements.menu.removeClass("hide").find('.plain:contains("'+a+'")').closest(".button");0<d.length&&
return}document.title="MistServer MI";UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");c.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", (UI.elements.menu.find(".button.active").removeClass("active"),d.addClass("active"));MistVideoObject&&MistVideoObject.reference&&MistVideoObject.reference.unload();UI.interval.clear();c.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");return}document.title="MistServer MI";UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");c.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."},
"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:"rawpassword"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword;mist.send(function(){UI.navto("Overview")})}}]}])); {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:"rawpassword"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.user.password=
break;case "Create a new account":UI.elements.menu.addClass("hide");c.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));c.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.", MD5(mist.user.rawpassword);delete mist.user.rawpassword;mist.send(function(){UI.navto("Overview")})}}]}]));break;case "Create a new account":UI.elements.menu.addClass("hide");c.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));c.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",
pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,b){$(".match_password.field").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:"rawpassword"},classes:["match_password"]},{label:"Repeat password",type:"password",validate:["required",function(a,b){return a!=$(".match_password.field").not($(b)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.', 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.field").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:"rawpassword"},classes:["match_password"]},
classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");c.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text", {label:"Repeat password",type:"password",validate:["required",function(a,b){return a!=$(".match_password.field").not($(b)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});
text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)c.append("Unable to enable all protocols as protocol settings already exist.<br>");else{c.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)c.append('Could not enable protocol "'+d+'" because it has required settings.<br>'); mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");c.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)c.append("Unable to enable all protocols as protocol settings already exist.<br>");
else{b.push({connector:d});c.append('Enabled protocol "'+d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});c.append("Loading..");return}var e= else{c.append("Retrieving available protocols..<br>");mist.send(function(a){var b=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)c.append('Could not enable protocol "'+d+'" because it has required settings.<br>');else{b.push({connector:d});c.append('Enabled protocol "'+d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},
$("<span>").text("Loading.."),l=$("<span>"),n=$("<span>").addClass("logs"),h=$("<span>"),t=$("<span>"),m=$("<span>").text("Unknown"),k=$("<span>"),w=$("<span>"),i=parseURL(mist.user.host),i=i.protocol+i.host+i.port,f={};c.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},{type:"span",label:"Version",pointer:{main:mist.data.config, {label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});c.append("Loading..");return}var f=$("<span>").text("Loading.."),l=$("<span>"),m=$("<span>").addClass("logs"),e=$("<span>"),t=$("<span>"),o=$("<span>").text("Unknown"),k=$("<span>"),x=$("<span>"),h=parseURL(mist.user.host),h=h.protocol+h.host+h.port,g={};c.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},
index:"version"}},{type:"span",label:"Version check",value:e},{type:"span",label:"Server time",value:t},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:""},{type:"span",label:"Active licenses",value:m},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:l},{type:"span",label:"Current connections",value:h},{type:"span",label:"Enabled protocols",value:k},{type:"span", {type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f},{type:"span",label:"Server time",value:t},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.user:""},{type:"span",label:"Active licenses",value:o},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:l},{type:"span",label:"Current connections",
label:"Disabled protocols",value:w},{type:"span",label:"Recent problems",value:n},$("<br>"),$("<h3>").text("Write config now"),{type:"help",help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},{type:"checkbox",label:"Force configurations save",pointer:{main:f,index:"save"}},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a= value:e},{type:"span",label:"Enabled protocols",value:k},{type:"span",label:"Disabled protocols",value:x},{type:"span",label:"Recent problems",value:m},$("<br>"),$("<h3>").text("Write config now"),{type:"help",help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},{type:"checkbox",label:"Force configurations save",pointer:{main:g,index:"save"}},
{};if(f.save)a.save=f.save;delete f.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var g=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");e.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=$("<div>");e.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}} {type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};if(g.save)a.save=g.save;delete g.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var i=function(a){function b(a){if(a.update){var d="";"progress"in a.update&&(d=" ("+a.update.progress+"%)");f.text("Updating.."+d);c(a.log);setTimeout(function(){mist.send(function(a){b(a)},{update:true})},1E3)}else UI.showTab("Overview")}function c(a){a=a.filter(function(a){return a[1]=="UPDR"});if(a.length){var b=
if(!a.update||!("uptodate"in a.update)){e.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&g(a)},{checkupdate:true})},5E3)}else if(a.update.error)e.addClass("red").text(a.update.error);else if(a.update.uptodate)e.text("Your version is up to date.").addClass("green");else{if(a.update.progress){e.addClass("orange").removeClass("red").text("Updating..");b(a)}else{e.text("");e.append($("<span>").addClass("red").text("On "+(new Date(a.update.date)).toLocaleDateString()+ $("<div>");f.append(b);for(var d in a)b.append($("<div>").text(a[d][2]))}}if(!a.update||!("uptodate"in a.update)){f.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){"update"in a&&i(a)},{checkupdate:true})},5E3)}else if(a.update.error)f.addClass("red").text(a.update.error);else if(a.update.uptodate)f.text("Your version is up to date.").addClass("green");else{if(a.update.progress){f.addClass("orange").removeClass("red").text("Updating..");b(a)}else{f.text("");f.append($("<span>").addClass("red").text("On "+
" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&e.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){e.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target","_blank").text("Manual download");d[0].protocol= (new Date(a.update.date)).toLocaleDateString()+" version "+a.update.version+" became available."));(!a.update.url||a.update.url.slice(-4)!=".zip")&&f.append($("<button>").text("Rolling update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){b(a)},{autoupdate:true})}}));var d=$("<a>").attr("href",a.update.url).attr("target",
"https:";e.append($("<div>").append(d))}c(a.log)}};g(mist.data);if("license"in mist.data.config){if("active_products"in mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var j=$("<table>").css("text-indent","0");m.html(j);j.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(var r in mist.data.config.license.active_products){var F= "_blank").text("Manual download");d[0].protocol="https:";f.append($("<div>").append(d))}c(a.log)}};i(mist.data);if("license"in mist.data.config){if("active_products"in mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var j=$("<table>").css("text-indent","0");o.html(j);j.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(var q in mist.data.config.license.active_products){var G=
mist.data.config.license.active_products[r];j.append($("<tr>").append($("<td>").append(F.name)).append($("<td>").append(F.updates_final?F.updates_final:"&infin;")).append($("<td>").append(F.use_final?F.use_final:"&infin;")).append($("<td>").append(F.amount?F.amount:"&infin;")))}}else m.text("None. ");m.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else e.text("");var Ca=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true}; mist.data.config.license.active_products[q];j.append($("<tr>").append($("<td>").append(G.name)).append($("<td>").append(G.updates_final?G.updates_final:"&infin;")).append($("<td>").append(G.use_final?G.use_final:"&infin;")).append($("<td>").append(G.amount?G.amount:"&infin;")))}}else o.text("None. ");o.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else f.text("");var Da=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};
if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){Da()},a)},Da=function(){l.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";h.text(a);t.text(UI.format.dateTime(mist.data.config.time,"long"));n.html("");a=0;"license"in mist.data.config&&"user_msg"in if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){Ea()},a)},Ea=function(){l.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";e.text(a);t.text(UI.format.dateTime(mist.data.config.time,"long"));m.html("");a=0;"license"in mist.data.config&&"user_msg"in
mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),e=c[2].split("|");for(b in e)d.append($("<span>").text(e[b]));n.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&n.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b]; mist.data.config.license&&mist.data.log.unshift([mist.data.config.license.time,"ERROR",mist.data.config.license.user_msg]);for(var b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),f=c[2].split("|");for(b in f)d.append($("<span>").text(f[b]));m.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&m.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];
a.indexOf(d.connector)>-1||a.push(d.connector)}k.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);w.text(c.length?c.join(", "):"None.")}else w.text("Loading..")};Ca();Da();UI.interval.set(Ca,3E4);break;case "General":var U={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus,defaultStream:mist.data.config.defaultStream},I= a.indexOf(d.connector)>-1||a.push(d.connector)}k.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);x.text(c.length?c.join(", "):"None.")}else x.text("Loading..")};Da();Ea();UI.interval.set(Da,3E4);break;case "General":var U={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus,defaultStream:mist.data.config.defaultStream},J=
{sessionViewerMode:mist.data.config.sessionViewerMode,sessionInputMode:mist.data.config.sessionInputMode,sessionOutputMode:mist.data.config.sessionOutputMode,sessionUnspecifiedMode:mist.data.config.sessionUnspecifiedMode,tknMode:mist.data.config.tknMode,sessionStreamInfoMode:mist.data.config.sessionStreamInfoMode,trustedproxy:mist.data.config.trustedproxy},ea={location:"location"in mist.data.config?mist.data.config.location:{}},D={limit:""};"bandwidth"in mist.data&&(D=mist.data.bandwidth,null==D&& {sessionViewerMode:mist.data.config.sessionViewerMode,sessionInputMode:mist.data.config.sessionInputMode,sessionOutputMode:mist.data.config.sessionOutputMode,sessionUnspecifiedMode:mist.data.config.sessionUnspecifiedMode,tknMode:mist.data.config.tknMode,sessionStreamInfoMode:mist.data.config.sessionStreamInfoMode,trustedproxy:mist.data.config.trustedproxy},ea={location:"location"in mist.data.config?mist.data.config.location:{}},E={limit:""};"bandwidth"in mist.data&&(E=mist.data.bandwidth,null==E&&
(D={}),D.limit||(D.limit=""));var Fa=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s"));c.html(UI.buildUI([$("<h2>").text("General settings"),{type:"help",help:"These are settings that apply to your MistServer instance in general."},{type:"str",label:"Human readable name",pointer:{main:U,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."}, (E={}),E.limit||(E.limit=""));var Ga=$("<select>").html($("<option>").val(1).text("bytes/s")).append($("<option>").val(1024).text("KiB/s")).append($("<option>").val(1048576).text("MiB/s")).append($("<option>").val(1073741824).text("GiB/s"));c.html(UI.buildUI([$("<h2>").text("General settings"),{type:"help",help:"These are settings that apply to your MistServer instance in general."},{type:"str",label:"Human readable name",pointer:{main:U,index:"serverid"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},
{type:"debug",label:"Debug level",pointer:{main:U,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},{type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:U,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput", {type:"debug",label:"Debug level",pointer:{main:U,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},{type:"selectinput",label:"Access log",selectinput:[["","Do not track"],["LOG","Log to MistServer log"],[{type:"str",label:"Path",LTSonly:!0},"Log to file"]],pointer:{main:U,index:"accesslog"},help:"Enable access logs.",LTSonly:!0},{type:"selectinput",
label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:U,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+i+"/PASSPHRASE or "+i+"/PASSPHRASE.json.",LTSonly:!0},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",pointer:{main:f,index:"trustedproxy"}}, label:"Prometheus stats output",selectinput:[["","Disabled"],[{type:"str",label:"Passphrase",LTSonly:!0},"Enabled"]],pointer:{main:U,index:"prometheus"},help:"Make stats available in Prometheus format. These can be accessed via "+h+"/PASSPHRASE or "+h+"/PASSPHRASE.json.",LTSonly:!0},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",pointer:{main:g,index:"trustedproxy"}},
{type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:U,index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",LTSonly:!0},$("<h3>").text("Sessions"),{type:"bitmask",label:"Bundle viewer sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:I, {type:"str",validate:["streamname_with_wildcard_and_variables"],label:"Fallback stream",pointer:{main:U,index:"defaultStream"},help:"When this is set, if someone attempts to view a stream that does not exist, or is offline, they will be redirected to this stream instead. $stream may be used to refer to the original stream name.",LTSonly:!0},$("<h3>").text("Sessions"),{type:"bitmask",label:"Bundle viewer sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:J,
index:"sessionViewerMode"},help:"Change the way viewer connections are bundled into sessions.<br>Default: stream name, viewer IP and token"},{type:"bitmask",label:"Bundle input sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:I,index:"sessionInputMode"},help:"Change the way input connections are bundled into sessions.<br>Default: stream name, input IP, token and protocol"},{type:"bitmask",label:"Bundle output sessions by",bitmask:[[8,"Stream name"], index:"sessionViewerMode"},help:"Change the way viewer connections are bundled into sessions.<br>Default: stream name, viewer IP and token"},{type:"bitmask",label:"Bundle input sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:J,index:"sessionInputMode"},help:"Change the way input connections are bundled into sessions.<br>Default: stream name, input IP, token and protocol"},{type:"bitmask",label:"Bundle output sessions by",bitmask:[[8,"Stream name"],
[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:I,index:"sessionOutputMode"},help:"Change the way output connections are bundled into sessions.<br>Default: stream name, output IP, token and protocol"},{type:"bitmask",label:"Bundle unspecified sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:I,index:"sessionUnspecifiedMode"},help:"Change the way unspecified connections are bundled into sessions.<br>Default: none"},{type:"select",label:"Treat HTTP-only sessions as", [4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:J,index:"sessionOutputMode"},help:"Change the way output connections are bundled into sessions.<br>Default: stream name, output IP, token and protocol"},{type:"bitmask",label:"Bundle unspecified sessions by",bitmask:[[8,"Stream name"],[4,"IP address"],[2,"Token"],[1,"Protocol"]],pointer:{main:J,index:"sessionUnspecifiedMode"},help:"Change the way unspecified connections are bundled into sessions.<br>Default: none"},{type:"select",label:"Treat HTTP-only sessions as",
select:[[1,"A viewer session"],[2,"An output session: skip executing the USER_NEW and USER_END triggers"],[4,"A separate 'unspecified' session: skip executing the USER_NEW and USER_END triggers"],[3,"Do not start a session: skip executing the USER_NEW and USER_END triggers and do not count for statistics"]],pointer:{main:I,index:"sessionStreamInfoMode"},help:"Change the way the stream info connection gets treated.<br>Default: as a viewer session"},{type:"bitmask",label:"Communicate session token", select:[[1,"A viewer session"],[2,"An output session: skip executing the USER_NEW and USER_END triggers"],[4,"A separate 'unspecified' session: skip executing the USER_NEW and USER_END triggers"],[3,"Do not start a session: skip executing the USER_NEW and USER_END triggers and do not count for statistics"]],pointer:{main:J,index:"sessionStreamInfoMode"},help:"Change the way the stream info connection gets treated.<br>Default: as a viewer session"},{type:"bitmask",label:"Communicate session token",
bitmask:[[8,"Write to cookie"],[4,"Write to URL parameter"],[2,"Read from cookie"],[1,"Read from URL parameter"]],pointer:{main:I,index:"tknMode"},help:"Change the way the session token gets passed to and from MistServer, which can be set as a cookie or URL parameter named `tkn`. Reading the session token as a URL parameter takes precedence over reading from the cookie.<br>Default: all"},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.", bitmask:[[8,"Write to cookie"],[4,"Write to URL parameter"],[2,"Read from cookie"],[1,"Read from URL parameter"]],pointer:{main:J,index:"tknMode"},help:"Change the way the session token gets passed to and from MistServer, which can be set as a cookie or URL parameter named `tkn`. Reading the session token as a URL parameter takes precedence over reading from the cookie.<br>Default: all"},{type:"inputlist",label:"Trusted proxies",help:"List of proxy server addresses that are allowed to override the viewer IP address to arbitrary values.<br>You may use a hostname or IP address.",
LTSonly:!0,pointer:{main:I,index:"trustedproxy"}},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(a){$(a).text("Saving..");mist.send(function(){UI.navto("General")},{config:I})}}]}]));var ma=$("<div>").html("Loading..");mist.send(function(a){if(a.variable_list){var b=$("<tbody>");ma.html($("<table>").html($("<thead>").html($("<tr>").append($("<th>").text("Variable")).append($("<th>").text("Latest value")).append($("<th>").text("Command")).append($("<th>").text("Check interval")).append($("<th>").text("Last checked")).append($("<th>")))).append(b)); LTSonly:!0,pointer:{main:J,index:"trustedproxy"}},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(a){$(a).text("Saving..");mist.send(function(){UI.navto("General")},{config:J})}}]}]));var ma=$("<div>").html("Loading..");mist.send(function(a){if(a.variable_list){var b=$("<tbody>");ma.html($("<table>").html($("<thead>").html($("<tr>").append($("<th>").text("Variable")).append($("<th>").text("Latest value")).append($("<th>").text("Command")).append($("<th>").text("Check interval")).append($("<th>").text("Last checked")).append($("<th>")))).append(b));
for(var c in a.variable_list){var d=a.variable_list[c];b.append($("<tr>").addClass("variable").attr("data-name",c).html($("<td>").text("$"+c)).append($("<td>").html($("<code>").text(typeof d=="string"?JSON.stringify(d):d[2]>0?JSON.stringify(d[3]):""))).append($("<td>").text(typeof d=="string"?"":d[0])).append($("<td>").html(typeof d=="string"?"Never":d[1]==0?"Once":UI.format.duration(d[1]))).append($("<td>").attr("title",d[2]>0?typeof d=="string"?"":"At "+UI.format.dateTime(new Date(d[2]),"long"): for(var c in a.variable_list){var d=a.variable_list[c];b.append($("<tr>").addClass("variable").attr("data-name",c).html($("<td>").text("$"+c)).append($("<td>").html($("<code>").text(typeof d=="string"?JSON.stringify(d):d[2]>0?JSON.stringify(d[3]):""))).append($("<td>").text(typeof d=="string"?"":d[0])).append($("<td>").html(typeof d=="string"?"Never":d[1]==0?"Once":UI.format.duration(d[1]))).append($("<td>").attr("title",d[2]>0?typeof d=="string"?"":"At "+UI.format.dateTime(new Date(d[2]),"long"):
"Not yet").html(typeof d=="string"?"":d[2]>0?UI.format.duration((new Date).getTime()*0.001-d[2])+" ago":"Not yet")).append($("<td>").html($("<button>").text("Edit").click(function(){var a=$(this).closest("tr").attr("data-name");UI.navto("Edit variable",a)})).append($("<button>").text("Remove").click(function(){var a=$(this).closest("tr").attr("data-name");confirm("Are you sure you want to remove the custom variable $"+a+"?")&&mist.send(function(){UI.showTab("General")},{variable_remove:a})}))))}}else ma.html("None configured.")}, "Not yet").html(typeof d=="string"?"":d[2]>0?UI.format.duration((new Date).getTime()*0.001-d[2])+" ago":"Not yet")).append($("<td>").html($("<button>").text("Edit").click(function(){var a=$(this).closest("tr").attr("data-name");UI.navto("Edit variable",a)})).append($("<button>").text("Remove").click(function(){var a=$(this).closest("tr").attr("data-name");confirm("Are you sure you want to remove the custom variable $"+a+"?")&&mist.send(function(){UI.showTab("General")},{variable_remove:a})}))))}}else ma.html("None configured.")},
{variable_list:!0});c.append(UI.buildUI([$("<h3>").text("Custom variables"),{type:"help",help:"In certain places, like target URL's and pushes, variable substitution is applied in order to replace a $variable with their corresponding value. Here you can define your own constants and variables which will be used when variable substitution is applied. Variables can be used within variables but will not be reflected in their latest value on this page."},$("<div>").css("text-align","right").html($("<button>").text("New variable").click(function(){UI.navto("Edit variable", {variable_list:!0});c.append(UI.buildUI([$("<h3>").text("Custom variables"),{type:"help",help:"In certain places, like target URL's and pushes, variable substitution is applied in order to replace a $variable with their corresponding value. Here you can define your own constants and variables which will be used when variable substitution is applied. Variables can be used within variables but will not be reflected in their latest value on this page."},$("<div>").css("text-align","right").html($("<button>").text("New variable").click(function(){UI.navto("Edit variable",
"")})),ma]));c.append(UI.buildUI([$("<h3>").text("Load balancer"),{type:"help",help:"If you're using MistServer's load balancer, the information below is passed to it so that it can make informed decisions."},{type:"selectinput",label:"Server's bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:Fa},"Custom"]],pointer:{main:D,index:"limit"},help:"This is the amount of traffic this server is willing to handle."},{type:"inputlist",label:"Bandwidth exceptions", "")})),ma]));c.append(UI.buildUI([$("<h3>").text("Load balancer"),{type:"help",help:"If you're using MistServer's load balancer, the information below is passed to it so that it can make informed decisions."},{type:"selectinput",label:"Server's bandwidth limit",selectinput:[["","Default (1 gbps)"],[{label:"Custom",type:"int",min:0,unit:Ga},"Custom"]],pointer:{main:E,index:"limit"},help:"This is the amount of traffic this server is willing to handle."},{type:"inputlist",label:"Bandwidth exceptions",
pointer:{main:D,index:"exceptions"},help:"Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>"},{type:"int",step:1E-8,label:"Server latitude",pointer:{main:ea.location,index:"lat"},help:"This setting is only useful when MistServer is combined with a load balancer. When this is set, the balancer can send users to a server close to them."},{type:"int",step:1E-8, pointer:{main:E,index:"exceptions"},help:"Data sent to the hosts and subnets listed here will not count towards reported bandwidth usage.<br>Examples:<ul><li>192.168.0.0/16</li><li>localhost</li><li>10.0.0.0/8</li><li>fe80::/16</li></ul>"},{type:"int",step:1E-8,label:"Server latitude",pointer:{main:ea.location,index:"lat"},help:"This setting is only useful when MistServer is combined with a load balancer. When this is set, the balancer can send users to a server close to them."},{type:"int",step:1E-8,
label:"Server longitude",pointer:{main:ea.location,index:"lon"},help:"This setting is only useful when MistServer is combined with a load balancer. When this is set, the balancer can send users to a server close to them."},{type:"str",label:"Server location name",pointer:{main:ea.location,index:"name"},help:"This setting is only useful when MistServer is combined with a load balancer. This will be displayed as the server's location."},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(a){$(a).text("Saving.."); label:"Server longitude",pointer:{main:ea.location,index:"lon"},help:"This setting is only useful when MistServer is combined with a load balancer. When this is set, the balancer can send users to a server close to them."},{type:"str",label:"Server location name",pointer:{main:ea.location,index:"name"},help:"This setting is only useful when MistServer is combined with a load balancer. This will be displayed as the server's location."},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(a){$(a).text("Saving..");
var a={config:ea},b={};b.limit=D.limit?Fa.val()*D.limit:0;b.exceptions=D.exceptions;if(b.exceptions===null)b.exceptions=[];a.bandwidth=b;mist.send(function(){UI.navto("Overview")},a)}}]}]));break;case "Edit variable":var C=!1;""!=b&&(C=!0);var Ha=function(a,d){C?c.html($("<h2>").text('Edit Variable "$'+b+'"')):c.html($("<h2>").text("New Variable"));var e=$("<div>");c.append(UI.buildUI([{type:"str",maxlength:31,label:"Variable name",help:"What should the variable be called? A dollar sign will automatically be prepended.", var a={config:ea},b={};b.limit=E.limit?Ga.val()*E.limit:0;b.exceptions=E.exceptions;if(b.exceptions===null)b.exceptions=[];a.bandwidth=b;mist.send(function(){UI.navto("Overview")},a)}}]}]));break;case "Edit variable":var D=!1;""!=b&&(D=!0);var Ia=function(a,d){D?c.html($("<h2>").text('Edit Variable "$'+b+'"')):c.html($("<h2>").text("New Variable"));var f=$("<div>");c.append(UI.buildUI([{type:"str",maxlength:31,label:"Variable name",prefix:"$",help:"What should the variable be called? A dollar sign will automatically be prepended.",
pointer:{main:a,index:"name"},validate:["required",function(a){if(a.length&&a[0]=="$")return{msg:"The dollar sign will automatically be prepended. You don't need to type it here.",classes:["red"]};if(a.indexOf("{")!==-1||a.indexOf("}")!==-1||a.indexOf("$")!==-1)return{msg:'The following symbols are not permitted: "$ { }".',classes:["red"]}}]},{type:"select",label:"Type",help:"What kind of variable is this? It can either be a static value that you can enter below, or a dynamic one that is returned by a command.", pointer:{main:a,index:"name"},validate:["required",function(a){if(a.length&&a[0]=="$")return{msg:"The dollar sign will automatically be prepended. You don't need to type it here.",classes:["red"]};if(a.indexOf("{")!==-1||a.indexOf("}")!==-1||a.indexOf("$")!==-1)return{msg:'The following symbols are not permitted: "$ { }".',classes:["red"]}}]},{type:"select",label:"Type",help:"What kind of variable is this? It can either be a static value that you can enter below, or a dynamic one that is returned by a command.",
select:[["value","Static value"],["command","Dynamic through command"]],value:"value",pointer:{main:d,index:"type"},"function":function(){var a=[$("Invalid variable type")];switch($(this).val()){case "value":a=[{type:"str",label:"Value",pointer:{main:d,index:"value"},help:"The static value that this variable should be replaced with. There is a character limit of 63 characters.",validate:["required"]}];break;case "command":a=[{type:"str",label:"Command",help:"The command that should be executed to retrieve the value for this variable.<br>For example:<br><code>/usr/bin/date +%A</code><br>There is a character limit of 511 characters.", select:[["value","Static value"],["command","Dynamic through command"]],value:"value",pointer:{main:d,index:"type"},"function":function(){var a=[$("Invalid variable type")];switch($(this).val()){case "value":a=[{type:"str",label:"Value",pointer:{main:d,index:"value"},help:"The static value that this variable should be replaced with. There is a character limit of 63 characters.",validate:["required"]}];break;case "command":a=[{type:"str",label:"Command",help:"The command that should be executed to retrieve the value for this variable.<br>For example:<br><code>/usr/bin/date +%A</code><br>There is a character limit of 511 characters.",
validate:["required"],pointer:{main:d,index:"target"}},{type:"int",min:0,max:4294967295,"default":0,label:"Checking interval",unit:"s",help:"At what interval, in seconds, MistServer should execute the command and update the value.<br>To execute the command once when MistServer starts up (and then never update), set the interval to 0.",pointer:{main:d,index:"interval"}},{type:"int",min:0,max:4294967295,"default":1,label:"Wait time",unit:"s",help:"Specifies the maximum time, in seconds, MistServer should wait for data when executing the variable target. If set to 0 this variable takes on the same value as the interval.<br>MistServer only updates one variable at a time, so setting this value too high can block other variables from updating.", validate:["required"],pointer:{main:d,index:"target"}},{type:"int",min:0,max:4294967295,"default":0,label:"Checking interval",unit:"s",help:"At what interval, in seconds, MistServer should execute the command and update the value.<br>To execute the command once when MistServer starts up (and then never update), set the interval to 0.",pointer:{main:d,index:"interval"}},{type:"int",min:0,max:4294967295,"default":1,label:"Wait time",unit:"s",help:"Specifies the maximum time, in seconds, MistServer should wait for data when executing the variable target. If set to 0 this variable takes on the same value as the interval.<br>MistServer only updates one variable at a time, so setting this value too high can block other variables from updating.",
pointer:{main:d,index:"waitTime"}}]}e.html(UI.buildUI(a))}},e,{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={variable_add:a};switch(d.type){case "value":a.value=d.value;break;case "command":a.target=d.target;a.interval=d.interval;a.waitTime=d.waitTime}if(a.name!=b)c.variable_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};c.html("Loading..");C?mist.send(function(a){if(b in a.variable_list){a= pointer:{main:d,index:"waitTime"}}]}f.html(UI.buildUI(a))}},f,{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={variable_add:a};switch(d.type){case "value":a.value=d.value;break;case "command":a.target=d.target;a.interval=d.interval;a.waitTime=d.waitTime}if(a.name!=b)c.variable_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};c.html("Loading..");D?mist.send(function(a){if(b in a.variable_list){a=
a.variable_list[b];Ha({name:b},typeof a=="string"?{value:a,type:"value"}:{target:a[0],interval:a[1],waitTime:a[4],type:"command"})}else c.append('Variable "$'+b+'" does not exist.')},{variable_list:!0}):Ha({},{});break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var E=$("<tbody>");c.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols= a.variable_list[b];Ia({name:b},typeof a=="string"?{value:a,type:"value"}:{target:a[0],interval:a[1],waitTime:a[4],type:"command"})}else c.append('Variable "$'+b+'" does not exist.')},{variable_list:!0}):Ia({},{});break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var F=$("<tbody>");c.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=
[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n "; [];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n ";
c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){if(mist.data.config.protocols===null)mist.data.config.protocols=[];for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear", c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){if(mist.data.config.protocols===null)mist.data.config.protocols=[];for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear",
"both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(E));var Ea=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],e=["required","optional"],M;for(M in e)for(var f in c[e[M]])b[f]&&b[f]!=""?d.push(f+": "+b[f]):c[e[M]][f]["default"]&&d.push(f+": "+c[e[M]][f]["default"]);return $("<span>").addClass("description").text(d.join(", "))} "both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(F));var Fa=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],f=["required","optional"],w;for(w in f)for(var g in c[f[w]])b[g]&&b[g]!=""?d.push(g+": "+b[g]):c[f[w]][g]["default"]&&d.push(g+": "+c[f[w]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}
E.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b],d=mist.data.capabilities.connectors[c.connector];E.append($("<tr>").data("index",b).append($("<td>").text(d&&d.friendly?d.friendly:c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a= F.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b],d=mist.data.capabilities.connectors[c.connector];F.append($("<tr>").data("index",b).append($("<td>").text(d&&d.friendly?d.friendly:c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align","right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=
$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};Ea();UI.interval.set(function(){mist.send(function(){Ea()})},1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}C= $(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};Fa();UI.interval.set(function(){mist.send(function(){Fa()})},1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}D=
!1;""!=b&&0<=b&&(C=!0);var V={};for(r in mist.data.config.protocols)V[mist.data.config.protocols[r].connector]=1;var Ga=function(a){var b=mist.data.capabilities.connectors[a],c=mist.convertBuildOptions(b,p);if(C)var d=$.extend({},p);c.push({type:"hidden",pointer:{main:p,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};C?a.updateprotocol=[d,p]:a.addprotocol=p;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel", !1;""!=b&&0<=b&&(D=!0);var V={};for(q in mist.data.config.protocols)V[mist.data.config.protocols[q].connector]=1;var Ha=function(a){var b=mist.data.capabilities.connectors[a],c=mist.convertBuildOptions(b,p);if(D)var d=$.extend({},p);c.push({type:"hidden",pointer:{main:p,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};D?a.updateprotocol=[d,p]:a.addprotocol=p;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel",
"function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){j=$("<span>").text("Dependencies:");$ul=$("<ul>");j.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var e in b.deps){a=$("<li>").text(b.deps[e]+" ");$ul.append(a);typeof V[b.deps[e]]!="undefined"||typeof V[b.deps[e]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:j[0].innerHTML})}return UI.buildUI(c)}, "function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){j=$("<span>").text("Dependencies:");$ul=$("<ul>");j.append($ul);if(typeof b.deps=="string")b.deps=b.deps.split(", ");for(var f in b.deps){a=$("<li>").text(b.deps[f]+" ");$ul.append(a);typeof V[b.deps[f]]!="undefined"||typeof V[b.deps[f]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:j[0].innerHTML})}return UI.buildUI(c)},
V={};for(r in mist.data.config.protocols)V[mist.data.config.protocols[r].connector]=1;if(C){var s=mist.data.config.protocols[b],p=s;c.find("h2").append(' "'+s.connector+'"');c.append(Ga(s.connector))}else{c.html($("<h2>").text("New Protocol"));var p={},u=[["",""]];for(r in mist.data.capabilities.connectors)u.push([r,mist.data.capabilities.connectors[r].friendly?mist.data.capabilities.connectors[r].friendly:r]);var R=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:u,"function":function(){$(this).getval()!= V={};for(q in mist.data.config.protocols)V[mist.data.config.protocols[q].connector]=1;if(D){var s=mist.data.config.protocols[b],p=s;c.find("h2").append(' "'+s.connector+'"');c.append(Ha(s.connector))}else{c.html($("<h2>").text("New Protocol"));var p={},u=[["",""]];for(q in mist.data.capabilities.connectors)u.push([q,mist.data.capabilities.connectors[q].friendly?mist.data.capabilities.connectors[q].friendly:q]);var R=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:u,"function":function(){$(this).getval()!=
""&&R.html(Ga($(this).getval()))}}])).append(R)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}var Ia=$("<button>"),N=$("<span>").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(Ia).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(N); ""&&R.html(Ha($(this).getval()))}}])).append(R)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}var Ja=$("<button>"),N=$("<span>").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(Ja).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(N);
""==b&&(f=mist.stored.get(),"viewmode"in f&&(b=f.viewmode));Ia.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var A=$.extend(!0,{},mist.data.streams),na=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},oa=function(b,d,e){N.remove();switch(b){case "thumbnails":var f=$("<div>").addClass("preview_icons"), ""==b&&(g=mist.stored.get(),"viewmode"in g&&(b=g.viewmode));Ja.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var B=$.extend(!0,{},mist.data.streams),na=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},pa=function(b,d,f){N.remove();switch(b){case "thumbnails":var g=$("<div>").addClass("preview_icons"),
g;g=e||[];d.sort();d.unshift("");N.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();f.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(f); e;e=f||[];d.sort();d.unshift("");N.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();g.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(g);
for(var h in d){var b=d[h],i="",j=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),k=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),e=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}), for(var i in d){var b=d[i],h="",j=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};b.deletestream=[a];mist.send(function(){UI.navto("Streams")},b)}}),k=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),f=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),
l=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),q=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];k=j="";q.addClass("wildcard")}else{i=mist.data.streams[b].source;if(g.indexOf(b)>-1){l=e="";q.addClass("folder")}}f.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(q).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(k).append(j).append(e).append(l)).attr("title", l=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),r=$("<span>").addClass("image");if(b.indexOf("+")>-1){h=b.split("+");h=mist.data.streams[h[0]].source+h[1];k=j="";r.addClass("wildcard")}else{h=mist.data.streams[b].source;if(e.indexOf(b)>-1){l=f="";r.addClass("folder")}}g.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(r).append($("<span>").addClass("description").text(h)).append($("<span>").addClass("button_container").append(k).append(j).append(f).append(l)).attr("title",
b).attr("data-stream",b))}break;default:var n=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(n); b).attr("data-stream",b))}break;default:var oa=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));i=$("<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(oa);
c.append(h);h.stupidtable();var m=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,A,mist.data.streams);var a=0;n.html("");d.sort();for(var b in d){var c=d[b],e;e=c in mist.data.streams?mist.data.streams[c]:A[c];var f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),g=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!= c.append(i);i.stupidtable();var m=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,B,mist.data.streams);var a=0;oa.html("");d.sort();for(var b in d){var c=d[b],f;f=c in mist.data.streams?mist.data.streams[c]:B[c];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),w=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!=
"undefined"){var h=mist.data.totals[c].all_protocols.clients,g=0;if(h.length){for(a in h)g=g+h[a][1];g=Math.round(g/h.length)}}f.html(UI.format.number(g));if(g==0&&e.online==1)e.online=2;g=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||!e.ischild)&&g.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+ "undefined"){var e=mist.data.totals[c].all_protocols.clients,w=0;if(e.length){for(a in e)w=w+e[a][1];w=Math.round(w/e.length)}}g.html(UI.format.number(w));if(w==0&&f.online==1)f.online=2;w=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in f)||!f.ischild)&&w.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));h=$("<span>").text(e.name);e.ischild&&h.css("padding-left","1em");var M=UI.format.status(e),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),q=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in A[c]||e.online<0){M.html(""); a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));e=$("<span>").text(f.name);f.ischild&&e.css("padding-left","1em");var i=UI.format.status(f),h=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),r=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in B[c]||f.online<0){i.html("");
i="";f.html("");q=""}n.append($("<tr>").data("index",c).html($("<td>").html(h).attr("title",e.name=="..."?"The results were truncated":e.name).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(M)).append(f).append($("<td>").css("white-space","nowrap").html(i).append(q)).append(g));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var o= h="";g.html("");r=""}oa.append($("<tr>").data("index",c).html($("<td>").html(e).attr("title",f.name=="..."?"The results were truncated":f.name).addClass("overflow_ellipsis")).append($("<td>").text(f.source).attr("title",f.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",f.online).html(i)).append(g).append($("<td>").css("white-space","nowrap").html(h).append(r)).append(w));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var q=
0,p=0;for(g in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[g].source)){A[g].source=A[g].source+"*";A[g].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,e;a:for(e in a.browse.files){var g;for(g in mist.data.capabilities.inputs)if(!(g.indexOf("Buffer")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder")>=0||g.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[g].source_match, 0,n=0;for(e in mist.data.streams){i=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!i)break;if(mist.inputMatch(i.source_match,mist.data.streams[e].source)){B[e].source=B[e].source+"*";B[e].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,f;a:for(f in a.browse.files){var g;for(g in mist.data.capabilities.inputs)if(!(g.indexOf("Buffer")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder")>=0||g.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[g].source_match,
"/"+a.browse.files[e])){var f=c+"+"+a.browse.files[e];A[f]=na(f,mist.data.streams[c]);A[f].source=mist.data.streams[c].source+a.browse.files[e];d++;if(d>=500){A[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?A[c].filesfound=true:mist.data.streams[c].filesfound=false;p++;if(o==p){mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}},{browse:mist.data.streams[g].source},{stream:g});o++}}if(o==0){mist.send(function(){m()}, "/"+a.browse.files[f])){var w=c+"+"+a.browse.files[f];B[w]=na(w,mist.data.streams[c]);B[w].source=mist.data.streams[c].source+a.browse.files[f];d++;if(d>=500){B[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?B[c].filesfound=true:mist.data.streams[c].filesfound=false;n++;if(q==n){mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});q++}}if(q==0){mist.send(function(){m()},
{active_streams:true});UI.interval.set(function(){m()},5E3)}}else{mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}}};if(mist.data.LTS){var pa=0,Ja=0,u={},Ka=[];for(f in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[f].source))Ka.push(f),mist.send(function(a,c){var d=c.stream,e=0,g;a:for(g in a.browse.files){var f;for(f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>= {active_streams:true});UI.interval.set(function(){m()},5E3)}}else{mist.send(function(){m()},{active_streams:true});UI.interval.set(function(){m()},5E3)}}};if(mist.data.LTS){var qa=0,Ka=0,u={},La=[];for(g in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[g].source))La.push(g),mist.send(function(a,c){var d=c.stream,f=0,g;a:for(g in a.browse.files){var e;for(e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
0||f.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[g])){u[d+"+"+a.browse.files[g]]=true;e++;if(e>=500){u[d+"+zzzzzzzzz"]=true;break a}}}Ja++;pa==Ja&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){u[mist.data.active_streams[a]]=true;A[mist.data.active_streams[a]]=na(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);u=u.concat(Object.keys(mist.data.streams)); 0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[g])){u[d+"+"+a.browse.files[g]]=true;f++;if(f>=500){u[d+"+zzzzzzzzz"]=true;break a}}}Ka++;qa==Ka&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){u[mist.data.active_streams[a]]=true;B[mist.data.active_streams[a]]=na(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);u=u.concat(Object.keys(mist.data.streams));
u.sort();oa(b,u,Ka)},{active_streams:true})},{browse:mist.data.streams[f].source},{stream:f}),pa++;0==pa&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){u[mist.data.active_streams[a]]=true;A[mist.data.active_streams[a]]=na(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);mist.data.streams&&(u=u.concat(Object.keys(mist.data.streams)));u.sort();oa(b,u)},{active_streams:!0})}else oa(b, u.sort();pa(b,u,La)},{active_streams:true})},{browse:mist.data.streams[g].source},{stream:g}),qa++;0==qa&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){u[mist.data.active_streams[a]]=true;B[mist.data.active_streams[a]]=na(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);mist.data.streams&&(u=u.concat(Object.keys(mist.data.streams)));u.sort();pa(b,u)},{active_streams:!0})}else pa(b,
Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}C=!1;""!=b&&(C=!0);if(C){var La=b,p=mist.data.streams[La];c.find("h2").append(' "'+La+'"')}else c.html($("<h2>").text("New Stream")),p={};var Ma=[];for(r in mist.data.capabilities.inputs)Ma.push(mist.data.capabilities.inputs[r].source_match);var fa=$("<div>"),Na=function(a){var c={};if(!mist.data.streams)mist.data.streams= Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}D=!1;""!=b&&(D=!0);if(D){var Ma=b,p=mist.data.streams[Ma];c.find("h2").append(' "'+Ma+'"')}else c.html($("<h2>").text("New Stream")),p={};var Na=[];for(q in mist.data.capabilities.inputs)Na.push(mist.data.capabilities.inputs[q].source_match);var fa=$("<div>"),Oa=function(a){var c={};if(!mist.data.streams)mist.data.streams=
{};mist.data.streams[p.name]=p;b!=p.name&&delete mist.data.streams[b];c.addstream={};c.addstream[p.name]=p;if(b!=p.name)c.deletestream=[b];if(p.stop_sessions&&b!=""){c.stop_sessions=b;delete p.stop_sessions}mist.send(function(){delete mist.data.streams[p.name].online;delete mist.data.streams[p.name].error;UI.navto(a,a=="Preview"?p.name:"")},c)},Oa=$("<style>").text("button.saveandpreview { display: none; }"),O=$("<span>"),qa=function(){var a=c.find("[name=name]").val();if(a){var b=parseURL(mist.user.host), {};mist.data.streams[p.name]=p;b!=p.name&&delete mist.data.streams[b];c.addstream={};c.addstream[p.name]=p;if(b!=p.name)c.deletestream=[b];if(p.stop_sessions&&b!=""){c.stop_sessions=b;delete p.stop_sessions}mist.send(function(){delete mist.data.streams[p.name].online;delete mist.data.streams[p.name].error;UI.navto(a,a=="Preview"?p.name:"")},c)},Pa=$("<style>").text("button.saveandpreview { display: none; }"),O=$("<span>"),ra=function(){var a=c.find("[name=name]").val();if(a){var b=parseURL(mist.user.host),
d=c.find("[name=source]").val(),e=d.match(/@.*/);e&&(e=e[0].substring(1));var g=d.replace(/(?:.+?):\/\//,""),g=g.split("/"),g=g[0],g=g.split(":"),g=g[0];(d=d.match(/:\d+/))&&(d=d[0]);var f={},h=["RTMP","RTSP","RTMP.exe","RTSP.exe"],i;for(i in h)h[i]in mist.data.capabilities.connectors&&(f[h[i]]=mist.data.capabilities.connectors[h[i]].optional.port["default"]);var h={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},j;for(j in f){for(i in mist.data.config.protocols){var k=mist.data.config.protocols[i]; d=c.find("[name=source]").val(),f=d.match(/@.*/);f&&(f=f[0].substring(1));var g=d.replace(/(?:.+?):\/\//,""),g=g.split("/"),g=g[0],g=g.split(":"),g=g[0];(d=d.match(/:\d+/))&&(d=d[0]);var e={},i=["RTMP","RTSP","RTMP.exe","RTSP.exe"],h;for(h in i)i[h]in mist.data.capabilities.connectors&&(e[i[h]]=mist.data.capabilities.connectors[i[h]].optional.port["default"]);var i={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},j;for(j in e){for(h in mist.data.config.protocols){var k=mist.data.config.protocols[h];
if(k.connector==j){if("port"in k)f[j]=k.port;break}}f[j]=f[j]==h[j]?"":":"+f[j]}f.TS="";f["TS.exe"]="";O.find(".field").closest("label").hide();for(i in f){var q;j=d?d:f[i];switch(i){case "RTMP":case "RTMP.exe":q="rtmp://"+b.host+j+"/"+(e?e:"live")+"/";O.find(".field.RTMPurl").setval(q).closest("label").show();O.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();q=q+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":q="rtsp://"+b.host+j+"/"+(a==""?"STREAMNAME":a)+(e? if(k.connector==j){if("port"in k)e[j]=k.port;break}}e[j]=e[j]==i[j]?"":":"+e[j]}e.TS="";e["TS.exe"]="";O.find(".field").closest("label").hide();for(h in e){var r;j=d?d:e[h];switch(h){case "RTMP":case "RTMP.exe":r="rtmp://"+b.host+j+"/"+(f?f:"live")+"/";O.find(".field.RTMPurl").setval(r).closest("label").show();O.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();r=r+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":r="rtsp://"+b.host+j+"/"+(a==""?"STREAMNAME":a)+(f?
"?pass="+e:"");break;case "TS":case "TS.exe":q="udp://"+(g==""?b.host:g)+j+"/"}O.find(".field."+i.replace(".exe","")).setval(q).closest("label").show()}}},Pa=$("<div>"),ra={},u=[],Qa=$("<div>");for(r in mist.data.capabilities.processes)u.push([r,mist.data.capabilities.processes[r].hrn?mist.data.capabilities.processes[r].hrn:mist.data.capabilities.processes[r].name]);if(u.length){var fb=[{label:"New process",type:"select",select:u,value:u[0][0],pointer:{main:ra,index:"process"},"function":function(){var a= "?pass="+f:"");break;case "TS":case "TS.exe":r="udp://"+(g==""?b.host:g)+j+"/"}O.find(".field."+h.replace(".exe","")).setval(r).closest("label").show()}}},Qa=$("<div>"),sa={},u=[],Ra=$("<div>");for(q in mist.data.capabilities.processes)u.push([q,mist.data.capabilities.processes[q].hrn?mist.data.capabilities.processes[q].hrn:mist.data.capabilities.processes[q].name]);if(u.length){var gb=[{label:"New process",type:"select",select:u,value:u[0][0],pointer:{main:sa,index:"process"},"function":function(){var a=
$(this).getval();if(a!=null){var a=mist.data.capabilities.processes[a],b=[$("<h4>").text(a.name+" Process options")];Qa.html(UI.buildUI(b.concat(mist.convertBuildOptions(a,ra))))}}},Qa];Pa.append(UI.buildUI([$("<br>"),$("<h3>").text("Stream processes"),{label:"Stream processes",itemLabel:"stream process",type:"sublist",sublist:fb,saveas:ra,pointer:{main:p,index:"processes"}}]))}c.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:p,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."}, $(this).getval();if(a!=null){var a=mist.data.capabilities.processes[a],b=[$("<h4>").text(a.name+" Process options")];Ra.html(UI.buildUI(b.concat(mist.convertBuildOptions(a,sa))))}}},Ra];Qa.append(UI.buildUI([$("<br>"),$("<h3>").text("Stream processes"),{label:"Stream processes",itemLabel:"stream process",type:"sublist",sublist:gb,saveas:sa,pointer:{main:p,index:"processes"}}]))}c.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:p,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},
{label:"Source",type:"browse",filetypes:Ma,pointer:{main:p,index:"source"},help:"<p> Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified. </p> <table class=valigntop> <tr> <th colspan=3><b>File inputs</b></th> </tr> <tr> <th>File</th> <td> Linux/MacOS:&nbsp;/PATH/FILE<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/FILE </td> <td> For file input please specify the proper path and file.<br> Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input. </td> </tr> <th> Folder </th> <td> Linux/MacOS:&nbsp;/PATH/<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/ </td> <td> A folder stream makes all the recognised files in the selected folder available as a stream. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Push inputs</b></th> </tr> <tr> <th>RTMP</th> <td>push://(IP)(@PASSWORD)</td> <td> IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br> PASSWORD is the application under which to push to MistServer, if it doesn't match the stream will be rejected. PASSWORD is MistServer Pro only. </td> </tr> <tr> <th>RTSP</th> <td>push://(IP)(@PASSWORD)</td> <td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td> </tr> <tr> <th>TS</th> <td>tsudp://(IP):PORT(/INTERFACE)</td> <td> IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br> PORT is the port you reserve for this stream on the chosen IP.<br> INTERFACE is the interface used, if left all interfaces will be used. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Pull inputs</b></th> </tr> <tr> <th>DTSC</th> <td>dtsc://MISTSERVER_IP:PORT/(STREAMNAME)</td> <td>MISTSERVER_IP is the IP of another MistServer to pull from.<br> PORT is the DTSC port of the other MistServer. (default is 4200)<br> STREAMNAME is the name of the target stream on the other MistServer. If left empty, the name of this stream will be used. </td> </tr> <tr> <th>HLS</th> <td>http://URL/TO/STREAM.m3u8</td> <td>The URL where the HLS stream is available to MistServer.</td> </tr> <tr> <th>RTSP</th> <td>rtsp://(USER:PASSWORD@)IP(:PORT)(/path)</td> <td> USER:PASSWORD is the account used if authorization is required.<br> IP is the IP address used to pull this stream from.<br> PORT is the port used to connect through.<br> PATH is the path to be used to identify the correct stream. </td> </tr> </table>", {label:"Source",type:"browse",filetypes:Na,pointer:{main:p,index:"source"},help:"<p> Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified. </p> <table class=valigntop> <tr> <th colspan=3><b>File inputs</b></th> </tr> <tr> <th>File</th> <td> Linux/MacOS:&nbsp;/PATH/FILE<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/FILE </td> <td> For file input please specify the proper path and file.<br> Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input. </td> </tr> <th> Folder </th> <td> Linux/MacOS:&nbsp;/PATH/<br> Windows:&nbsp;/cygdrive/DRIVE/PATH/ </td> <td> A folder stream makes all the recognised files in the selected folder available as a stream. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Push inputs</b></th> </tr> <tr> <th>RTMP</th> <td>push://(IP)(@PASSWORD)</td> <td> IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br> PASSWORD is the application under which to push to MistServer, if it doesn't match the stream will be rejected. PASSWORD is MistServer Pro only. </td> </tr> <tr> <th>RTSP</th> <td>push://(IP)(@PASSWORD)</td> <td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td> </tr> <tr> <th>TS</th> <td>tsudp://(IP):PORT(/INTERFACE)</td> <td> IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br> PORT is the port you reserve for this stream on the chosen IP.<br> INTERFACE is the interface used, if left all interfaces will be used. </td> </tr> <tr><td colspan=3>&nbsp;</td></tr> <tr> <th colspan=3><b>Pull inputs</b></th> </tr> <tr> <th>DTSC</th> <td>dtsc://MISTSERVER_IP:PORT/(STREAMNAME)</td> <td>MISTSERVER_IP is the IP of another MistServer to pull from.<br> PORT is the DTSC port of the other MistServer. (default is 4200)<br> STREAMNAME is the name of the target stream on the other MistServer. If left empty, the name of this stream will be used. </td> </tr> <tr> <th>HLS</th> <td>http://URL/TO/STREAM.m3u8</td> <td>The URL where the HLS stream is available to MistServer.</td> </tr> <tr> <th>RTSP</th> <td>rtsp://(USER:PASSWORD@)IP(:PORT)(/path)</td> <td> USER:PASSWORD is the account used if authorization is required.<br> IP is the IP address used to pull this stream from.<br> PORT is the port used to connect through.<br> PATH is the path to be used to identify the correct stream. </td> </tr> </table>",
"function":function(){var a=$(this).val();Oa.remove();O.html("");if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)fa.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];fa.html($("<h3>").text(b.name+" Input options")); "function":function(){var a=$(this).val();Pa.remove();O.html("");if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)fa.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];fa.html($("<h3>").text(b.name+" Input options"));
var e=mist.convertBuildOptions(b,p);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&e.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:p,index:"always_on"}});fa.append(UI.buildUI(e));if(b.name=="Folder")c.append(Oa);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){d=[$("<br>"),$("<span>").text("Configure your source to push to:")]; var f=mist.convertBuildOptions(b,p);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&f.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:p,index:"always_on"}});fa.append(UI.buildUI(f));if(b.name=="Folder")c.append(Pa);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){d=[$("<br>"),$("<span>").text("Configure your source to push to:")];
switch(b.name){case "Buffer":case "Buffer.exe":d.push({label:"RTMP full url",type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});d.push({label:"RTMP url",type:"span",clipboard:true,readonly:true,classes:["RTMPurl"],help:"Use this RTMP url if your client also asks for a stream key"});d.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"}); switch(b.name){case "Buffer":case "Buffer.exe":d.push({label:"RTMP full url",type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});d.push({label:"RTMP url",type:"span",clipboard:true,readonly:true,classes:["RTMPurl"],help:"Use this RTMP url if your client also asks for a stream key"});d.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"});
d.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});break;case "TS":case "TS.exe":a.charAt(0)=="/"?d=[]:d.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}O.html(UI.buildUI(d));qa()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",pointer:{main:p,index:"stop_sessions"}},O,$("<br>"),{type:"custom",custom:fa},Pa,{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}}, d.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});break;case "TS":case "TS.exe":a.charAt(0)=="/"?d=[]:d.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}O.html(UI.buildUI(d));ra()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",pointer:{main:p,index:"stop_sessions"}},O,$("<br>"),{type:"custom",custom:fa},Qa,{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},
{type:"save",label:"Save","function":function(){Na("Streams")}},{type:"save",label:"Save and Preview","function":function(){Na("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){qa()});qa();break;case "Preview":""==b&&UI.navto("Streams");var P=parseURL(mist.user.host),W=P.protocol,S=P.host,J=":8080",v=W+S+J+"/";for(r in mist.data.config.protocols)if(s=mist.data.config.protocols[r],"HTTP"==s.connector||"HTTP.exe"==s.connector){s.pubaddr&&s.pubaddr.length?"string"== {type:"save",label:"Save","function":function(){Oa("Streams")}},{type:"save",label:"Save and Preview","function":function(){Oa("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){ra()});ra();break;case "Preview":""==b&&UI.navto("Streams");var P=parseURL(mist.user.host),W=P.protocol,S=P.host,K=":8080",v=W+S+K+"/";for(q in mist.data.config.protocols)if(s=mist.data.config.protocols[q],"HTTP"==s.connector||"HTTP.exe"==s.connector){s.pubaddr&&s.pubaddr.length?"string"==
typeof s.pubaddr?v=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(v=s.pubaddr[0].replace(/\/$/,"")+"/"):(J=s.port?":"+s.port:":8080",v=W+S+J+"/");break}var R=$("<div>").css({display:"flex","flex-flow":"row wrap","flex-shrink":1,"min-width":"auto"}),X="";-1==b.indexOf("+")&&(X=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(X).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed", typeof s.pubaddr?v=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(v=s.pubaddr[0].replace(/\/$/,"")+"/"):(K=s.port?":"+s.port:":8080",v=W+S+K+"/");break}var R=$("<div>").css({display:"flex","flex-flow":"row wrap","flex-shrink":1,"min-width":"auto"}),X="";-1==b.indexOf("+")&&(X=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(X).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",
b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(R);var K=encodeURIComponent(b),Ra=$("<div>").css("flex-shrink","1").css("min-width","auto").css("max-width","100%");R.append(Ra);var Sa=$("<div>"),Y=$("<div>").text("Loading player..").css("max-width","100%").css("flex-shrink","1").css("min-width","auto"),sa=$("<div>").addClass("controls");Ra.append(Y).append(Sa).append(sa);$("link#devcss").length|| b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(R);var L=encodeURIComponent(b),Sa=$("<div>").css("flex-shrink","1").css("min-width","auto").css("max-width","100%");R.append(Sa);var Ta=$("<div>"),Y=$("<div>").text("Loading player..").css("max-width","100%").css("flex-shrink","1").css("min-width","auto"),ta=$("<div>").addClass("controls");Sa.append(Y).append(Ta).append(ta);$("link#devcss").length||
c.append($("<link>").attr("rel","stylesheet").attr("type","text/css").attr("href",v+"skins/dev.css").attr("id","devcss"));var Ta=function(){Sa.text("");var d=document.createElement("script");c.append(d);d.src=v+"player.js";d.onerror=function(){Y.html($("<p>").append('Failed to load <a href="'+v+'player.js">'+v+"player.js</a>.")).append($("<p>").append("Please check if you've activated the HTTP protocol, if your http port is blocked, or if you're trying to load HTTPS on an HTTP page.")).append($("<button>").text("Reload").css("display", c.append($("<link>").attr("rel","stylesheet").attr("type","text/css").attr("href",v+"skins/dev.css").attr("id","devcss"));var Ua=function(){Ta.text("");var d=document.createElement("script");c.append(d);d.src=v+"player.js";d.onerror=function(){Y.html($("<p>").append('Failed to load <a href="'+v+'player.js">'+v+"player.js</a>.")).append($("<p>").append("Please check if you've activated the HTTP protocol, if your http port is blocked, or if you're trying to load HTTPS on an HTTP page.")).append($("<button>").text("Reload").css("display",
"block").click(function(){Ta()}))};d.onload=function(){var e=b,g=function(){var a=MistVideoObject.reference;sa.html("");sa.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"],style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues", "block").click(function(){Ua()}))};d.onload=function(){var f=b,g=function(){var a=MistVideoObject.reference;ta.html("");ta.append(a.UI.buildStructure({type:"container",classes:["mistvideo-column"],style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.source},then:{type:"container",classes:["mistvideo-description"],style:{display:"block"},children:[{type:"playername",style:{display:"inline"}},{type:"text",text:"is playing",style:{margin:"0 0.2em"}},{type:"mimetype"}]}},{type:"decodingIssues",
style:{"max-width":"30em","flex-flow":"column nowrap"}},{type:"container",classes:["mistvideo-column","mistvideo-devcontrols"],children:[{type:"text",text:"Player control"},{type:"container",classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{"if":function(){return!(!this.player||!this.player.api)},then:{type:"button",title:"Reload the video source",label:"Reload video",onclick:function(){this.player.api.load()}}},{type:"button",title:"Build MistVideo again",label:"Reload player", style:{"max-width":"30em","flex-flow":"column nowrap"}},{type:"container",classes:["mistvideo-column","mistvideo-devcontrols"],children:[{type:"text",text:"Player control"},{type:"container",classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{"if":function(){return!(!this.player||!this.player.api)},then:{type:"button",title:"Reload the video source",label:"Reload video",onclick:function(){this.player.api.load()}}},{type:"button",title:"Build MistVideo again",label:"Reload player",
onclick:function(){this.reload()}},{type:"button",title:"Switch to the next available player and source combination",label:"Try next combination",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},{type:"forceType"},{type:"forceSource"}]},{type:"log"}]}))};if(!(a!="Preview"||!b||b==""||e!=b)){Y[0].addEventListener("initialized",g);Y[0].addEventListener("initializeFailed",g);MistVideoObject.reference=mistPlay(e,{target:Y[0],host:v,skin:"dev",loop:true,MistVideoObject:MistVideoObject})}c[0].removeChild(d)}; onclick:function(){this.reload()}},{type:"button",title:"Switch to the next available player and source combination",label:"Try next combination",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},{type:"forceType"},{type:"forceSource"}]},{type:"log"}]}))};if(!(a!="Preview"||!b||b==""||f!=b)){Y[0].addEventListener("initialized",g);Y[0].addEventListener("initializeFailed",g);MistVideoObject.reference=mistPlay(f,{target:Y[0],host:v,skin:"dev",loop:true,MistVideoObject:MistVideoObject})}c[0].removeChild(d)};
MistVideoObject.reference={unload:function(){d.onload=function(){this.parentElement&&this.parentElement.removeChild(this)}}}};Ta();var ta=$("<div>").append($("<h3>").text("Meta information")),ga=$("<span>").text("Loading..");ta.append(ga);var Ua=$("<div>").addClass("process_info");ta.append(Ua);R.append(ta);if(""!=K){$.ajax({type:"GET",url:v+"json_"+K+".js",success:function(a){var b=function(a,b){return"maxbps"in a?UI.format.bytes(a[b],1):b=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},c=a.meta;if(!c|| MistVideoObject.reference={unload:function(){d.onload=function(){this.parentElement&&this.parentElement.removeChild(this)}}}};Ua();var ua=$("<div>").append($("<h3>").text("Meta information")),ga=$("<span>").text("Loading..");ua.append(ga);var Va=$("<div>").addClass("process_info");ua.append(Va);R.append(ua);if(""!=L){$.ajax({type:"GET",url:v+"json_"+L+".js",success:function(a){var b=function(a,b){return"maxbps"in a?UI.format.bytes(a[b],1):b=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},c=a.meta;if(!c||
!c.tracks)ga.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(c.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language","Track index"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate", !c.tracks)ga.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(c.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language","Track index"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate",
"Peak bitrate","Size","Framerate","Language","Track index","Has B-Frames"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},e=Object.keys(c.tracks);e.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});var g=1,f=1,h=1,i;for(i in e){var j=e[i],q=c.tracks[j];switch(q.type){case "audio":d.audio.content.push({header:"Track "+j.split("_").pop(),body:[q.codec,UI.format.duration((q.lastms-q.firstms)/ "Peak bitrate","Size","Framerate","Language","Track index","Has B-Frames"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},f=Object.keys(c.tracks);f.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});var g=1,e=1,i=1,h;for(h in f){var j=f[h],r=c.tracks[j];switch(r.type){case "audio":d.audio.content.push({header:"Track "+j.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/
1E3)+"<br><span class=description>"+UI.format.duration(q.firstms/1E3)+" to "+UI.format.duration(q.lastms/1E3)+"</span>",b(q,"bps"),b(q,"maxbps"),q.channels,UI.format.addUnit(UI.format.number(q.rate),"Hz"),"language"in q?q.language:"unknown",g]});g++;break;case "video":d.video.content.push({header:"Track "+j.split("_").pop(),body:[q.codec,UI.format.duration((q.lastms-q.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(q.firstms/1E3)+" to "+UI.format.duration(q.lastms/1E3)+"</span>",b(q, 1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/1E3)+"</span>",b(r,"bps"),b(r,"maxbps"),r.channels,UI.format.addUnit(UI.format.number(r.rate),"Hz"),"language"in r?r.language:"unknown",g]});g++;break;case "video":d.video.content.push({header:"Track "+j.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/1E3)+"</span>",b(r,
"bps"),b(q,"maxbps"),UI.format.addUnit(q.width,"x ")+UI.format.addUnit(q.height,"px"),UI.format.addUnit(UI.format.number(q.fpks/1E3),"fps"),"language"in q?q.language:"unknown",f,"bframes"in q?"yes":"no"]});f++;break;case "meta":case "subtitle":if(q.codec=="subtitle"||q.type=="subtitle"){d.subtitle.content.push({header:"Track "+j.split("_").pop(),body:[q.codec,UI.format.duration((q.lastms-q.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(q.firstms/1E3)+" to "+UI.format.duration(q.lastms/ "bps"),b(r,"maxbps"),UI.format.addUnit(r.width,"x ")+UI.format.addUnit(r.height,"px"),UI.format.addUnit(UI.format.number(r.fpks/1E3),"fps"),"language"in r?r.language:"unknown",e,"bframes"in r?"yes":"no"]});e++;break;case "meta":case "subtitle":if(r.codec=="subtitle"||r.type=="subtitle"){d.subtitle.content.push({header:"Track "+j.split("_").pop(),body:[r.codec,UI.format.duration((r.lastms-r.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(r.firstms/1E3)+" to "+UI.format.duration(r.lastms/
1E3)+"</span>",b(q,"bps"),b(q,"maxbps"),"language"in q?q.language:"unknown",h]});h++}}}b=["audio","video","subtitle"];i=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(j in b)d[b[j]].content.length&&i.append(UI.buildVheaderTable(d[b[j]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(i);ga.html(UI.buildUI(a))}},error:function(){ga.html("Error while retrieving stream info.")}});var Va=function(){var a={proc_list:b};if(!mist.data.capabilities)a.capabilities= 1E3)+"</span>",b(r,"bps"),b(r,"maxbps"),"language"in r?r.language:"unknown",i]});i++}}}b=["audio","video","subtitle"];h=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(j in b)d[b[j]].content.length&&h.append(UI.buildVheaderTable(d[b[j]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(h);ga.html(UI.buildUI(a))}},error:function(){ga.html("Error while retrieving stream info.")}});var Wa=function(){var a={proc_list:b};if(!mist.data.capabilities)a.capabilities=
true;mist.send(function(a){if(a.proc_list){var b=$("<table>").css("width","auto"),c={"Process type:":function(a){return $("<b>").text(a.process)},"Source:":function(a){var b=$("<span>").text(a.source);a.source_tracks&&a.source_tracks.length&&b.append($("<span>").addClass("description").text(" track "+a.source_tracks.slice(0,-2).concat(a.source_tracks.slice(-2).join(" and ")).join(", ")));return b},"Sink:":function(a){var b=$("<span>").text(a.sink);a.sink_tracks&&a.sink_tracks.length&&b.append($("<span>").addClass("description").text(" track "+ true;mist.send(function(a){if(a.proc_list){var b=$("<table>").css("width","auto"),c={"Process type:":function(a){return $("<b>").text(a.process)},"Source:":function(a){var b=$("<span>").text(a.source);a.source_tracks&&a.source_tracks.length&&b.append($("<span>").addClass("description").text(" track "+a.source_tracks.slice(0,-2).concat(a.source_tracks.slice(-2).join(" and ")).join(", ")));return b},"Sink:":function(a){var b=$("<span>").text(a.sink);a.sink_tracks&&a.sink_tracks.length&&b.append($("<span>").addClass("description").text(" track "+
a.sink_tracks.slice(0,-2).concat(a.sink_tracks.slice(-2).join(" and ")).join(", ")));return b},"Active for:":function(a){var b=(new Date).setSeconds((new Date).getSeconds()-a.active_seconds);return $("<span>").append($("<span>").text(UI.format.duration(a.active_seconds))).append($("<span>").addClass("description").text(" since "+UI.format.time(b/1E3)))},"Pid:":function(a,b){return b},"Logs:":function(a){var b=$("<div>").text("None.");if(a.logs&&a.logs.length){b.html("").addClass("description").css({overflow:"auto", a.sink_tracks.slice(0,-2).concat(a.sink_tracks.slice(-2).join(" and ")).join(", ")));return b},"Active for:":function(a){var b=(new Date).setSeconds((new Date).getSeconds()-a.active_seconds);return $("<span>").append($("<span>").text(UI.format.duration(a.active_seconds))).append($("<span>").addClass("description").text(" since "+UI.format.time(b/1E3)))},"Pid:":function(a,b){return b},"Logs:":function(a){var b=$("<div>").text("None.");if(a.logs&&a.logs.length){b.html("").addClass("description").css({overflow:"auto",
maxHeight:"6em",display:"flex",flexFlow:"column-reverse nowrap"});for(var c in a.logs){var d=a.logs[c];b.prepend($("<div>").append(UI.format.time(d[0])+" ["+d[1]+"] "+d[2]))}}return b},"Additional info:":function(a){var b;if(a.ainfo&&Object.keys(a.ainfo).length){b=$("<table>");for(var c in a.ainfo){var d=mist.data.capabilities.processes[a.process].ainfo[c];d||(d={name:c});b.append($("<tr>").append($("<th>").text(d.name+":")).append($("<td>").html(a.ainfo[c]).append(d.unit?$("<span>").addClass("unit").text(d.unit): maxHeight:"6em",display:"flex",flexFlow:"column-reverse nowrap"});for(var c in a.logs){var d=a.logs[c];b.prepend($("<div>").append(UI.format.time(d[0])+" ["+d[1]+"] "+d[2]))}}return b},"Additional info:":function(a){var b;if(a.ainfo&&Object.keys(a.ainfo).length){b=$("<table>");for(var c in a.ainfo){var d=mist.data.capabilities.processes[a.process].ainfo[c];d||(d={name:c});b.append($("<tr>").append($("<th>").text(d.name+":")).append($("<td>").html(a.ainfo[c]).append(d.unit?$("<span>").addClass("unit").text(d.unit):
"")))}}else b=$("<span>").addClass("description").text("N/A");return b}};Ua.html($("<h4>").text("Stream processes")).append(b);for(var d in c){var e=$("<tr>");b.append(e);e.append($("<th>").text(d).css("vertical-align","top"));for(var g in a.proc_list){$out=c[d](a.proc_list[g],g);e.append($("<td>").html($out).css("vertical-align","top"))}}}},a)};UI.interval.set(function(){Va()},5E3);Va()}break;case "Embed":""==b&&UI.navTo("Streams");X="";-1==b.indexOf("+")&&(X=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit", "")))}}else b=$("<span>").addClass("description").text("N/A");return b}};Va.html($("<h4>").text("Stream processes")).append(b);for(var d in c){var f=$("<tr>");b.append(f);f.append($("<th>").text(d).css("vertical-align","top"));for(var g in a.proc_list){$out=c[d](a.proc_list[g],g);f.append($("<td>").html($out).css("vertical-align","top"))}}}},a)};UI.interval.set(function(){Wa()},5E3);Wa()}break;case "Embed":""==b&&UI.navTo("Streams");X="";-1==b.indexOf("+")&&(X=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",
b)}));c.html($("<div>").addClass("bigbuttons").append(X).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var Z=$("<span>");c.append(Z);var K=encodeURIComponent(b),P=parseURL(mist.user.host),W=P.protocol,S=P.host,J=":8080",aa,ha={},v={http:W+S+J+"/"};for(r in mist.data.config.protocols)if(s=mist.data.config.protocols[r], b)}));c.html($("<div>").addClass("bigbuttons").append(X).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var Z=$("<span>");c.append(Z);var L=encodeURIComponent(b),P=parseURL(mist.user.host),W=P.protocol,S=P.host,K=":8080",aa,ha={},v={http:W+S+K+"/"};for(q in mist.data.config.protocols)if(s=mist.data.config.protocols[q],
"HTTP"==s.connector||"HTTP.exe"==s.connector)s.pubaddr?("string"==typeof s.pubaddr?v.http=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(v.http=s.pubaddr[0].replace(/\/$/,"")+"/"),ha.http=s.pubaddr):(J=s.port?":"+s.port:":8080",v.http=W+S+J+"/");else if("HTTPS"==s.connector||"HTTPS.exe"==s.connector)s.pubaddr&&s.pubaddr.length?("string"==typeof s.pubaddr?v.https=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(v.https=s.pubaddr[0].replace(/\/$/,"")+"/"),ha.https=s.pubaddr):(aa=s.port?":"+s.port: "HTTP"==s.connector||"HTTP.exe"==s.connector)s.pubaddr?("string"==typeof s.pubaddr?v.http=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(v.http=s.pubaddr[0].replace(/\/$/,"")+"/"),ha.http=s.pubaddr):(K=s.port?":"+s.port:":8080",v.http=W+S+K+"/");else if("HTTPS"==s.connector||"HTTPS.exe"==s.connector)s.pubaddr&&s.pubaddr.length?("string"==typeof s.pubaddr?v.https=s.pubaddr.replace(/\/$/,"")+"/":s.pubaddr.length&&(v.https=s.pubaddr[0].replace(/\/$/,"")+"/"),ha.https=s.pubaddr):(aa=s.port?":"+s.port:
":4433",v.https="https://"+S+aa+"/");var Q=v.http,B={http:v.http};"https"in v&&(B.https=v.https);if(otherhost.host||otherhost.https){Q=(otherhost.https&&aa?"https://":"http://")+(otherhost.host?otherhost.host:P.host)+(otherhost.https&&aa?aa:J)+"/";if(otherhost.host&&("http"in ha||(B.http=parseURL(B.http,{hostname:otherhost.host}).full),"https"in B&&!("https"in ha)))B.https=parseURL(B.https,{hostname:otherhost.host}).full;Q=otherhost.https?B.https:B.http}var ba=!1,ua={forcePlayer:"",forceType:"",controls:!0, ":4433",v.https="https://"+S+aa+"/");var Q=v.http,C={http:v.http};"https"in v&&(C.https=v.https);if(otherhost.host||otherhost.https){Q=(otherhost.https&&aa?"https://":"http://")+(otherhost.host?otherhost.host:P.host)+(otherhost.https&&aa?aa:K)+"/";if(otherhost.host&&("http"in ha||(C.http=parseURL(C.http,{hostname:otherhost.host}).full),"https"in C&&!("https"in ha)))C.https=parseURL(C.https,{hostname:otherhost.host}).full;Q=otherhost.https?C.https:C.http}var ba=!1,va={forcePlayer:"",forceType:"",controls:!0,
autoplay:!0,loop:!1,muted:!1,fillSpace:!1,poster:"",urlappend:"",setTracks:{}},o=$.extend({},ua),Wa=UI.stored.getOpts();"embedoptions"in Wa&&(o=$.extend(o,Wa.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks={}));var ia={};switch(o.controls){case "stock":ia.controls="stock";break;case !0:ia.controls=1;break;case !1:ia.controls=0}var y=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}ba&&UI.stored.saveOpt("embedoptions", autoplay:!0,loop:!1,muted:!1,fillSpace:!1,poster:"",urlappend:"",setTracks:{}},n=$.extend({},va),Xa=UI.stored.getOpts();"embedoptions"in Xa&&(n=$.extend(n,Xa.embedoptions,!0),"object"!=typeof n.setTracks&&(n.setTracks={}));var ia={};switch(n.controls){case "stock":ia.controls="stock";break;case !0:ia.controls=1;break;case !1:ia.controls=0}var z=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}ba&&UI.stored.saveOpt("embedoptions",
o);for(var c=b+"_",d=12,e="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+61);e=e+g}var c=c+e,d=['target: document.getElementById("'+c+'")'],f;for(f in o)f=="prioritize_type"?o[f]&&o[f]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[o[f]]]]})):f=="monitor_action"?o[f]&&o[f]!=""&&o[f]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'): n);for(var c=b+"_",d=12,f="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+61);f=f+g}var c=c+f,d=['target: document.getElementById("'+c+'")'],e;for(e in n)e=="prioritize_type"?n[e]&&n[e]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[n[e]]]]})):e=="monitor_action"?n[e]&&n[e]!=""&&n[e]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'):
o[f]!=ua[f]&&(o[f]!=null&&(typeof o[f]!="object"||JSON.stringify(o[f])!=JSON.stringify(ua[f])))&&d.push(f+": "+a(o[f]));f=[];f.push('<div class="mistvideo" id="'+c+'">');f.push(" <noscript>");f.push(' <a href="'+(otherhost.https?B.https:B.http)+K+'.html" target="_blank">');f.push(" Click here to play this video");f.push(" </a>");f.push(" </noscript>");f.push(" <script>");f.push(" var a = function(){");f.push(' mistPlay("'+b+'",{');f.push(" "+d.join(",\n "));f.push(" });"); n[e]!=va[e]&&(n[e]!=null&&(typeof n[e]!="object"||JSON.stringify(n[e])!=JSON.stringify(va[e])))&&d.push(e+": "+a(n[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+(otherhost.https?C.https:C.http)+L+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+b+'",{');e.push(" "+d.join(",\n "));e.push(" });");
f.push(" };");f.push(" if (!window.mistplayers) {");f.push(' var p = document.createElement("script");');if("https"in v&&parseURL(v.http).protocol!="https://"){f.push(' if (location.protocol == "https:") { p.src = "'+B.https+'player.js" } ');f.push(' else { p.src = "'+B.http+'player.js" } ')}else f.push(' p.src = "'+Q+'player.js"');f.push(" document.head.appendChild(p);");f.push(" p.onload = a;");f.push(" }");f.push(" else { a(); }");f.push(" <\/script>"); e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');if("https"in v&&parseURL(v.http).protocol!="https://"){e.push(' if (location.protocol == "https:") { p.src = "'+C.https+'player.js" } ');e.push(' else { p.src = "'+C.http+'player.js" } ')}else e.push(' p.src = "'+Q+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>");
f.push("</div>");return f.join("\n")},va=$("<span>").text("Loading.."),Xa=y(o),T=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),Ya="";"https"in v&&(Ya=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));Z.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type", e.push("</div>");return e.join("\n")},wa=$("<span>").text("Loading.."),Ya=z(n),T=$("<div>").text("Loading..").css("display","flex").css("flex-flow","column nowrap"),Za="";"https"in v&&(Za=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));Z.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type",
"text").addClass("field").val(otherhost.host?otherhost.host:P.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=$(this).closest("label").find("input").val();UI.navto("Embed",b)}))))).append(Ya)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:Q+"json_"+K+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:Q+"info_"+K+".js",readonly:!0, "text").addClass("field").val(otherhost.host?otherhost.host:P.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=$(this).closest("label").find("input").val();UI.navto("Embed",b)}))))).append(Za)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:Q+"json_"+L+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:Q+"info_"+L+".js",readonly:!0,
clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:Q+K+".html",readonly:!0,qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:Xa,rows:Xa.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."}, clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:Q+L+".html",readonly:!0,qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:Ya,rows:Ya.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},
$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},{label:"Prioritize type",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"prioritize_type"},classes:["prioritize_type"],"function":function(){if(ba){o.prioritize_type=$(this).getval();$(".embed_code").setval(y(o))}},help:"Try to use this source type first, but full back to something else if it is not available."}, $("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},{label:"Prioritize type",type:"select",select:[["","Automatic"]],pointer:{main:n,index:"prioritize_type"},classes:["prioritize_type"],"function":function(){if(ba){n.prioritize_type=$(this).getval();$(".embed_code").setval(z(n))}},help:"Try to use this source type first, but full back to something else if it is not available."},
{label:"Force type",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){if(ba){o.forceType=$(this).getval();$(".embed_code").setval(y(o))}},help:"Only use this particular source."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){if(ba){o.forcePlayer=$(this).getval();$(".embed_code").setval(y(o))}},help:"Only use this particular player."}, {label:"Force type",type:"select",select:[["","Automatic"]],pointer:{main:n,index:"forceType"},classes:["forceType"],"function":function(){if(ba){n.forceType=$(this).getval();$(".embed_code").setval(z(n))}},help:"Only use this particular source."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:n,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){if(ba){n.forcePlayer=$(this).getval();$(".embed_code").setval(z(n))}},help:"Only use this particular player."},
{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:ia,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(y(o))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval(); {label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:ia,index:"controls"},"function":function(){n.controls=$(this).getval()==1;switch($(this).getval()){case 0:n.controls=false;break;case 1:n.controls=true;break;case "stock":n.controls="stock"}$(".embed_code").setval(z(n))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:n,index:"autoplay"},"function":function(){n.autoplay=$(this).getval();
$(".embed_code").setval(y(o))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(y(o))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:o,index:"muted"},"function":function(){o.muted=$(this).getval();$(".embed_code").setval(y(o))},help:"If the video should restart when the end is reached."}, $(".embed_code").setval(z(n))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:n,index:"loop"},"function":function(){n.loop=$(this).getval();$(".embed_code").setval(z(n))},help:"If the video should restart when the end is reached."},{label:"Start muted",type:"checkbox",pointer:{main:n,index:"muted"},"function":function(){n.muted=$(this).getval();$(".embed_code").setval(z(n))},help:"If the video should restart when the end is reached."},
{label:"Fill available space",type:"checkbox",pointer:{main:o,index:"fillSpace"},"function":function(){o.fillSpace=$(this).getval();$(".embed_code").setval(y(o))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(y(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition", {label:"Fill available space",type:"checkbox",pointer:{main:n,index:"fillSpace"},"function":function(){n.fillSpace=$(this).getval();$(".embed_code").setval(z(n))},help:"The video will fit the available space in its container, even if the video stream has a smaller resolution."},{label:"Poster",type:"str",pointer:{main:n,index:"poster"},"function":function(){n.poster=$(this).getval();$(".embed_code").setval(z(n))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",
type:"str",pointer:{main:o,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){o.urlappend=$(this).getval();$(".embed_code").setval(y(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:T,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:o, type:"str",pointer:{main:n,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){n.urlappend=$(this).getval();$(".embed_code").setval(z(n))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:T,help:"Pre-select these tracks."},{label:"Monitoring action",type:"select",select:[["","Ask the viewer what to do"],["nextCombo","Try the next source / player combination"]],pointer:{main:n,
index:"monitor_action"},"function":function(){o.monitor_action=$(this).getval();$(".embed_code").setval(y(o))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),va]));$.ajax({type:"GET",url:Q+"json_"+K+".js",success:function(a){var b=[],c=Z.find(".field.forceType"),d=Z.find(".field.prioritize_type"),e;for(e in a.source){var f=a.source[e],g=UI.humanMime(f.type);b.push({label:g?g+" <span class=description>("+f.type+")</span>":UI.format.capital(f.type),type:"str", index:"monitor_action"},"function":function(){n.monitor_action=$(this).getval();$(".embed_code").setval(z(n))},help:"What the player should do when playback is poor."},$("<h3>").text("Protocol stream urls"),wa]));$.ajax({type:"GET",url:Q+"json_"+L+".js",success:function(a){var b=[],c=Z.find(".field.forceType"),d=Z.find(".field.prioritize_type"),f;for(f in a.source){var e=a.source[f],g=UI.humanMime(e.type);b.push({label:g?g+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",
value:f.url,readonly:true,qrcode:true,clipboard:true});g=UI.humanMime(f.type);if(c.children('option[value="'+f.type+'"]').length==0){c.append($("<option>").text(g?g+" ("+f.type+")":UI.format.capital(f.type)).val(f.type));d.append($("<option>").text(g?g+" ("+f.type+")":UI.format.capital(f.type)).val(f.type))}}c.val(o.forceType);d.val(o.prioritize_type);va.html(UI.buildUI(b));T.html("");b={};for(e in a.meta.tracks){c=a.meta.tracks[e];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!= value:e.url,readonly:true,qrcode:true,clipboard:true});g=UI.humanMime(e.type);if(c.children('option[value="'+e.type+'"]').length==0){c.append($("<option>").text(g?g+" ("+e.type+")":UI.format.capital(e.type)).val(e.type));d.append($("<option>").text(g?g+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}}c.val(n.forceType);d.val(n.prioritize_type);wa.html(UI.buildUI(b));T.html("");b={};for(f in a.meta.tracks){c=a.meta.tracks[f];if(c.codec=="subtitle")c.type="subtitle";if(!(c.type!="audio"&&c.type!=
"video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){T.closest("label").show();var a=["audio","video","subtitle"],h;for(h in a){e=a[h];if(b[e]&&b[e].length){c=$("<select>").attr("data-type",e).css("flex-grow","1").change(function(){$(this).val()==""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]= "video"&&c.type!="subtitle")){c.type in b||(b[c.type]=c.type=="subtitle"?[]:[["","Autoselect "+c.type]]);b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+(c.type=="subtitle"?1:0))])}}if(Object.keys(b).length){T.closest("label").show();var a=["audio","video","subtitle"],i;for(i in a){f=a[i];if(b[f]&&b[f].length){c=$("<select>").attr("data-type",f).css("flex-grow","1").change(function(){$(this).val()==""?delete n.setTracks[$(this).attr("data-type")]:n.setTracks[$(this).attr("data-type")]=
$(this).val();$(".embed_code").setval(y(o))});T.append(c);e=="subtitle"?b[e].unshift(["","No "+e]):b[e].push([-1,"No "+e]);for(var i in b[e])c.append($("<option>").val(b[e][i][0]).text(b[e][i][1]));if(e in o.setTracks){c.val(o.setTracks[e]);if(c.val()==null){c.val("");delete o.setTracks[e];$(".embed_code").setval(y(o))}}}}}else T.closest("label").hide();ba=true},error:function(){va.html("Error while retrieving stream info.");T.closest("label").hide();o.setTracks={}}});var ja=document.createElement("script"); $(this).val();$(".embed_code").setval(z(n))});T.append(c);f=="subtitle"?b[f].unshift(["","No "+f]):b[f].push([-1,"No "+f]);for(var h in b[f])c.append($("<option>").val(b[f][h][0]).text(b[f][h][1]));if(f in n.setTracks){c.val(n.setTracks[f]);if(c.val()==null){c.val("");delete n.setTracks[f];$(".embed_code").setval(z(n))}}}}}else T.closest("label").hide();ba=true},error:function(){wa.html("Error while retrieving stream info.");T.closest("label").hide();n.setTracks={}}});var ja=document.createElement("script");
ja.src=v.http+"player.js";document.head.appendChild(ja);ja.onload=function(){var a=Z.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};ja.onerror=function(){document.head.removeChild(this)};break;case "Push":var L=$("<div>").text("Loading..");c.append(L);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true, ja.src=v.http+"player.js";document.head.appendChild(ja);ja.onload=function(){var a=Z.find(".field.forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};ja.onerror=function(){document.head.removeChild(this)};break;case "Push":var M=$("<div>").text("Loading..");c.append(M);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,
f;for(f in c.push_list)if(a.indexOf(c.push_list[f][0])>-1){d=false;break}}else d=true;if(d)for(f in a)e.find("tr[data-pushid="+a[f]+"]").remove();else b()},{push_list:1})},1E3)}function c(f,g){var h=$("<span>"),i=$("<span>");if(g=="Automatic"&&f.length>=4){h.append($("<span>").text(f[2]));f[3]&&h.append($("<span>").text(", schedule on "+(new Date(f[3]*1E3)).toLocaleString()));f.length>=5&&f[4]&&h.append($("<span>").text(", complete on "+(new Date(f[4]*1E3)).toLocaleString()))}else f.length>=4&&f[2]!= e;for(e in c.push_list)if(a.indexOf(c.push_list[e][0])>-1){d=false;break}}else d=true;if(d)for(e in a)f.find("tr[data-pushid="+a[e]+"]").remove();else b()},{push_list:1})},1E3)}function c(e,g){var i=$("<span>"),h=$("<span>");if(g=="Automatic"&&e.length>=4){var j=function(a,b,c){a=""+("$"+a+" ");switch(Number(b)){case 0:a=a+"is true";break;case 1:a=a+"is false";break;case 2:a=a+("== "+c);break;case 3:a=a+("!= "+c);break;case 10:a=a+("> (numerical) "+c);break;case 11:a=a+(">= (numerical) "+c);break;
f[3]?h.append($("<span>").text(f[2])).append($("<span>").html("&#187").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(f[3])):h.append($("<span>").text(f[2]));var j=$("<td>").append($("<button>").text(g=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+f[1]+" to "+f[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(g=="Automatic"?"Removing..":"Stopping.."))); case 12:a=a+("< (numerical) "+c);break;case 13:a=a+("<= (numerical) "+c);break;case 20:a=a+("> (lexical) "+c);break;case 21:a=a+(">= (lexical) "+c);break;case 22:a=a+("< (lexical) "+c);break;case 23:a=a+("<= (lexical) "+c);break;default:a=a+"comparison operator unknown"}return a};i.append($("<span>").text(e[2]));e[3]&&i.append($("<span>").text(", schedule on "+(new Date(e[3]*1E3)).toLocaleString()));e.length>=5&&e[4]&&i.append($("<span>").text(", complete on "+(new Date(e[4]*1E3)).toLocaleString()));
if(g=="Automatic"){var c=f.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([f[0]])},{push_stop:[f[0]]})}}));if(g=="Automatic"){j.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));j.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+f[1]+" to "+f[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.": e.length>=8&&e[5]&&i.append($("<span>").text(", starts if "+j(e[5],e[6],e[7])));e.length>=11&&e[8]&&i.append($("<span>").text(", stops if "+j(e[8],e[9],e[10])))}else e.length>=4&&e[2]!=e[3]?i.append($("<span>").text(e[2])).append($("<span>").html("&#187").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(e[3])):i.append($("<span>").text(e[2]));j=$("<td>").append($("<button>").text(g=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+
""))){var c=$(this);c.text("Stopping pushes..");var g=[],h;for(h in a.push_list)if(f[1]==a.push_list[h][1]&&f[2]==a.push_list[h][2]){g.push(a.push_list[h][0]);e.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(g)},{push_stop:g,push_settings:{wait:0}})}}))}else{if(f.length>=6){var k=f[5];i.append($("<div>").append("Active for: "+UI.format.duration(k.active_seconds))).append($("<div>").append("Data transfered: "+ " this push?\n"+e[1]+" to "+e[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(g=="Automatic"?"Removing..":"Stopping..")));if(g=="Automatic"){var c=e.slice(1);mist.send(function(){a.remove()},{push_auto_remove:[c]})}else mist.send(function(){b([e[0]])},{push_stop:[e[0]]})}}));if(g=="Automatic"){j.prepend($("<button>").text("Edit").click(function(){UI.navto("Start Push","auto_"+($(this).closest("tr").index()-1))}));j.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+
UI.format.bytes(k.bytes))).append($("<div>").append("Media time transfered: "+UI.format.duration(k.mediatime*0.001)));"pkt_retrans_count"in k&&i.append($("<div>").append("Packets retransmitted: "+UI.format.number(k.pkt_retrans_count||0)));"pkt_loss_count"in k&&i.append($("<div>").append("Packets lost: "+UI.format.number(k.pkt_loss_count||0)+" ("+UI.format.addUnit(UI.format.number(k.pkt_loss_perc||0),"%")+" over the last "+UI.format.addUnit(5,"s")+")"))}if(f.length>=5)for(var l in f[4]){k=f[4][l]; e[1]+" to "+e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var c=$(this);c.text("Stopping pushes..");var g=[],i;for(i in a.push_list)if(e[1]==a.push_list[i][1]&&e[2]==a.push_list[i][2]){g.push(a.push_list[i][0]);f.find("tr[data-pushid="+a.push_list[i][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(g)},{push_stop:g,push_settings:{wait:0}})}}))}else{if(e.length>=6){var k=
i.append($("<div>").append(UI.format.time(k[0])+" ["+k[1]+"] "+k[2]))}}return $("<tr>").css("vertical-align","top").attr("data-pushid",f[0]).append($("<td>").text(f[1])).append($("<td>").append(h.children())).append($("<td>").addClass("logs").append(i.children())).append(j)}L.html(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."}]));var d=a.push_settings;d||(d={});var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>")).append($("<th>"))), e[5];h.append($("<div>").append("Active for: "+UI.format.duration(k.active_seconds))).append($("<div>").append("Data transfered: "+UI.format.bytes(k.bytes))).append($("<div>").append("Media time transfered: "+UI.format.duration(k.mediatime*0.001)));"pkt_retrans_count"in k&&h.append($("<div>").append("Packets retransmitted: "+UI.format.number(k.pkt_retrans_count||0)));"pkt_loss_count"in k&&h.append($("<div>").append("Packets lost: "+UI.format.number(k.pkt_loss_count||0)+" ("+UI.format.addUnit(UI.format.number(k.pkt_loss_perc||
f=e.clone();if("push_list"in a)for(var g in a.push_list)e.append(c(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list){var h=a.push_auto_list[g].slice();h.unshift(-1);f.append(c(h,"Automatic"))}L.append($("<h3>").text("Automatic pushes")).append(UI.buildUI([{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"}},{label:"Maximum retries", 0),"%")+" over the last "+UI.format.addUnit(5,"s")+")"))}if(e.length>=5)for(var m in e[4]){k=e[4][m];h.append($("<div>").append(UI.format.time(k[0])+" ["+k[1]+"] "+k[2]))}}return $("<tr>").css("vertical-align","top").attr("data-pushid",e[0]).append($("<td>").text(e[1])).append($("<td>").append(i.children())).append($("<td>").addClass("logs").append(h.children())).append(j)}M.html(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."}]));
unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"}},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}])).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));f.find("tr").length==1?L.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top", var d=a.push_settings;d||(d={});var f=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>")).append($("<th>"))),e=f.clone();if("push_list"in a)for(var g in a.push_list)f.append(c(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list){var i=a.push_auto_list[g].slice();i.unshift(-1);e.append(c(i,"Automatic"))}M.append($("<h3>").text("Automatic push settings")).append(UI.buildUI([{label:"Delay before retry",unit:"s",type:"int",
"0.5em")):L.append(f);L.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)L.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var f=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(g in a.push_list){f.indexOf(a.push_list[g][1])== min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":3,pointer:{main:d,index:"wait"}},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"}},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}])).append($("<h3>").text("Automatic push settings")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push",
-1&&f.push(a.push_list[g][1]);h.indexOf(a.push_list[g][2])==-1&&h.push(a.push_list[g][2])}f.sort();h.sort();for(g in f)i.append($("<option>").text(f[g]));for(g in h)j.append($("<option>").text(h[g]));L.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},{push_stop:c});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping.."))); "auto")}));e.find("tr").length==1?M.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):M.append(e);M.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(f.find("tr").length==1)M.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var e=[],i=[],h=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),
$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var f={},g;for(g in a.push_list)if((c==""|| j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(g in a.push_list){e.indexOf(a.push_list[g][1])==-1&&e.push(a.push_list[g][1]);i.indexOf(a.push_list[g][2])==-1&&i.push(a.push_list[g][2])}e.sort();i.sort();for(g in e)h.append($("<option>").text(e[g]));for(g in i)j.append($("<option>").text(i[g]));M.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},
a.push_list[g][1]==c)&&(d==""||a.push_list[g][2]==d))f[a.push_list[g][0]]=a.push_list[g];if(Object.keys(f).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(g in f)c=c+(f[g][1]+" to "+f[g][2]+"\n");if(confirm(c)){f=Object.keys(f);mist.send(function(){b(f)},{push_stop:f});for(g in f)e.find("tr[data-pushid="+f[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}UI.interval.set(function(){mist.send(function(a){var b= {push_stop:c});f.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(h).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=h.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");
e.find("tr").first();e.empty();e.append(b);for(var d in a.push_list)e.append(c(a.push_list[d]))},{push_list:1})},5E3)},{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1});return}var x,ka=function(a){var d=false,f=b.split("_");b=f[0];f.length==2&&(d=f[1]);if(d!==false&&typeof a=="undefined")mist.send(function(a){ka(a.push_auto_list[d])},{push_auto_list:1}); var e={},g;for(g in a.push_list)if((c==""||a.push_list[g][1]==c)&&(d==""||a.push_list[g][2]==d))e[a.push_list[g][0]]=a.push_list[g];if(Object.keys(e).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(g in e)c=c+(e[g][1]+" to "+e[g][2]+"\n");if(confirm(c)){e=Object.keys(e);mist.send(function(){b(e)},{push_stop:e});for(g in e)f.find("tr[data-pushid="+e[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(f)}UI.interval.set(function(){mist.send(function(a){var b=
else{var e=[],g={},h;for(h in mist.data.capabilities.connectors){f=mist.data.capabilities.connectors[h];if("push_urls"in f){e=e.concat(f.push_urls);g[h]=f.push_urls}}b=="auto"&&c.find("h2").text("Add automatic push");var i={params:{}};if(b=="auto"&&typeof a!="undefined"){i={stream:a[0],target:a[1],params:{}};f=i.target.split("?");if(f.length>1){params=f.pop();i.target=f.join("?");params=params.split("&");for(h in params){f=params[h].split("=");i.params[f.shift()]=f.join("=")}}}var j=$("<div>").css("margin", f.find("tr").first();f.empty();f.append(b);for(var d in a.push_list)f.append(c(a.push_list[d]))},{push_list:1})},5E3)},{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)||!("variable_list"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1,variable_list:!0});return}var y,ka=function(a){var d=false,e=b.split("_");b=e[0];e.length==2&&(d=e[1]);if(d!==false&&typeof a=="undefined")mist.send(function(a){ka(a.push_auto_list[d])},
"1em 0");h=[{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use: <ul> <li><i>a</i>: the stream configured as <i>a</i></li> <li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li> <li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li> </ul>", {push_auto_list:1});else{var f=[],g={},i;for(i in mist.data.capabilities.connectors){e=mist.data.capabilities.connectors[i];if("push_urls"in e){f=f.concat(e.push_urls);g[i]=e.push_urls}}b=="auto"&&c.find("h2").text("Add automatic push");var h={params:{}},j=[];if(b=="auto"&&typeof a!="undefined"){h={stream:a[0],target:a[1],params:{}};e=h.target.split("?");if(e.length>1){j=e.pop();h.target=e.join("?");j=j.split("&");for(i in j){e=j[i].split("=");h.params[e.shift()]=e.join("=")}}if(a.length>=3)h.scheduletime=
pointer:{main:i,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["orange"],"break":false}}],datalist:x},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid formats: <ul> <li>"+e.join("</li><li>")+"</li> </ul> Valid text replacements: <ul> <li>$stream - inserts the stream name used to push to MistServer</li> <li>$day - inserts the current day number</li><li>$month - inserts the current month number</li> <li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li> <li>$minute - inserts the minute timestamp the stream was received</li> <li>$seconds - inserts the seconds timestamp when the stream was received</li> <li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li> </ul> Valid URL parameters: <ul> <li>recstart=123 - media timestamp in milisseconds where the push should start</li> <li>recstop=456 - media timestamp in miliseconds where the push should stop</li> <li>recstartunix=150000000 - unix time in seconds where the push should start. This will override the recstart parameter.</li> <li>recstopunix=150000000 - unix time in seconds where the push should stop. This will override the recstop parameter.</li> </ul>", a[2]!=0?a[2]:null;if(a.length>=4)h.completetime=a[3]!=0?a[3]:null;if(a.length>=5)h.startVariableName=a[4]!=""?a[4]:null;if(a.length>=6)h.startVariableOperator=a[5]!=""?a[5]:null;if(a.length>=7)h.startVariableValue=a[6]!=""?a[6]:null;if(a.length>=8)h.endVariableName=a[7]!=""?a[7]:null;if(a.length>=9)h.endVariableOperator=a[8]!=""?a[8]:null;if(a.length>=10)h.endVariableValue=a[9]!=""?a[9]:null}var k=$("<div>").css("margin","1em 0"),m=$("<div>"),l;if(b=="auto"){m.css("margin","1em 0").html(UI.buildUI([{label:"This push should be active",
pointer:{main:i,index:"target"},validate:["required",function(a){for(var b in e)if(mist.inputMatch(e[b],a))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+e.join("</li><li>")+"</li></ul>",classes:["red"]}}],"function":function(){var a=false;for(connector in g)for(var b in g[connector])if(mist.inputMatch(g[connector][b],$(this).getval())){a=connector;break}if(a){j.html($("<h3>").text(mist.data.capabilities.connectors[a].friendly));j.append(UI.buildUI(mist.convertBuildOptions({desc:mist.data.capabilities.connectors[a].desc, help:"When 'based on server time' is selected, a start and/or end timestamp can be configured. When it's 'based on a variable', the push will be activated while the specified variable matches the specified value.",type:"select",select:[["time","Based on server time"],["variable","Based on a variable"]],value:h.startVariableName||h.endVariableName?"variable":"time",classes:["activewhen"],"function":function(){var a=m.find(".varbased").closest(".UIelement"),b=m.find(".timebased").closest(".UIelement");
optional:mist.data.capabilities.connectors[a].push_parameters},i.params)))}else j.html($("<h4>").addClass("red").text("Unrecognized target.")).append($("<span>").text("Please edit the push target."))}},j];h.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var c=i.params,d;for(d in c)c[d]===null&&delete c[d];if(Object.keys(c).length){var f="?",e=i.target.split("?");if(e.length>1){f="&";e=e[e.length- if($(this).getval()=="time"){a.hide();b.css("display","")}else{b.hide();a.css("display","");m.find('[name="startVariableOperator"]').trigger("change");m.find('[name="endVariableOperator"]').trigger("change")}}},$("<br>"),$("<span>").addClass("UIelement").append($("<h3>").text("Start the push").addClass("varbased")),{classes:["varbased"],label:"Use this variable",type:"str",help:"This variable should be used to determine if this push should be started.",prefix:"$",datalist:Object.keys(mist.data.variable_list||
1];e=e.split("&");for(d in e){var g=e[d].split("=")[0];g in c&&delete c[g]}}if(Object.keys(c).length){e=[];for(d in c)e.push(d+"="+c[d]);f=f+e.join("&");i.target=i.target+f}}c={};c[b=="auto"?"push_auto_add":"push_start"]=i;if(typeof a!="undefined"&&(a[0]!=i.stream||a[1]!=i.target))c.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},c)}}]});c.append(UI.buildUI(h))}};mist.data.LTS?mist.send(function(a){(x=a.active_streams)||(x=[]);var a=[],b;for(b in x)x[b].indexOf("+")!=-1&&a.push(x[b].replace(/\+.*/, []),pointer:{main:h,index:"startVariableName"}},{classes:["varbased"],label:"Comparison operator",type:"select",select:[[0,"is true"],[1,"is false"],[2,"=="],[3,"!="],[10,"> (numerical)"],[11,">= (numerical)"],[12,"< (numerical)"],[13,"<= (numerical)"],[20,"> (lexical)"],[21,">= (lexical)"],[22,"< (lexical)"],[23,"<= (lexical)"]],value:2,css:{display:"none"},help:"How would you like to compare this variable?",pointer:{main:h,index:"startVariableOperator"},"function":function(){var a=m.find('[name="startVariableValue"]').closest(".UIelement");
"")+"+");x=x.concat(a);var c=0,d=0;for(b in mist.data.streams){x.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){x.push(b+"+");mist.send(function(a,b){var f=b.stream,e;for(e in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||(g.indexOf("Folder")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&x.push(f+"+"+a.browse.files[e]); Number($(this).getval())<2?a.hide():a.css("display","")}},{classes:["varbased"],label:"Variable value",type:"str",help:"The variable will be compared with this value to determine if this push should be started.<br>You can also enter another variable here!",datalist:Object.values(mist.data.variable_list||[]).map(function(a){return typeof a=="string"?a:a[3]}).concat(Object.keys(mist.data.variable_list||[]).map(function(a){return"$"+a})),pointer:{main:h,index:"startVariableValue"}},$("<span>").addClass("UIelement").append($("<h3>").text("Stop the push").addClass("varbased")),
d++;if(c==d){x=x.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ka()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){x=x.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ka()}},{active_streams:1}):(x=Object.keys(mist.data.streams),ka());break;case "Triggers":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};var E=$("<tbody>"),Za=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type", {classes:["varbased"],label:"Use this variable",type:"str",help:"This variable should be used to determine if this push should be stopped.<br>You can leave this field blank if you do not want to have a stop condition. (You can always stop the push manually)",prefix:"$",datalist:Object.keys(mist.data.variable_list||[]),pointer:{main:h,index:"endVariableName"}},{classes:["varbased"],label:"Comparison operator",type:"select",select:[[0,"is true"],[1,"is false"],[2,"=="],[3,"!="],[10,"> (numerical)"],
"string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(E);c.append(UI.buildUI([{type:"help",help:"Triggers are a way to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(Za); [11,">= (numerical)"],[12,"< (numerical)"],[13,"<= (numerical)"],[20,"> (lexical)"],[21,">= (lexical)"],[22,"< (lexical)"],[23,"<= (lexical)"]],value:2,help:"How would you like to compare this variable?",pointer:{main:h,index:"endVariableOperator"},"function":function(){var a=m.find('[name="endVariableValue"]').closest(".UIelement");Number($(this).getval())<2?a.hide():a.css("display","")}},{classes:["varbased"],label:"Variable value",type:"str",help:"The variable will be compared with this value to determine if this push should be stopped.<br>You can also enter another variable here!",
Za.stupidtable();var wa=mist.data.config.triggers;for(r in wa)for(var $a in wa[r]){var xa=triggerRewrite(wa[r][$a]);E.append($("<tr>").attr("data-index",r+","+$a).append($("<td>").text(r)).append($("<td>").text("streams"in xa?xa.streams.join(", "):"")).append($("<td>").text(xa.handler)).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(","); datalist:Object.values(mist.data.variable_list||[]).map(function(a){return typeof a=="string"?a:a[3]}).concat(Object.keys(mist.data.variable_list||[]).map(function(a){return"$"+a})),pointer:{main:h,index:"endVariableValue"}},{classes:["timebased"],type:"unix",label:"Start time",min:0,help:"The time where the push will become active. The default is to start immediately.",pointer:{main:h,index:"scheduletime"}},{classes:["timebased"],type:"unix",label:"End time",min:0,help:"The time where the push will stop. Defaults to never stop automatically.<br>Only makes sense for live streams.",
if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))))}break;case "Edit Trigger":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading.."); pointer:{main:h,index:"completetime"}}],h));m.find(".activewhen").trigger("change")}i=[{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use: <ul> <li><i>a</i>: the stream configured as <i>a</i></li> <li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li> <li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li> </ul>",
return}if(b)var b=b.split(","),ca=triggerRewrite(mist.data.config.triggers[b[0]][b[1]]),p={triggeron:b[0],appliesto:ca.streams,url:ca.handler,async:ca.sync,"default":ca["default"],params:ca.params};else c.html($("<h2>").text("New Trigger")),p={};var ab=[];for(r in mist.data.capabilities.triggers)ab.push([r,r+": "+mist.data.capabilities.triggers[r].when]);var ya=$("<div>").addClass("desc"),bb=$("<div>");c.append(UI.buildUI([{label:"Trigger on",pointer:{main:p,index:"triggeron"},help:"For what event this trigger should activate.", pointer:{main:h,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["orange"],"break":false}}],datalist:y},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br> Valid formats: <ul> <li>"+f.join("</li><li>")+"</li> </ul> Valid text replacements: <ul> <li>$stream - inserts the stream name used to push to MistServer</li> <li>$day - inserts the current day number</li><li>$month - inserts the current month number</li> <li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li> <li>$minute - inserts the minute timestamp the stream was received</li> <li>$seconds - inserts the seconds timestamp when the stream was received</li> <li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li> </ul>",
type:"select",select:ab,validate:["required"],"function":function(){var a=$(this).getval(),b=mist.data.capabilities.triggers[a];ya.html("");if(b){a=[$("<h4>").text("Trigger properties"),{type:"help",help:'The trigger "<i>'+a+'</i>" has the following properties:'},{type:"span",label:"Triggers",value:b.when,help:"When this trigger is activated"}];b.payload!=""&&a.push({label:"Payload",type:"textarea",value:b.payload,rows:b.payload.split("\n").length,readonly:true,clipboard:true,help:"The information this trigger sends to the handler."}); pointer:{main:h,index:"target"},validate:["required",function(a){for(var b in f)if(mist.inputMatch(f[b],a))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+f.join("</li><li>")+"</li></ul>",classes:["red"]}}],"function":function(){var a=false,b=$(this).getval();for(connector in g)for(var c in g[connector])if(mist.inputMatch(g[connector][c],b)){a=connector;break}if(a){k.html($("<h3>").text(mist.data.capabilities.connectors[a].friendly));l={};for(c in mist.data.capabilities.connectors[a].push_parameters){var d=
mist.data.capabilities.connectors[a].push_parameters[c];if(!d.prot_only||!(String().match&&b.match(/.+\:\/\/.+/)===null))d.file_only&&b[0]!="/"||(l[c]=d)}a=mist.convertBuildOptions({desc:mist.data.capabilities.connectors[a].desc,optional:l,sort:"sort"},h.params);b=[];for(c in j){var d=j[c].split("="),e=d[0];e in l||b.push(e+(d.length>1?"="+d.slice(1).join("="):""))}a.push($("<br>"));a.push({type:"inputlist",label:"Custom url parameters",value:b,classes:["custom_url_parameters"],input:{type:"str",
placeholder:"name=value",prefix:""},help:"Any custom url parameters not covered by the parameters configurable above.",pointer:{main:h,index:"custom_url_params"}});k.append(UI.buildUI(a))}else k.html($("<h4>").addClass("red").text("Unrecognized target.")).append($("<span>").text("Please edit the push target."))}},m,k];i.push({type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save",preSave:function(){delete h.startVariableName;delete h.startVariableOperator;
delete h.startVariableValue;delete h.endVariableName;delete h.endVariableOperator;delete h.endVariableValue;delete h.completetime;delete h.scheduletime},"function":function(){var c=h.params,d;for(d in c)c[d]===null?delete c[d]:d in l||delete c[d];if(h.startVariableName||h.endVariableName){h.scheduletime=0;h.completetime=0}if(h.startVariableName===null){delete h.startVariableName;delete h.startVariableOperator;delete h.startVariableValue}if(h.endVariableName===null){delete h.endVariableName;delete h.endVariableOperator;
delete h.endVariableValue}if(h.scheduletime)c.recstartunix=h.scheduletime;if(Object.keys(c).length||h.custom_url_params&&h.custom_url_params.length){var e="?",f=h.target.split("?");if(f.length>1){e="&";f=f[f.length-1];f=f.split("&");for(d in f){var g=f[d].split("=")[0];g in c&&delete c[g]}}if(Object.keys(c).length||h.custom_url_params&&h.custom_url_params.length){f=[];for(d in c)f.push(d+"="+c[d]);for(d in h.custom_url_params)f.push(h.custom_url_params[d]);e=e+f.join("&");h.target=h.target+e}}delete h.params;
delete h.custom_url_params;c={};c[b=="auto"?"push_auto_add":"push_start"]=h;if(typeof a!="undefined"&&(a[0]!=h.stream||a[1]!=h.target))c.push_auto_remove=[a];mist.send(function(){UI.navto("Push")},c)}}]});c.append(UI.buildUI(i))}};mist.data.LTS?mist.send(function(a){(y=a.active_streams)||(y=[]);var a=[],b;for(b in y)y[b].indexOf("+")!=-1&&a.push(y[b].replace(/\+.*/,"")+"+");y=y.concat(a);var c=0,d=0;for(b in mist.data.streams){y.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){y.push(b+
"+");mist.send(function(a,b){var e=b.stream,f;for(f in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||(g.indexOf("Folder")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder.exe")>=0)||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[f])&&y.push(e+"+"+a.browse.files[f]);d++;if(c==d){y=y.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ka()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){y=y.filter(function(a,
b,c){return c.lastIndexOf(a)===b}).sort();ka()}},{active_streams:1}):(y=Object.keys(mist.data.streams),ka());break;case "Triggers":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};var F=$("<tbody>"),$a=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type",
"string")).append($("<th>")))).append(F);c.append(UI.buildUI([{type:"help",help:"Triggers are a way to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append($a);$a.stupidtable();var xa=mist.data.config.triggers;
for(q in xa)for(var ab in xa[q]){var ya=triggerRewrite(xa[q][ab]);F.append($("<tr>").attr("data-index",q+","+ab).append($("<td>").text(q)).append($("<td>").text("streams"in ya?ya.streams.join(", "):"")).append($("<td>").text(ya.handler)).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");if(confirm("Are you sure you want to delete this "+
a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))))}break;case "Edit Trigger":if(!("triggers"in mist.data.config)||!mist.data.config.triggers)mist.data.config.triggers={};if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}if(b)var b=b.split(","),ca=
triggerRewrite(mist.data.config.triggers[b[0]][b[1]]),p={triggeron:b[0],appliesto:ca.streams,url:ca.handler,async:ca.sync,"default":ca["default"],params:ca.params};else c.html($("<h2>").text("New Trigger")),p={};var bb=[];for(q in mist.data.capabilities.triggers)bb.push([q,q+": "+mist.data.capabilities.triggers[q].when]);var za=$("<div>").addClass("desc"),cb=$("<div>");c.append(UI.buildUI([{label:"Trigger on",pointer:{main:p,index:"triggeron"},help:"For what event this trigger should activate.",type:"select",
select:bb,validate:["required"],"function":function(){var a=$(this).getval(),b=mist.data.capabilities.triggers[a];za.html("");if(b){a=[$("<h4>").text("Trigger properties"),{type:"help",help:'The trigger "<i>'+a+'</i>" has the following properties:'},{type:"span",label:"Triggers",value:b.when,help:"When this trigger is activated"}];b.payload!=""&&a.push({label:"Payload",type:"textarea",value:b.payload,rows:b.payload.split("\n").length,readonly:true,clipboard:true,help:"The information this trigger sends to the handler."});
a.push({type:"span",label:"Requires response",value:function(a){switch(a){case "ignored":return"No. The trigger will ignore the response of the handler.";case "always":return"Yes. The trigger needs a response to proceed.";case "when-blocking":return"The trigger needs a response to proceed if it is configured to be blocking.";default:return a}}(b.response),help:"Whether this trigger requires a response from the trigger handler"});a.push({type:"span",label:"Response action",value:b.response_action, a.push({type:"span",label:"Requires response",value:function(a){switch(a){case "ignored":return"No. The trigger will ignore the response of the handler.";case "always":return"Yes. The trigger needs a response to proceed.";case "when-blocking":return"The trigger needs a response to proceed if it is configured to be blocking.";default:return a}}(b.response),help:"Whether this trigger requires a response from the trigger handler"});a.push({type:"span",label:"Response action",value:b.response_action,
help:"What this trigger will do with its handler's response"});ya.append(UI.buildUI(a));b.stream_specific?$("[name=appliesto]").closest(".UIelement").show():$("[name=appliesto]").setval([]).closest(".UIelement").hide();if(b.argument){$("[name=params]").closest(".UIelement").show();bb.text(b.argument)}else $("[name=params]").setval("").closest(".UIelement").hide()}}},ya,$("<h4>").text("Trigger settings"),{label:"Applies to",pointer:{main:p,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)", help:"What this trigger will do with its handler's response"});za.append(UI.buildUI(a));b.stream_specific?$("[name=appliesto]").closest(".UIelement").show():$("[name=appliesto]").setval([]).closest(".UIelement").hide();if(b.argument){$("[name=params]").closest(".UIelement").show();cb.text(b.argument)}else $("[name=params]").setval("").closest(".UIelement").hide()}}},za,$("<h4>").text("Trigger settings"),{label:"Applies to",pointer:{main:p,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",
type:"checklist",checklist:Object.keys(mist.data.streams)},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:p,index:"url"},validate:["required"],type:"str"},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.", type:"checklist",checklist:Object.keys(mist.data.streams)},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:p,index:"url"},validate:["required"],type:"str"},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.",
pointer:{main:p,index:"async"}},{label:"Parameters",type:"str",help:$("<div>").text("The extra data you want this trigger to use.").append(bb),pointer:{main:p,index:"params"}},{label:"Default response",type:"str",help:"The default response in case the handler fails or is set to non-blocking.",placeholder:"true",pointer:{main:p,index:"default"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){b&&mist.data.config.triggers[b[0]].splice(b[1], pointer:{main:p,index:"async"}},{label:"Parameters",type:"str",help:$("<div>").text("The extra data you want this trigger to use.").append(cb),pointer:{main:p,index:"params"}},{label:"Default response",type:"str",help:"The default response in case the handler fails or is set to non-blocking.",placeholder:"true",pointer:{main:p,index:"default"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){b&&mist.data.config.triggers[b[0]].splice(b[1],
1);var a={handler:p.url,sync:p.async?true:false,streams:typeof p.appliesto=="undefined"?[]:p.appliesto,params:p.params,"default":p["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};p.triggeron in mist.data.config.triggers||(mist.data.config.triggers[p.triggeron]=[]);mist.data.config.triggers[p.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var cb=$("<button>").text("Refresh now").click(function(){$(this).text("Loading.."); 1);var a={handler:p.url,sync:p.async?true:false,streams:typeof p.appliesto=="undefined"?[]:p.appliesto,params:p.params,"default":p["default"]};if(!("triggers"in mist.data.config))mist.data.config.triggers={};p.triggeron in mist.data.config.triggers||(mist.data.config.triggers[p.triggeron]=[]);mist.data.config.triggers[p.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var db=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");
mist.send(function(){za();cb.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){za()})}, mist.send(function(){Aa();db.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){Aa()})},
$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:cb,help:"Instantly refresh the table below."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));E=$("<tbody>").css("font-size","0.9em");c.append($("<table>").addClass("logs").append(E));var gb=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b}, $(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:db,help:"Instantly refresh the table below."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));F=$("<tbody>").css("font-size","0.9em");c.append($("<table>").addClass("logs").append(F));var hb=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},
za=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();E.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),f;for(f in d)c.append($("<span>").text(d[f]));E.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(gb(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};za();break;case "Statistics":var G=$("<span>").text("Loading.."); Aa=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();F.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),e;for(e in d)c.append($("<span>").text(d[e]));F.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(hb(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};Aa();break;case "Statistics":var H=$("<span>").text("Loading..");
c.append(G);var p={graph:"new"},z=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},da={};for(r in mist.data.streams)da[r]=!0;for(r in mist.data.active_streams)da[mist.data.active_streams[r]]=!0;var da=Object.keys(da).sort(),Aa=[];for(r in mist.data.config.protocols)Aa.push(mist.data.config.protocols[r].connector);Aa.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+ c.append(H);var p={graph:"new"},A=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},da={};for(q in mist.data.streams)da[q]=!0;for(q in mist.data.active_streams)da[mist.data.active_streams[q]]=!0;var da=Object.keys(da).sort(),Ba=[];for(q in mist.data.config.protocols)Ba.push(mist.data.config.protocols[q].connector);Ba.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+
mist.data.capabilities.cpu[a].cores;G.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:p,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=G.find(".graph_xaxis"),b=G.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled", mist.data.capabilities.cpu[a].cores;H.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:p,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=H.find(".graph_xaxis"),b=H.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",
false);b.setval("Graph "+(Object.keys(z).length+1)).closest("label").show()}else{var c=z[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:p,index:"id"},classes:["graph_id"],validate:[function(a){return a in z?{msg:"This graph id has already been used. Please enter something else.", false);b.setval("Graph "+(Object.keys(A).length+1)).closest("label").show()}else{var c=A[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:p,index:"id"},classes:["graph_id"],validate:[function(a){return a in A?{msg:"This graph id has already been used. Please enter something else.",
classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:p,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=G.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()+ classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:p,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=H.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+
'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"],["perc_lost","Lost packages"],["perc_retrans","Re-transmitted packages"]],pointer:{main:p,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=G.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled", '"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"],["perc_lost","Lost packages"],["perc_retrans","Re-transmitted packages"]],pointer:{main:p,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=H.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",
true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",da],["protocol","The protocol:",Aa]],pointer:{main:p,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(p.graph=="new"){a=UI.plot.addGraph(p,b);z[a.id]=a;G.find("input.graph_id").val(""); true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",da],["protocol","The protocol:",Ba]],pointer:{main:p,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(p.graph=="new"){a=UI.plot.addGraph(p,b);A[a.id]=a;H.find("input.graph_id").val("");
G.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=z[p.graph];var c=UI.plot.datatype.getOptions({datatype:p.datatype,origin:p.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(z)}}]}]));var b=$("<div>").addClass("graph_container");c.append(b);var d=G.find("select.graph_ids");for(a in z){var f=UI.plot.addGraph(z[a],b);d.append($("<option>").text(f.id)).val(f.id);var e=[],g;for(g in z[a].datasets){var h=UI.plot.datatype.getOptions({datatype:z[a].datasets[g].datatype, H.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=A[p.graph];var c=UI.plot.datatype.getOptions({datatype:p.datatype,origin:p.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(A)}}]}]));var b=$("<div>").addClass("graph_container");c.append(b);var d=H.find("select.graph_ids");for(a in A){var e=UI.plot.addGraph(A[a],b);d.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in A[a].datasets){var h=UI.plot.datatype.getOptions({datatype:A[a].datasets[g].datatype,
origin:z[a].datasets[g].origin});e.push(h)}f.datasets=e;z[f.id]=f}d.trigger("change");UI.plot.go(z);UI.interval.set(function(){UI.plot.go(z)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var Ba=$("<table>"),N=$("<table>"),db={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(r in mist.data.capabilities.cpu){var la= origin:A[a].datasets[g].origin});f.push(h)}e.datasets=f;A[e.id]=e}d.trigger("change");UI.plot.go(A);UI.interval.set(function(){UI.plot.go(A)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var Ca=$("<table>"),N=$("<table>"),eb={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(q in mist.data.capabilities.cpu){var la=
mist.data.capabilities.cpu[r];db.content.push({header:"CPU #"+(Number(r)+1),body:[la.model,UI.format.addUnit(UI.format.number(la.mhz),"MHz"),la.cores,la.threads]})}var hb=UI.buildVheaderTable(db),eb=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* mist.data.capabilities.cpu[q];eb.content.push({header:"CPU #"+(Number(q)+1),body:[la.model,UI.format.addUnit(UI.format.number(la.mhz),"MHz"),la.cores,la.threads]})}var ib=UI.buildVheaderTable(eb),fb=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);Ba.replaceWith(a);Ba=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:"&nbsp;",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/ 1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);Ca.replaceWith(a);Ca=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:"&nbsp;",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/
100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);N.replaceWith(b);N=b};eb();c.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(Ba)).append($("<td>").append(N))).append($("<tr>").append($("<td>").append(hb).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){eb()}, 100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);N.replaceWith(b);N=b};fb();c.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(Ca)).append($("<td>").append(N))).append($("<tr>").append($("<td>").append(ib).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){fb()},
{capabilities:true})},3E4);break;case "Email for Help":var H=$.extend({},mist.data);delete H.statistics;delete H.totals;delete H.clients;delete H.capabilities;H=JSON.stringify(H);H="Version: "+mist.data.config.version+"\n\nConfig:\n"+H;p={};c.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:p, {capabilities:true})},3E4);break;case "Email for Help":var 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;p={};c.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:p,
index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:p,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:p,index:"subject"}},{type:"hidden",value:"-",pointer:{main:p,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:p,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:H,pointer:{main:p,index:"configfile"}},{type:"buttons",buttons:[{type:"save", index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:p,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:p,index:"subject"}},{type:"hidden",value:"-",pointer:{main:p,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:p,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:I,pointer:{main:p,index:"configfile"}},{type:"buttons",buttons:[{type:"save",
label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"https://mistserver.org/contact?skin=plain",data:p,success:function(a){a=$("<span>").html(a);a.find("script").remove();c.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:c.append($("<p>").text("This tab does not exist."))}c.find(".field").filter(function(){var a=$(this).getval(); label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"https://mistserver.org/contact?skin=plain",data:p,success:function(a){a=$("<span>").html(a);a.find("script").remove();c.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:c.append($("<p>").text("This tab does not exist."))}c.find(".field").filter(function(){var a=$(this).getval();
return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api"; return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api";
var mist={data:{},user:{name:"",password:"",host:host},send:function(a,b,c){var b=b||{},c=c||{},c=$.extend(true,{timeOut:3E4,sendData:b},c),d={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,d,b);log("Send",$.extend(true,{},b));var e={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:true,timeout:c.timeout*1E3,async:true,error:function(d,e,l){console.warn("connection failed :(", var mist={data:{},user:{name:"",password:"",host:host},send:function(a,b,c){var b=b||{},c=c||{},c=$.extend(true,{timeOut:3E4,sendData:b},c),d={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,d,b);log("Send",$.extend(true,{},b));var f={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:true,timeout:c.timeout*1E3,async:true,error:function(d,e,f){console.warn("connection failed :(",
l);delete mist.user.loggedin;if(!c.hide){switch(e){case "timeout":e=$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append($("<span>").text(e)).append($("<a>").text("Send server request again").click(function(){mist.send(a,b,c)}))}UI.navto("Login")}, f);delete mist.user.loggedin;if(!c.hide){switch(e){case "timeout":e=$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append($("<span>").text(e)).append($("<a>").text("Send server request again").click(function(){mist.send(a,b,c)}))}UI.navto("Login")},
success:function(e){log("Receive",$.extend(true,{},e),"as reply to",c.sendData);delete mist.user.loggedin;switch(e.authorize.status){case "OK":if("streams"in e)if(e.streams)if("incomplete list"in e.streams){delete e.streams["incomplete list"];$.extend(mist.data.streams,e.streams)}else mist.data.streams=e.streams;else mist.data.streams={};var h=$.extend({},e),l=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth"],m;for(m in h)l.indexOf(m)==-1&&delete h[m]; success:function(f){log("Receive",$.extend(true,{},f),"as reply to",c.sendData);delete mist.user.loggedin;switch(f.authorize.status){case "OK":if("streams"in f)if(f.streams)if("incomplete list"in f.streams){delete f.streams["incomplete list"];$.extend(mist.data.streams,f.streams)}else mist.data.streams=f.streams;else mist.data.streams={};var e=$.extend({},f),l=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth","variable_list"],o;for(o in e)l.indexOf(o)==
if("bandwidth"in d&&!("bandwidth"in e))h.bandwidth=null;$.extend(mist.data,h);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));if(e.log){h=e.log[e.log.length-1];UI.elements.connection.msg.append($("<br>")).append($("<span>").text("Last log entry: "+ -1&&delete e[o];if("bandwidth"in d&&!("bandwidth"in f))e.bandwidth=null;$.extend(mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));if(f.log){e=f.log[f.log.length-1];UI.elements.connection.msg.append($("<br>")).append($("<span>").text("Last log entry: "+
UI.format.time(h[0])+" ["+h[1]+"] "+h[2]))}if("totals"in e){h=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([m,0])};var e={},h;for(h in c.fields)e[c.fields[h]]=[];var l=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(h in c.data){if(h==0){m=c.start*1E3;var n=0}else{m=m+c.interval[n][1]*1E3;c.interval[n][0]--;if(c.interval[n][0]<=0){n++;n<c.interval.length-1&&(l=l+2)}}if(l%2==1){d();l--}for(var t in c.data[h])e[c.fields[t]].push([m, UI.format.time(e[0])+" ["+e[1]+"] "+e[2]))}if("totals"in f){e=function(a,b,c){var d;d=function(){for(var a in c.fields)f[c.fields[a]].push([m,0])};var f={},e;for(e in c.fields)f[c.fields[e]]=[];var l=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(e in c.data){if(e==0){m=c.start*1E3;var o=0}else{m=m+c.interval[o][1]*1E3;c.interval[o][0]--;if(c.interval[o][0]<=0){o++;o<c.interval.length-1&&(l=l+2)}}if(l%2==1){d();l--}for(var t in c.data[e])f[c.fields[t]].push([m,
c.data[h][t]]);if(l){d();l--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in e.totals)h(b.totals.streams, c.data[e][t]]);if(l){d();l--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(mist.data.config.time-15)*1E3;d()}d=f;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in f.totals)e(b.totals.streams,
b.totals.protocols,e.totals);else for(m in e.totals)h(b.totals[m].streams,b.totals[m].protocols,e.totals[m])}a&&a(e,c);break;case "CHALL":if(e.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=e.authorize.challenge;mist.send(a,b,c);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host, b.totals.protocols,f.totals);else for(o in f.totals)e(b.totals[o].streams,b.totals[o].protocols,f.totals[o])}a&&a(f,c);break;case "CHALL":if(f.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=f.authorize.challenge;mist.send(a,b,c);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,
name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete b.authorize;mist.send(a,b,c);break;default:UI.navto("Login")}}};c.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){l.abort()}));var l=$.ajax(e)},inputMatch:function(a,b){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var c in a){var d= name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete b.authorize;mist.send(a,b,c);break;default:UI.navto("Login")}}};c.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){l.abort()}));var l=$.ajax(f)},inputMatch:function(a,b){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var c in a){var d=
a[c].replace(/[^\w\s]/g,"\\$&"),d=d.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+d+"(?:\\?[^\\?]*)?$","i").test(b))return true}return false},convertBuildOptions:function(a,b){function c(a,c,d){var g={label:UI.format.capital(d.name?d.name:c),pointer:{main:b,index:c},validate:[]};e[a]=="required"&&(!("default"in d)||d["default"]=="")&&g.validate.push("required");if("default"in d){g.placeholder=d["default"];if(d.type=="select")for(var h in d.select)if(d.select[h][0]==d["default"]){g.placeholder= a[c].replace(/[^\w\s]/g,"\\$&"),d=d.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+d+"(?:\\?[^\\?]*)?$","i").test(b))return true}return false},convertBuildOptions:function(a,b){function c(a,c,d){var e={label:UI.format.capital(d.name?d.name:c),pointer:{main:b,index:c},validate:[]};f[a]=="required"&&(!("default"in d)||d["default"]=="")&&e.validate.push("required");if("default"in d){e.placeholder=d["default"];if(d.type=="select")for(var j in d.select)if(d.select[j][0]==d["default"]){e.placeholder=
d.select[h][1];break}}if("help"in d)g.help=d.help;if("unit"in d)g.unit=d.unit;if("placeholder"in d)g.placeholder=d.placeholder;if("type"in d)switch(d.type){case "int":g.type="int";if("max"in d)g.max=d.max;if("min"in d)g.min=d.min;break;case "uint":g.type="int";g.min=0;if("max"in d)g.max=d.max;if("min"in d)g.min=Math.max(g.min,d.min);break;case "json":case "debug":case "inputlist":g.type=d.type;break;case "radioselect":g.type="radioselect";g.radioselect=d.radioselect;break;case "select":g.type="select"; d.select[j][1];break}}if("help"in d)e.help=d.help;if("unit"in d)e.unit=d.unit;if("placeholder"in d)e.placeholder=d.placeholder;if("type"in d)switch(d.type){case "int":e.type="int";if("max"in d)e.max=d.max;if("min"in d)e.min=d.min;break;case "uint":e.type="int";e.min=0;if("max"in d)e.max=d.max;if("min"in d)e.min=Math.max(e.min,d.min);break;case "radioselect":e.type="radioselect";e.radioselect=d.radioselect;break;case "select":e.type="select";e.select=d.select.slice(0);e.validate.indexOf("required")>=
g.select=d.select.slice(0);g.validate.indexOf("required")>=0&&g.select.unshift(["","placeholder"in g?"Default ("+g.placeholder+")":""]);break;case "sublist":g.type="sublist";g.saveas={};g.itemLabel=d.itemLabel;g.sublist=mist.convertBuildOptions(d,g.saveas);break;default:g.type="str"}else g.type="checkbox";"influences"in d&&(g["function"]=function(){var a=$(this).closest(".UIelement"),b=a.find("style");if(b.length)b=b[0];else{b=$("<style>").addClass("dependencies")[0];a.append(b)}b.innerHTML=".UIelement[data-dependent-"+ 0&&e.select.unshift(["","placeholder"in e?"Default ("+e.placeholder+")":""]);break;case "sublist":e.type="sublist";e.saveas={};e.itemLabel=d.itemLabel;e.sublist=mist.convertBuildOptions(d,e.saveas);break;case "bool":e.type="checkbox";break;case "unixtime":e.type="unix";break;default:e.type="str"}else e.type="checkbox";if("format"in d)switch(d.format){case "set_or_unset":e.postSave=function(){var a=$(this).data("pointer");a.main[a.index]||delete a.main[a.index]}}"influences"in d?e["function"]=function(){var a=
c+"]:not([data-dependent-"+c+'~="'+$(this).getval()+'"]) { display: none; }\n';$(b).data("content",b.innerHTML);$("style.dependencies.hidden").each(function(){$(this).html($(this).data("content")).removeClass("hidden")});$(".UIelement:not(:visible) style.dependencies:not(.hidden)").each(function(){$(this).addClass("hidden");$(this).html("")})});if("dependent"in d)g.dependent=d.dependent;if("value"in d)g.value=d.value;if("validate"in d)g.validate=g.validate.concat(d.validate);return g}var d=[],e=["required", $(this).closest(".UIelement"),b=a.find("style");if(b.length)b=b[0];else{b=$("<style>").addClass("dependencies")[0];a.append(b)}b.innerHTML=".UIelement[data-dependent-"+c+"]:not([data-dependent-"+c+'~="'+$(this).getval()+'"]) { display: none; }\n';$(b).data("content",b.innerHTML);$("style.dependencies.hidden").each(function(){$(this).html($(this).data("content")).removeClass("hidden")});$(".UIelement:not(:visible) style.dependencies:not(.hidden)").each(function(){$(this).addClass("hidden");$(this).html("")})}:
"optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var l in e)if(a[e[l]]){d.push($("<h4>").text(UI.format.capital(e[l])+" parameters"));var n=Object.keys(a[e[l]]);"sort"in a&&n.sort(function(b,c){return(""+a[e[l]][b][a.sort]).localeCompare(a[e[l]][c][a.sort])});for(var h in n){var t=n[h],m=a[e[l]][t];if(Array.isArray(m))for(var k in m)d.push(c(l,t,m[k]));else d.push(c(l,t,m))}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,b){var c=this.get();c[a]=b;mist.send(function(){}, "disable"in d&&(e["function"]=function(){for(var a=$(this).closest(".input_container"),b=$(this).getval(),c=0;c<d.disable.length;c++){var e=a.find('.field[name="'+d.disable[c]+'"]').closest(".UIelement");if(e.length)b==""?e[0].style.display="":e.hide()}});if("dependent"in d)e.dependent=d.dependent;if("value"in d)e.value=d.value;if("validate"in d){e.validate=e.validate.concat(d.validate);if(d.validate.indexOf("track_selector_parameter")>-1)e.help="<div>"+d.help+"</div><p>Track selector parameters consist of a string value which may be any of the following:</p> <ul><li><code>selector,selector</code>: Selects the union of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,!selector</code>: Selects the difference of the given selectors. Specifically, all tracks part of the first selector that are not part of the second selector. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,selector</code>: Selects the intersection of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>none</code> or <code>-1</code>: Selects no tracks of this type.</li> <li><code>all</code> or <code>*</code>: Selects all tracks of this type.</li> <li>Any positive integer: Select this specific track ID. Does not apply if the given track ID does not exist or is of the wrong type. <strong>Does</strong> apply if the given track ID is incompatible with the currently active protocol or container format.</li> <li>ISO 639-1/639-3 language code: Select all tracks marked as the given language. Case insensitive.</li> <li>Codec string (e.g. <code>h264</code>): Select all tracks of the given codec. Case insensitive.</li> <li><code>highbps</code>, <code>maxbps</code> or <code>bestbps</code>: Select the track of this type with the highest bit rate.</li> <li><code>lowbps</code>, <code>minbps</code> or <code>worstbps</code>: Select the track of this type with the lowest bit rate.</li> <li><code>Xbps</code> or <code>Xkbps</code> or <code>Xmbps</code>: Select the single of this type which has a bit rate closest to the given number X. This number is in bits, not bytes.</li> <li><code>&gt;Xbps</code> or <code>&gt;Xkbps</code> or <code>&gt;Xmbps</code>: Select all tracks of this type which have a bit rate greater than the given number X. This number is in bits, not bytes.</li> <li><code>&lt;Xbps</code> or <code>&lt;Xkbps</code> or <code>&lt;Xmbps</code>: Select all tracks of this type which have a bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>max&lt;Xbps</code> or <code>max&lt;Xkbps</code> or <code>max&lt;Xmbps</code>: Select the one track of this type which has the highest bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>highres</code>, <code>maxres</code> or <code>bestres</code>: Select the track of this type with the highest pixel surface area. Only applied when the track type is video.</li> <li><code>lowres</code>, <code>minres</code> or <code>worstres</code>: Select the track of this type with the lowest pixel surface area. Only applied when the track type is video.</li> <li><code>XxY</code>: Select all tracks of this type with the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>~XxY</code>: Select the single track of this type closest to the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>&gt;XxY</code>: Select all tracks of this type with a pixel surface area greater than X by Y pixels. Only applied when the track type is video.</li> <li><code>&lt;XxY</code>: Select all tracks of this type with a pixel surface area less than X by Y pixels. Only applied when the track type is video.</li> <li><code>720p</code>, <code>1080p</code>, <code>1440p</code>, <code>2k</code>, <code>4k</code>, <code>5k</code>, or <code>8k</code>: Select all tracks of this type with the given pixel surface area. Only applied when the track type is video.</li> <li><code>surround</code>, <code>mono</code>, <code>stereo</code>, <code>Xch</code>: Select all tracks of this type with the given channel count. The 'Xch' variant can use any positive integer for 'X'. Only applied when the track type is audio.</li></ul>";
{ui_settings:c})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}} if(d.validate.indexOf("track_selector")>-1)e.help="<div>"+d.help+"</div><p>A track selector is at least one track type (audio, video or subtitle) combined with a track selector parameter. For example: <code>audio=none&video=maxres</code>.<p>Track selector parameters consist of a string value which may be any of the following:</p> <ul><li><code>selector,selector</code>: Selects the union of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,!selector</code>: Selects the difference of the given selectors. Specifically, all tracks part of the first selector that are not part of the second selector. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,selector</code>: Selects the intersection of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>none</code> or <code>-1</code>: Selects no tracks of this type.</li> <li><code>all</code> or <code>*</code>: Selects all tracks of this type.</li> <li>Any positive integer: Select this specific track ID. Does not apply if the given track ID does not exist or is of the wrong type. <strong>Does</strong> apply if the given track ID is incompatible with the currently active protocol or container format.</li> <li>ISO 639-1/639-3 language code: Select all tracks marked as the given language. Case insensitive.</li> <li>Codec string (e.g. <code>h264</code>): Select all tracks of the given codec. Case insensitive.</li> <li><code>highbps</code>, <code>maxbps</code> or <code>bestbps</code>: Select the track of this type with the highest bit rate.</li> <li><code>lowbps</code>, <code>minbps</code> or <code>worstbps</code>: Select the track of this type with the lowest bit rate.</li> <li><code>Xbps</code> or <code>Xkbps</code> or <code>Xmbps</code>: Select the single of this type which has a bit rate closest to the given number X. This number is in bits, not bytes.</li> <li><code>&gt;Xbps</code> or <code>&gt;Xkbps</code> or <code>&gt;Xmbps</code>: Select all tracks of this type which have a bit rate greater than the given number X. This number is in bits, not bytes.</li> <li><code>&lt;Xbps</code> or <code>&lt;Xkbps</code> or <code>&lt;Xmbps</code>: Select all tracks of this type which have a bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>max&lt;Xbps</code> or <code>max&lt;Xkbps</code> or <code>max&lt;Xmbps</code>: Select the one track of this type which has the highest bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>highres</code>, <code>maxres</code> or <code>bestres</code>: Select the track of this type with the highest pixel surface area. Only applied when the track type is video.</li> <li><code>lowres</code>, <code>minres</code> or <code>worstres</code>: Select the track of this type with the lowest pixel surface area. Only applied when the track type is video.</li> <li><code>XxY</code>: Select all tracks of this type with the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>~XxY</code>: Select the single track of this type closest to the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>&gt;XxY</code>: Select all tracks of this type with a pixel surface area greater than X by Y pixels. Only applied when the track type is video.</li> <li><code>&lt;XxY</code>: Select all tracks of this type with a pixel surface area less than X by Y pixels. Only applied when the track type is video.</li> <li><code>720p</code>, <code>1080p</code>, <code>1440p</code>, <code>2k</code>, <code>4k</code>, <code>5k</code>, or <code>8k</code>: Select all tracks of this type with the given pixel surface area. Only applied when the track type is video.</li> <li><code>surround</code>, <code>mono</code>, <code>stereo</code>, <code>Xch</code>: Select all tracks of this type with the given channel count. The 'Xch' variant can use any positive integer for 'X'. Only applied when the track type is audio.</li></ul>"}return e}
var d=[],f=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var l in f)if(a[f[l]]){d.push($("<h4>").text(UI.format.capital(f[l])+" parameters"));var m=Object.keys(a[f[l]]);"sort"in a&&m.sort(function(b,c){return(""+a[f[l]][b][a.sort]).localeCompare(a[f[l]][c][a.sort])});for(var e in m){var t=m[e],o=a[f[l]][t];if(Array.isArray(o))for(var k in o)d.push(c(l,t,o[k]));else d.push(c(l,t,o))}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,b){var c=
this.get();c[a]=b;mist.send(function(){},{ui_settings:c})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}}
$.fn.getval=function(){var a=$(this).data("opts"),b=$(this).val();if(a&&"type"in a)switch(a.type){case "int":b!=""&&(b=Number(b));break;case "span":b=$(this).html();break;case "debug":b=$(this).val()==""?null:Number($(this).val());break;case "checkbox":b=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){b=[];b.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&b.push(a.val())}else b="";break;case "checklist":b= $.fn.getval=function(){var a=$(this).data("opts"),b=$(this).val();if(a&&"type"in a)switch(a.type){case "int":b!=""&&(b=Number(b));break;case "span":b=$(this).html();break;case "debug":b=$(this).val()==""?null:Number($(this).val());break;case "checkbox":b=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){b=[];b.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&b.push(a.val())}else b="";break;case "checklist":b=
[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){b.push($(this).attr("name"))});break;case "unix":b!=""&&(b=Math.round(new Date($(this).val())/1E3));break;case "selectinput":b=$(this).children("select").first().val();b=="CUSTOM"&&(b=$(this).children("label").first().find(".field_container").children().first().getval());break;case "inputlist":b=[];$(this).children().each(function(){$(this).val()!=""&&b.push($(this).val())});break;case "sublist":b=$(this).data("savelist"); [];$(this).find(".checklist input[type=checkbox]:checked").each(function(){b.push($(this).attr("name"))});break;case "unix":b!=""&&(b=Math.round(new Date($(this).val())/1E3));break;case "selectinput":b=$(this).children("select").first().val();b=="CUSTOM"&&(b=$(this).children("label").first().find(".field_container").children().first().getval());break;case "inputlist":b=[];$(this).find(".field").each(function(){$(this).getval()!=""&&b.push($(this).getval())});break;case "sublist":b=$(this).data("savelist");
break;case "json":try{b=JSON.parse($(this).val())}catch(c){b=null}break;case "bitmask":b=0;$(this).find("input").each(function(){$(this).prop("checked")&&(b=b+Number($(this).val()))})}return b}; break;case "json":try{b=JSON.parse($(this).val())}catch(c){b=null}break;case "bitmask":b=0;$(this).find("input").each(function(){$(this).prop("checked")&&(b=b+Number($(this).val()))})}return b};
$.fn.setval=function(a){var b=$(this).data("opts");$(this).val(a);if(b&&"type"in b)switch(b.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":b=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";b.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),c;for(c in a)b.values.append(b.prototype.clone(true).val(a[c]));b.blackwhite.trigger("change");break;case "radioselect":if(typeof a== $.fn.setval=function(a){var b=$(this).data("opts");$(this).val(a);if(b&&"type"in b)switch(b.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":b=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";b.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),c;for(c in a)b.values.append(b.prototype.clone(true).val(a[c]));b.blackwhite.trigger("change");break;case "radioselect":if(typeof a==
"undefined")return $(this);c=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&c.children("select").val(a[1]);break;case "checklist":b=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(c in a)b.filter('[name="'+a[c]+'"]').prop("checked",true);break;case "unix":if(typeof a!="undefined"){a=new Date(Math.round(a)*1E3);a.setMinutes(a.getMinutes()-a.getTimezoneOffset());a=a.toISOString();$(this).val(a.split("Z")[0])}break;case "selectinput":a=== "undefined")return $(this);c=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&c.children("select").val(a[1]);break;case "checklist":b=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(c in a)b.filter('[name="'+a[c]+'"]').prop("checked",true);break;case "unix":if(typeof a!="undefined"&&a!=""&&a!==null){a=new Date(Math.round(a)*1E3);a.setMinutes(a.getMinutes()-a.getTimezoneOffset());a=a.toISOString();$(this).val(a.split("Z")[0])}break;
null&&(a="");var d=false;for(c in b.selectinput){var e;typeof b.selectinput[c]=="string"?e=b.selectinput[c]:typeof b.selectinput[c][0]=="string"&&(e=b.selectinput[c][0]);if(e==a){$(this).children("select").first().val(a);d=true;break}}if(!d){$(this).children("label").first().find(".field_container").children().first().setval(a);$(this).children("select").first().val("CUSTOM").trigger("change")}break;case "inputlist":typeof a=="string"&&(a=[a]);for(c in a)$(this).append($(this).data("newitem")().val(a[c])); case "selectinput":a===null&&(a="");var d=false;for(c in b.selectinput){var f;typeof b.selectinput[c]=="string"?f=b.selectinput[c]:typeof b.selectinput[c][0]=="string"&&(f=b.selectinput[c][0]);if(f==a){$(this).children("select").first().val(a);d=true;break}}if(!d){$(this).children("label").first().find(".field_container").children().first().setval(a);$(this).children("select").first().val("CUSTOM").trigger("change")}break;case "inputlist":typeof a=="string"&&(a=[a]);for(c in a){b=$(this).data("newitem")();
$(this).append($(this).children().first());break;case "sublist":var l=$(this),b=$(this).children(".curvals");b.html("");if(a&&a.length)for(c in a){var d=$.extend(true,{},a[c]),n=function(a){for(var b in a)b.slice(0,6)=="x-LSP-"?delete a[b]:typeof a[b]=="object"&&n(a[b])};n(d);b.append($("<div>").addClass("subitem").append($("<span>").addClass("itemdetails").text(a[c]["x-LSP-name"]?a[c]["x-LSP-name"]:JSON.stringify(d)).attr("title",JSON.stringify(d,null,2))).append($("<button>").addClass("move").text("^").attr("title", b.find(".field").setval(a[c]);$(this).append(b)}$(this).append($(this).children().first());break;case "sublist":var l=$(this),b=$(this).children(".curvals");b.html("");if(a&&a.length)for(c in a){var d=$.extend(true,{},a[c]),m=function(a){for(var b in a)b.slice(0,6)=="x-LSP-"?delete a[b]:typeof a[b]=="object"&&m(a[b])};m(d);b.append($("<div>").addClass("subitem").append($("<span>").addClass("itemdetails").text(a[c]["x-LSP-name"]?a[c]["x-LSP-name"]:JSON.stringify(d)).attr("title",JSON.stringify(d,null,
"Move item up").click(function(){var a=$(this).parent().index();if(a!=0){var b=l.getval();b.splice(a-1,0,b.splice(a,1)[0]);l.setval(b)}})).append($("<button>").text("Edit").click(function(){var a=$(this).parent().index(),b=$(this).closest(".field");b.data("build")(Object.assign({},b.getval()[a]),a)})).append($("<button>").text("x").attr("title","Remove item").click(function(a){var b=$(this).parent().index(),c=l.data("savelist");c.splice(b,1);l.setval(c);a.preventDefault()})))}else b.append("None."); 2))).append($("<button>").addClass("move").text("^").attr("title","Move item up").click(function(){var a=$(this).parent().index();if(a!=0){var b=l.getval();b.splice(a-1,0,b.splice(a,1)[0]);l.setval(b)}})).append($("<button>").text("Edit").click(function(){var a=$(this).parent().index(),b=$(this).closest(".field");b.data("build")(Object.assign({},b.getval()[a]),a)})).append($("<button>").text("x").attr("title","Remove item").click(function(a){var b=$(this).parent().index(),c=l.data("savelist");c.splice(b,
l.data("savelist",a);break;case "json":$(this).val(a===null?"":JSON.stringify(a,null,2));break;case "bitmask":d=$(this).data("opts").bitmask;b=$(this).find("input");for(c in d){$el=b.eq(c);(a&d[c][0])==d[c][0]?$el.attr("checked","checked"):$el.removeAttr("checked")}}$(this).trigger("change");return $(this)};function parseURL(a,b){var c=document.createElement("a");c.href=a;if(b)for(var d in b)c[d]=b[d];return{full:c.href,protocol:c.protocol+"//",host:c.hostname,port:c.port?":"+c.port:""}} 1);l.setval(c);a.preventDefault()})))}else b.append("None.");l.data("savelist",a);break;case "json":$(this).val(a===null?"":JSON.stringify(a,null,2));break;case "bitmask":d=$(this).data("opts").bitmask;b=$(this).find("input");for(c in d){$el=b.eq(c);(a&d[c][0])==d[c][0]?$el.attr("checked","checked"):$el.removeAttr("checked")}}$(this).trigger("change");return $(this)};
function triggerRewrite(a){return typeof a=="object"&&typeof a.length=="undefined"?a:obj={handler:a[0],sync:a[1],streams:a[2],"default":a[3]}}; function parseURL(a,b){var c=document.createElement("a");c.href=a;if(b)for(var d in b)c[d]=b[d];return{full:c.href,protocol:c.protocol+"//",host:c.hostname,port:c.port?":"+c.port:""}}function triggerRewrite(a){return typeof a=="object"&&typeof a.length=="undefined"?a:obj={handler:a[0],sync:a[1],streams:a[2],"default":a[3]}};

View file

@ -474,6 +474,10 @@ var UI = {
//save //save
pointer.main[pointer.index] = val; pointer.main[pointer.index] = val;
var fn = $(this).data('opts')['postSave'];
if (fn) { fn.call(this); }
}); });
var fn = $(this).data('opts')['function']; var fn = $(this).data('opts')['function'];
@ -688,22 +692,35 @@ var UI = {
case "inputlist": case "inputlist":
$field = $('<div>').addClass('inputlist'); $field = $('<div>').addClass('inputlist');
var newitem = function(){ var newitem = function(){
var $part = $("<input>").attr("type","text").addClass("listitem"); var $part;
if (e.readonly) { if ("input" in e) {
$part.prop('disabled',true); $part = UI.buildUI([e.input]).find(".field_container");
} }
else {
var o = Object.assign({},e);
o.type = "str";
$part = UI.buildUI([o]).find(".field_container");
}
$part.addClass("listitem");
var keyup = function(e){ var keyup = function(e){
if ($(this).is(":last-child")) { if ($(this).is(":last-child")) {
if ($(this).val() != "") { if ($(this).find(".field").getval() != "") {
$(this).after($part.clone().keyup(keyup).val("")); var $clone = $part.clone().keyup(keyup);
$clone.find(".field").setval("");
$(this).after($clone);
} }
else if (e.which == 8) { //backspace else if (e.which == 8) { //backspace
$(this).prev().focus(); $(this).prev().find(".field").focus();
} }
} }
else { else {
if ($(this).val() == "") { if ($(this).find(".field").getval() == "") {
$(this).next().focus(); var $f = $(this).prev();
if (!$f.length) {
$f = $(this).next();
}
$f.find(".field").focus();
$(this).remove(); $(this).remove();
} }
} }
@ -892,6 +909,11 @@ var UI = {
$('<span>').addClass('unit').html(e.unit) $('<span>').addClass('unit').html(e.unit)
); );
} }
if ('prefix' in e) {
$fc.prepend(
$('<span>').addClass('unit').html(e.prefix)
);
}
if ('readonly' in e) { if ('readonly' in e) {
$field.attr('readonly','readonly'); $field.attr('readonly','readonly');
$field.click(function(){ $field.click(function(){
@ -1153,7 +1175,7 @@ var UI = {
} }
} }
} }
if ((($field.getval() == "") || ($field.getval() == null)) && ('value' in e)) { if ((($field.getval() == "") || ($field.getval() == null) || !("pointer" in e)) && ('value' in e)) {
$field.setval(e.value); $field.setval(e.value);
} }
if ('datalist' in e) { if ('datalist' in e) {
@ -1341,9 +1363,21 @@ var UI = {
}; };
break; break;
} }
case 'track_selector_parameter': {
//the value passed to audio= or video=,
//so something like 1, maxbps or eng
//leave default for now
f = function(){};
break;
}
case 'track_selector': { case 'track_selector': {
//something like "audio=1&video=eng" //something like "audio=1&video=eng"
//keep at default for now.. //leave default for now
f = function(){};
break;
} }
default: default:
f = function(){}; f = function(){};
@ -3130,6 +3164,7 @@ var UI = {
type: "str", type: "str",
maxlength: 31, maxlength: 31,
label: "Variable name", label: "Variable name",
prefix: "$",
help: "What should the variable be called? A dollar sign will automatically be prepended.", help: "What should the variable be called? A dollar sign will automatically be prepended.",
pointer: { pointer: {
main: saveas, main: saveas,
@ -5549,6 +5584,28 @@ var UI = {
var $target = $('<span>'); var $target = $('<span>');
var $logs = $("<span>"); var $logs = $("<span>");
if ((type == "Automatic") && (push.length >= 4)) { if ((type == "Automatic") && (push.length >= 4)) {
function printPrettyComparison(a,b,c){
var str = "";
str += "$"+a+" ";
switch (Number(b)) {
case 0: { str += "is true"; break; }
case 1: { str += "is false"; break; }
case 2: { str += "== "+c; break; }
case 3: { str += "!= "+c; break; }
case 10: { str += "> (numerical) " +c; break; }
case 11: { str += ">= (numerical) "+c; break; }
case 12: { str += "< (numerical) " +c; break; }
case 13: { str += "<= (numerical) "+c; break; }
case 20: { str += "> (lexical) " +c; break; }
case 21: { str += ">= (lexical) "+c; break; }
case 22: { str += "< (lexical) " +c; break; }
case 23: { str += "<= (lexical) "+c; break; }
default: { str += "comparison operator unknown"; break; }
}
return str;
}
$target.append( $target.append(
$('<span>').text(push[2]) $('<span>').text(push[2])
); );
@ -5562,6 +5619,17 @@ var UI = {
$('<span>').text(", complete on "+(new Date(push[4]*1e3)).toLocaleString()) $('<span>').text(", complete on "+(new Date(push[4]*1e3)).toLocaleString())
); );
} }
if ((push.length >= 8) && (push[5])) {
$target.append(
$('<span>').text(", starts if "+printPrettyComparison(push[5],push[6],push[7]))
);
}
if ((push.length >= 11) && (push[8])) {
$target.append(
$('<span>').text(", stops if "+printPrettyComparison(push[8],push[9],push[10]))
);
}
} }
else if ((push.length >= 4) && (push[2] != push[3])) { else if ((push.length >= 4) && (push[2] != push[3])) {
$target.append( $target.append(
@ -5706,7 +5774,7 @@ var UI = {
} }
$c.append( $c.append(
$('<h3>').text('Automatic pushes') $('<h3>').text('Automatic push settings')
).append( ).append(
UI.buildUI([ UI.buildUI([
{ {
@ -5715,7 +5783,7 @@ var UI = {
type: 'int', type: 'int',
min: 0, min: 0,
help: 'How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.', help: 'How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.',
'default': 0, 'default': 3,
pointer: { pointer: {
main: push_settings, main: push_settings,
index: 'wait' index: 'wait'
@ -5746,6 +5814,8 @@ var UI = {
}] }]
} }
]) ])
).append(
$('<h3>').text('Automatic push settings')
).append( ).append(
$('<button>').text('Add an automatic push').click(function(){ $('<button>').text('Add an automatic push').click(function(){
UI.navto('Start Push','auto'); UI.navto('Start Push','auto');
@ -5887,11 +5957,11 @@ var UI = {
break; break;
case 'Start Push': case 'Start Push':
if (!('capabilities' in mist.data)) { if (!('capabilities' in mist.data) || !('variable_list' in mist.data)) {
$main.append('Loading Mist capabilities..'); $main.append('Loading Mist capabilities..');
mist.send(function(){ mist.send(function(){
UI.navto('Start Push',other); UI.navto('Start Push',other);
},{capabilities:1}); },{capabilities:1,variable_list:true});
return; return;
} }
@ -5924,9 +5994,9 @@ var UI = {
$main.find('h2').text('Add automatic push'); $main.find('h2').text('Add automatic push');
} }
//FOR NOW, ASSUME PROTOCOL SETTINGS BUILDSETTINGS ARE USED
var saveas = {params:{}}; var saveas = {params:{}};
var params = []; //will contain all target url params as an array
if ((other == "auto") && (typeof edit != "undefined")) { if ((other == "auto") && (typeof edit != "undefined")) {
saveas = { saveas = {
"stream": edit[0], "stream": edit[0],
@ -5945,22 +6015,163 @@ var UI = {
} }
} }
/* if (edit.length >= 3) { saveas.scheduletime = edit[2] != 0 ? edit[2] : null; }
if (edit.length >= 3) { saveas.scheduletime = edit[2]; } if (edit.length >= 4) { saveas.completetime = edit[3] != 0 ? edit[3] : null; }
if (edit.length >= 4) { saveas.completetime = edit[3]; } if (edit.length >= 5) { saveas.startVariableName = edit[4] != '' ? edit[4] : null; }
if (saveas.target.indexOf("recstartunix=") > -1) { if (edit.length >= 6) { saveas.startVariableOperator = edit[5] != '' ? edit[5] : null; }
if (edit.length >= 7) { saveas.startVariableValue = edit[6] != '' ? edit[6] : null; }
//retrieve recstartunix param value if (edit.length >= 8) { saveas.endVariableName = edit[7] != '' ? edit[7] : null; }
var t = saveas.target.split("recstartunix=")[1]; if (edit.length >= 9) { saveas.endVariableOperator = edit[8] != '' ? edit[8] : null; }
saveas.recstartunix = t.split("&")[0]; if (edit.length >= 10){ saveas.endVariableValue = edit[9] != '' ? edit[9] : null; }
//remove param from target
saveas.target = saveas.target.replace("recstartunix="+saveas.recstartunix,"").replace("?&","?").replace("&&","&");
if (saveas.target[saveas.target.length-1] == "?") { saveas.target = saveas.target.slice(0,-1); }
}*/
} }
var $additional_params = $("<div>").css("margin","1em 0"); var $additional_params = $("<div>").css("margin","1em 0");
var $autopush = $("<div>");
var push_parameters;
if (other == "auto") {
$autopush.css("margin","1em 0").html(UI.buildUI([{
label: "This push should be active",
help: "When 'based on server time' is selected, a start and/or end timestamp can be configured. When it's 'based on a variable', the push will be activated while the specified variable matches the specified value.",
type: "select",
select: [["time","Based on server time"],["variable","Based on a variable"]],
value: (saveas.startVariableName || saveas.endVariableName ? "variable" : "time"),
classes: ["activewhen"],
"function": function(){
var $varbased = $autopush.find(".varbased").closest(".UIelement");
var $timebased = $autopush.find(".timebased").closest(".UIelement");
if ($(this).getval() == "time") {
$varbased.hide();
$timebased.css("display","");
}
else {
$timebased.hide();
$varbased.css("display","");
$autopush.find("[name=\"startVariableOperator\"]").trigger("change");
$autopush.find("[name=\"endVariableOperator\"]").trigger("change");
}
}
},
$("<br>"),
$("<span>").addClass("UIelement").append(
$("<h3>").text("Start the push").addClass("varbased")
),{
classes: ["varbased"],
label: "Use this variable",
type: "str",
help: "This variable should be used to determine if this push should be started.",
prefix: "$",
datalist: Object.keys(mist.data.variable_list || []),
pointer: { main: saveas, index: "startVariableName" }
},{
classes: ["varbased"],
label: "Comparison operator",
type: "select",
select: [
[0,"is true"],
[1,"is false"],
[2,"=="],
[3,"!="],
[10,"> (numerical)"],
[11,">= (numerical)"],
[12,"< (numerical)"],
[13,"<= (numerical)"],
[20,"> (lexical)"],
[21,">= (lexical)"],
[22,"< (lexical)"],
[23,"<= (lexical)"]
],
value: 2,
css: {display:"none"},
help: "How would you like to compare this variable?",
pointer: { main: saveas, index: "startVariableOperator" },
"function": function(){
var $varvalue = $autopush.find("[name=\"startVariableValue\"]").closest(".UIelement");
if (Number($(this).getval()) < 2) {
$varvalue.hide();
}
else {
$varvalue.css("display","");
}
}
},{
classes: ["varbased"],
label: "Variable value",
type: "str",
help: "The variable will be compared with this value to determine if this push should be started.<br>You can also enter another variable here!",
datalist: Object.values(mist.data.variable_list || []).map(function(a){return typeof a == "string" ? a : a[3]}).concat(Object.keys(mist.data.variable_list || []).map(function(a){ return "$"+a; })),
pointer: { main: saveas, index: "startVariableValue" }
},
$("<span>").addClass("UIelement").append(
$("<h3>").text("Stop the push").addClass("varbased")
),{
classes: ["varbased"],
label: "Use this variable",
type: "str",
help: "This variable should be used to determine if this push should be stopped.<br>You can leave this field blank if you do not want to have a stop condition. (You can always stop the push manually)",
prefix: "$",
datalist: Object.keys(mist.data.variable_list || []),
pointer: { main: saveas, index: "endVariableName" }
},{
classes: ["varbased"],
label: "Comparison operator",
type: "select",
select: [
[0,"is true"],
[1,"is false"],
[2,"=="],
[3,"!="],
[10,"> (numerical)"],
[11,">= (numerical)"],
[12,"< (numerical)"],
[13,"<= (numerical)"],
[20,"> (lexical)"],
[21,">= (lexical)"],
[22,"< (lexical)"],
[23,"<= (lexical)"]
],
value: 2,
help: "How would you like to compare this variable?",
pointer: { main: saveas, index: "endVariableOperator" },
"function": function(){
var $varvalue = $autopush.find("[name=\"endVariableValue\"]").closest(".UIelement");
if (Number($(this).getval()) < 2) {
$varvalue.hide();
}
else {
$varvalue.css("display","");
}
}
},{
classes: ["varbased"],
label: "Variable value",
type: "str",
help: "The variable will be compared with this value to determine if this push should be stopped.<br>You can also enter another variable here!",
datalist: Object.values(mist.data.variable_list || []).map(function(a){return typeof a == "string" ? a : a[3]}).concat(Object.keys(mist.data.variable_list || []).map(function(a){ return "$"+a; })),
pointer: { main: saveas, index: "endVariableValue" }
},{
classes: ["timebased"],
type: "unix",
label: "Start time",
min: 0,
help: "The time where the push will become active. The default is to start immediately.",
pointer: {
main: saveas,
index: "scheduletime"
}
},{
classes: ["timebased"],
type: "unix",
label: "End time",
min: 0,
help: "The time where the push will stop. Defaults to never stop automatically.<br>Only makes sense for live streams.",
pointer: {
main: saveas,
index: "completetime"
}
}],saveas));
$autopush.find(".activewhen").trigger("change");
}
var build = [{ var build = [{
label: 'Stream name', label: 'Stream name',
type: 'str', type: 'str',
@ -6003,13 +6214,6 @@ var UI = {
<li>$minute - inserts the minute timestamp the stream was received</li>\ <li>$minute - inserts the minute timestamp the stream was received</li>\
<li>$seconds - inserts the seconds timestamp when the stream was received</li>\ <li>$seconds - inserts the seconds timestamp when the stream was received</li>\
<li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>\ <li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>\
</ul>\
Valid URL parameters:\
<ul>\
<li>recstart=123 - media timestamp in milisseconds where the push should start</li>\
<li>recstop=456 - media timestamp in miliseconds where the push should stop</li>\
<li>recstartunix=150000000 - unix time in seconds where the push should start. This will override the recstart parameter.</li>\
<li>recstopunix=150000000 - unix time in seconds where the push should stop. This will override the recstop parameter.</li>\
</ul>', </ul>',
pointer: { pointer: {
main: saveas, main: saveas,
@ -6029,9 +6233,10 @@ var UI = {
"function": function(){ "function": function(){
//find what kind of target this is //find what kind of target this is
var match = false; var match = false;
var val = $(this).getval();
for (connector in connector2target_match) { for (connector in connector2target_match) {
for (var i in connector2target_match[connector]) { for (var i in connector2target_match[connector]) {
if (mist.inputMatch(connector2target_match[connector][i],$(this).getval())) { if (mist.inputMatch(connector2target_match[connector][i],val)) {
match = connector; match = connector;
break; break;
} }
@ -6046,13 +6251,55 @@ var UI = {
return; return;
} }
$additional_params.html($("<h3>").text(mist.data.capabilities.connectors[match].friendly)); $additional_params.html($("<h3>").text(mist.data.capabilities.connectors[match].friendly));
push_parameters = {};
//filter out protocol only or file only options. This does not need to be dynamic as when the target changes, the whole $additional_params container is overwritten anyway
for (var i in mist.data.capabilities.connectors[match].push_parameters) {
var param = mist.data.capabilities.connectors[match].push_parameters[i];
if (param.prot_only && String().match && (val.match(/.+\:\/\/.+/) === null)) { continue; }
if (param.file_only && (val[0] != "/")) { continue; }
push_parameters[i] = param;
}
var capa = { var capa = {
desc: mist.data.capabilities.connectors[match].desc, desc: mist.data.capabilities.connectors[match].desc,
optional: mist.data.capabilities.connectors[match].push_parameters optional: push_parameters,
sort: "sort"
}; };
$additional_params.append(UI.buildUI(mist.convertBuildOptions(capa,saveas.params))); var capaform = mist.convertBuildOptions(capa,saveas.params);
//find left over url params that are not covered by this connector's capabilities
var custom_params = [];
for (var i in params) {
var p = params[i].split("=");
var name = p[0];
if (!(name in push_parameters)) {
custom_params.push(name+(p.length > 1 ? "="+p.slice(1).join("=") : ""));
}
}
capaform.push($("<br>"));
capaform.push({
type: "inputlist",
label: "Custom url parameters",
value: custom_params,
classes: ["custom_url_parameters"],
input: {
type: "str",
placeholder: "name=value",
prefix: ""
},
help: "Any custom url parameters not covered by the parameters configurable above.",
pointer: {
main: saveas,
index: "custom_url_params"
}
});
$additional_params.append(UI.buildUI(capaform));
} }
},$additional_params]; },
$autopush,
$additional_params];
@ -6101,22 +6348,49 @@ var UI = {
},{ },{
type: 'save', type: 'save',
label: 'Save', label: 'Save',
preSave: function(){
//is executed before the variables are saved
//clean the object of old settings that may not be part of the current form
delete saveas.startVariableName;
delete saveas.startVariableOperator;
delete saveas.startVariableValue;
delete saveas.endVariableName;
delete saveas.endVariableOperator;
delete saveas.endVariableValue;
delete saveas.completetime;
delete saveas.scheduletime;
},
'function': function(){ 'function': function(){
var params = saveas.params; var params = saveas.params;
for (var i in params) { for (var i in params) {
if (params[i] === null) { if (params[i] === null) {
//remove any params that are set to null
delete params[i];
}
else if (!(i in push_parameters)) {
//remove any params that are not supported by this protocol (they will have been duplicatec to saveas.custom_url_parameters if the user wanted to keep them)
delete params[i]; delete params[i];
} }
} }
/*if (saveas.recstartunix) { if (saveas.startVariableName || saveas.endVariableName) {
//append recstartunix to target saveas.scheduletime = 0;
params["recstartunix"] = "recstartunix="+saveas.recstartunix; saveas.completetime = 0;
} }
else if (saveas.scheduletime) { if (saveas.startVariableName === null) {
params["recstartunix"] = "recstartunix="+saveas.scheduletime; delete saveas.startVariableName;
delete saveas.startVariableOperator;
delete saveas.startVariableValue;
} }
delete saveas.recstartunix;*/ if (saveas.endVariableName === null) {
if (Object.keys(params).length) { delete saveas.endVariableName;
delete saveas.endVariableOperator;
delete saveas.endVariableValue;
}
if (saveas.scheduletime) {
params["recstartunix"] = saveas.scheduletime;
}
if (Object.keys(params).length || (saveas.custom_url_params && saveas.custom_url_params.length)) {
var append = "?"; var append = "?";
var curparams = saveas.target.split("?"); var curparams = saveas.target.split("?");
if (curparams.length > 1) { if (curparams.length > 1) {
@ -6128,15 +6402,20 @@ var UI = {
if (key in params) { delete params[key]; } if (key in params) { delete params[key]; }
} }
} }
if (Object.keys(params).length) { if (Object.keys(params).length || (saveas.custom_url_params && saveas.custom_url_params.length)) {
var str = []; var str = [];
for (var i in params) { for (var i in params) {
str.push(i+"="+params[i]); str.push(i+"="+params[i]);
} }
for (var i in saveas.custom_url_params) {
str.push(saveas.custom_url_params[i]);
}
append += str.join("&"); append += str.join("&");
saveas.target += append; saveas.target += append;
} }
} }
delete saveas.params; //these are now part of the target url and we don't need them seperately
delete saveas.custom_url_params;
var obj = {}; var obj = {};
obj[(other == 'auto' ? 'push_auto_add' : 'push_start')] = saveas; obj[(other == 'auto' ? 'push_auto_add' : 'push_start')] = saveas;
@ -7135,7 +7414,7 @@ var mist = {
//remove everything we don't care about //remove everything we don't care about
var save = $.extend({},d); var save = $.extend({},d);
var keep = ['config','capabilities','ui_settings','LTS','active_streams','browse','log','totals','bandwidth']; //streams was already copied above var keep = ['config','capabilities','ui_settings','LTS','active_streams','browse','log','totals','bandwidth','variable_list']; //streams was already copied above
for (var i in save) { for (var i in save) {
if (keep.indexOf(i) == -1) { if (keep.indexOf(i) == -1) {
delete save[i]; delete save[i];
@ -7397,11 +7676,6 @@ var mist = {
if ("max" in ele) { obj.max = ele.max; } if ("max" in ele) { obj.max = ele.max; }
if ("min" in ele) { obj.min = Math.max(obj.min,ele.min); } if ("min" in ele) { obj.min = Math.max(obj.min,ele.min); }
break; break;
case 'json':
case 'debug':
case 'inputlist':
obj.type = ele.type;
break;
case 'radioselect': case 'radioselect':
obj.type = 'radioselect'; obj.type = 'radioselect';
obj.radioselect = ele.radioselect; obj.radioselect = ele.radioselect;
@ -7422,7 +7696,14 @@ var mist = {
obj.sublist = mist.convertBuildOptions(ele,obj.saveas); obj.sublist = mist.convertBuildOptions(ele,obj.saveas);
break; break;
} }
case 'str': case 'bool': {
obj.type = 'checkbox';
break;
}
case 'unixtime': {
obj.type = 'unix';
break;
}
default: default:
obj.type = 'str'; obj.type = 'str';
} }
@ -7430,6 +7711,22 @@ var mist = {
else { else {
obj.type = "checkbox"; obj.type = "checkbox";
} }
if ("format" in ele) {
switch (ele.format) {
case "set_or_unset": {
//whatever is set as 'postSave' will be called by the save button after validation and after the value has been saved to whatever is set as the pointer
obj['postSave'] = function(){
//if the value evaluates to false, remove it from the parent object
var pointer = $(this).data('pointer');
if (!pointer.main[pointer.index]) {
delete pointer.main[pointer.index];
}
};
break;
}
}
}
if ("influences" in ele) { if ("influences" in ele) {
obj["function"] = function(){ obj["function"] = function(){
var $cont = $(this).closest(".UIelement"); var $cont = $(this).closest(".UIelement");
@ -7455,6 +7752,24 @@ var mist = {
}); });
}; };
} }
else if ("disable" in ele) {
obj["function"] = function(){
var $cont = $(this).closest(".input_container");
var val = $(this).getval();
for (var i = 0; i < ele.disable.length; i++) {
var dependent = ele.disable[i];
var $dependency = $cont.find(".field[name=\""+dependent+"\"]").closest(".UIelement");
if ($dependency.length) {
if (val == "") {
$dependency[0].style.display = "";
}
else {
$dependency.hide();
}
}
}
};
}
if ("dependent" in ele) { if ("dependent" in ele) {
obj.dependent = ele.dependent; obj.dependent = ele.dependent;
} }
@ -7463,6 +7778,12 @@ var mist = {
} }
if ("validate" in ele) { if ("validate" in ele) {
obj.validate = obj.validate.concat(ele.validate); obj.validate = obj.validate.concat(ele.validate);
if (ele.validate.indexOf("track_selector_parameter") > -1) {
obj.help = "<div>"+ele.help+"</div>"+"<p>Track selector parameters consist of a string value which may be any of the following:</p> <ul><li><code>selector,selector</code>: Selects the union of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,!selector</code>: Selects the difference of the given selectors. Specifically, all tracks part of the first selector that are not part of the second selector. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,selector</code>: Selects the intersection of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>none</code> or <code>-1</code>: Selects no tracks of this type.</li> <li><code>all</code> or <code>*</code>: Selects all tracks of this type.</li> <li>Any positive integer: Select this specific track ID. Does not apply if the given track ID does not exist or is of the wrong type. <strong>Does</strong> apply if the given track ID is incompatible with the currently active protocol or container format.</li> <li>ISO 639-1/639-3 language code: Select all tracks marked as the given language. Case insensitive.</li> <li>Codec string (e.g. <code>h264</code>): Select all tracks of the given codec. Case insensitive.</li> <li><code>highbps</code>, <code>maxbps</code> or <code>bestbps</code>: Select the track of this type with the highest bit rate.</li> <li><code>lowbps</code>, <code>minbps</code> or <code>worstbps</code>: Select the track of this type with the lowest bit rate.</li> <li><code>Xbps</code> or <code>Xkbps</code> or <code>Xmbps</code>: Select the single of this type which has a bit rate closest to the given number X. This number is in bits, not bytes.</li> <li><code>&gt;Xbps</code> or <code>&gt;Xkbps</code> or <code>&gt;Xmbps</code>: Select all tracks of this type which have a bit rate greater than the given number X. This number is in bits, not bytes.</li> <li><code>&lt;Xbps</code> or <code>&lt;Xkbps</code> or <code>&lt;Xmbps</code>: Select all tracks of this type which have a bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>max&lt;Xbps</code> or <code>max&lt;Xkbps</code> or <code>max&lt;Xmbps</code>: Select the one track of this type which has the highest bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>highres</code>, <code>maxres</code> or <code>bestres</code>: Select the track of this type with the highest pixel surface area. Only applied when the track type is video.</li> <li><code>lowres</code>, <code>minres</code> or <code>worstres</code>: Select the track of this type with the lowest pixel surface area. Only applied when the track type is video.</li> <li><code>XxY</code>: Select all tracks of this type with the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>~XxY</code>: Select the single track of this type closest to the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>&gt;XxY</code>: Select all tracks of this type with a pixel surface area greater than X by Y pixels. Only applied when the track type is video.</li> <li><code>&lt;XxY</code>: Select all tracks of this type with a pixel surface area less than X by Y pixels. Only applied when the track type is video.</li> <li><code>720p</code>, <code>1080p</code>, <code>1440p</code>, <code>2k</code>, <code>4k</code>, <code>5k</code>, or <code>8k</code>: Select all tracks of this type with the given pixel surface area. Only applied when the track type is video.</li> <li><code>surround</code>, <code>mono</code>, <code>stereo</code>, <code>Xch</code>: Select all tracks of this type with the given channel count. The 'Xch' variant can use any positive integer for 'X'. Only applied when the track type is audio.</li></ul>";
}
if (ele.validate.indexOf("track_selector") > -1) {
obj.help = "<div>"+ele.help+"</div>"+"<p>A track selector is at least one track type (audio, video or subtitle) combined with a track selector parameter. For example: <code>audio=none&video=maxres</code>.<p>Track selector parameters consist of a string value which may be any of the following:</p> <ul><li><code>selector,selector</code>: Selects the union of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,!selector</code>: Selects the difference of the given selectors. Specifically, all tracks part of the first selector that are not part of the second selector. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>selector,selector</code>: Selects the intersection of the given selectors. Any number of comma-separated selector combinations may be used, they are evaluated one by one from left to right.</li> <li><code>none</code> or <code>-1</code>: Selects no tracks of this type.</li> <li><code>all</code> or <code>*</code>: Selects all tracks of this type.</li> <li>Any positive integer: Select this specific track ID. Does not apply if the given track ID does not exist or is of the wrong type. <strong>Does</strong> apply if the given track ID is incompatible with the currently active protocol or container format.</li> <li>ISO 639-1/639-3 language code: Select all tracks marked as the given language. Case insensitive.</li> <li>Codec string (e.g. <code>h264</code>): Select all tracks of the given codec. Case insensitive.</li> <li><code>highbps</code>, <code>maxbps</code> or <code>bestbps</code>: Select the track of this type with the highest bit rate.</li> <li><code>lowbps</code>, <code>minbps</code> or <code>worstbps</code>: Select the track of this type with the lowest bit rate.</li> <li><code>Xbps</code> or <code>Xkbps</code> or <code>Xmbps</code>: Select the single of this type which has a bit rate closest to the given number X. This number is in bits, not bytes.</li> <li><code>&gt;Xbps</code> or <code>&gt;Xkbps</code> or <code>&gt;Xmbps</code>: Select all tracks of this type which have a bit rate greater than the given number X. This number is in bits, not bytes.</li> <li><code>&lt;Xbps</code> or <code>&lt;Xkbps</code> or <code>&lt;Xmbps</code>: Select all tracks of this type which have a bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>max&lt;Xbps</code> or <code>max&lt;Xkbps</code> or <code>max&lt;Xmbps</code>: Select the one track of this type which has the highest bit rate less than the given number X. This number is in bits, not bytes.</li> <li><code>highres</code>, <code>maxres</code> or <code>bestres</code>: Select the track of this type with the highest pixel surface area. Only applied when the track type is video.</li> <li><code>lowres</code>, <code>minres</code> or <code>worstres</code>: Select the track of this type with the lowest pixel surface area. Only applied when the track type is video.</li> <li><code>XxY</code>: Select all tracks of this type with the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>~XxY</code>: Select the single track of this type closest to the given pixel surface area in X by Y pixels. Only applied when the track type is video.</li> <li><code>&gt;XxY</code>: Select all tracks of this type with a pixel surface area greater than X by Y pixels. Only applied when the track type is video.</li> <li><code>&lt;XxY</code>: Select all tracks of this type with a pixel surface area less than X by Y pixels. Only applied when the track type is video.</li> <li><code>720p</code>, <code>1080p</code>, <code>1440p</code>, <code>2k</code>, <code>4k</code>, <code>5k</code>, or <code>8k</code>: Select all tracks of this type with the given pixel surface area. Only applied when the track type is video.</li> <li><code>surround</code>, <code>mono</code>, <code>stereo</code>, <code>Xch</code>: Select all tracks of this type with the given channel count. The 'Xch' variant can use any positive integer for 'X'. Only applied when the track type is audio.</li></ul>";
}
} }
return obj; return obj;
@ -7584,9 +7905,9 @@ $.fn.getval = function(){
break; break;
case "inputlist": case "inputlist":
val = []; val = [];
$(this).children().each(function(){ $(this).find(".field").each(function(){
if ($(this).val() != "") { if ($(this).getval() != "") {
val.push($(this).val()); val.push($(this).getval());
} }
}); });
break; break;
@ -7655,7 +7976,7 @@ $.fn.setval = function(val){
} }
break; break;
case "unix": case "unix":
if (typeof val != "undefined") { if ((typeof val != "undefined") && (val != "") && (val !== null)) {
var datetime = new Date(Math.round(val) * 1e3); var datetime = new Date(Math.round(val) * 1e3);
datetime.setMinutes(datetime.getMinutes() - datetime.getTimezoneOffset()); //correct for the browser being a pain and converting to UTC datetime.setMinutes(datetime.getMinutes() - datetime.getTimezoneOffset()); //correct for the browser being a pain and converting to UTC
datetime = datetime.toISOString(); datetime = datetime.toISOString();
@ -7691,9 +8012,9 @@ $.fn.setval = function(val){
case "inputlist": case "inputlist":
if (typeof val == "string") { val = [val]; } if (typeof val == "string") { val = [val]; }
for (var i in val) { for (var i in val) {
$(this).append( var $newitem = $(this).data("newitem")();
$(this).data("newitem")().val(val[i]) $newitem.find(".field").setval(val[i]);
); $(this).append($newitem);
} }
$(this).append($(this).children().first()); //put empty input last $(this).append($(this).children().first()); //put empty input last
break; break;

View file

@ -157,9 +157,10 @@ int main(int argc, char *argv[]){
capa["optional"]["source_track"]["name"] = "Input selection"; capa["optional"]["source_track"]["name"] = "Input selection";
capa["optional"]["source_track"]["help"] = capa["optional"]["source_track"]["help"] =
"Track ID, codec or language of the source stream to encode."; "Track ID, codec or language of the source stream to encode.";
capa["optional"]["source_track"]["type"] = "track_selector_parameter"; capa["optional"]["source_track"]["type"] = "string";
capa["optional"]["source_track"]["n"] = 1; capa["optional"]["source_track"]["n"] = 1;
capa["optional"]["source_track"]["default"] = "automatic"; capa["optional"]["source_track"]["default"] = "automatic";
capa["optional"]["source_track"]["validate"][0u] = "track_selector_parameter";
// use an array for this parameter, because there are two input field variations // use an array for this parameter, because there are two input field variations
capa["required"]["codec"][0u]["name"] = "Target codec"; capa["required"]["codec"][0u]["name"] = "Target codec";