Merge branch 'development' into LTS_development

This commit is contained in:
Thulinma 2017-05-11 14:14:44 +02:00
commit c0dd64bc7b
23 changed files with 759 additions and 39886 deletions

View file

@ -433,7 +433,9 @@ add_executable(MistOutHTTP
generated/videojs.js.h
generated/img.js.h
generated/playerdash.js.h
generated/playerdashlic.js.h
generated/playervideo.js.h
generated/playerhlsvideo.js.h
generated/core.js.h
generated/mist.css.h
)
@ -535,13 +537,21 @@ add_custom_command(OUTPUT generated/img.js.h
COMMAND ./sourcery ${SOURCE_DIR}/embed/wrappers/img.js img_js generated/img.js.h
DEPENDS sourcery ${SOURCE_DIR}/embed/wrappers/img.js
)
add_custom_command(OUTPUT generated/playerdashlic.js.h
COMMAND ./sourcery ${SOURCE_DIR}/embed/players/dash.js.license.js playerdashlic_js generated/playerdashlic.js.h
DEPENDS sourcery ${SOURCE_DIR}/embed/players/dash.js.license.js
)
add_custom_command(OUTPUT generated/playerdash.js.h
COMMAND ./sourcery ${SOURCE_DIR}/embed/players/dash.js playerdash_js generated/playerdash.js.h
DEPENDS sourcery ${SOURCE_DIR}/embed/players/dash.js
COMMAND ./sourcery ${SOURCE_DIR}/embed/players/dash.all.min.js playerdash_js generated/playerdash.js.h
DEPENDS sourcery ${SOURCE_DIR}/embed/players/dash.all.min.js
)
add_custom_command(OUTPUT generated/playervideo.js.h
COMMAND ./sourcery ${SOURCE_DIR}/embed/players/videojs.js playervideo_js generated/playervideo.js.h
DEPENDS sourcery ${SOURCE_DIR}/embed/players/videojs.js
COMMAND ./sourcery ${SOURCE_DIR}/embed/players/video.min.js playervideo_js generated/playervideo.js.h
DEPENDS sourcery ${SOURCE_DIR}/embed/players/video.min.js
)
add_custom_command(OUTPUT generated/playerhlsvideo.js.h
COMMAND ./sourcery ${SOURCE_DIR}/embed/players/videojs-contrib-hls.min.js playerhlsvideo_js generated/playerhlsvideo.js.h
DEPENDS sourcery ${SOURCE_DIR}/embed/players/videojs-contrib-hls.min.js
)
add_custom_command(OUTPUT generated/core.js.h
COMMAND ./sourcery ${SOURCE_DIR}/embed/core.js core_js generated/core.js.h
@ -555,9 +565,9 @@ add_custom_command(OUTPUT generated/mist.css.h
########################################
# Local Settings Page #
########################################
set(lspSOURCES
${SOURCE_DIR}/lsp/plugins/jquery.js
${SOURCE_DIR}/lsp/plugins/jquery.flot.min.js
set(lspSOURCES
${SOURCE_DIR}/lsp/plugins/jquery.js
${SOURCE_DIR}/lsp/plugins/jquery.flot.min.js
${SOURCE_DIR}/lsp/plugins/jquery.flot.time.min.js
${SOURCE_DIR}/lsp/plugins/jquery.qrcode.min.js
${SOURCE_DIR}/lsp/minified.js

View file

@ -27,12 +27,12 @@ MistPlayer.prototype.sendEvent = function(type,message,target) {
return true;
}
MistPlayer.prototype.addlog = function(msg) {
this.sendEvent('log',msg,this.element);
this.sendEvent('log',msg,(this.element ? this.element: this.target));
}
MistPlayer.prototype.adderror = function(msg) {
this.sendEvent('error',msg,this.element);
this.sendEvent('error',msg,(this.element ? this.element: this.target));
}
MistPlayer.prototype.build = function () {
MistPlayer.prototype.build = function (options,callback) {
this.addlog('Error in player implementation');
var err = document.createElement('div');
var msgnode = document.createTextNode(msg);
@ -673,7 +673,12 @@ MistPlayer.prototype.askNextCombo = function(msg){
err.style.width = '100%';
err.style['margin-left'] = 0;
this.target.appendChild(err);
this.element.style.opacity = '0.2';
if (this.element) {
this.element.style.opacity = '0.2';
if (this.element.parentElement != this.target) {
err.style.position = '';
}
}
//if there is a next source/player, show a button to activate it
var opts = this.mistplaySettings.options;
@ -788,14 +793,16 @@ MistPlayer.prototype.report = function(msg) {
}
MistPlayer.prototype.unload = function(){
this.addlog('Unloading..');
if (('pause' in this) && (this.pause)) { this.pause(); }
if ('updateSrc' in this) {
this.updateSrc('');
this.element.load(); //dont use this.load() to avoid interrupting play/pause
if (this.element) {
if (('pause' in this) && (this.pause)) { this.pause(); }
if ('updateSrc' in this) {
this.updateSrc('');
this.element.load(); //dont use this.load() to avoid interrupting play/pause
}
this.element.innerHTML = '';
}
this.timer.clear();
this.target.innerHTML = '';
this.element.innerHTML = '';
};
function mistCheck(streaminfo,options,embedLog) {
@ -1187,6 +1194,142 @@ function mistPlay(streamName,options) {
}
}
function onplayerbuilt(element) {
options.target.appendChild(element);
element.setAttribute('data-player',mistPlayer);
element.setAttribute('data-mime',source.type);
player.report({
type: 'init',
info: 'Player built'
});
if (player.setTracks(false)) {
player.onready(function(){
//player.setTracks(usetracks);
if ('setTracks' in options) { player.setTracks(options.setTracks); }
});
}
//monitor for errors
element.sendPingTimeout = setInterval(function(){
if (player.paused) { return; }
player.report({
type: 'playback',
info: 'ping'
});
},150e3);
element.addEventListener('error',function(e){
player.askNextCombo('The player has thrown an error');
var r = {
type: 'playback',
error: 'The player has thrown an error'
};
if ('readyState' in player.element) {
r.readyState = player.element.readyState;
}
if ('networkState' in player.element) {
r.networkState = player.element.networkState;
}
if (('error' in player.element) && (player.element.error) && ('code' in player.element.error)) {
r.code = player.element.error.code;
}
player.report(r);
});
element.checkStalledTimeout = false;
var stalled = function(e){
if (element.checkStalledTimeout) { return; }
var curpos = player.element.currentTime;
if (curpos == 0) { return; }
element.checkStalledTimeout = player.timer.add(function(){
if ((player.paused) || (curpos != player.element.currentTime)) { return; }
player.askNextCombo('Playback has stalled');
player.report({
'type': 'playback',
'warn': 'Playback was stalled for > 30 sec'
});
},30e3);
};
element.addEventListener('stalled',stalled,true);
element.addEventListener('waiting',stalled,true);
if (playerOpts.live) {
element.checkProgressTimeout = false;
var progress = function(e){
if (element.checkStalledTimeout) {
player.timer.remove(element.checkStalledTimeout);
element.checkStalledTimeout = false;
player.cancelAskNextCombo();
}
};
//element.addEventListener('progress',progress,true); //sometimes, there is progress but no playback
element.addEventListener('playing',progress,true);
element.addEventListener('play',function(){
player.paused = false;
if ((!element.checkProgressTimeout) && (player.element) && ('currentTime' in player.element)) {
//check if the progress made is equal to the time spent
var lasttime = player.element.currentTime;
element.checkProgressTimeout = player.timer.add(function(){
var newtime = player.element.currentTime;
var progress = newtime - lasttime;
lasttime = newtime;
if (progress < 0) { return; } //its probably a looping VOD or we've just seeked
if (progress == 0) {
var msg = 'There should be playback but nothing was played';
var r = {
type: 'playback',
warn: msg
};
player.addlog(msg);
if ('readyState' in player.element) {
r.readyState = player.element.readyState;
}
if ('networkState' in player.element) {
r.networkState = player.element.networkState;
}
if (('error' in player.element) && (player.element.error) && ('code' in player.element.error)) {
r.code = player.element.error.code;
}
player.report(r);
player.askNextCombo('No playback');
return;
}
player.cancelAskNextCombo();
if (progress < 20) {
var msg = 'It seems playback is lagging (progressed '+Math.round(progress*100)/100+'/30s)'
player.addlog(msg);
player.report({
type: 'playback',
warn: msg
});
return;
}
},30e3,true);
}
},true);
element.addEventListener('pause',function(){
player.paused = true;
if (element.checkProgressTimeout) {
player.timer.remove(element.checkProgressTimeout);
element.checkProgressTimeout = false;
}
},true);
}
if (player.resize) {
//monitor for resizes and fire if needed
window.addEventListener('resize',function(){
player.resize(calcSize());
});
}
for (var i in player.onreadylist) {
player.onreadylist[i]();
}
protoplay.sendEvent('initialized','',options.target);
if (options.callback) { options.callback(player); }
}
//build the player
player.mistplaySettings = {
streamname: streamName,
@ -1198,11 +1341,10 @@ function mistPlay(streamName,options) {
};
player.options = playerOpts;
try {
var element = player.build(playerOpts);
var element = player.build(playerOpts,onplayerbuilt);
}
catch (e) {
//show the next player/reload buttons if there is an error in the player build code
options.target.appendChild(player.element);
player.askNextCombo('Error while building player: '+e.stack);
throw e;
player.report({
@ -1211,139 +1353,6 @@ function mistPlay(streamName,options) {
});
return;
}
options.target.appendChild(element);
element.setAttribute('data-player',mistPlayer);
element.setAttribute('data-mime',source.type);
player.report({
type: 'init',
info: 'Player built'
});
if (player.setTracks(false)) {
player.onready(function(){
//player.setTracks(usetracks);
if ('setTracks' in options) { player.setTracks(options.setTracks); }
});
}
//monitor for errors
element.sendPingTimeout = setInterval(function(){
if (player.paused) { return; }
player.report({
type: 'playback',
info: 'ping'
});
},150e3);
element.addEventListener('error',function(e){
player.askNextCombo('The player has thrown an error');
var r = {
type: 'playback',
error: 'The player has thrown an error'
};
if ('readyState' in player.element) {
r.readyState = player.element.readyState;
}
if ('networkState' in player.element) {
r.networkState = player.element.networkState;
}
if (('error' in player.element) && (player.element.error) && ('code' in player.element.error)) {
r.code = player.element.error.code;
}
player.report(r);
});
element.checkStalledTimeout = false;
var stalled = function(e){
if (element.checkStalledTimeout) { return; }
var curpos = player.element.currentTime;
if (curpos == 0) { return; }
element.checkStalledTimeout = player.timer.add(function(){
if ((player.paused) || (curpos != player.element.currentTime)) { return; }
player.askNextCombo('Playback has stalled');
player.report({
'type': 'playback',
'warn': 'Playback was stalled for > 30 sec'
});
},30e3);
};
element.addEventListener('stalled',stalled,true);
element.addEventListener('waiting',stalled,true);
if (playerOpts.live) {
element.checkProgressTimeout = false;
var progress = function(e){
if (element.checkStalledTimeout) {
player.timer.remove(element.checkStalledTimeout);
element.checkStalledTimeout = false;
player.cancelAskNextCombo();
}
};
//element.addEventListener('progress',progress,true); //sometimes, there is progress but no playback
element.addEventListener('playing',progress,true);
element.addEventListener('play',function(){
player.paused = false;
if ((!element.checkProgressTimeout) && (player.element) && ('currentTime' in player.element)) {
//check if the progress made is equal to the time spent
var lasttime = player.element.currentTime;
element.checkProgressTimeout = player.timer.add(function(){
var newtime = player.element.currentTime;
var progress = newtime - lasttime;
lasttime = newtime;
if (progress < 0) { return; } //its probably a looping VOD or we've just seeked
if (progress == 0) {
var msg = 'There should be playback but nothing was played';
var r = {
type: 'playback',
warn: msg
};
player.addlog(msg);
if ('readyState' in player.element) {
r.readyState = player.element.readyState;
}
if ('networkState' in player.element) {
r.networkState = player.element.networkState;
}
if (('error' in player.element) && (player.element.error) && ('code' in player.element.error)) {
r.code = player.element.error.code;
}
player.report(r);
player.askNextCombo('No playback');
return;
}
player.cancelAskNextCombo();
if (progress < 20) {
var msg = 'It seems playback is lagging (progressed '+Math.round(progress*100)/100+'/30s)'
player.addlog(msg);
player.report({
type: 'playback',
warn: msg
});
return;
}
},30e3,true);
}
},true);
element.addEventListener('pause',function(){
player.paused = true;
if (element.checkProgressTimeout) {
player.timer.remove(element.checkProgressTimeout);
element.checkProgressTimeout = false;
}
},true);
}
if (player.resize) {
//monitor for resizes and fire if needed
window.addEventListener('resize',function(){
player.resize(calcSize());
});
}
for (var i in player.onreadylist) {
player.onreadylist[i]();
}
protoplay.sendEvent('initialized','',options.target);
if (options.callback) { options.callback(player); }
}
else {
if (streaminfo.error) {

14
embed/players/dash.all.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,15 @@
/**
dash.js BSD License Agreement
The copyright in this software is being made available under the BSD License, included below. This software may be subject to other third party and contributor rights, including patent rights, and no such rights are granted under this license.
Copyright (c) 2015, Dash Industry Forum. **All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the Dash Industry Forum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ?AS IS? AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

View file

@ -1,902 +0,0 @@
<!DOCTYPE html>
<html lang="en" class=" is-copy-enabled is-u2f-enabled">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object# article: http://ogp.me/ns/article# profile: http://ogp.me/ns/profile#">
<meta charset='utf-8'>
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/frameworks-a56791f00ea569012c620526e115f9be8d519034262393f82c045116a52b0817.css" integrity="sha256-pWeR8A6laQEsYgUm4RX5vo1RkDQmI5P4LARRFqUrCBc=" media="all" rel="stylesheet" />
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github-5deed352941c0958fa4fa1d6f62607987d97095b986d6994657867ea4d843cbd.css" integrity="sha256-Xe7TUpQcCVj6T6HW9iYHmH2XCVuYbWmUZXhn6k2EPL0=" media="all" rel="stylesheet" />
<link as="script" href="https://assets-cdn.github.com/assets/frameworks-149d9338c2665172870825c78fa48fdcca4d431d067cbf5fda7120d9e39cc738.js" rel="preload" />
<link as="script" href="https://assets-cdn.github.com/assets/github-109daf4a404ee43b316c94cbb025dd5c390990eacc3b1d807ec6e1150039af02.js" rel="preload" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Language" content="en">
<meta name="viewport" content="width=device-width">
<title>dash.js/LICENSE.md at development · Dash-Industry-Forum/dash.js</title>
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub">
<link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png">
<meta property="fb:app_id" content="1401488693436528">
<meta content="https://avatars3.githubusercontent.com/u/2762280?v=3&amp;s=400" name="twitter:image:src" /><meta content="@github" name="twitter:site" /><meta content="summary" name="twitter:card" /><meta content="Dash-Industry-Forum/dash.js" name="twitter:title" /><meta content="dash.js - A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers." name="twitter:description" />
<meta content="https://avatars3.githubusercontent.com/u/2762280?v=3&amp;s=400" property="og:image" /><meta content="GitHub" property="og:site_name" /><meta content="object" property="og:type" /><meta content="Dash-Industry-Forum/dash.js" property="og:title" /><meta content="https://github.com/Dash-Industry-Forum/dash.js" property="og:url" /><meta content="dash.js - A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers." property="og:description" />
<meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats">
<meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors">
<link rel="assets" href="https://assets-cdn.github.com/">
<link rel="web-socket" href="wss://live.github.com/_sockets/Mjk4MDcwNTphZTZkYTAwNTEzNGY3MDQ0NjZiNzcwOTYwMzlmM2JmNjo3YmM0Y2RkNTYzOTVjOWZlOTUxOTM0NDU5MzNkZjM0MmIxYzhjOTk5OGY1MWZkZThjNTk3ZTg2ODljMDE3MmFl--dfbe7e220e7abcec65b5a48721918ce1ab85a3c6">
<meta name="pjax-timeout" content="1000">
<link rel="sudo-modal" href="/sessions/sudo_modal">
<meta name="msapplication-TileImage" content="/windows-tile.png">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="selected-link" value="repo_source" data-pjax-transient>
<meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU">
<meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA">
<meta name="google-analytics" content="UA-3769691-2">
<meta content="collector.githubapp.com" name="octolytics-host" /><meta content="github" name="octolytics-app-id" /><meta content="5C44947A:2B25:14702F7A:578354FD" name="octolytics-dimension-request_id" /><meta content="2980705" name="octolytics-actor-id" /><meta content="thoronwen" name="octolytics-actor-login" /><meta content="9dae7495ad90123d0cea295f73d352139e0239dc9ba7463110880f318df82c83" name="octolytics-actor-hash" />
<meta content="/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show" data-pjax-transient="true" name="analytics-location" />
<meta class="js-ga-set" name="dimension1" content="Logged In">
<meta name="hostname" content="github.com">
<meta name="user-login" content="thoronwen">
<meta name="expected-hostname" content="github.com">
<meta name="js-proxy-site-detection-payload" content="YWMzZjEyOWU1ZjQxNTA3ZTU0ODFjZjQ3N2Y1N2IxNTBiYzYyYTA5YjBjZjg3OGViYjlkZWZjN2NiZDBjZmE0OHx7InJlbW90ZV9hZGRyZXNzIjoiOTIuNjguMTQ4LjEyMiIsInJlcXVlc3RfaWQiOiI1QzQ0OTQ3QToyQjI1OjE0NzAyRjdBOjU3ODM1NEZEIiwidGltZXN0YW1wIjoxNDY4MjI0NzY2fQ==">
<link rel="mask-icon" href="https://assets-cdn.github.com/pinned-octocat.svg" color="#4078c0">
<link rel="icon" type="image/x-icon" href="https://assets-cdn.github.com/favicon.ico">
<meta name="html-safe-nonce" content="9d724374e791efca9d9e0daa13addd3144fb9062">
<meta content="e31b8b36558bb93709d07c04a8282c2434e31128" name="form-nonce" />
<meta http-equiv="x-pjax-version" content="6b9c431dbe5856e2eed898e3470e5eb3">
<meta name="description" content="dash.js - A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers.">
<meta name="go-import" content="github.com/Dash-Industry-Forum/dash.js git https://github.com/Dash-Industry-Forum/dash.js.git">
<meta content="2762280" name="octolytics-dimension-user_id" /><meta content="Dash-Industry-Forum" name="octolytics-dimension-user_login" /><meta content="6621471" name="octolytics-dimension-repository_id" /><meta content="Dash-Industry-Forum/dash.js" name="octolytics-dimension-repository_nwo" /><meta content="true" name="octolytics-dimension-repository_public" /><meta content="false" name="octolytics-dimension-repository_is_fork" /><meta content="6621471" name="octolytics-dimension-repository_network_root_id" /><meta content="Dash-Industry-Forum/dash.js" name="octolytics-dimension-repository_network_root_nwo" />
<link href="https://github.com/Dash-Industry-Forum/dash.js/commits/development.atom" rel="alternate" title="Recent Commits to dash.js:development" type="application/atom+xml">
<link rel="canonical" href="https://github.com/Dash-Industry-Forum/dash.js/blob/development/LICENSE.md" data-pjax-transient>
</head>
<body class="logged-in env-production linux vis-public page-blob">
<div id="js-pjax-loader-bar" class="pjax-loader-bar"></div>
<a href="#start-of-content" tabindex="1" class="accessibility-aid js-skip-to-content">Skip to content</a>
<div class="header header-logged-in true" role="banner">
<div class="container clearfix">
<a class="header-logo-invertocat" href="https://github.com/" data-hotkey="g d" aria-label="Homepage" data-ga-click="Header, go to dashboard, icon:logo">
<svg aria-hidden="true" class="octicon octicon-mark-github" height="28" version="1.1" viewBox="0 0 16 16" width="28"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
</a>
<div class="header-search scoped-search site-scoped-search js-site-search" role="search">
<!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="/Dash-Industry-Forum/dash.js/search" class="js-site-search-form" data-scoped-search-url="/Dash-Industry-Forum/dash.js/search" data-unscoped-search-url="/search" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div>
<label class="form-control header-search-wrapper js-chromeless-input-container">
<div class="header-search-scope">This repository</div>
<input type="text"
class="form-control header-search-input js-site-search-focus js-site-search-field is-clearable"
data-hotkey="s"
name="q"
placeholder="Search"
aria-label="Search this repository"
data-unscoped-placeholder="Search GitHub"
data-scoped-placeholder="Search"
tabindex="1"
autocapitalize="off">
</label>
</form></div>
<ul class="header-nav left" role="navigation">
<li class="header-nav-item">
<a href="/pulls" class="js-selected-navigation-item header-nav-link" data-ga-click="Header, click, Nav menu - item:pulls context:user" data-hotkey="g p" data-selected-links="/pulls /pulls/assigned /pulls/mentioned /pulls">
Pull requests
</a> </li>
<li class="header-nav-item">
<a href="/issues" class="js-selected-navigation-item header-nav-link" data-ga-click="Header, click, Nav menu - item:issues context:user" data-hotkey="g i" data-selected-links="/issues /issues/assigned /issues/mentioned /issues">
Issues
</a> </li>
<li class="header-nav-item">
<a class="header-nav-link" href="https://gist.github.com/" data-ga-click="Header, go to gist, text:gist">Gist</a>
</li>
</ul>
<ul class="header-nav user-nav right" id="user-links">
<li class="header-nav-item">
<a href="/notifications" aria-label="You have unread notifications" class="header-nav-link notification-indicator tooltipped tooltipped-s js-socket-channel js-notification-indicator" data-channel="tenant:1:notification-changed:2980705" data-ga-click="Header, go to notifications, icon:unread" data-hotkey="g n">
<span class="mail-status unread"></span>
<svg aria-hidden="true" class="octicon octicon-bell" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M14 12v1H0v-1l.73-.58c.77-.77.81-2.55 1.19-4.42C2.69 3.23 6 2 6 2c0-.55.45-1 1-1s1 .45 1 1c0 0 3.39 1.23 4.16 5 .38 1.88.42 3.66 1.19 4.42l.66.58H14zm-7 4c1.11 0 2-.89 2-2H5c0 1.11.89 2 2 2z"></path></svg>
</a>
</li>
<li class="header-nav-item dropdown js-menu-container">
<a class="header-nav-link tooltipped tooltipped-s js-menu-target" href="/new"
aria-label="Create new…"
data-ga-click="Header, create new, icon:add">
<svg aria-hidden="true" class="octicon octicon-plus left" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 9H7v5H5V9H0V7h5V2h2v5h5z"></path></svg>
<span class="dropdown-caret"></span>
</a>
<div class="dropdown-menu-content js-menu-content">
<ul class="dropdown-menu dropdown-menu-sw">
<a class="dropdown-item" href="/new" data-ga-click="Header, create new repository">
New repository
</a>
<a class="dropdown-item" href="/new/import" data-ga-click="Header, import a repository">
Import repository
</a>
<a class="dropdown-item" href="/organizations/new" data-ga-click="Header, create new organization">
New organization
</a>
<div class="dropdown-divider"></div>
<div class="dropdown-header">
<span title="Dash-Industry-Forum/dash.js">This repository</span>
</div>
<a class="dropdown-item" href="/Dash-Industry-Forum/dash.js/issues/new" data-ga-click="Header, create new issue">
New issue
</a>
</ul>
</div>
</li>
<li class="header-nav-item dropdown js-menu-container">
<a class="header-nav-link name tooltipped tooltipped-sw js-menu-target" href="/thoronwen"
aria-label="View profile and more"
data-ga-click="Header, show menu, icon:avatar">
<img alt="@thoronwen" class="avatar" height="20" src="https://avatars2.githubusercontent.com/u/2980705?v=3&amp;s=40" width="20" />
<span class="dropdown-caret"></span>
</a>
<div class="dropdown-menu-content js-menu-content">
<div class="dropdown-menu dropdown-menu-sw">
<div class="dropdown-header header-nav-current-user css-truncate">
Signed in as <strong class="css-truncate-target">thoronwen</strong>
</div>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/thoronwen" data-ga-click="Header, go to profile, text:your profile">
Your profile
</a>
<a class="dropdown-item" href="/stars" data-ga-click="Header, go to starred repos, text:your stars">
Your stars
</a>
<a class="dropdown-item" href="/explore" data-ga-click="Header, go to explore, text:explore">
Explore
</a>
<a class="dropdown-item" href="/integrations" data-ga-click="Header, go to integrations, text:integrations">
Integrations
</a>
<a class="dropdown-item" href="https://help.github.com" data-ga-click="Header, go to help, text:help">
Help
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/settings/profile" data-ga-click="Header, go to settings, icon:settings">
Settings
</a>
<!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="/logout" class="logout-form" data-form-nonce="e31b8b36558bb93709d07c04a8282c2434e31128" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="HnZks7yM48r7+We6aFWR9F8uqBnEZDm3239GCmMBDhcgJcKQjTfjY4EynwssOH/JX19SG5CDKQN/UkpbkNpwgw==" /></div>
<button class="dropdown-item dropdown-signout" data-ga-click="Header, sign out, icon:logout">
Sign out
</button>
</form> </div>
</div>
</li>
</ul>
</div>
</div>
<div id="start-of-content" class="accessibility-aid"></div>
<div id="js-flash-container">
</div>
<div role="main" class="main-content">
<div itemscope itemtype="http://schema.org/SoftwareSourceCode">
<div id="js-repo-pjax-container" data-pjax-container>
<div class="pagehead repohead instapaper_ignore readability-menu experiment-repo-nav">
<div class="container repohead-details-container">
<ul class="pagehead-actions">
<li>
<!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="/notifications/subscribe" class="js-social-container" data-autosubmit="true" data-form-nonce="e31b8b36558bb93709d07c04a8282c2434e31128" data-remote="true" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="dyaT7hDPcpgNqbi0PGF35WwGx6Yrti4is82pVLEuH8kHuMSxLn+Q/C4PUT4i2/1V5VOOiQsPC0Qv64zDYBMwEQ==" /></div> <input class="form-control" id="repository_id" name="repository_id" type="hidden" value="6621471" />
<div class="select-menu js-menu-container js-select-menu">
<a href="/Dash-Industry-Forum/dash.js/subscription"
class="btn btn-sm btn-with-count select-menu-button js-menu-target" role="button" tabindex="0" aria-haspopup="true"
data-ga-click="Repository, click Watch settings, action:blob#show">
<span class="js-select-button">
<svg aria-hidden="true" class="octicon octicon-eye" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"></path></svg>
Watch
</span>
</a>
<a class="social-count js-social-count" href="/Dash-Industry-Forum/dash.js/watchers">
206
</a>
<div class="select-menu-modal-holder">
<div class="select-menu-modal subscription-menu-modal js-menu-content" aria-hidden="true">
<div class="select-menu-header js-navigation-enable" tabindex="-1">
<svg aria-label="Close" class="octicon octicon-x js-menu-close" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg>
<span class="select-menu-title">Notifications</span>
</div>
<div class="select-menu-list js-navigation-container" role="menu">
<div class="select-menu-item js-navigation-item selected" role="menuitem" tabindex="0">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<div class="select-menu-item-text">
<input checked="checked" id="do_included" name="do" type="radio" value="included" />
<span class="select-menu-item-heading">Not watching</span>
<span class="description">Be notified when participating or @mentioned.</span>
<span class="js-select-button-text hidden-select-button-text">
<svg aria-hidden="true" class="octicon octicon-eye" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"></path></svg>
Watch
</span>
</div>
</div>
<div class="select-menu-item js-navigation-item " role="menuitem" tabindex="0">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<div class="select-menu-item-text">
<input id="do_subscribed" name="do" type="radio" value="subscribed" />
<span class="select-menu-item-heading">Watching</span>
<span class="description">Be notified of all conversations.</span>
<span class="js-select-button-text hidden-select-button-text">
<svg aria-hidden="true" class="octicon octicon-eye" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"></path></svg>
Unwatch
</span>
</div>
</div>
<div class="select-menu-item js-navigation-item " role="menuitem" tabindex="0">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<div class="select-menu-item-text">
<input id="do_ignore" name="do" type="radio" value="ignore" />
<span class="select-menu-item-heading">Ignoring</span>
<span class="description">Never be notified.</span>
<span class="js-select-button-text hidden-select-button-text">
<svg aria-hidden="true" class="octicon octicon-mute" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8 2.81v10.38c0 .67-.81 1-1.28.53L3 10H1c-.55 0-1-.45-1-1V7c0-.55.45-1 1-1h2l3.72-3.72C7.19 1.81 8 2.14 8 2.81zm7.53 3.22l-1.06-1.06-1.97 1.97-1.97-1.97-1.06 1.06L11.44 8 9.47 9.97l1.06 1.06 1.97-1.97 1.97 1.97 1.06-1.06L13.56 8l1.97-1.97z"></path></svg>
Stop ignoring
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</li>
<li>
<div class="js-toggler-container js-social-container starring-container ">
<!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="/Dash-Industry-Forum/dash.js/unstar" class="starred" data-form-nonce="e31b8b36558bb93709d07c04a8282c2434e31128" data-remote="true" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="b6D5S9lSA12ygF/oSCL24/lYMn/Q84qaiAIBEaufxBoCI1j8EdPKP25z+NWHRY7lhEmg8+R6kcj+X07nayVX3A==" /></div>
<button
class="btn btn-sm btn-with-count js-toggler-target"
aria-label="Unstar this repository" title="Unstar Dash-Industry-Forum/dash.js"
data-ga-click="Repository, click unstar button, action:blob#show; text:Unstar">
<svg aria-hidden="true" class="octicon octicon-star" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74z"></path></svg>
Unstar
</button>
<a class="social-count js-social-count" href="/Dash-Industry-Forum/dash.js/stargazers">
1,253
</a>
</form>
<!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="/Dash-Industry-Forum/dash.js/star" class="unstarred" data-form-nonce="e31b8b36558bb93709d07c04a8282c2434e31128" data-remote="true" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="Y7mapw0zGwQxg3i6cCOK5gmYQnzvckuzkx935P6UWnb9R/BCrVuk+Uf9BkvXj+lz5ksTA4y88uKm+lwMtRGl9A==" /></div>
<button
class="btn btn-sm btn-with-count js-toggler-target"
aria-label="Star this repository" title="Star Dash-Industry-Forum/dash.js"
data-ga-click="Repository, click star button, action:blob#show; text:Star">
<svg aria-hidden="true" class="octicon octicon-star" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74z"></path></svg>
Star
</button>
<a class="social-count js-social-count" href="/Dash-Industry-Forum/dash.js/stargazers">
1,253
</a>
</form> </div>
</li>
<li>
<a href="#fork-destination-box" class="btn btn-sm btn-with-count"
title="Fork your own copy of Dash-Industry-Forum/dash.js to your account"
aria-label="Fork your own copy of Dash-Industry-Forum/dash.js to your account"
rel="facebox"
data-ga-click="Repository, show fork modal, action:blob#show; text:Fork">
<svg aria-hidden="true" class="octicon octicon-repo-forked" height="16" version="1.1" viewBox="0 0 10 16" width="10"><path d="M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
Fork
</a>
<div id="fork-destination-box" style="display: none;">
<h2 class="facebox-header" data-facebox-id="facebox-header">Where should we fork this repository?</h2>
<include-fragment src=""
class="js-fork-select-fragment fork-select-fragment"
data-url="/Dash-Industry-Forum/dash.js/fork?fragment=1">
<img alt="Loading" height="64" src="https://assets-cdn.github.com/images/spinners/octocat-spinner-128.gif" width="64" />
</include-fragment>
</div>
<a href="/Dash-Industry-Forum/dash.js/network" class="social-count">
589
</a>
</li>
</ul>
<h1 class="public ">
<svg aria-hidden="true" class="octicon octicon-repo" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg>
<span class="author" itemprop="author"><a href="/Dash-Industry-Forum" class="url fn" rel="author">Dash-Industry-Forum</a></span><!--
--><span class="path-divider">/</span><!--
--><strong itemprop="name"><a href="/Dash-Industry-Forum/dash.js" data-pjax="#js-repo-pjax-container">dash.js</a></strong>
</h1>
</div>
<div class="container">
<nav class="reponav js-repo-nav js-sidenav-container-pjax"
itemscope
itemtype="http://schema.org/BreadcrumbList"
role="navigation"
data-pjax="#js-repo-pjax-container">
<span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
<a href="/Dash-Industry-Forum/dash.js" aria-selected="true" class="js-selected-navigation-item selected reponav-item" data-hotkey="g c" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches /Dash-Industry-Forum/dash.js" itemprop="url">
<svg aria-hidden="true" class="octicon octicon-code" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"></path></svg>
<span itemprop="name">Code</span>
<meta itemprop="position" content="1">
</a> </span>
<span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
<a href="/Dash-Industry-Forum/dash.js/issues" class="js-selected-navigation-item reponav-item" data-hotkey="g i" data-selected-links="repo_issues repo_labels repo_milestones /Dash-Industry-Forum/dash.js/issues" itemprop="url">
<svg aria-hidden="true" class="octicon octicon-issue-opened" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
<span itemprop="name">Issues</span>
<span class="counter">122</span>
<meta itemprop="position" content="2">
</a> </span>
<span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
<a href="/Dash-Industry-Forum/dash.js/pulls" class="js-selected-navigation-item reponav-item" data-hotkey="g p" data-selected-links="repo_pulls /Dash-Industry-Forum/dash.js/pulls" itemprop="url">
<svg aria-hidden="true" class="octicon octicon-git-pull-request" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
<span itemprop="name">Pull requests</span>
<span class="counter">3</span>
<meta itemprop="position" content="3">
</a> </span>
<a href="/Dash-Industry-Forum/dash.js/wiki" class="js-selected-navigation-item reponav-item" data-hotkey="g w" data-selected-links="repo_wiki /Dash-Industry-Forum/dash.js/wiki">
<svg aria-hidden="true" class="octicon octicon-book" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M3 5h4v1H3V5zm0 3h4V7H3v1zm0 2h4V9H3v1zm11-5h-4v1h4V5zm0 2h-4v1h4V7zm0 2h-4v1h4V9zm2-6v9c0 .55-.45 1-1 1H9.5l-1 1-1-1H2c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h5.5l1 1 1-1H15c.55 0 1 .45 1 1zm-8 .5L7.5 3H2v9h6V3.5zm7-.5H9.5l-.5.5V12h6V3z"></path></svg>
Wiki
</a>
<a href="/Dash-Industry-Forum/dash.js/pulse" class="js-selected-navigation-item reponav-item" data-selected-links="pulse /Dash-Industry-Forum/dash.js/pulse">
<svg aria-hidden="true" class="octicon octicon-pulse" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M11.5 8L8.8 5.4 6.6 8.5 5.5 1.6 2.38 8H0v2h3.6l.9-1.8.9 5.4L9 8.5l1.6 1.5H14V8z"></path></svg>
Pulse
</a>
<a href="/Dash-Industry-Forum/dash.js/graphs" class="js-selected-navigation-item reponav-item" data-selected-links="repo_graphs repo_contributors /Dash-Industry-Forum/dash.js/graphs">
<svg aria-hidden="true" class="octicon octicon-graph" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M16 14v1H0V0h1v14h15zM5 13H3V8h2v5zm4 0H7V3h2v10zm4 0h-2V6h2v7z"></path></svg>
Graphs
</a>
</nav>
</div>
</div>
<div class="container new-discussion-timeline experiment-repo-nav">
<div class="repository-content">
<a href="/Dash-Industry-Forum/dash.js/blob/7a65bce3dc97c003dbe64012a7f567bb57c2f4b7/LICENSE.md" class="hidden js-permalink-shortcut" data-hotkey="y">Permalink</a>
<!-- blob contrib key: blob_contributors:v21:764190169e735619c08db6ec1167107a -->
<div class="file-navigation js-zeroclipboard-container">
<div class="select-menu branch-select-menu js-menu-container js-select-menu left">
<button class="btn btn-sm select-menu-button js-menu-target css-truncate" data-hotkey="w"
title="development"
type="button" aria-label="Switch branches or tags" tabindex="0" aria-haspopup="true">
<i>Branch:</i>
<span class="js-select-button css-truncate-target">development</span>
</button>
<div class="select-menu-modal-holder js-menu-content js-navigation-container" data-pjax aria-hidden="true">
<div class="select-menu-modal">
<div class="select-menu-header">
<svg aria-label="Close" class="octicon octicon-x js-menu-close" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg>
<span class="select-menu-title">Switch branches/tags</span>
</div>
<div class="select-menu-filters">
<div class="select-menu-text-filter">
<input type="text" aria-label="Filter branches/tags" id="context-commitish-filter-field" class="form-control js-filterable-field js-navigation-enable" placeholder="Filter branches/tags">
</div>
<div class="select-menu-tabs">
<ul>
<li class="select-menu-tab">
<a href="#" data-tab-filter="branches" data-filter-placeholder="Filter branches/tags" class="js-select-menu-tab" role="tab">Branches</a>
</li>
<li class="select-menu-tab">
<a href="#" data-tab-filter="tags" data-filter-placeholder="Find a tag…" class="js-select-menu-tab" role="tab">Tags</a>
</li>
</ul>
</div>
</div>
<div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="branches" role="menu">
<div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring">
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/blob/Public_Release_v1.6.0/LICENSE.md"
data-name="Public_Release_v1.6.0"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target js-select-menu-filter-text" title="Public_Release_v1.6.0">
Public_Release_v1.6.0
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open selected"
href="/Dash-Industry-Forum/dash.js/blob/development/LICENSE.md"
data-name="development"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target js-select-menu-filter-text" title="development">
development
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/blob/gh-pages/LICENSE.md"
data-name="gh-pages"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target js-select-menu-filter-text" title="gh-pages">
gh-pages
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/blob/master/LICENSE.md"
data-name="master"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target js-select-menu-filter-text" title="master">
master
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/blob/revert-1387-fix-1362/LICENSE.md"
data-name="revert-1387-fix-1362"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target js-select-menu-filter-text" title="revert-1387-fix-1362">
revert-1387-fix-1362
</span>
</a>
</div>
<div class="select-menu-no-results">Nothing to show</div>
</div>
<div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="tags">
<div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring">
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v2.2.0/LICENSE.md"
data-name="v2.2.0"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v2.2.0">
v2.2.0
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v2.1.1/LICENSE.md"
data-name="v2.1.1"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v2.1.1">
v2.1.1
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v2.1.0/LICENSE.md"
data-name="v2.1.0"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v2.1.0">
v2.1.0
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v2.0.0/LICENSE.md"
data-name="v2.0.0"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v2.0.0">
v2.0.0
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v1.6.0/LICENSE.md"
data-name="v1.6.0"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v1.6.0">
v1.6.0
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v1.5.1/LICENSE.md"
data-name="v1.5.1"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v1.5.1">
v1.5.1
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v1.5.0/LICENSE.md"
data-name="v1.5.0"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v1.5.0">
v1.5.0
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v1.4/LICENSE.md"
data-name="v1.4"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v1.4">
v1.4
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v1.3.0/LICENSE.md"
data-name="v1.3.0"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v1.3.0">
v1.3.0
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v1.2.0/LICENSE.md"
data-name="v1.2.0"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v1.2.0">
v1.2.0
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v1.1.2/LICENSE.md"
data-name="v1.1.2"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v1.1.2">
v1.1.2
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/v0.2.4/LICENSE.md"
data-name="v0.2.4"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="v0.2.4">
v0.2.4
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/V0.1/LICENSE.md"
data-name="V0.1"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="V0.1">
V0.1
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/1.0.0/LICENSE.md"
data-name="1.0.0"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="1.0.0">
1.0.0
</span>
</a>
<a class="select-menu-item js-navigation-item js-navigation-open "
href="/Dash-Industry-Forum/dash.js/tree/0.2.5/LICENSE.md"
data-name="0.2.5"
data-skip-pjax="true"
rel="nofollow">
<svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
<span class="select-menu-item-text css-truncate-target" title="0.2.5">
0.2.5
</span>
</a>
</div>
<div class="select-menu-no-results">Nothing to show</div>
</div>
</div>
</div>
</div>
<div class="btn-group right">
<a href="/Dash-Industry-Forum/dash.js/find/development"
class="js-pjax-capture-input btn btn-sm"
data-pjax
data-hotkey="t">
Find file
</a>
<button aria-label="Copy file path to clipboard" class="js-zeroclipboard btn btn-sm zeroclipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="button">Copy path</button>
</div>
<div class="breadcrumb js-zeroclipboard-target">
<span class="repo-root js-repo-root"><span class="js-path-segment"><a href="/Dash-Industry-Forum/dash.js"><span>dash.js</span></a></span></span><span class="separator">/</span><strong class="final-path">LICENSE.md</strong>
</div>
</div>
<div class="commit-tease">
<span class="right">
<a class="commit-tease-sha" href="/Dash-Industry-Forum/dash.js/commit/e01ae7f9363253c2d29d8d636c92c338bd1c450b" data-pjax>
e01ae7f
</a>
<relative-time datetime="2015-01-20T19:38:53Z">Jan 20, 2015</relative-time>
</span>
<div>
<img alt="@AkamaiDASH" class="avatar" height="20" src="https://avatars0.githubusercontent.com/u/7864462?v=3&amp;s=40" width="20" />
<a href="/AkamaiDASH" class="user-mention" rel="contributor">AkamaiDASH</a>
<a href="/Dash-Industry-Forum/dash.js/commit/e01ae7f9363253c2d29d8d636c92c338bd1c450b" class="message" data-pjax="true" title="modified license.md">modified license.md</a>
</div>
<div class="commit-tease-contributors">
<button type="button" class="btn-link muted-link contributors-toggle" data-facebox="#blob_contributors_box">
<strong>1</strong>
contributor
</button>
</div>
<div id="blob_contributors_box" style="display:none">
<h2 class="facebox-header" data-facebox-id="facebox-header">Users who have contributed to this file</h2>
<ul class="facebox-user-list" data-facebox-id="facebox-description">
<li class="facebox-user-list-item">
<img alt="@AkamaiDASH" height="24" src="https://avatars2.githubusercontent.com/u/7864462?v=3&amp;s=48" width="24" />
<a href="/AkamaiDASH">AkamaiDASH</a>
</li>
</ul>
</div>
</div>
<div class="file">
<div class="file-header">
<div class="file-actions">
<div class="btn-group">
<a href="/Dash-Industry-Forum/dash.js/raw/development/LICENSE.md" class="btn btn-sm " id="raw-url">Raw</a>
<a href="/Dash-Industry-Forum/dash.js/blame/development/LICENSE.md" class="btn btn-sm js-update-url-with-hash">Blame</a>
<a href="/Dash-Industry-Forum/dash.js/commits/development/LICENSE.md" class="btn btn-sm " rel="nofollow">History</a>
</div>
<!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="/Dash-Industry-Forum/dash.js/edit/development/LICENSE.md" class="inline-form js-update-url-with-hash" data-form-nonce="e31b8b36558bb93709d07c04a8282c2434e31128" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="rQy0aX/nhsMc/AQdK4Yc2vaT+cM+NWUCjNBPQkgI/D9N30aZ8bC02XdjhGWmRtcbGYw21KgsASThCoRWvhYdPg==" /></div>
<button class="btn-octicon tooltipped tooltipped-nw" type="submit"
aria-label="Fork this project and edit the file" data-hotkey="e" data-disable-with>
<svg aria-hidden="true" class="octicon octicon-pencil" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M0 12v3h3l8-8-3-3-8 8zm3 2H1v-2h1v1h1v1zm10.3-9.3L12 6 9 3l1.3-1.3a.996.996 0 0 1 1.41 0l1.59 1.59c.39.39.39 1.02 0 1.41z"></path></svg>
</button>
</form> <!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="/Dash-Industry-Forum/dash.js/delete/development/LICENSE.md" class="inline-form" data-form-nonce="e31b8b36558bb93709d07c04a8282c2434e31128" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="pxfnBgN4PKYQqT0ZX3hy9FUxDAvLC4d4dNerfRk0zPIdAb0beNMQpFuhdlLBqhrdHMSy9IYnQmg02N0MSVigtg==" /></div>
<button class="btn-octicon btn-octicon-danger tooltipped tooltipped-nw" type="submit"
aria-label="Fork this project and delete the file" data-disable-with>
<svg aria-hidden="true" class="octicon octicon-trashcan" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M11 2H9c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 12H3V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9zm1-10H2V3h9v1z"></path></svg>
</button>
</form> </div>
<div class="file-info">
14 lines (9 sloc)
<span class="file-info-divider"></span>
1.74 KB
</div>
</div>
<div id="readme" class="readme blob instapaper_body">
<article class="markdown-body entry-content" itemprop="text"><h1><a id="user-content-dashjs-bsd-license-agreement" class="anchor" href="#dashjs-bsd-license-agreement" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>dash.js BSD License Agreement</h1>
<p>The copyright in this software is being made available under the BSD License, included below. This software may be subject to other third party and contributor rights, including patent rights, and no such rights are granted under this license.</p>
<p><strong>Copyright (c) 2015, Dash Industry Forum.
**All rights reserved.</strong></p>
<ul>
<li>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</li>
<li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li>
<li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li>
<li>Neither the name of the Dash Industry Forum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.</li>
</ul>
<p><strong>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</strong></p>
</article>
</div>
</div>
<button type="button" data-facebox="#jump-to-line" data-facebox-class="linejump" data-hotkey="l" class="hidden">Jump to Line</button>
<div id="jump-to-line" style="display:none">
<!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="" class="js-jump-to-line-form" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div>
<input class="form-control linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line&hellip;" aria-label="Jump to line" autofocus>
<button type="submit" class="btn">Go</button>
</form></div>
</div>
<div class="modal-backdrop js-touch-events"></div>
</div>
</div>
</div>
</div>
<div class="container site-footer-container">
<div class="site-footer" role="contentinfo">
<ul class="site-footer-links right">
<li><a href="https://status.github.com/" data-ga-click="Footer, go to status, text:status">Status</a></li>
<li><a href="https://developer.github.com" data-ga-click="Footer, go to api, text:api">API</a></li>
<li><a href="https://training.github.com" data-ga-click="Footer, go to training, text:training">Training</a></li>
<li><a href="https://shop.github.com" data-ga-click="Footer, go to shop, text:shop">Shop</a></li>
<li><a href="https://github.com/blog" data-ga-click="Footer, go to blog, text:blog">Blog</a></li>
<li><a href="https://github.com/about" data-ga-click="Footer, go to about, text:about">About</a></li>
</ul>
<a href="https://github.com" aria-label="Homepage" class="site-footer-mark" title="GitHub">
<svg aria-hidden="true" class="octicon octicon-mark-github" height="24" version="1.1" viewBox="0 0 16 16" width="24"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
</a>
<ul class="site-footer-links">
<li>&copy; 2016 <span title="0.12132s from github-fe157-cp1-prd.iad.github.net">GitHub</span>, Inc.</li>
<li><a href="https://github.com/site/terms" data-ga-click="Footer, go to terms, text:terms">Terms</a></li>
<li><a href="https://github.com/site/privacy" data-ga-click="Footer, go to privacy, text:privacy">Privacy</a></li>
<li><a href="https://github.com/security" data-ga-click="Footer, go to security, text:security">Security</a></li>
<li><a href="https://github.com/contact" data-ga-click="Footer, go to contact, text:contact">Contact</a></li>
<li><a href="https://help.github.com" data-ga-click="Footer, go to help, text:help">Help</a></li>
</ul>
</div>
</div>
<div id="ajax-error-message" class="ajax-error-message flash flash-error">
<svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"></path></svg>
<button type="button" class="flash-close js-flash-close js-ajax-error-dismiss" aria-label="Dismiss error">
<svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg>
</button>
Something went wrong with that request. Please try again.
</div>
<script crossorigin="anonymous" integrity="sha256-FJ2TOMJmUXKHCCXHj6SP3MpNQx0GfL9f2nEg2eOcxzg=" src="https://assets-cdn.github.com/assets/frameworks-149d9338c2665172870825c78fa48fdcca4d431d067cbf5fda7120d9e39cc738.js"></script>
<script async="async" crossorigin="anonymous" integrity="sha256-EJ2vSkBO5DsxbJTLsCXdXDkJkOrMOx2AfsbhFQA5rwI=" src="https://assets-cdn.github.com/assets/github-109daf4a404ee43b316c94cbb025dd5c390990eacc3b1d807ec6e1150039af02.js"></script>
<div class="js-stale-session-flash stale-session-flash flash flash-warn flash-banner hidden">
<svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"></path></svg>
<span class="signed-in-tab-flash">You signed in with another tab or window. <a href="">Reload</a> to refresh your session.</span>
<span class="signed-out-tab-flash">You signed out in another tab or window. <a href="">Reload</a> to refresh your session.</span>
</div>
<div class="facebox" id="facebox" style="display:none;">
<div class="facebox-popup">
<div class="facebox-content" role="dialog" aria-labelledby="facebox-header" aria-describedby="facebox-description">
</div>
<button type="button" class="facebox-close js-facebox-close" aria-label="Close modal">
<svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg>
</button>
</div>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
mistplayers.dashjs = {
name: 'Dash.js Player',
version: '1.1',
version: '1.2',
mimes: ['dash/video/mp4'],
priority: Object.keys(mistplayers).length + 1,
isMimeSupported: function (mimetype) {
@ -8,7 +8,7 @@ mistplayers.dashjs = {
},
isBrowserSupported: function (mimetype,source,options) {
if ((options.host.substr(0,7) == 'http://') && (source.url.substr(0,8) == 'https://')) { return false; }
return (('dashjs' in window) && ('MediaSource' in window) && (location.protocol != 'file:'));
return (('MediaSource' in window) && (location.protocol != 'file:'));
},
player: function(){}
};
@ -19,93 +19,113 @@ p.prototype.build = function (options,callback) {
cont.className = 'mistplayer';
var me = this;
var ele = this.getElement('video');
ele.className = '';
cont.appendChild(ele);
ele.width = options.width;
ele.height = options.height;
if (options.autoplay) {
ele.setAttribute('autoplay','');
}
if (options.loop) {
ele.setAttribute('loop','');
}
if (options.poster) {
ele.setAttribute('poster',options.poster);
}
if (options.controls) {
if (options.controls == 'stock') {
ele.setAttribute('controls','');
function onplayerload () {
var ele = me.getElement('video');
ele.className = '';
cont.appendChild(ele);
ele.width = options.width;
ele.height = options.height;
if (options.autoplay) {
ele.setAttribute('autoplay','');
}
else {
this.buildMistControls();
if (options.loop) {
ele.setAttribute('loop','');
}
}
ele.addEventListener('error',function(e){
var msg;
if ('message' in e) {
msg = e.message;
if (options.poster) {
ele.setAttribute('poster',options.poster);
}
else {
msg = 'readyState: ';
switch (me.element.readyState) {
case 0:
msg += 'HAVE_NOTHING';
break;
case 1:
msg += 'HAVE_METADATA';
break;
case 2:
msg += 'HAVE_CURRENT_DATA';
break;
case 3:
msg += 'HAVE_FUTURE_DATA';
break;
case 4:
msg += 'HAVE_ENOUGH_DATA';
break;
if (options.controls) {
if (options.controls == 'stock') {
ele.setAttribute('controls','');
}
msg += ' networkState: ';
switch (me.element.networkState) {
case 0:
msg += 'NETWORK_EMPTY';
break;
case 1:
msg += 'NETWORK_IDLE';
break;
case 2:
msg += 'NETWORK_LOADING';
break;
case 3:
msg += 'NETWORK_NO_SOURCE';
break;
else {
me.buildMistControls();
}
}
//prevent onerror loops
if (e.target == me.element) {
e.message = msg;
}
else {
me.adderror(msg);
}
});
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting'];
for (var i in events) {
ele.addEventListener(events[i],function(e){
me.addlog('Player event fired: '+e.type);
ele.addEventListener('error',function(e){
var msg;
if ('message' in e) {
msg = e.message;
}
else {
msg = 'readyState: ';
switch (me.element.readyState) {
case 0:
msg += 'HAVE_NOTHING';
break;
case 1:
msg += 'HAVE_METADATA';
break;
case 2:
msg += 'HAVE_CURRENT_DATA';
break;
case 3:
msg += 'HAVE_FUTURE_DATA';
break;
case 4:
msg += 'HAVE_ENOUGH_DATA';
break;
}
msg += ' networkState: ';
switch (me.element.networkState) {
case 0:
msg += 'NETWORK_EMPTY';
break;
case 1:
msg += 'NETWORK_IDLE';
break;
case 2:
msg += 'NETWORK_LOADING';
break;
case 3:
msg += 'NETWORK_NO_SOURCE';
break;
}
}
//prevent onerror loops
if (e.target == me.element) {
e.message = msg;
}
else {
me.adderror(msg);
}
});
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting'];
for (var i in events) {
ele.addEventListener(events[i],function(e){
me.addlog('Player event fired: '+e.type);
});
}
var player = dashjs.MediaPlayer().create();
player.getDebug().setLogToBrowserConsole(false);
player.initialize(ele,options.src,true);
me.dash = player;
me.src = options.src;
me.addlog('Built html');
callback(cont);
}
var player = dashjs.MediaPlayer().create();
player.getDebug().setLogToBrowserConsole(false);
player.initialize(ele,options.src,true);
this.dash = player;
this.src = options.src;
this.addlog('Built html');
return cont;
if ('dash' in window) {
onplayerload();
}
else {
//load the dashjs player
var scripttag = document.createElement('script');
scripttag.src = options.host+'/dashjs.js';
me.addlog('Retrieving dashjs player code from '+scripttag.src);
document.head.appendChild(scripttag);
scripttag.onerror = function(){
me.askNextCombo('Failed to load dashjs.js');
}
scripttag.onload = function(){
onplayerload();
}
}
}
p.prototype.play = function(){ return this.element.play(); };
p.prototype.pause = function(){ return this.element.pause(); };

View file

@ -1,6 +1,6 @@
mistplayers.flash_strobe = {
name: 'Strobe Flash Media Playback',
version: '1.0',
version: '1.1',
mimes: ['flash/10','flash/11','flash/7'],
priority: Object.keys(mistplayers).length + 1,
isMimeSupported: function (mimetype) {
@ -28,7 +28,7 @@ mistplayers.flash_strobe = {
};
var p = mistplayers.flash_strobe.player;
p.prototype = new MistPlayer();
p.prototype.build = function (options) {
p.prototype.build = function (options,callback) {
function createParam(name,value) {
var p = document.createElement('param');
p.setAttribute('name',name);
@ -62,5 +62,5 @@ p.prototype.build = function (options) {
this.addlog('Built html');
return ele;
callback(ele);
}

View file

@ -1,6 +1,6 @@
mistplayers.html5 = {
name: 'HTML5 video player',
version: '1.0',
version: '1.1',
mimes: ['html5/application/vnd.apple.mpegurl','html5/video/mp4','html5/video/ogg','html5/video/webm','html5/audio/mp3','html5/audio/webm','html5/audio/ogg','html5/audio/wav'],
priority: Object.keys(mistplayers).length + 1,
isMimeSupported: function (mimetype) {
@ -32,7 +32,7 @@ mistplayers.html5 = {
};
var p = mistplayers.html5.player;
p.prototype = new MistPlayer();
p.prototype.build = function (options) {
p.prototype.build = function (options,callback) {
var cont = document.createElement('div');
cont.className = 'mistplayer';
var me = this; //to allow nested functions to access the player class itself
@ -43,7 +43,11 @@ p.prototype.build = function (options) {
var ele = this.getElement((shortmime[0] == 'audio' ? 'audio' : 'video'));
ele.className = '';
cont.appendChild(ele);
ele.crossOrigin = 'anonymous'; //required for subtitles
if (options.source.type != "html5/video/ogg") {
ele.crossOrigin = 'anonymous'; //required for subtitles, but if ogg, the video won't load
}
if (shortmime[0] == 'audio') {
this.setTracks = function() { return false; }
this.fullscreen = false;
@ -100,6 +104,7 @@ p.prototype.build = function (options) {
//forward events
ele.addEventListener('error',function(e){
if (!e.isTrusted) { return; } //don't trigger on errors we have thrown ourselves
if (options.live) {
if ((ele.error) && (ele.error.code == 3)) {
@ -160,13 +165,8 @@ p.prototype.build = function (options) {
break;
}
}
//prevent onerror loops
if (e.target == me.element) {
e.message = msg;
}
else {
me.adderror(msg);
}
me.adderror(msg);
});
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting','progress'];
for (var i in events) {
@ -174,7 +174,7 @@ p.prototype.build = function (options) {
me.addlog('Player event fired: '+e.type);
});
}
return cont;
callback(cont);
}
p.prototype.play = function(){ return this.element.play(); };
p.prototype.pause = function(){ return this.element.pause(); };

View file

@ -1,6 +1,6 @@
mistplayers.img = {
name: 'HTML img tag',
version: '1.0',
version: '1.1',
mimes: ['html5/image/jpeg'],
priority: Object.keys(mistplayers).length + 1,
isMimeSupported: function (mimetype) {
@ -15,9 +15,9 @@ mistplayers.img = {
};
var p = mistplayers.img.player;
p.prototype = new MistPlayer();
p.prototype.build = function (options) {
p.prototype.build = function (options,callback) {
var ele = this.getElement('img');
ele.src = options.src;
ele.style.display = 'block';
return ele;
callback(ele);
}

View file

@ -1,6 +1,6 @@
mistplayers.jwplayer = {
name: 'JWPlayer',
version: '0.1',
version: '0.2',
mimes: ['html5/video/mp4','html5/video/webm','dash/video/mp4','flash/10','flash/7','html5/application/vnd.apple.mpegurl','html5/audio/mp3','html5/audio/aac'],
priority: Object.keys(mistplayers).length + 1,
isMimeSupported: function (mimetype) {
@ -17,7 +17,7 @@ mistplayers.jwplayer = {
};
var p = mistplayers.jwplayer.player;
p.prototype = new MistPlayer();
p.prototype.build = function (options) {
p.prototype.build = function (options,callback) {
var ele = this.getElement('div');
this.jw = jwplayer(ele).setup({
@ -30,7 +30,7 @@ p.prototype.build = function (options) {
});
this.addlog('Built html');
return ele;
callback(ele);
}
p.prototype.play = function(){ return this.jw.play(); };
p.prototype.pause = function(){ return this.jw.pause(); };

View file

@ -1,6 +1,6 @@
mistplayers.polytrope = {
name: 'Polytrope Flash Player',
version: '0.1',
version: '0.2',
mimes: ['flash/11','flash/10','flash/7'],
priority: Object.keys(mistplayers).length + 1,
isMimeSupported: function (mimetype) {
@ -27,7 +27,7 @@ mistplayers.polytrope = {
};
var p = mistplayers.polytrope.player;
p.prototype = new MistPlayer();
p.prototype.build = function (options) {
p.prototype.build = function (options,callback) {
function createParam(name,value) {
var p = document.createElement('param');
p.setAttribute('name',name);
@ -97,5 +97,5 @@ p.prototype.build = function (options) {
ele.innerHTML = '<param name="wmode" value="opaque"> <param name="menu" value="false"> <param name="allowFullScreen" value="true"> <param name="allowFullScreenInteractive" value="true"> <param name="allowScriptAccess" value="always"> <param name="expressInstall" value="/shared/swf/expressInstall.swf"> <param name="flashvars" value="rtmp_url=rtmp://www.stickystage.com/play/&amp;stream_name=stickystage_archive+SrA-2016.07.08.23.54.08&amp;poster=http://stickystage.com/stickystage/users/SrA/archive/SrA-2016.07.08.23.54.08.jpg&amp;autoplay=true&amp;color_1=0x1d1d1d&amp;color_2=0xffffff&amp;buffer_time=0.1&amp;is_streaming_url=/api/user/is_streaming&amp;username=SrA&amp;mode=archive&amp;guid=4dc64c18-59af-91a2-d0c5-ab8df4f45c65"> <param name="movie" value="players/polytrope.swf">';
this.addlog('Built html');
return ele;
callback(ele);
}

View file

@ -1,6 +1,6 @@
mistplayers.silverlight = {
name: 'Silverlight',
version: '1.0',
version: '1.1',
mimes: ['silverlight'],
priority: Object.keys(mistplayers).length + 1,
isMimeSupported: function (mimetype) {
@ -25,7 +25,7 @@ mistplayers.silverlight = {
};
var p = mistplayers.silverlight.player;
p.prototype = new MistPlayer();
p.prototype.build = function (options) {
p.prototype.build = function (options,callback) {
function createParam(name,value) {
var p = document.createElement('param');
p.setAttribute('name',name);
@ -52,5 +52,5 @@ p.prototype.build = function (options) {
img.setAttribute('style','border-style: none;')
this.addlog('Built html');
return ele;
callback(ele);
}

View file

@ -14,11 +14,11 @@ mistplayers.myplayer = {
};
var p = mistplayers.myplayer.player;
p.prototype = new MistPlayer();
p.prototype.build = function (options) {
p.prototype.build = function (options,callback) {
var ele = this.element('object');
//TODO your code here
this.addlog('Built html');
return ele;
callback(ele);
}

View file

@ -1,6 +1,6 @@
mistplayers.theoplayer = {
name: 'TheoPlayer',
version: '0.1',
version: '0.2',
mimes: ['html5/application/vnd.apple.mpegurl','dash/video/mp4'],
priority: Object.keys(mistplayers).length + 1,
isMimeSupported: function (mimetype) {
@ -17,7 +17,7 @@ mistplayers.theoplayer = {
};
var p = mistplayers.theoplayer.player;
p.prototype = new MistPlayer();
p.prototype.build = function (options) {
p.prototype.build = function (options,callback) {
var ele = this.getElement('video');
ele.src = options.src;
@ -40,7 +40,7 @@ p.prototype.build = function (options) {
this.theoplayer = theoplayer(ele);
this.addlog('Built html');
return ele;
callback(ele);
}
p.prototype.play = function(){ return this.theoplayer.play(); };
p.prototype.pause = function(){ return this.theoplayer.pause(); };

View file

@ -1,6 +1,6 @@
mistplayers.videojs = {
name: 'VideoJS player',
version: '1.0',
version: '1.1',
mimes: ['html5/video/mp4','html5/application/vnd.apple.mpegurl','html5/video/ogg','html5/video/webm'],
priority: Object.keys(mistplayers).length + 1,
isMimeSupported: function (mimetype) {
@ -22,12 +22,21 @@ mistplayers.videojs = {
//dont use HLS if there is an MP3 audio track, unless we're on apple or edge
if ((mimetype == 'html5/application/vnd.apple.mpegurl') && (['iPad','iPhone','iPod','MacIntel'].indexOf(navigator.platform) == -1) && (navigator.userAgent.indexOf('Edge') == -1)) {
var audio = false;
var nonmp3 = false;
for (var i in streaminfo.meta.tracks) {
var t = streaminfo.meta.tracks[i];
if (t.codec == 'MP3') {
return false;
if (t.type == 'audio') {
audio = true;
if (t.codec != 'MP3') {
nonmp3 = true;
}
}
}
if ((audio) && (!nonmp3)) {
if (logfunc) { logfunc('This source has audio, but only MP3, and this browser can\'t play MP3 via HLS'); }
return false;
}
}
@ -37,118 +46,138 @@ mistplayers.videojs = {
};
var p = mistplayers.videojs.player;
p.prototype = new MistPlayer();
p.prototype.build = function (options) {
var cont = document.createElement('div');
cont.className = 'mistplayer';
p.prototype.build = function (options,callback) {
var me = this; //to allow nested functions to access the player class itself
this.addlog('Building VideoJS player..');
var ele = this.getElement('video');
cont.appendChild(ele);
ele.className = '';
ele.crossOrigin = 'anonymous'; //required for subtitles
var shortmime = options.source.type.split('/');
shortmime.shift();
var source = document.createElement('source');
source.setAttribute('src',options.src);
this.source = source;
ele.appendChild(source);
source.type = shortmime.join('/');
this.addlog('Adding '+source.type+' source @ '+options.src);
if (source.type == 'application/vnd.apple.mpegurl') { source.type = 'application/x-mpegURL'; }
ele.className += ' video-js';
ele.width = options.width;
ele.height = options.height;
ele.style.width = options.width+'px';
ele.style.height = options.height+'px';
var vjsopts = {
preload: 'auto'
};
if (options.autoplay) { vjsopts.autoplay = true; }
if (options.loop) {
vjsopts.loop = true;
ele.loop = true;
}
if (options.poster) { vjsopts.poster = options.poster; }
if (options.controls) {
if ((options.controls == 'stock') || (!this.buildMistControls())) {
//MistControls have failed to build in the if condition
ele.setAttribute('controls',true);
function onplayerload () {
me.addlog('Building VideoJS player..');
var cont = document.createElement('div');
cont.className = 'mistplayer';
var ele = me.getElement('video');
cont.appendChild(ele);
ele.className = '';
if (options.source.type != "html5/video/ogg") {
ele.crossOrigin = 'anonymous'; //required for subtitles, but if ogg, the video won't load
}
}
me.onready(function(){
me.videojs = videojs(ele,vjsopts,function(){
me.addlog('Videojs initialized');
var shortmime = options.source.type.split('/');
shortmime.shift();
var source = document.createElement('source');
source.setAttribute('src',options.src);
me.source = source;
ele.appendChild(source);
source.type = shortmime.join('/');
me.addlog('Adding '+source.type+' source @ '+options.src);
if (source.type == 'application/vnd.apple.mpegurl') { source.type = 'application/x-mpegURL'; }
ele.className += ' video-js';
ele.width = options.width;
ele.height = options.height;
ele.style.width = options.width+'px';
ele.style.height = options.height+'px';
var vjsopts = {
preload: 'auto'
};
if (options.autoplay) { vjsopts.autoplay = true; }
if (options.loop) {
vjsopts.loop = true;
ele.loop = true;
}
if (options.poster) { vjsopts.poster = options.poster; }
if (options.controls) {
if ((options.controls == 'stock') || (!me.buildMistControls())) {
//MistControls have failed to build in the if condition
ele.setAttribute('controls',true);
}
}
me.onready(function(){
me.videojs = videojs(ele,vjsopts,function(){
me.addlog('Videojs initialized');
});
});
});
this.addlog('Built html');
//forward events
ele.addEventListener('error',function(e){
var msg;
if ('message' in e) {
msg = e.message;
}
else {
msg = 'readyState: ';
switch (me.element.readyState) {
case 0:
msg += 'HAVE_NOTHING';
break;
case 1:
msg += 'HAVE_METADATA';
break;
case 2:
msg += 'HAVE_CURRENT_DATA';
break;
case 3:
msg += 'HAVE_FUTURE_DATA';
break;
case 4:
msg += 'HAVE_ENOUGH_DATA';
break;
me.addlog('Built html');
//forward events
ele.addEventListener('error',function(e){
if (!e.isTrusted) { return; } //don't trigger on errors we have thrown ourselves
var msg;
if ('message' in e) {
msg = e.message;
}
msg += ' networkState: ';
switch (me.element.networkState) {
case 0:
msg += 'NETWORK_EMPTY';
break;
case 1:
msg += 'NETWORK_IDLE';
break;
case 2:
msg += 'NETWORK_LOADING';
break;
case 3:
msg += 'NETWORK_NO_SOURCE';
break;
else {
msg = 'readyState: ';
switch (me.element.readyState) {
case 0:
msg += 'HAVE_NOTHING';
break;
case 1:
msg += 'HAVE_METADATA';
break;
case 2:
msg += 'HAVE_CURRENT_DATA';
break;
case 3:
msg += 'HAVE_FUTURE_DATA';
break;
case 4:
msg += 'HAVE_ENOUGH_DATA';
break;
}
msg += ' networkState: ';
switch (me.element.networkState) {
case 0:
msg += 'NETWORK_EMPTY';
break;
case 1:
msg += 'NETWORK_IDLE';
break;
case 2:
msg += 'NETWORK_LOADING';
break;
case 3:
msg += 'NETWORK_NO_SOURCE';
break;
}
}
}
//prevent onerror loops
if (e.target == me.element) {
e.message = msg;
}
else {
me.adderror(msg);
}
});
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting','progress'];
for (var i in events) {
ele.addEventListener(events[i],function(e){
me.addlog('Player event fired: '+e.type);
});
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting','progress'];
for (var i in events) {
ele.addEventListener(events[i],function(e){
me.addlog('Player event fired: '+e.type);
});
}
callback(cont);
}
return cont;
if ('videojs' in window) {
onplayerload();
}
else {
//load the videojs player
var scripttag = document.createElement('script');
scripttag.src = options.host+'/videojs.js';
me.addlog('Retrieving videojs player code from '+scripttag.src);
document.head.appendChild(scripttag);
scripttag.onerror = function(){
me.askNextCombo('Failed to load videojs.js');
}
scripttag.onload = function(){
onplayerload();
}
}
}
p.prototype.play = function(){ return this.element.play(); };
p.prototype.pause = function(){ return this.element.pause(); };
@ -177,13 +206,16 @@ if (document.fullscreenEnabled || document.webkitFullscreenEnabled || document.m
};
}
p.prototype.updateSrc = function(src){
if (src == '') {
this.videojs.dispose();
return;
if (videojs in this) {
if (src == '') {
this.videojs.dispose();
return;
}
this.videojs.src({
src: src,
type: this.source.type
});
return true;
}
this.videojs.src({
src: src,
type: this.source.type
});
return true;
return false;
};

View file

@ -1,11 +1,11 @@
var MD5=function(a){function c(a,c){var b,d,g,e,h;g=a&2147483648;e=c&2147483648;b=a&1073741824;d=c&1073741824;h=(a&1073741823)+(c&1073741823);return b&d?h^2147483648^g^e:b|d?h&1073741824?h^3221225472^g^e:h^1073741824^g^e:h^g^e}function d(a,b,d,g,e,h,i){a=c(a,c(c(b&d|~b&g,e),i));return c(a<<h|a>>>32-h,b)}function b(a,b,d,g,e,h,i){a=c(a,c(c(b&g|d&~g,e),i));return c(a<<h|a>>>32-h,b)}function e(a,b,d,g,e,h,i){a=c(a,c(c(b^d^g,e),i));return c(a<<h|a>>>32-h,b)}function g(a,b,d,g,e,h,i){a=c(a,c(c(d^(b|~g),
e),i));return c(a<<h|a>>>32-h,b)}function m(a){var c="",b="",d;for(d=0;3>=d;d++)b=a>>>8*d&255,b="0"+b.toString(16),c+=b.substr(b.length-2,2);return c}var f=[],q,p,l,u,h,i,k,j,f=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<f.length;q++)p=f.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));f=a;a=f.length;q=a+8;p=16*((q-q%64)/64+1);l=Array(p-1);for(h=u=0;h<a;)q=
(h-h%4)/4,u=8*(h%4),l[q]|=f.charCodeAt(h)<<u,h++;q=(h-h%4)/4;l[q]|=128<<8*(h%4);l[p-2]=a<<3;l[p-1]=a>>>29;f=l;h=1732584193;i=4023233417;k=2562383102;j=271733878;for(a=0;a<f.length;a+=16)q=h,p=i,l=k,u=j,h=d(h,i,k,j,f[a+0],7,3614090360),j=d(j,h,i,k,f[a+1],12,3905402710),k=d(k,j,h,i,f[a+2],17,606105819),i=d(i,k,j,h,f[a+3],22,3250441966),h=d(h,i,k,j,f[a+4],7,4118548399),j=d(j,h,i,k,f[a+5],12,1200080426),k=d(k,j,h,i,f[a+6],17,2821735955),i=d(i,k,j,h,f[a+7],22,4249261313),h=d(h,i,k,j,f[a+8],7,1770035416),
j=d(j,h,i,k,f[a+9],12,2336552879),k=d(k,j,h,i,f[a+10],17,4294925233),i=d(i,k,j,h,f[a+11],22,2304563134),h=d(h,i,k,j,f[a+12],7,1804603682),j=d(j,h,i,k,f[a+13],12,4254626195),k=d(k,j,h,i,f[a+14],17,2792965006),i=d(i,k,j,h,f[a+15],22,1236535329),h=b(h,i,k,j,f[a+1],5,4129170786),j=b(j,h,i,k,f[a+6],9,3225465664),k=b(k,j,h,i,f[a+11],14,643717713),i=b(i,k,j,h,f[a+0],20,3921069994),h=b(h,i,k,j,f[a+5],5,3593408605),j=b(j,h,i,k,f[a+10],9,38016083),k=b(k,j,h,i,f[a+15],14,3634488961),i=b(i,k,j,h,f[a+4],20,3889429448),
h=b(h,i,k,j,f[a+9],5,568446438),j=b(j,h,i,k,f[a+14],9,3275163606),k=b(k,j,h,i,f[a+3],14,4107603335),i=b(i,k,j,h,f[a+8],20,1163531501),h=b(h,i,k,j,f[a+13],5,2850285829),j=b(j,h,i,k,f[a+2],9,4243563512),k=b(k,j,h,i,f[a+7],14,1735328473),i=b(i,k,j,h,f[a+12],20,2368359562),h=e(h,i,k,j,f[a+5],4,4294588738),j=e(j,h,i,k,f[a+8],11,2272392833),k=e(k,j,h,i,f[a+11],16,1839030562),i=e(i,k,j,h,f[a+14],23,4259657740),h=e(h,i,k,j,f[a+1],4,2763975236),j=e(j,h,i,k,f[a+4],11,1272893353),k=e(k,j,h,i,f[a+7],16,4139469664),
i=e(i,k,j,h,f[a+10],23,3200236656),h=e(h,i,k,j,f[a+13],4,681279174),j=e(j,h,i,k,f[a+0],11,3936430074),k=e(k,j,h,i,f[a+3],16,3572445317),i=e(i,k,j,h,f[a+6],23,76029189),h=e(h,i,k,j,f[a+9],4,3654602809),j=e(j,h,i,k,f[a+12],11,3873151461),k=e(k,j,h,i,f[a+15],16,530742520),i=e(i,k,j,h,f[a+2],23,3299628645),h=g(h,i,k,j,f[a+0],6,4096336452),j=g(j,h,i,k,f[a+7],10,1126891415),k=g(k,j,h,i,f[a+14],15,2878612391),i=g(i,k,j,h,f[a+5],21,4237533241),h=g(h,i,k,j,f[a+12],6,1700485571),j=g(j,h,i,k,f[a+3],10,2399980690),
k=g(k,j,h,i,f[a+10],15,4293915773),i=g(i,k,j,h,f[a+1],21,2240044497),h=g(h,i,k,j,f[a+8],6,1873313359),j=g(j,h,i,k,f[a+15],10,4264355552),k=g(k,j,h,i,f[a+6],15,2734768916),i=g(i,k,j,h,f[a+13],21,1309151649),h=g(h,i,k,j,f[a+4],6,4149444226),j=g(j,h,i,k,f[a+11],10,3174756917),k=g(k,j,h,i,f[a+2],15,718787259),i=g(i,k,j,h,f[a+9],21,3951481745),h=c(h,q),i=c(i,p),k=c(k,l),j=c(j,u);return(m(h)+m(i)+m(k)+m(j)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(c){var b=0,d;a(c).children("td,th").each(function(){if(b==q)return d=a(this),!1;var c=a(this).attr("colspan");b+=c?Number(c):1});c="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":c=String(c).toLowerCase();break;case "int":c=
parseInt(Number(c));break;case "float":c=Number(c)}return c}var d=a(this),b=d.closest("table"),e=b.children("tbody"),g=e.children("tr"),m=d.attr("data-sort-type");if(m){var f=!0;d.hasClass("sorting-asc")&&(f=!1);var q=0;d.prevAll().each(function(){var c=a(this).attr("colspan");q+=c?Number(c):1});g.sort(function(a,b){var d=f?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});e.append(g);b.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");d.addClass(f?"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(c){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host=
var MD5=function(a){function c(a,c){var b,d,f,e,g;f=a&2147483648;e=c&2147483648;b=a&1073741824;d=c&1073741824;g=(a&1073741823)+(c&1073741823);return b&d?g^2147483648^f^e:b|d?g&1073741824?g^3221225472^f^e:g^1073741824^f^e:g^f^e}function d(a,b,d,f,e,g,i){a=c(a,c(c(b&d|~b&f,e),i));return c(a<<g|a>>>32-g,b)}function b(a,b,d,f,e,g,i){a=c(a,c(c(b&f|d&~f,e),i));return c(a<<g|a>>>32-g,b)}function e(a,b,d,f,e,g,i){a=c(a,c(c(b^d^f,e),i));return c(a<<g|a>>>32-g,b)}function g(a,b,d,f,g,e,i){a=c(a,c(c(d^(b|~f),
g),i));return c(a<<e|a>>>32-e,b)}function m(a){var c="",b="",d;for(d=0;3>=d;d++)b=a>>>8*d&255,b="0"+b.toString(16),c+=b.substr(b.length-2,2);return c}var h=[],q,p,l,t,f,i,j,k,h=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<h.length;q++)p=h.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));h=a;a=h.length;q=a+8;p=16*((q-q%64)/64+1);l=Array(p-1);for(f=t=0;f<a;)q=
(f-f%4)/4,t=8*(f%4),l[q]|=h.charCodeAt(f)<<t,f++;q=(f-f%4)/4;l[q]|=128<<8*(f%4);l[p-2]=a<<3;l[p-1]=a>>>29;h=l;f=1732584193;i=4023233417;j=2562383102;k=271733878;for(a=0;a<h.length;a+=16)q=f,p=i,l=j,t=k,f=d(f,i,j,k,h[a+0],7,3614090360),k=d(k,f,i,j,h[a+1],12,3905402710),j=d(j,k,f,i,h[a+2],17,606105819),i=d(i,j,k,f,h[a+3],22,3250441966),f=d(f,i,j,k,h[a+4],7,4118548399),k=d(k,f,i,j,h[a+5],12,1200080426),j=d(j,k,f,i,h[a+6],17,2821735955),i=d(i,j,k,f,h[a+7],22,4249261313),f=d(f,i,j,k,h[a+8],7,1770035416),
k=d(k,f,i,j,h[a+9],12,2336552879),j=d(j,k,f,i,h[a+10],17,4294925233),i=d(i,j,k,f,h[a+11],22,2304563134),f=d(f,i,j,k,h[a+12],7,1804603682),k=d(k,f,i,j,h[a+13],12,4254626195),j=d(j,k,f,i,h[a+14],17,2792965006),i=d(i,j,k,f,h[a+15],22,1236535329),f=b(f,i,j,k,h[a+1],5,4129170786),k=b(k,f,i,j,h[a+6],9,3225465664),j=b(j,k,f,i,h[a+11],14,643717713),i=b(i,j,k,f,h[a+0],20,3921069994),f=b(f,i,j,k,h[a+5],5,3593408605),k=b(k,f,i,j,h[a+10],9,38016083),j=b(j,k,f,i,h[a+15],14,3634488961),i=b(i,j,k,f,h[a+4],20,3889429448),
f=b(f,i,j,k,h[a+9],5,568446438),k=b(k,f,i,j,h[a+14],9,3275163606),j=b(j,k,f,i,h[a+3],14,4107603335),i=b(i,j,k,f,h[a+8],20,1163531501),f=b(f,i,j,k,h[a+13],5,2850285829),k=b(k,f,i,j,h[a+2],9,4243563512),j=b(j,k,f,i,h[a+7],14,1735328473),i=b(i,j,k,f,h[a+12],20,2368359562),f=e(f,i,j,k,h[a+5],4,4294588738),k=e(k,f,i,j,h[a+8],11,2272392833),j=e(j,k,f,i,h[a+11],16,1839030562),i=e(i,j,k,f,h[a+14],23,4259657740),f=e(f,i,j,k,h[a+1],4,2763975236),k=e(k,f,i,j,h[a+4],11,1272893353),j=e(j,k,f,i,h[a+7],16,4139469664),
i=e(i,j,k,f,h[a+10],23,3200236656),f=e(f,i,j,k,h[a+13],4,681279174),k=e(k,f,i,j,h[a+0],11,3936430074),j=e(j,k,f,i,h[a+3],16,3572445317),i=e(i,j,k,f,h[a+6],23,76029189),f=e(f,i,j,k,h[a+9],4,3654602809),k=e(k,f,i,j,h[a+12],11,3873151461),j=e(j,k,f,i,h[a+15],16,530742520),i=e(i,j,k,f,h[a+2],23,3299628645),f=g(f,i,j,k,h[a+0],6,4096336452),k=g(k,f,i,j,h[a+7],10,1126891415),j=g(j,k,f,i,h[a+14],15,2878612391),i=g(i,j,k,f,h[a+5],21,4237533241),f=g(f,i,j,k,h[a+12],6,1700485571),k=g(k,f,i,j,h[a+3],10,2399980690),
j=g(j,k,f,i,h[a+10],15,4293915773),i=g(i,j,k,f,h[a+1],21,2240044497),f=g(f,i,j,k,h[a+8],6,1873313359),k=g(k,f,i,j,h[a+15],10,4264355552),j=g(j,k,f,i,h[a+6],15,2734768916),i=g(i,j,k,f,h[a+13],21,1309151649),f=g(f,i,j,k,h[a+4],6,4149444226),k=g(k,f,i,j,h[a+11],10,3174756917),j=g(j,k,f,i,h[a+2],15,718787259),i=g(i,j,k,f,h[a+9],21,3951481745),f=c(f,q),i=c(i,p),j=c(j,l),k=c(k,t);return(m(f)+m(i)+m(j)+m(k)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function c(c){var b=0,d;a(c).children("td,th").each(function(){if(b==q)return d=a(this),!1;var c=a(this).attr("colspan");b+=c?Number(c):1});c="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":c=String(c).toLowerCase();break;case "int":c=
parseInt(Number(c));break;case "float":c=Number(c)}return c}var d=a(this),b=d.closest("table"),e=b.children("tbody"),g=e.children("tr"),m=d.attr("data-sort-type");if(m){var h=!0;d.hasClass("sorting-asc")&&(h=!1);var q=0;d.prevAll().each(function(){var c=a(this).attr("colspan");q+=c?Number(c):1});g.sort(function(a,b){var d=h?1:-1,a=c(a),b=c(b);return a>b?1*d:a<b?-1*d:0});e.append(g);b.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");d.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(c){}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 d=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=d&&UI.elements.header.css("margin-right",-1*a+"px");d=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 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,c){this.vars[a]=c;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,c){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");
this.opts={delay:c,callback:a};this.opts.id=setInterval(a,c)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"&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,46 +21,46 @@ clearTimeout(this.hiding);delete this.hiding;var d=$(document).height()-$tooltip
"HLS";break;case "html5/video/mp4":c="MP4";break;case "dash/video/mp4":c="DASH";break;case "flash/11":c="HDS";break;case "flash/10":c="RTMP";break;case "flash/7":c="Progressive";break;case "html5/audio/mp3":c="MP3";break;case "html5/video/mp2t":c="TS";break;case "html5/application/vnd.ms-ss":c="Smooth";break;case "html5/text/vtt":c="VTT Subtitles";break;case "html5/text/plain":c="SRT Subtitles";break;case "html5/text/javascript":c="JSON Subtitles"}return c},popup:{element:null,show:function(a){this.element=
$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{hiddenmenu:{Edit:{},Preview:{},Embed:{}}},Push:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},
"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{},ToS:{link:"http://mistserver.org/documentation#Legal"}}}}],buildMenu:function(){function a(a,c){var b=$("<a>").addClass("button");b.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in c.classes)b.addClass(c.classes[d]);"LTSonly"in c&&b.addClass("LTSonly");"link"in c?b.attr("href",c.link).attr("target","_blank"):"submenu"in c||b.click(function(c){$(this).closest(".menu").hasClass("hide")||
(UI.navto(a),c.stopPropagation())});return b}var c=UI.elements.menu,d;for(d in UI.menu){0<d&&c.append($("<br>"));for(var b in UI.menu[d]){var e=UI.menu[d][b],g=a(b,e);c.append(g);if("submenu"in e){var m=$("<span>").addClass("submenu");g.addClass("arrowdown").append(m);for(var f in e.submenu)m.append(a(f,e.submenu[f]))}else if("hiddenmenu"in e)for(f in m=$("<span>").addClass("hiddenmenu"),g.append(m),e.hiddenmenu)m.append(a(f,e.hiddenmenu[f]))}}d=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");
(UI.navto(a),c.stopPropagation())});return b}var c=UI.elements.menu,d;for(d in UI.menu){0<d&&c.append($("<br>"));for(var b in UI.menu[d]){var e=UI.menu[d][b],g=a(b,e);c.append(g);if("submenu"in e){var m=$("<span>").addClass("submenu");g.addClass("arrowdown").append(m);for(var h in e.submenu)m.append(a(h,e.submenu[h]))}else if("hiddenmenu"in e)for(h in m=$("<span>").addClass("hiddenmenu"),g.append(m),e.hiddenmenu)m.append(a(h,e.hiddenmenu[h]))}}d=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");
UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");c.after(d).after($("<div>").addClass("separator"))},findInput:function(a){return this.findInOutput("inputs",a)},findOutput:function(a){return this.findInOutput("connectors",a)},findInOutput:function(a,c){if("capabilities"in mist.data){var d=!1,b=mist.data.capabilities[a];c in b&&(d=b[c]);c+".exe"in b&&(d=b[c+".exe"]);return d}throw"Request capabilities first";
},buildUI:function(a){var c=$("<div>").addClass("input_container"),d;for(d in a){var b=a[d];if(b instanceof jQuery)c.append(b);else if("help"==b.type){var e=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(b.help));c.append(e);if("classes"in b)for(var g in b.classes)e.addClass(b.classes[g])}else if("text"==b.type)c.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(b.text)));else if("custom"==b.type)c.append(b.custom);else if("buttons"==
b.type)for(g in e=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&e.css(b.css),c.append(e),b.buttons){var m=b.buttons[g],f=$("<button>").text(m.label).data("opts",m);"css"in m&&f.css(m.css);if("classes"in m)for(var q in m.classes)f.addClass(m.classes[q]);e.append(f);switch(m.type){case "cancel":f.addClass("cancel").click(m["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),c=!1;a.find(".hasValidate").each(function(){if(c=
$(this).data("validate")(this,!0))return!1});c||(a.find(".isSetting").each(function(){var a=$(this).getval(),c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete c.main[c.index],!0;c.main[c.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in b&&m.css(b.css);m.append($("<span>").addClass("label").html("label"in b?b.label+
":":""));f=$("<span>").addClass("field_container");m.append(f);switch(b.type){case "password":e=$("<input>").attr("type","password");break;case "int":e=$("<input>").attr("type","number");"min"in b&&e.attr("min",b.min);"max"in b&&e.attr("max",b.min);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":e=$("<span>");break;case "debug":b.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],
b.type)for(g in e=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in b&&e.css(b.css),c.append(e),b.buttons){var m=b.buttons[g],h=$("<button>").text(m.label).data("opts",m);"css"in m&&h.css(m.css);if("classes"in m)for(var q in m.classes)h.addClass(m.classes[q]);e.append(h);switch(m.type){case "cancel":h.addClass("cancel").click(m["function"]);break;case "save":h.addClass("save").click(function(){var a=$(this).closest(".input_container"),c=!1;a.find(".hasValidate").each(function(){if(c=
$(this).data("validate")(this,!0))return!1});c||(a.find(".isSetting").each(function(){var a=$(this).getval(),c=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return c.main[c.index]=null,!0;c.main[c.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:h.click(m["function"])}}else{m=$("<label>").addClass("UIelement");c.append(m);"css"in b&&m.css(b.css);m.append($("<span>").addClass("label").html("label"in b?b.label+":":
""));h=$("<span>").addClass("field_container");m.append(h);switch(b.type){case "password":e=$("<input>").attr("type","password");break;case "int":e=$("<input>").attr("type","number");"min"in b&&e.attr("min",b.min);"max"in b&&e.attr("max",b.min);"validate"in b?b.validate.push("int"):b.validate=["int"];break;case "span":e=$("<span>");break;case "debug":b.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],
[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":e=$("<select>");for(g in b.select){var p=$("<option>");"string"==typeof b.select[g]?
p.text(b.select[g]):p.val(b.select[g][0]).text(b.select[g][1]);e.append(p)}break;case "textarea":e=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":e=$("<input>").attr("type","checkbox");break;case "hidden":e=$("<input>").attr("type","hidden");m.hide();break;case "email":e=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":e=$("<input>").attr("type","text");"filetypes"in b&&e.data("filetypes",b.filetypes);break;case "geolimited":case "hostlimited":e=
$("<input>").attr("type","hidden");break;case "radioselect":e=$("<div>").addClass("radioselect");for(d in b.radioselect){var l=$("<input>").attr("type","radio").val(b.radioselect[d][0]).attr("name",b.label);("LTSonly"in b&&!mist.data.LTS||b.readonly)&&l.prop("disabled",!0);p=$("<label>").append(l).append($("<span>").html(b.radioselect[d][1]));e.append(p);if(2<b.radioselect[d].length)for(g in l=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),
p.append(l),("LTSonly"in b&&!mist.data.LTS||b.readonly)&&l.prop("disabled",!0),b.radioselect[d][2])p=$("<option>"),l.append(p),b.radioselect[d][2][g]instanceof Array?p.val(b.radioselect[d][2][g][0]).html(b.radioselect[d][2][g][1]):p.html(b.radioselect[d][2][g])}break;case "checklist":e=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");e.append($checklist);for(d in b.checklist)"string"==typeof b.checklist[d]&&(b.checklist[d]=
[b.checklist[d],b.checklist[d]]),$checklist.append($("<label>").text(b.checklist[d][1]).prepend($("<input>").attr("type","checkbox").attr("name",b.checklist[d][0])));break;case "DOMfield":e=b.DOMfield;break;default:e=$("<input>").attr("type","text")}e.addClass("field").data("opts",b);"pointer"in b&&e.attr("name",b.pointer.index);f.append(e);if("classes"in b)for(g in b.classes)e.addClass(b.classes[g]);"placeholder"in b&&e.attr("placeholder",b.placeholder);"default"in b&&e.attr("placeholder",b["default"]);
"unit"in b&&f.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in b&&f.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),c=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(c));c.qrcode({text:a,
size:Math.min(c.width(),c.height())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&f.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()),c=document.createElement("textarea");c.value=a;document.body.appendChild(c);c.select();var b=false;try{b=document.execCommand("copy")}catch(d){}if(b){$(this).text("Copied to clipboard!");document.body.removeChild(c);
var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(c);alert("Failed to copy:\n"+a)}})));"rows"in b&&e.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(f.addClass("LTSonly"),e.prop("disabled",!0));switch(b.type){case "browse":l=$("<div>").addClass("grouper").append(m);c.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});f.append(l);l.click(function(){function a(c){m.text("Loading..");mist.send(function(a){f.text(a.browse.path[0]);
mist.data.LTS&&d.setval(a.browse.path[0]+"/");m.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var e=a.browse.subdirectories[c];m.append(l.clone(true).attr("title",f.text()+q+e).text(e))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var e=a.browse.files[c],h=f.text()+q+e,e=$("<a>").text(e).addClass("file").attr("title",h);m.append(e);if(p){var n=true,u;for(u in p)if(typeof p[u]!=
"undefined"&&mist.inputMatch(p[u],h)){n=false;break}n&&e.hide()}e.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field").attr("readonly","readonly").css("opacity",0.5),g=$(this),e=$("<button>").text("Stop browsing").click(function(){g.show();b.remove();d.removeAttr("readonly").css("opacity",1)}),f=$("<span>").addClass("field"),
m=$("<div>").addClass("browse_contents"),l=$("<a>").addClass("folder"),p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(f).append(e))).append(m);var q="/";mist.data.config.version.indexOf("indows")>-1&&(q="\\");l.click(function(){var c=f.text()+q+$(this).text();a(c)});c=d.getval();e=c.split("://");e.length>1&&(c=e[0]=="file"?e[1]:"");c=c.split(q);c.pop();
c=c.join(q);g.hide();a(c)});break;case "geolimited":case "hostlimited":l={field:e};l.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));l.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":l.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(d in UI.countrylist)l.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":l.prototype=$("<input>").attr("type",
[b.checklist[d],b.checklist[d]]),$checklist.append($("<label>").text(b.checklist[d][1]).prepend($("<input>").attr("type","checkbox").attr("name",b.checklist[d][0])));break;case "DOMfield":e=b.DOMfield;break;default:e=$("<input>").attr("type","text")}e.addClass("field").data("opts",b);"pointer"in b&&e.attr("name",b.pointer.index);h.append(e);if("classes"in b)for(g in b.classes)e.addClass(b.classes[g]);"placeholder"in b&&e.attr("placeholder",b.placeholder);"default"in b&&e.attr("placeholder",b["default"]);
"unit"in b&&h.append($("<span>").addClass("unit").html(b.unit));"readonly"in b&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in b&&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()),c=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(c));c.qrcode({text:a,
size:Math.min(c.width(),c.height())})})));"clipboard"in b&&document.queryCommandSupported("copy")&&h.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),c=document.createElement("textarea");c.value=a;document.body.appendChild(c);c.select();var b=false;try{b=document.execCommand("copy")}catch(d){}if(b){$(this).text("Copied to clipboard!");document.body.removeChild(c);
var e=$(this);setTimeout(function(){e.text("Copy")},5E3)}else{document.body.removeChild(c);alert("Failed to copy:\n"+a)}})));"rows"in b&&e.attr("rows",b.rows);"LTSonly"in b&&!mist.data.LTS&&(h.addClass("LTSonly"),e.prop("disabled",!0));switch(b.type){case "browse":l=$("<div>").addClass("grouper").append(m);c.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});h.append(l);l.click(function(){function a(c){m.text("Loading..");mist.send(function(a){h.text(a.browse.path[0]);
mist.data.LTS&&d.setval(a.browse.path[0]+"/");m.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var c in a.browse.subdirectories){var g=a.browse.subdirectories[c];m.append(l.clone(true).attr("title",h.text()+q+g).text(g))}}if(a.browse.files){a.browse.files.sort();for(c in a.browse.files){var g=a.browse.files[c],f=h.text()+q+g,g=$("<a>").text(g).addClass("file").attr("title",f);m.append(g);if(p){var t=true,z;for(z in p)if(typeof p[z]!=
"undefined"&&mist.inputMatch(p[z],f)){t=false;break}t&&g.hide()}g.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);e.show();b.remove()})}}},{browse:c})}var c=$(this).closest(".grouper"),b=$("<div>").addClass("browse_container"),d=c.find(".field").attr("readonly","readonly").css("opacity",0.5),e=$(this),g=$("<button>").text("Stop browsing").click(function(){e.show();b.remove();d.removeAttr("readonly").css("opacity",1)}),h=$("<span>").addClass("field"),
m=$("<div>").addClass("browse_contents"),l=$("<a>").addClass("folder"),p=d.data("filetypes");c.append(b);b.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(h).append(g))).append(m);var q="/";mist.data.config.version.indexOf("indows")>-1&&(q="\\");l.click(function(){var c=h.text()+q+$(this).text();a(c)});c=d.getval();g=c.split("://");g.length>1&&(c=g[0]=="file"?g[1]:"");c=c.split(q);c.pop();
c=c.join(q);e.hide();a(c)});break;case "geolimited":case "hostlimited":l={field:e};l.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));l.values=$("<span>").addClass("limit_value_list");switch(b.type){case "geolimited":l.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));for(d in UI.countrylist)l.prototype.append($("<option>").val(d).html(UI.countrylist[d]));break;case "hostlimited":l.prototype=$("<input>").attr("type",
"text").attr("placeholder","type a host")}l.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});l.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),c=[],b=false;a.values.children().each(function(){b=$(this).val();b!=""?c.push(b):$(this).remove()});a.values.append(a.prototype.clone(true));c.length>0?a.field.val($(this).val()+c.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in b&&
!mist.data.LTS&&(l.blackwhite.prop("disabled",!0),l.prototype.prop("disabled",!0));l.values.append(l.prototype.clone(!0));f.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in b&&(e.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(l=b.pointer.main[b.pointer.index],"undefined"!=l&&e.setval(l)));"value"in b&&e.setval(b.value);if("datalist"in b)for(d in l="datalist_"+d+MD5(e[0].outerHTML),e.attr("list",l),l=$("<datalist>").attr("id",l),f.append(l),
b.datalist)l.append($("<option>").val(b.datalist[d]));f=$("<span>").addClass("help_container");m.append(f);"help"in b&&(f.append($("<span>").addClass("ih_balloon").html(b.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in b){m=[];for(g in b.validate){l=b.validate[g];if("function"!=typeof l)switch(l){case "required":l=function(a){return a==""||a==null?{msg:"This is a required field.",
!mist.data.LTS&&(l.blackwhite.prop("disabled",!0),l.prototype.prop("disabled",!0));l.values.append(l.prototype.clone(!0));h.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in b&&(e.data("pointer",b.pointer).addClass("isSetting"),b.pointer.main&&(l=b.pointer.main[b.pointer.index],"undefined"!=l&&e.setval(l)));"value"in b&&e.setval(b.value);if("datalist"in b)for(d in l="datalist_"+d+MD5(e[0].outerHTML),e.attr("list",l),l=$("<datalist>").attr("id",l),h.append(l),
b.datalist)l.append($("<option>").val(b.datalist[d]));h=$("<span>").addClass("help_container");m.append(h);"help"in b&&(h.append($("<span>").addClass("ih_balloon").html(b.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in b){m=[];for(g in b.validate){l=b.validate[g];if("function"!=typeof l)switch(l){case "required":l=function(a){return a==""||a==null?{msg:"This is a required field.",
classes:["red"]}:false};break;case "int":l=function(a,c){var b=$(c).data("opts");if(!$(c)[0].validity.valid){var d=[];"min"in b&&d.push(" greater than or equal to "+b.min);"max"in b&&d.push(" smaller than or equal to "+b.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};break;case "streamname":l=function(a,c){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};
if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(c).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",classes:["red"]}};break;default:l=function(){}}m.push(l)}e.data("validate_functions",
m).data("help_container",f).data("validate",function(a,c){var b=$(a).getval(),d=$(a).data("validate_functions"),e=$(a).data("help_container");e.find(".err_balloon").remove();for(var g in d){var f=d[g](b,a);if(f){$err=$("<span>").addClass("err_balloon").html(f.msg);for(var m in f.classes)$err.addClass(f.classes[m]);e.prepend($err);c&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in
m).data("help_container",h).data("validate",function(a,c){var b=$(a).getval(),d=$(a).data("validate_functions"),g=$(a).data("help_container");g.find(".err_balloon").remove();for(var e in d){var h=d[e](b,a);if(h){$err=$("<span>").addClass("err_balloon").html(h.msg);for(var m in h.classes)$err.addClass(h.classes[m]);g.prepend($err);c&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in
b&&(e.on("change keyup",b["function"]),e.trigger("change"))}}c.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").first().trigger("click");break;case 27:$(this).find("button.cancel").first().trigger("click")}});return c},buildVheaderTable:function(a){var c=$("<table>").css("margin","0.2em"),d=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+1).append($("<span>").text(a.vheader))),b=[];d.append($("<td>"));for(var e in a.labels)b.push($("<tr>").append($("<td>").html(""==
a.labels[e]?"&nbsp;":a.labels[e]+":")));for(var g in a.content)for(e in d.append($("<td>").html(a.content[g].header)),a.content[g].body)b[e].append($("<td>").html(a.content[g].body[e]));c.append($("<tbody>").append(d).append(b));return c},plot:{addGraph:function(a,c){var d={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(d.elements.legend);d.elements.cont.append(d.elements.plot).append(d.elements.legend);
c.append(d.elements.cont);return d},go:function(a){if(!(1>Object.keys(a).length)){var c={totals:[],clients:[]},d;for(d in a)for(var b in a[d].datasets){var e=a[d].datasets[b];switch(e.datatype){case "clients":case "upbps":case "downbps":switch(e.origin[0]){case "total":c.totals.push({fields:[e.datatype],end:-15});break;case "stream":c.totals.push({fields:[e.datatype],streams:[e.origin[1]],end:-15});break;case "protocol":c.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":c.capabilities=
{}}}0==c.totals.length&&delete c.totals;0==c.clients.length&&delete c.clients;mist.send(function(){for(var c in a){var b=a[c];if(1>b.datasets.length){b.elements.plot.html("");b.elements.legend.html("");break}switch(b.xaxis){case "time":var d=[];b.yaxes={};var e=[],p;for(p in b.datasets){var l=b.datasets[p];l.display&&(l.getdata(),l.yaxistype in b.yaxes||(d.push(UI.plot.yaxes[l.yaxistype]),b.yaxes[l.yaxistype]=d.length),l.yaxis=b.yaxes[l.yaxistype],e.push(l))}d[0]&&(d[0].color=0);b.plot=$.plot(b.elements.plot,
e,{legend:{show:!1},xaxis:UI.plot.xaxes[b.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(b.id))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",b).text("X").addClass("close").click(function(){var c=
$(this).data("opts");if(confirm("Are you sure you want to remove "+c.id+"?")){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();UI.plot.del(c.id);delete a[c.id];d.trigger("change");UI.plot.go(a)}}))));b.elements.legend.html(d);var u=function(a){var c=b.elements.legend.find(".value"),d=1;if(typeof a=="undefined")c.eq(0).html("Latest:");else{var e=b.plot.getXAxes()[0],a=Math.min(e.max,a),a=Math.max(e.min,a);c.eq(0).html(UI.format.time(a/1E3))}for(var g in b.datasets){var f=
"&nbsp;";if(b.datasets[g].display){var e=UI.plot.yaxes[b.datasets[g].yaxistype].tickFormatter,h=b.datasets[g].data;if(a)for(var l in h){if(h[l][0]==a){f=e(h[l][1]);break}if(h[l][0]>a){if(l!=0){f=h[l];h=h[l-1];f=e(f[1]+(a-f[0])*(h[1]-f[1])/(h[0]-f[0]))}break}}else f=e(b.datasets[g].data[b.datasets[g].data.length-1][1])}c.eq(d).html(f);d++}};b.plot.getOptions();for(p in b.datasets)e=$("<input>").attr("type","checkbox").data("index",p).data("graph",b).click(function(){var a=$(this).data("graph");$(this).is(":checked")?
$(this).data("opts");if(confirm("Are you sure you want to remove "+c.id+"?")){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();UI.plot.del(c.id);delete a[c.id];d.trigger("change");UI.plot.go(a)}}))));b.elements.legend.html(d);var t=function(a){var c=b.elements.legend.find(".value"),d=1;if(typeof a=="undefined")c.eq(0).html("Latest:");else{var g=b.plot.getXAxes()[0],a=Math.min(g.max,a),a=Math.max(g.min,a);c.eq(0).html(UI.format.time(a/1E3))}for(var e in b.datasets){var f=
"&nbsp;";if(b.datasets[e].display){var g=UI.plot.yaxes[b.datasets[e].yaxistype].tickFormatter,h=b.datasets[e].data;if(a)for(var l in h){if(h[l][0]==a){f=g(h[l][1]);break}if(h[l][0]>a){if(l!=0){f=h[l];h=h[l-1];f=g(f[1]+(a-f[0])*(h[1]-f[1])/(h[0]-f[0]))}break}}else f=g(b.datasets[e].data[b.datasets[e].data.length-1][1])}c.eq(d).html(f);d++}};b.plot.getOptions();for(p in b.datasets)e=$("<input>").attr("type","checkbox").data("index",p).data("graph",b).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 c={};c[a.id]=a;UI.plot.go(c)}),b.datasets[p].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",b.datasets[p].color)).append(b.datasets[p].label))).append($("<td>").css("padding-right","2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",
p).data("graph",b).click(function(){var c=$(this).data("index"),b=$(this).data("graph");if(confirm("Are you sure you want to remove "+b.datasets[c].label+" from "+b.id+"?")){b.datasets.splice(c,1);if(b.datasets.length==0){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();d.trigger("change");UI.plot.del(b.id);delete a[b.id];UI.plot.go(a)}else{UI.plot.save(b);c={};c[b.id]=b;UI.plot.go(c)}}}))));u();var h=!1;b.elements.plot.on("plothover",function(a,c,b){if(c.x!=
h){u(c.x);h=c.x}if(b){a=$("<span>").append($("<h3>").text(b.series.label).prepend($("<div>").addClass("series-color").css("background-color",b.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(b.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(b.series.yaxis.tickFormatter(b.datapoint[1],b.series.yaxis)))));UI.tooltip.show(c,a.children())}else UI.tooltip.hide()}).on("mouseout",
function(){u()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},d;for(d in a.datasets)c.datasets.push({origin:a.datasets[d].origin,datatype:a.datasets[d].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general),d=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,
p).data("graph",b).click(function(){var c=$(this).data("index"),b=$(this).data("graph");if(confirm("Are you sure you want to remove "+b.datasets[c].label+" from "+b.id+"?")){b.datasets.splice(c,1);if(b.datasets.length==0){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();d.trigger("change");UI.plot.del(b.id);delete a[b.id];UI.plot.go(a)}else{UI.plot.save(b);c={};c[b.id]=b;UI.plot.go(c)}}}))));t();var f=!1;b.elements.plot.on("plothover",function(a,c,b){if(c.x!=
f){t(c.x);f=c.x}if(b){a=$("<span>").append($("<h3>").text(b.series.label).prepend($("<div>").addClass("series-color").css("background-color",b.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(b.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(b.series.yaxis.tickFormatter(b.datapoint[1],b.series.yaxis)))));UI.tooltip.show(c,a.children())}else UI.tooltip.hide()}).on("mouseout",
function(){t()})}}},c)}},save:function(a){var c={id:a.id,xaxis:a.xaxis,datasets:[]},d;for(d in a.datasets)c.datasets.push({origin:a.datasets[d].origin,datatype:a.datasets[d].datatype});a=mist.stored.get().graphs||{};a[c.id]=c;mist.stored.set("graphs",a)},del:function(a){var c=mist.stored.get().graphs||{};delete c[a];mist.stored.set("graphs",c)},datatype:{getOptions:function(a){var c=$.extend(!0,{},UI.plot.datatype.templates.general),d=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,
d,a),a=$.extend(!0,c,a);switch(a.origin[0]){case "total":switch(a.datatype){case "cpuload":case "memload":break;default:a.label+=" (total)"}break;case "stream":case "protocol":a.label+=" ("+a.origin[1]+")"}var c=[],b;for(b in a.basecolor)d=a.basecolor[b],d+=50*(0.5-Math.random()),d=Math.round(d),d=Math.min(255,Math.max(0,d)),c.push(d);a.color="rgb("+c.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"",yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a=
mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",
yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,c;for(c in this.data)this.data[c][0]<1E3*(mist.data.config.time-600)&&(a=c);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",
color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,ticks:function(a){var c=0.3*Math.sqrt($(".graph").first().height()),c=(a.max-
a.min)/c,d=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),b=c/Math.pow(1024,d),e=-Math.floor(Math.log(b)/Math.LN10),g=a.tickDecimals;null!=g&&e>g&&(e=g);var m=Math.pow(10,-e),b=b/m,f;if(1.5>b)f=1;else if(3>b){if(f=2,2.25<b&&(null==g||e+1<=g))f=2.5,++e}else f=7.5>b?5:10;f=f*m*Math.pow(1024,d);null!=a.minTickSize&&f<a.minTickSize&&(f=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=g?g:e);a.tickSize=f;c=[];d=a.tickSize*Math.floor(a.min/a.tickSize);e=0;g=Number.NaN;do m=g,g=d+e*a.tickSize,
a.min)/c,d=Math.floor(Math.log(Math.abs(c))/Math.log(1024)),b=c/Math.pow(1024,d),e=-Math.floor(Math.log(b)/Math.LN10),g=a.tickDecimals;null!=g&&e>g&&(e=g);var m=Math.pow(10,-e),b=b/m,h;if(1.5>b)h=1;else if(3>b){if(h=2,2.25<b&&(null==g||e+1<=g))h=2.5,++e}else h=7.5>b?5:10;h=h*m*Math.pow(1024,d);null!=a.minTickSize&&h<a.minTickSize&&(h=a.minTickSize);a.delta=c;a.tickDecimals=Math.max(0,null!=g?g:e);a.tickSize=h;c=[];d=a.tickSize*Math.floor(a.min/a.tickSize);e=0;g=Number.NaN;do m=g,g=d+e*a.tickSize,
c.push(g),++e;while(g<a.max&&g!=m);return c},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 d=$(this).data("dragstart"),b=d.ele.x-d.click.x+a.originalEvent.pageX,a=d.ele.y-d.click.y+a.originalEvent.pageY;$(this).css({opacity:1,
top:a,left:b,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,c){var d=new Date(1E3*a),b=[];b.push(("0"+d.getHours()).slice(-2));b.push(("0"+d.getMinutes()).slice(-2));"short"!=c&&b.push(("0"+d.getSeconds()).slice(-2));return b.join(":")},date:function(a,c){var d=new Date(1E3*a),b="Sun Mon Tue Wed Thu Fri Sat".split(" "),e=[];"long"==c&&e.push(b[d.getDay()]);e.push(("0"+d.getDate()).slice(-2));e.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[d.getMonth()]);
"short"!=c&&e.push(d.getFullYear());return e.join(" ")},dateTime:function(a,c){return UI.format.date(a,c)+", "+UI.format.time(a,c)},duration:function(a){var c=[0.001,1E3,60,60,24,7,1E9],d="ms sec min hr day week".split(" "),b={},e;for(e in d){var a=a/c[e],g=Math.round(a%c[Number(e)+1]);b[d[e]]=g;a-=g}var m;for(e=d.length-1;0<=e;e--)if(0<b[d[e]]){m=d[e];break}c=$("<span>");switch(m){case "week":c.append(UI.format.addUnit(b.week,"wks, ")).append(UI.format.addUnit(b.day,"days"));break;case "day":c.append(UI.format.addUnit(b.day,
@ -75,93 +75,95 @@ type:"str",validate:["required"],help:"Enter your desired username. In the futur
type:"password",validate:["required",function(a,c){return a!=$(".match_password").not($(c)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);
delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.<br>");else{d.append("Retrieving available protocols..<br>");
mist.send(function(a){var c=[],b;for(b in a.capabilities.connectors)if(a.capabilities.connectors[b].required)d.append('Could not enable protocol "'+b+'" because it has required settings.<br>');else{c.push({connector:b});d.append('Enabled protocol "'+b+'".<br>')}d.append("Saving protocol settings..<br>");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));
break;case "Overview":var f=$("<span>").text("Loading.."),q=$("<span>"),p=$("<span>").addClass("logs"),l=$("<span>"),u=$("<span>"),h=$("<span>"),i=$("<span>");d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,
LTSonly:!0},{type:"span",label:"Server time",value:u},{type:"span",label:"Licensed to","default":"unknown",pointer:{main:mist.data.config.license,index:"user"},LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:q},{type:"span",label:"Current connections",value:l},{type:"span",label:"Enabled protocols",value:h},{type:"span",label:"Disabled protocols",value:i},{type:"span",label:"Recent problems",
value:p},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:mist.data.config,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},{type:"checkbox",
label:"Force configurations save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var k=
function(a){"uptodate"in a?a.error?f.addClass("red").text(a.error):a.uptodate?f.text("Your version is up to date.").addClass("green"):f.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):
f.text("Unknown")};if(!mist.stored.get().update||36E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var j={};j.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",j);k(a.update)},{checkupdate:!0})}else mist.send(function(a){k(a.update)},{update:!0})}else f.text("");g=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){ga()},a)};var ga=function(){q.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..";l.text(a);u.text(UI.format.dateTime(mist.data.config.time,"long"));p.html("");var a=0,c;for(c in mist.data.log){var b=mist.data.log[c];if(["FAIL","ERROR"].indexOf(b[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),e=b[2].split("|");
for(c in e)d.append($("<span>").text(e[c]));p.append($("<div>").append($("<span>").append(UI.format.time(b[0]))).append(d));if(a==5)break}}a==0&&p.html("None.");a=[];b=[];for(c in mist.data.config.protocols){d=mist.data.config.protocols[c];a.indexOf(d.connector)>-1||a.push(d.connector)}h.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(c in mist.data.capabilities.connectors)a.indexOf(c)==-1&&b.push(c);i.text(b.length?b.join(", "):"None.")}else i.text("Loading..")};g();ga();UI.interval.set(g,
3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var z=$("<tbody>");d.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=
[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),c;for(c in mist.data.config.protocols){var b=a.indexOf(mist.data.config.protocols[c].connector);b>-1&&a.splice(b,1)}var d=[];for(c in a)(!("required"in mist.data.capabilities.connectors[a[c]])||Object.keys(mist.data.capabilities.connectors[a[c]].required).length==0)&&d.push(a[c]);b="Click OK to enable disabled protocols with their default settings:\n ";
b=d.length?b+d.join(", "):b+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});b=b+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(b)&&d.length){for(c in d)mist.data.config.protocols.push({connector:d[c]});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(z));
var K=function(){function a(c){var b=mist.data.capabilities.connectors[c.connector];if(!b)return"";var d=[],e=["required","optional"],g;for(g in e)for(var t in b[e[g]])c[t]&&c[t]!=""?d.push(t+": "+c[t]):b[e[g]][t]["default"]&&d.push(t+": "+b[e[g]][t]["default"]);return $("<span>").addClass("description").text(d.join(", "))}z.html("");for(var c in mist.data.config.protocols){var b=mist.data.config.protocols[c];z.append($("<tr>").data("index",c).append($("<td>").text(b.connector)).append($("<td>").html(UI.format.status(b))).append($("<td>").html(a(b))).append($("<td>").css("text-align",
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};K();UI.interval.set(function(){mist.send(function(){K()})},
1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");return}var D=!1;""!=c&&0<=c&&(D=!0);var L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;var ha=function(a){var c=mist.data.capabilities.connectors[a],b=mist.convertBuildOptions(c,n);if(D)var d=$.extend({},n);b.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});b.push({type:"buttons",buttons:[{type:"save",
label:"Save","function":function(){var a={};D?a.updateprotocol=[d,n]:a.addprotocol=n;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var e in c.deps){a=$("<li>").text(c.deps[e]+" ");$ul.append(a);typeof L[c.deps[e]]!="undefined"||typeof L[c.deps[e]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):
a.append($("<span>").addClass("red").text("(Not yet configured)"))}b.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(b)},L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;if(D)n=b=mist.data.config.protocols[c],d.find("h2").append(' "'+b.connector+'"'),d.append(ha(b.connector));else{d.html($("<h2>").text("New Protocol"));var n={},s=[["",""]];for(g in mist.data.capabilities.connectors)s.push([g,g]);var I=$("<span>");d.append(UI.buildUI([{label:"Protocol",
type:"select",select:s,"function":function(){$(this).getval()!=""&&I.html(ha($(this).getval()))}}])).append(I)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}g=$("<button>");var E=$("<span>").text("Loading..");d.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("<div>").css({width:"45.25em",display:"flex",
"justify-content":"flex-end"}).append(g).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(E);""==c&&(e=mist.stored.get(),"viewmode"in e&&(c=e.viewmode));g.text("Switch to "+("thumbnails"==c?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",c=="thumbnails"?"list":"thumbnails");UI.navto("Streams",c=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),U=function(a,c){var b=$.extend({},c);delete b.meta;delete b.error;
b.online=2;b.name=a;b.ischild=true;return b},V=function(c,b,e){E.remove();switch(c){case "thumbnails":var g=$("<div>").addClass("preview_icons"),f;f=e||[];b.sort();b.unshift("");E.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:b,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()})}}]));b.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(g);for(var h in b){var c=b[h],i="",k=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var c={};c.deletestream=[a];mist.send(function(){UI.navto("Streams")},c)}}),j=$("<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"))}),m=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),l=$("<span>").addClass("image");if(c.indexOf("+")>-1){i=c.split("+");i=mist.data.streams[i[0]].source+i[1];j=k="";l.addClass("wildcard")}else{i=mist.data.streams[c].source;if(f.indexOf(c)>-1){m=e="";l.addClass("folder")}}g.append($("<div>").append($("<span>").addClass("streamname").text(c)).append(l).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(j).append(k).append(e).append(m)).attr("title",
break;case "Overview":var h=$("<span>").text("Loading.."),q=$("<span>"),p=$("<span>").addClass("logs"),l=$("<span>"),t=$("<span>"),f=$("<span>").text("Unknown"),i=$("<span>"),j=$("<span>");d.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",
label:"Version check",value:h,LTSonly:!0},{type:"span",label:"Server time",value:t},{type:"span",label:"Licensed to",value:"license"in mist.data.config?mist.data.config.license.name:"",LTSonly:!0},{type:"span",label:"Active products",value:f,LTSonly:!0},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:q},{type:"span",label:"Current connections",value:l},{type:"span",label:"Enabled protocols",value:i},
{type:"span",label:"Disabled protocols",value:j},{type:"span",label:"Recent problems",value:p},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},{type:"debug",label:"Debug level",pointer:{main:mist.data.config,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},
{type:"checkbox",label:"Force configurations save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));
if(mist.data.LTS){var k=function(a){function c(a){if(a.update){var b="";"progress"in a.update&&(b=" ("+a.update.progress+"%)");h.text("Updating.."+b);setTimeout(function(){mist.send(function(a){c(a)},{update:true})},5E3)}else UI.showTab("Overview")}if(!a.update||!("uptodate"in a.update)){h.text("Unknown, checking..");setTimeout(function(){mist.send(function(a){k(a)},{checkupdate:true})},5E3)}else if(a.update.error)h.addClass("red").text(a.update.error);else if(a.update.uptodate)h.text("Your version is up to date.").addClass("green");
else if(a.update.progress){h.addClass("orange").removeClass("red").text("Updating..");c(a)}else h.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){h.addClass("orange").removeClass("red").text("Rolling update command sent..");mist.send(function(a){c(a)},{autoupdate:true})}}))};k(mist.data);if("license"in mist.data.config){if("active_products"in
mist.data.config.license&&Object.keys(mist.data.config.license.active_products).length){var z=$("<table>").css("text-indent","0");f.html(z);z.append($("<tr>").append($("<th>").append("Product")).append($("<th>").append("Updates until")).append($("<th>").append("Use until")).append($("<th>").append("Max. simul. instances")));for(g in mist.data.config.license.active_products)e=mist.data.config.license.active_products[g],z.append($("<tr>").append($("<td>").append(e.name)).append($("<td>").append(e.updates_final?
e.updates_final:"&infin;")).append($("<td>").append(e.use_final)).append($("<td>").append(e.amount?e.amount:"&infin;")))}else f.text("None.");f.append($("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank"))}}else h.text("");g=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=true;mist.send(function(){fa()},a)};var fa=function(){q.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..";l.text(a);t.text(UI.format.dateTime(mist.data.config.time,"long"));p.html("");var a=0,c;for(c in mist.data.log){var b=mist.data.log[c];if(["FAIL","ERROR"].indexOf(b[1])>-1){a++;var d=$("<span>").addClass("content").addClass("red"),g=b[2].split("|");for(c in g)d.append($("<span>").text(g[c]));
p.append($("<div>").append($("<span>").append(UI.format.time(b[0]))).append(d));if(a==5)break}}a==0&&p.html("None.");a=[];b=[];for(c in mist.data.config.protocols){d=mist.data.config.protocols[c];a.indexOf(d.connector)>-1||a.push(d.connector)}i.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(c in mist.data.capabilities.connectors)a.indexOf(c)==-1&&b.push(c);j.text(b.length?b.join(", "):"None.")}else j.text("Loading..")};g();fa();UI.interval.set(g,3E4);break;case "Protocols":if("undefined"==
typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var x=$("<tbody>");d.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=[];mist.send(function(){UI.navto("Protocols")},
{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),c;for(c in mist.data.config.protocols){var b=a.indexOf(mist.data.config.protocols[c].connector);b>-1&&a.splice(b,1)}var d=[];for(c in a)(!("required"in mist.data.capabilities.connectors[a[c]])||Object.keys(mist.data.capabilities.connectors[a[c]].required).length==0)&&d.push(a[c]);b="Click OK to enable disabled protocols with their default settings:\n ";
b=d.length?b+d.join(", "):b+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});b=b+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(b)&&d.length){for(c in d)mist.data.config.protocols.push({connector:d[c]});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(x));
var ga=function(){function a(c){var b=mist.data.capabilities.connectors[c.connector];if(!b)return"";var d=[],g=["required","optional"],e;for(e in g)for(var u in b[g[e]])c[u]&&c[u]!=""?d.push(u+": "+c[u]):b[g[e]][u]["default"]&&d.push(u+": "+b[g[e]][u]["default"]);return $("<span>").addClass("description").text(d.join(", "))}x.html("");for(var c in mist.data.config.protocols){var b=mist.data.config.protocols[c];x.append($("<tr>").data("index",c).append($("<td>").text(b.connector)).append($("<td>").html(UI.format.status(b))).append($("<td>").html(a(b))).append($("<td>").css("text-align",
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};ga();UI.interval.set(function(){mist.send(function(){ga()})},
1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");return}var D=!1;""!=c&&0<=c&&(D=!0);var K={};for(g in mist.data.config.protocols)K[mist.data.config.protocols[g].connector]=1;var ha=function(a){var c=mist.data.capabilities.connectors[a],b=mist.convertBuildOptions(c,n);if(D)var d=$.extend({},n);b.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});b.push({type:"buttons",buttons:[{type:"save",
label:"Save","function":function(){var a={};D?a.updateprotocol=[d,n]:a.addprotocol=n;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){z=$("<span>").text("Dependencies:");$ul=$("<ul>");z.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var g in c.deps){a=$("<li>").text(c.deps[g]+" ");$ul.append(a);typeof K[c.deps[g]]!="undefined"||typeof K[c.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):
a.append($("<span>").addClass("red").text("(Not yet configured)"))}b.unshift({type:"text",text:z[0].innerHTML})}return UI.buildUI(b)},K={};for(g in mist.data.config.protocols)K[mist.data.config.protocols[g].connector]=1;if(D)n=b=mist.data.config.protocols[c],d.find("h2").append(' "'+b.connector+'"'),d.append(ha(b.connector));else{d.html($("<h2>").text("New Protocol"));var n={},r=[["",""]];for(g in mist.data.capabilities.connectors)r.push([g,g]);var I=$("<span>");d.append(UI.buildUI([{label:"Protocol",
type:"select",select:r,"function":function(){$(this).getval()!=""&&I.html(ha($(this).getval()))}}])).append(I)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}g=$("<button>");var E=$("<span>").text("Loading..");d.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("<div>").css({width:"45.25em",display:"flex",
"justify-content":"flex-end"}).append(g).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(E);""==c&&(e=mist.stored.get(),"viewmode"in e&&(c=e.viewmode));g.text("Switch to "+("thumbnails"==c?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",c=="thumbnails"?"list":"thumbnails");UI.navto("Streams",c=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),T=function(a,c){var b=$.extend({},c);delete b.meta;delete b.error;
b.online=2;b.name=a;b.ischild=true;return b},U=function(c,b,g){E.remove();switch(c){case "thumbnails":var e=$("<div>").addClass("preview_icons"),f;f=g||[];b.sort();b.unshift("");E.remove();d.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:b,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();e.children().each(function(){$(this).hide();
$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));b.shift();d.append($("<span>").addClass("description").text("Choose a stream below.")).append(e);for(var h in b){var c=b[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 c={};c.deletestream=[a];mist.send(function(){UI.navto("Streams")},c)}}),k=$("<button>").text("Settings").click(function(){UI.navto("Edit",
$(this).closest("div").attr("data-stream"))}),g=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),m=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),l=$("<span>").addClass("image");if(c.indexOf("+")>-1){i=c.split("+");i=mist.data.streams[i[0]].source+i[1];k=j="";l.addClass("wildcard")}else{i=mist.data.streams[c].source;if(f.indexOf(c)>-1){m=g="";l.addClass("folder")}}e.append($("<div>").append($("<span>").addClass("streamname").text(c)).append(l).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(k).append(j).append(g).append(m)).attr("title",
c).attr("data-stream",c))}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);
d.append(h);h.stupidtable();var o=function(){var a=[],c;for(c in mist.data.active_streams)a.push({streams:[mist.data.active_streams[c]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;n.html("");b.sort();for(var c in b){var d=b[c],e;e=d in mist.data.streams?mist.data.streams[d]:y[d];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),t=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!=
"undefined"){var f=mist.data.totals[d].all_protocols.clients,t=0;if(f.length){for(a in f)t=t+f[a][1];t=Math.round(t/f.length)}}g.html(UI.format.number(t));if(t==0&&e.online==1)e.online=2;t=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||!e.ischild)&&t.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 c={};mist.data.LTS?c.deletestream=[a]:c.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},c)}}));f=$("<span>").text(d);e.ischild&&f.css("padding-left","1em");var h=UI.format.status(e),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),k=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[d]){h.html("");i="";g.html("");
k=""}n.append($("<tr>").data("index",d).html($("<td>").html(f).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(h)).append(g).append($("<td>").css("white-space","nowrap").html(i).append(k)).append(t));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(f in mist.data.streams){h=mist.data.capabilities.inputs.Folder||
mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[f].source)){y[f].source=y[f].source+"*";y[f].filesfound=null;mist.send(function(a,c){var b=c.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=0||e.indexOf("Buffer.exe")>=0||e.indexOf("Folder")>=0||e.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=b+"+"+a.browse.files[d];
y[g]=U(g,mist.data.streams[b]);y[g].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[b].filesfound=true:mist.data.streams[b].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[f].source},{stream:f});p++}}if(p==0){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},
5E3)}}};if(mist.data.LTS){var W=0,ia=0,s={},ja=[];for(e in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[e].source))ja.push(e),mist.send(function(a,b){var d=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||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&(s[d+"+"+a.browse.files[e]]=
true);ia++;W==ia&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=U(mist.data.active_streams[a],mist.data.streams[b[0]])}}s=Object.keys(s);s=s.concat(Object.keys(mist.data.streams));s.sort();V(c,s,ja)},{active_streams:true})},{browse:mist.data.streams[e].source},{stream:e}),W++;0==W&&mist.send(function(){for(var a in mist.data.active_streams){var b=
mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=U(mist.data.active_streams[a],mist.data.streams[b[0]])}}s=Object.keys(s);mist.data.streams&&(s=s.concat(Object.keys(mist.data.streams)));s.sort();V(c,s)},{active_streams:!0})}else V(c,Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");
return}D=!1;""!=c&&(D=!0);if(D){var r=c,n=mist.data.streams[r];d.find("h2").append(' "'+r+'"')}else d.html($("<h2>").text("New Stream")),n={};r=[];for(g in mist.data.capabilities.inputs)r.push(mist.data.capabilities.inputs[g].source_match);var Q=$("<div>"),ka=function(a){var b={};if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;c!=n.name&&delete mist.data.streams[c];b.addstream={};b.addstream[n.name]=n;if(c!=n.name)b.deletestream=[c];if(n.stop_sessions&&c!=""){b.stop_sessions=
c;delete n.stop_sessions}mist.send(function(){delete mist.data.streams[n.name].online;delete mist.data.streams[n.name].error;UI.navto(a,a=="Preview"?n.name:"")},b)},la=$("<style>").text("button.saveandpreview { display: none; }"),F=$("<span>"),X=function(){var a=d.find("[name=name]").val();if(a){var c=parseURL(mist.user.host),b=d.find("[name=source]").val().match(/@.*/);b&&(b=b[0].substring(1));var e=d.find("[name=source]").val().replace(/(?:.+?):\/\//,""),e=e.split("/"),e=e[0],e=e.split(":"),e=e[0],
g={},f=["RTMP","RTSP","TS","RTMP.exe","RTSP.exe","TS.exe"],h;for(h in f)f[h]in mist.data.capabilities.connectors&&(g[f[h]]=mist.data.capabilities.connectors[f[h]].optional.port["default"]);var f={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},i;for(i in g){for(h in mist.data.config.protocols){var k=mist.data.config.protocols[h];if(k.connector==i){if("port"in k)g[i]=k.port;break}}g[i]=g[i]==f[i]?"":":"+g[i]}F.find(".field").closest("label").hide();for(h in g){var j;switch(h){case "RTMP":case "RTMP.exe":j=
"rtmp://"+c.host+g[h]+"/"+(b?b:"live")+"/";F.find(".field.RTMPurl").setval(j).closest("label").show();F.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();j=j+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":j="rtsp://"+c.host+g[h]+"/"+(a==""?"STREAMNAME":a)+(b?"?pass="+b:"");break;case "TS":case "TS.exe":j="udp://"+(e==""?c.host:e)+g[h]+"/"}F.find(".field."+h.replace(".exe","")).setval(j).closest("label").show()}}};d.append(UI.buildUI([{label:"Stream name",type:"str",
validate:["required","streamname"],pointer:{main:n,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",filetypes:r,pointer:{main:n,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><tr><td>Input</td><td>Syntax</td><td>Explanation</td></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<br>(Pro&nbsp;only)</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><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. <tr><th>RTSP<br>(Pro&nbsp;only)</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<br>(Pro&nbsp;only)</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></table>",
"function":function(){var a=$(this).val();la.remove();F.html("");if(a!=""){var c=null,b;for(b in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[b].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[b].source_match,a)){c=b;break}if(c===null)Q.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{c=mist.data.capabilities.inputs[c];Q.html($("<h3>").text(c.name+" Input options"));
var e=mist.convertBuildOptions(c,n);"always_match"in mist.data.capabilities.inputs[b]&&mist.inputMatch(mist.data.capabilities.inputs[b].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:n,index:"always_on"}});Q.append(UI.buildUI(e));if(c.name=="Folder")d.append(la);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(c.name)>-1){a=[$("<span>").text("Configure your source to push to:")];switch(c.name){case "Buffer":case "Buffer.exe":a.push({label:"RTMP full url",
d.append(h);h.stupidtable();var o=function(){var a=[],c;for(c in mist.data.active_streams)a.push({streams:[mist.data.active_streams[c]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,y,mist.data.streams);var a=0;n.html("");b.sort();for(var c in b){var d=b[c],g;g=d in mist.data.streams?mist.data.streams[d]:y[d];var e=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!=
"undefined"){var u=mist.data.totals[d].all_protocols.clients,f=0;if(u.length){for(a in u)f=f+u[a][1];f=Math.round(f/u.length)}}e.html(UI.format.number(f));if(f==0&&g.online==1)g.online=2;f=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in g)||!g.ischild)&&f.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
a+'"?')){delete mist.data.streams[a];var c={};mist.data.LTS?c.deletestream=[a]:c.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},c)}}));u=$("<span>").text(d);g.ischild&&u.css("padding-left","1em");var h=UI.format.status(g),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),j=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[d]){h.html("");i="";e.html("");
j=""}n.append($("<tr>").data("index",d).html($("<td>").html(u).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(g.source).attr("title",g.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",g.online).html(h)).append(e).append($("<td>").css("white-space","nowrap").html(i).append(j)).append(f));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(f in mist.data.streams){h=mist.data.capabilities.inputs.Folder||
mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[f].source)){y[f].source=y[f].source+"*";y[f].filesfound=null;mist.send(function(a,c){var b=c.stream,d;for(d in a.browse.files)for(var 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[d])){var e=b+"+"+a.browse.files[d];
y[e]=T(e,mist.data.streams[b]);y[e].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[b].filesfound=true:mist.data.streams[b].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[f].source},{stream:f});p++}}if(p==0){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},
5E3)}}};if(mist.data.LTS){var V=0,ia=0,r={},ja=[];for(e in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[e].source))ja.push(e),mist.send(function(a,b){var d=b.stream,g;for(g in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[g])&&(r[d+"+"+a.browse.files[g]]=
true);ia++;V==ia&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){r[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=T(mist.data.active_streams[a],mist.data.streams[b[0]])}}r=Object.keys(r);r=r.concat(Object.keys(mist.data.streams));r.sort();U(c,r,ja)},{active_streams:true})},{browse:mist.data.streams[e].source},{stream:e}),V++;0==V&&mist.send(function(){for(var a in mist.data.active_streams){var b=
mist.data.active_streams[a].split("+");if(b.length>1&&b[0]in mist.data.streams){r[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=T(mist.data.active_streams[a],mist.data.streams[b[0]])}}r=Object.keys(r);mist.data.streams&&(r=r.concat(Object.keys(mist.data.streams)));r.sort();U(c,r)},{active_streams:!0})}else U(c,Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");
return}D=!1;""!=c&&(D=!0);D?(f=c,n=mist.data.streams[f],d.find("h2").append(' "'+f+'"')):(d.html($("<h2>").text("New Stream")),n={});f=[];for(g in mist.data.capabilities.inputs)f.push(mist.data.capabilities.inputs[g].source_match);var P=$("<div>"),ka=function(a){var b={};if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;c!=n.name&&delete mist.data.streams[c];b.addstream={};b.addstream[n.name]=n;if(c!=n.name)b.deletestream=[c];if(n.stop_sessions&&c!=""){b.stop_sessions=c;delete n.stop_sessions}mist.send(function(){delete mist.data.streams[n.name].online;
delete mist.data.streams[n.name].error;UI.navto(a,a=="Preview"?n.name:"")},b)},la=$("<style>").text("button.saveandpreview { display: none; }"),F=$("<span>"),W=function(){var a=d.find("[name=name]").val();if(a){var c=parseURL(mist.user.host),b=d.find("[name=source]").val().match(/@.*/);b&&(b=b[0].substring(1));var g=d.find("[name=source]").val().replace(/(?:.+?):\/\//,""),g=g.split("/"),g=g[0],g=g.split(":"),g=g[0],e={},f=["RTMP","RTSP","TS","RTMP.exe","RTSP.exe","TS.exe"],h;for(h in f)f[h]in mist.data.capabilities.connectors&&
(e[f[h]]=mist.data.capabilities.connectors[f[h]].optional.port["default"]);var f={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},i;for(i in e){for(h in mist.data.config.protocols){var j=mist.data.config.protocols[h];if(j.connector==i){if("port"in j)e[i]=j.port;break}}e[i]=e[i]==f[i]?"":":"+e[i]}F.find(".field").closest("label").hide();for(h in e){var k;switch(h){case "RTMP":case "RTMP.exe":k="rtmp://"+c.host+e[h]+"/"+(b?b:"live")+"/";F.find(".field.RTMPurl").setval(k).closest("label").show();
F.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();k=k+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":k="rtsp://"+c.host+e[h]+"/"+(a==""?"STREAMNAME":a)+(b?"?pass="+b:"");break;case "TS":case "TS.exe":k="udp://"+(g==""?c.host:g)+e[h]+"/"}F.find(".field."+h.replace(".exe","")).setval(k).closest("label").show()}}};d.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:n,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},
{label:"Source",type:"browse",filetypes:f,pointer:{main:n,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><tr><td>Input</td><td>Syntax</td><td>Explanation</td></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<br>(Pro&nbsp;only)</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><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. <tr><th>RTSP<br>(Pro&nbsp;only)</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<br>(Pro&nbsp;only)</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></table>",
"function":function(){var a=$(this).val();la.remove();F.html("");if(a!=""){var c=null,b;for(b in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[b].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[b].source_match,a)){c=b;break}if(c===null)P.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{c=mist.data.capabilities.inputs[c];P.html($("<h3>").text(c.name+" Input options"));
var g=mist.convertBuildOptions(c,n);"always_match"in mist.data.capabilities.inputs[b]&&mist.inputMatch(mist.data.capabilities.inputs[b].always_match,a)&&g.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:n,index:"always_on"}});P.append(UI.buildUI(g));if(c.name=="Folder")d.append(la);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(c.name)>-1){a=[$("<span>").text("Configure your source to push to:")];switch(c.name){case "Buffer":case "Buffer.exe":a.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"});a.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"});a.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"});a.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});
break;case "TS":case "TS.exe":a.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}F.html("<br>").append(UI.buildUI(a));X()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:n,index:"stop_sessions"}},F,$("<br>"),{type:"custom",custom:Q},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},
break;case "TS":case "TS.exe":a.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}F.html("<br>").append(UI.buildUI(a));W()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:n,index:"stop_sessions"}},F,$("<br>"),{type:"custom",custom:P},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},
{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:n,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:n,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:n,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:n,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){ka("Streams")}},
{type:"save",label:"Save and Preview","function":function(){ka("Preview")},classes:["saveandpreview"]}]}]));d.find("[name=name]").keyup(function(){X()});X();break;case "Preview":""==c&&UI.navto("Streams");e=":8080";for(g in mist.data.config.protocols)if(b=mist.data.config.protocols[g],"HTTP"==b.connector||"HTTP.exe"==b.connector)e=b.port?":"+b.port:":8080";var r=parseURL(mist.user.host),M=r.protocol+r.host+e+"/",I=$("<div>").css({display:"flex","flex-flow":"row wrap"}),r="";-1==c.indexOf("+")&&(r=
$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+c+'"')).append(I);var G=encodeURIComponent(c);g=$("<div>");I.append(g);var Y=$("<div>"),R=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}),
N=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}),r=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:R,help:"Choose a player to preview"},{label:"Use source",type:"DOMfield",DOMfield:N,help:"Choose an output type to preview"}]),O=$("<div>").addClass("mistvideo").text("Loading player..");g.append(O).append(Y).append(r);var Z=function(){A.html("");if(typeof mistvideo!="undefined")for(var a in mistvideo)if("embedded"in mistvideo[a])for(var b in mistvideo[a].embedded)try{mistvideo[a].embedded[b].player.unload()}catch(d){}a=
{target:O[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,host:M.replace(/\/$/,""),loop:true};if(R.val()!="")a.forcePlayer=R.val();if(N.val()!="")a.forceSource=N.val();mistPlay(c,a)},A=$("<div>").addClass("player_log");g.append($("<div>").append($("<h3>").text("Player log:")).append(A));var ma="";O.on("log error",function(a){var c=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(c=true);var b=a.type+a.originalEvent.message,d="["+UI.format.time((new Date).getTime()/
1E3)+"]";if(ma==b){var a=A.children().last(),c=a.children("[data-amount]"),e=c.attr("data-amount");e++;c.text("("+e+"x)").attr("data-amount",e);a.children(".timestamp").text(d)}else{A.append($("<div>").append($("<span>").addClass("timestamp").text(d).css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).append($("<span>").attr("data-amount",1).css("margin-left","0.5em")).addClass(a.type=="error"?"red":""));c&&A.scrollTop(A[0].scrollHeight)}ma=b});var na=function(){Y.text("");
var a=document.createElement("script");d.append(a);a.src=M+"player.js";a.onerror=function(){O.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){na()}))};a.onload=function(){for(var b in mistplayers)R.append($("<option>").text(mistplayers[b].name).val(b));Z();O.on("initialized",function(){if(N.children().length<=1)for(var a in mistvideo[c].source){var b=mistvideo[c].source[a],d=UI.humanMime(b.type);N.append($("<option>").val(a).text(d?d+" @ "+
b.url.substring(b.url.length-b.relurl.length,0):UI.format.capital(b.type)+" @ "+b.url.substring(b.url.length-b.relurl.length,0)))}a=mistvideo[c].embedded[mistvideo[c].embedded.length-1];d=UI.humanMime(a.player.options.source.type);Y.html("You're watching "+(d?d+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});d[0].removeChild(a)}};na();g=$("<div>").append($("<h3>").text("Meta information"));
var S=$("<span>").text("Loading..");g.append(S);I.append(g);$.ajax({type:"GET",url:M+"json_"+G+".js",success:function(a){var c=a.meta;if(!c||!c.tracks)S.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 b={audio:{vheader:"Audio",labels:["Codec","Duration","Peak bitrate",
"Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Peak bitrate","Language"],content:[]}},d=Object.keys(c.tracks);d.sort(function(a,c){a=a.split("_").pop();c=c.split("_").pop();return a-c});for(var e in d){var g=d[e],f=c.tracks[g];switch(f.type){case "audio":b.audio.content.push({header:"Track "+g.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-
f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz"),"lang"in f?f.lang:"unknown"]});break;case "video":b.video.content.push({header:"Track "+g.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,
1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps"),"lang"in f?f.lang:"unknown"]});break;case "subtitle":b.subtitle.content.push({header:"Track "+g.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),"lang"in f?f.lang:"unknown"]})}}e=["audio","video","subtitle"];c=$("<div>").css({display:"flex",
"flex-flow":"row wrap","font-size":"0.9em"});for(g in e)b[e[g]].content.length&&c.append(UI.buildVheaderTable(b[e[g]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(c);S.html(UI.buildUI(a))}},error:function(){S.html("Error while retrieving stream info.")}});break;case "Embed":""==c&&UI.navTo("Streams");r="";-1==c.indexOf("+")&&(r=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",
c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+c+'"'));var T=$("<span>");d.append(T);G=encodeURIComponent(c);r=parseURL(mist.user.host);e={"":{port:":8080"}};for(g in mist.data.config.protocols){b=mist.data.config.protocols[g];if("HTTP"==b.connector||"HTTP.exe"==b.connector)e[""].port=b.port?":"+b.port:":8080";if("HTTPS"==b.connector||"HTTPS.exe"==b.connector)e.s={},e.s.port=b.port?":"+b.port:
":4433"}var H=M="http://"+r.host+e[""].port+"/";if(otherhost.host||otherhost.https)H=(otherhost.https&&"s"in e?"https://":"http://")+(otherhost.host?otherhost.host:r.host)+(otherhost.https&&"s"in e?e.s.port:e[""].port)+"/";var aa={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},aa);g=UI.stored.getOpts();"embedoptions"in g&&(o=$.extend(o,g.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks=
{}));g={};switch(o.controls){case "stock":g.controls="stock";break;case !0:g.controls=1;break;case !1:g.controls=0}var w=function(){function a(c){switch(typeof c){case "string":return $.isNumeric(c)?c:'"'+c+'"';case "object":return JSON.stringify(c);default:return c}}UI.stored.saveOpt("embedoptions",o);for(var b=c+"_",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 b=b+e,d=['target: document.getElementById("'+b+'")'],
f;for(f in o)o[f]!=aa[f]&&(typeof o[f]!="object"||JSON.stringify(o[f])!=JSON.stringify(aa[f]))&&d.push(f+": "+a(o[f]));f=[];f.push('<div class="mistvideo" id="'+b+'">');f.push(" <noscript>");f.push(' <a href="'+H+G+'.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("'+c+'",{');f.push(" "+d.join(",\n "));f.push(" });");f.push(" };");
f.push(" if (!window.mistplayers) {");f.push(' var p = document.createElement("script");');f.push(' p.src = "'+H+'player.js"');f.push(" document.head.appendChild(p);");f.push(" p.onload = a;");f.push(" }");f.push(" else { a(); }");f.push(" <\/script>");f.push("</div>");return f.join("\n")},ba=$("<span>").text("Loading.."),b=w(o),J=$("<div>").text("Loading..").css("display","flex"),oa="";"s"in e&&(oa=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=
otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",c)}},value:otherhost.https}]).find("label"));T.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:r.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=
{type:"save",label:"Save and Preview","function":function(){ka("Preview")},classes:["saveandpreview"]}]}]));d.find("[name=name]").keyup(function(){W()});W();break;case "Preview":""==c&&UI.navto("Streams");e=":8080";for(g in mist.data.config.protocols)if(b=mist.data.config.protocols[g],"HTTP"==b.connector||"HTTP.exe"==b.connector)e=b.port?":"+b.port:":8080";var f=parseURL(mist.user.host),L=f.protocol+f.host+e+"/",I=$("<div>").css({display:"flex","flex-flow":"row wrap"}),f="";-1==c.indexOf("+")&&(f=
$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(f).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+c+'"')).append(I);var G=encodeURIComponent(c);g=$("<div>");I.append(g);var X=$("<div>"),Q=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Y()}),
M=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Y()}),f=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:Q,help:"Choose a player to preview"},{label:"Use source",type:"DOMfield",DOMfield:M,help:"Choose an output type to preview"}]),N=$("<div>").addClass("mistvideo").text("Loading player..");g.append(N).append(X).append(f);var Y=function(){A.html("");if(typeof mistvideo!="undefined")for(var a in mistvideo)if("embedded"in mistvideo[a])for(var b in mistvideo[a].embedded)try{mistvideo[a].embedded[b].player.unload()}catch(d){}a=
{target:N[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,host:L.replace(/\/$/,""),loop:true};if(Q.val()!="")a.forcePlayer=Q.val();if(M.val()!="")a.forceSource=M.val();mistPlay(c,a)},A=$("<div>").addClass("player_log");g.append($("<div>").append($("<h3>").text("Player log:")).append(A));var ma="";N.on("log error",function(a){var c=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(c=true);var b=a.type+a.originalEvent.message,d="["+UI.format.time((new Date).getTime()/
1E3)+"]";if(ma==b){var a=A.children().last(),c=a.children("[data-amount]"),g=c.attr("data-amount");g++;c.text("("+g+"x)").attr("data-amount",g);a.children(".timestamp").text(d)}else{A.append($("<div>").append($("<span>").addClass("timestamp").text(d).css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).append($("<span>").attr("data-amount",1).css("margin-left","0.5em")).addClass(a.type=="error"?"red":""));c&&A.scrollTop(A[0].scrollHeight)}ma=b});var na=function(){X.text("");
var a=document.createElement("script");d.append(a);a.src=L+"player.js";a.onerror=function(){N.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){na()}))};a.onload=function(){for(var b in mistplayers)Q.append($("<option>").text(mistplayers[b].name).val(b));Y();N.on("initialized",function(){if(M.children().length<=1)for(var a in mistvideo[c].source){var b=mistvideo[c].source[a],d=UI.humanMime(b.type);M.append($("<option>").val(a).text(d?d+" @ "+
b.url.substring(b.url.length-b.relurl.length,0):UI.format.capital(b.type)+" @ "+b.url.substring(b.url.length-b.relurl.length,0)))}a=mistvideo[c].embedded[mistvideo[c].embedded.length-1];d=UI.humanMime(a.player.options.source.type);X.html("You're watching "+(d?d+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});d[0].removeChild(a)}};na();g=$("<div>").append($("<h3>").text("Meta information"));
var R=$("<span>").text("Loading..");g.append(R);I.append(g);$.ajax({type:"GET",url:L+"json_"+G+".js",success:function(a){var c=a.meta;if(!c||!c.tracks)R.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 b={audio:{vheader:"Audio",labels:["Codec","Duration","Peak bitrate",
"Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Peak bitrate","Language"],content:[]}},d=Object.keys(c.tracks);d.sort(function(a,c){a=a.split("_").pop();c=c.split("_").pop();return a-c});for(var g in d){var e=d[g],f=c.tracks[e];switch(f.type){case "audio":b.audio.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-
f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz"),"lang"in f?f.lang:"unknown"]});break;case "video":b.video.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,
1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps"),"lang"in f?f.lang:"unknown"]});break;case "subtitle":b.subtitle.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),"lang"in f?f.lang:"unknown"]})}}g=["audio","video","subtitle"];c=$("<div>").css({display:"flex",
"flex-flow":"row wrap","font-size":"0.9em"});for(e in g)b[g[e]].content.length&&c.append(UI.buildVheaderTable(b[g[e]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(c);R.html(UI.buildUI(a))}},error:function(){R.html("Error while retrieving stream info.")}});break;case "Embed":""==c&&UI.navTo("Streams");f="";-1==c.indexOf("+")&&(f=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(f).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",
c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+c+'"'));var S=$("<span>");d.append(S);G=encodeURIComponent(c);f=parseURL(mist.user.host);e={"":{port:":8080"}};for(g in mist.data.config.protocols){b=mist.data.config.protocols[g];if("HTTP"==b.connector||"HTTP.exe"==b.connector)e[""].port=b.port?":"+b.port:":8080";if("HTTPS"==b.connector||"HTTPS.exe"==b.connector)e.s={},e.s.port=b.port?":"+b.port:
":4433"}var H=L="http://"+f.host+e[""].port+"/";if(otherhost.host||otherhost.https)H=(otherhost.https&&"s"in e?"https://":"http://")+(otherhost.host?otherhost.host:f.host)+(otherhost.https&&"s"in e?e.s.port:e[""].port)+"/";var Z={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},Z);g=UI.stored.getOpts();"embedoptions"in g&&(o=$.extend(o,g.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks=
{}));g={};switch(o.controls){case "stock":g.controls="stock";break;case !0:g.controls=1;break;case !1:g.controls=0}var v=function(){function a(c){switch(typeof c){case "string":return $.isNumeric(c)?c:'"'+c+'"';case "object":return JSON.stringify(c);default:return c}}UI.stored.saveOpt("embedoptions",o);for(var b=c+"_",d=12,g="";d--;){var e;e=Math.floor(Math.random()*62);e=e<10?e:e<36?String.fromCharCode(e+55):String.fromCharCode(e+61);g=g+e}var b=b+g,d=['target: document.getElementById("'+b+'")'],
f;for(f in o)o[f]!=Z[f]&&(typeof o[f]!="object"||JSON.stringify(o[f])!=JSON.stringify(Z[f]))&&d.push(f+": "+a(o[f]));f=[];f.push('<div class="mistvideo" id="'+b+'">');f.push(" <noscript>");f.push(' <a href="'+H+G+'.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("'+c+'",{');f.push(" "+d.join(",\n "));f.push(" });");f.push(" };");
f.push(" if (!window.mistplayers) {");f.push(' var p = document.createElement("script");');f.push(' p.src = "'+H+'player.js"');f.push(" document.head.appendChild(p);");f.push(" p.onload = a;");f.push(" }");f.push(" else { a(); }");f.push(" <\/script>");f.push("</div>");return f.join("\n")},aa=$("<span>").text("Loading.."),b=v(o),J=$("<div>").text("Loading..").css("display","flex"),oa="";"s"in e&&(oa=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=
otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",c)}},value:otherhost.https}]).find("label"));S.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:f.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=
$(this).closest("label").find("input").val();UI.navto("Embed",c)}))))).append(oa)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:H+"json_"+G+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:H+"info_"+G+".js",readonly:!0,clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:H+G+".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:b,rows:b.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:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular source."},{label:"Controls",
type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:g,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(w(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();$(".embed_code").setval(w(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(w(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",
pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(w(o))},help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(w(o))},
help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(w(o))},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(w(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:J,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),ba]));$.ajax({type:"GET",url:H+"json_"+G+".js",success:function(a){var c=[],b=T.find(".forceType"),d;for(d in a.source){var e=a.source[d],f=UI.humanMime(e.type);c.push({label:f?f+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(e.type);
b.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}ba.html(UI.buildUI(c));J.html("");c={};for(d in a.meta.tracks){b=a.meta.tracks[d];b.type!="audio"&&b.type!="video"||(b.type in c?c[b.type].push([b.trackid,UI.format.capital(b.type)+" track "+(c[b.type].length+1)]):c[b.type]=[["",UI.format.capital(b.type)+" track 1"]])}if(Object.keys(c).length){J.closest("label").show();for(d in c){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==
""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(w(o))});J.append(a);c[d].push([-1,"No "+d]);for(var g in c[d])a.append($("<option>").val(c[d][g][0]).text(c[d][g][1]));if(d in o.setTracks){a.val(o.setTracks[d]);if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(w(o))}}}}else J.closest("label").hide()},error:function(){ba.html("Error while retrieving stream info.");J.closest("label").hide();o.setTracks=
{}}});g=document.createElement("script");g.src=M+"player.js";document.head.appendChild(g);g.onload=function(){var a=T.find(".forcePlayer"),c;for(c in mistplayers)a.append($("<option>").text(mistplayers[c].name).val(c));document.head.removeChild(this)};g.onerror=function(){document.head.removeChild(this)};break;case "Push":var B=$("<div>").text("Loading..");d.append(B);mist.send(function(a){function c(a){setTimeout(function(){mist.send(function(b){var d=false;if("push_list"in b&&b.push_list&&b.push_list.length){var d=
true,f;for(f in b.push_list)if(a.indexOf(b.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 c()},{push_list:1})},1E3)}function b(f,g){var h=$("<span>");f.length>=4&&f[2]!=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 i=$("<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..")));g=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:f[1],target:f[2]}}):mist.send(function(){c([f[0]])},{push_stop:[f[0]]})}}));g=="Automatic"&&i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+f[1]+" to "+
f[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var b=$(this);b.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(){b.text("Stop pushes");c(g)},{push_stop:g,push_settings:{wait:0}})}}));return $("<tr>").attr("data-pushid",
{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(v(o))},help:"Only use this particular source."},{label:"Controls",
type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:g,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(v(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();$(".embed_code").setval(v(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(v(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",
pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(v(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(v(o))},help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(v(o))},
help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(v(o))},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(v(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:J,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),aa]));$.ajax({type:"GET",url:H+"json_"+G+".js",success:function(a){var c=[],b=S.find(".forceType"),d;for(d in a.source){var g=a.source[d],f=UI.humanMime(g.type);c.push({label:f?f+" <span class=description>("+g.type+")</span>":UI.format.capital(g.type),type:"str",value:g.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(g.type);
b.append($("<option>").text(f?f+" ("+g.type+")":UI.format.capital(g.type)).val(g.type))}aa.html(UI.buildUI(c));J.html("");c={};for(d in a.meta.tracks){b=a.meta.tracks[d];b.type!="audio"&&b.type!="video"||(b.type in c?c[b.type].push([b.trackid,UI.format.capital(b.type)+" track "+(c[b.type].length+1)]):c[b.type]=[["",UI.format.capital(b.type)+" track 1"]])}if(Object.keys(c).length){J.closest("label").show();for(d in c){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==
""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(v(o))});J.append(a);c[d].push([-1,"No "+d]);for(var e in c[d])a.append($("<option>").val(c[d][e][0]).text(c[d][e][1]));if(d in o.setTracks){a.val(o.setTracks[d]);if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(v(o))}}}}else J.closest("label").hide()},error:function(){aa.html("Error while retrieving stream info.");J.closest("label").hide();o.setTracks=
{}}});g=document.createElement("script");g.src=L+"player.js";document.head.appendChild(g);g.onload=function(){var a=S.find(".forcePlayer"),c;for(c in mistplayers)a.append($("<option>").text(mistplayers[c].name).val(c));document.head.removeChild(this)};g.onerror=function(){document.head.removeChild(this)};break;case "Push":var B=$("<div>").text("Loading..");d.append(B);mist.send(function(a){function c(a){setTimeout(function(){mist.send(function(b){var d=false;if("push_list"in b&&b.push_list&&b.push_list.length){var d=
true,f;for(f in b.push_list)if(a.indexOf(b.push_list[f][0])>-1){d=false;break}}else d=true;if(d)for(f in a)g.find("tr[data-pushid="+a[f]+"]").remove();else c()},{push_list:1})},1E3)}function b(f,e){var h=$("<span>");f.length>=4&&f[2]!=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 i=$("<td>").append($("<button>").text(e=="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(e=="Automatic"?"Removing..":"Stopping..")));e=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:f[1],target:f[2]}}):mist.send(function(){c([f[0]])},{push_stop:[f[0]]})}}));e=="Automatic"&&i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+f[1]+" to "+
f[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var b=$(this);b.text("Stopping pushes..");var e=[],h;for(h in a.push_list)if(f[1]==a.push_list[h][1]&&f[2]==a.push_list[h][2]){e.push(a.push_list[h][0]);g.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){b.text("Stop pushes");c(e)},{push_stop:e,push_settings:{wait:0}})}}));return $("<tr>").attr("data-pushid",
f[0]).append($("<td>").text(f[1])).append($("<td>").append(h.children())).append(i)}B.html("");var d=a.push_settings;d||(d={});B.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"},
LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),f=e.clone();
if("push_list"in a)for(var g in a.push_list)e.append(b(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list)f.append(b([-1,a.push_auto_list[g][0],a.push_auto_list[g][1]],"Automatic"));B.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));f.find("tr").length==1?B.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):B.append(f);
B.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)B.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])==-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]));B.append($("<button>").text("Stop all pushes").click(function(){var b=[],d;for(d in a.push_list)b.push(a.push_list[d][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){c(b)},{push_stop:b});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));
$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var b=i.val(),d=j.val();if(b==""&&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((b==""||
a.push_list[g][1]==b)&&(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.");b="Are you sure you want to stop these pushes?\n\n";for(g in f)b=b+(f[g][1]+" to "+f[g][2]+"\n");if(confirm(b)){f=Object.keys(f);mist.send(function(){c(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)}},{push_settings:1,push_list:1,push_auto_list:1});
break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});return}var v,ca=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[b];"push_urls"in f&&(a=a.concat(f.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var e={};d.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
pointer:{main:e,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:v,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
pointer:{main:e,index:"target"},validate:["required",function(c){for(var b in a)if(mist.inputMatch(a[b],c))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[c=="auto"?"push_auto_add":"push_start"]=e;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
mist.send(function(a){(v=a.active_streams)||(v=[]);var a=[],c;for(c in v)v[c].indexOf("+")!=-1&&a.push(v[c].replace(/\+.*/,"")+"+");v=v.concat(a);var b=0,d=0;for(c in mist.data.streams){v.push(c);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[c].source)){v.push(c+"+");mist.send(function(a,c){var f=c.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])&&v.push(f+"+"+a.browse.files[e]);d++;if(b==d){v=v.filter(function(a,c,b){return b.lastIndexOf(a)===c}).sort();ca()}},{browse:mist.data.streams[c].source},{stream:c});b++}}if(b==d){v=v.filter(function(a,c,b){return b.lastIndexOf(a)===c}).sort();ca()}},{active_streams:1}):(v=Object.keys(mist.data.streams),ca());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});z=$("<tbody>");e=
$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(z);d.append(UI.buildUI([{type:"help",help:"Triggers are a way to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(e);
e.stupidtable();e=mist.data.config.triggers;for(g in e)for(r in e[g])b=triggerRewrite(e[g][r]),z.append($("<tr>").attr("data-index",g+","+r).append($("<td>").text(g)).append($("<td>").text("streams"in b?b.streams.join(", "):"")).append($("<td>").text(b.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(",");
LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var g=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),f=g.clone();
if("push_list"in a)for(var e in a.push_list)g.append(b(a.push_list[e],"Manual"));if("push_auto_list"in a)for(e in a.push_auto_list)f.append(b([-1,a.push_auto_list[e][0],a.push_auto_list[e][1]],"Automatic"));B.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));f.find("tr").length==1?B.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):B.append(f);
B.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(g.find("tr").length==1)B.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(e in a.push_list){f.indexOf(a.push_list[e][1])==-1&&f.push(a.push_list[e][1]);
h.indexOf(a.push_list[e][2])==-1&&h.push(a.push_list[e][2])}f.sort();h.sort();for(e in f)i.append($("<option>").text(f[e]));for(e in h)j.append($("<option>").text(h[e]));B.append($("<button>").text("Stop all pushes").click(function(){var b=[],d;for(d in a.push_list)b.push(a.push_list[d][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){c(b)},{push_stop:b});g.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));
$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var b=i.val(),d=j.val();if(b==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var f={},e;for(e in a.push_list)if((b==""||
a.push_list[e][1]==b)&&(d==""||a.push_list[e][2]==d))f[a.push_list[e][0]]=a.push_list[e];if(Object.keys(f).length==0)return alert("No matching pushes.");b="Are you sure you want to stop these pushes?\n\n";for(e in f)b=b+(f[e][1]+" to "+f[e][2]+"\n");if(confirm(b)){f=Object.keys(f);mist.send(function(){c(f)},{push_stop:f});for(e in f)g.find("tr[data-pushid="+f[e]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(g)}},{push_settings:1,push_list:1,push_auto_list:1});
break;case "Start Push":if(!("capabilities"in mist.data)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});return}var s,ba=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[b];"push_urls"in f&&(a=a.concat(f.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var g={};d.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
pointer:{main:g,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:s,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
pointer:{main:g,index:"target"},validate:["required",function(c){for(var b in a)if(mist.inputMatch(a[b],c))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[c=="auto"?"push_auto_add":"push_start"]=g;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
mist.send(function(a){(s=a.active_streams)||(s=[]);var a=[],c;for(c in s)s[c].indexOf("+")!=-1&&a.push(s[c].replace(/\+.*/,"")+"+");s=s.concat(a);var b=0,d=0;for(c in mist.data.streams){s.push(c);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[c].source)){s.push(c+"+");mist.send(function(a,c){var f=c.stream,g;for(g in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||(e.indexOf("Folder")>=0||e.indexOf("Buffer.exe")>=0||e.indexOf("Folder.exe")>=
0)||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[g])&&s.push(f+"+"+a.browse.files[g]);d++;if(b==d){s=s.filter(function(a,c,b){return b.lastIndexOf(a)===c}).sort();ba()}},{browse:mist.data.streams[c].source},{stream:c});b++}}if(b==d){s=s.filter(function(a,c,b){return b.lastIndexOf(a)===c}).sort();ba()}},{active_streams:1}):(s=Object.keys(mist.data.streams),ba());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});x=$("<tbody>");e=
$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type","string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(x);d.append(UI.buildUI([{type:"help",help:"Triggers are a way to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(e);
e.stupidtable();e=mist.data.config.triggers;for(g in e)for(f in e[g])b=triggerRewrite(e[g][f]),x.append($("<tr>").attr("data-index",g+","+f).append($("<td>").text(g)).append($("<td>").text("streams"in b?b.streams.join(", "):"")).append($("<td>").text(b.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":"triggers"in mist.data.config||(mist.data.config.triggers={});c?(c=c.split(","),g=triggerRewrite(mist.data.config.triggers[c[0]][c[1]]),n={triggeron:c[0],appliesto:g.streams,url:g.handler,async:g.sync,
"default":g["default"],params:g.params}):(d.html($("<h2>").text("New Trigger")),n={});d.append(UI.buildUI([{label:"Trigger on",pointer:{main:n,index:"triggeron"},help:"For what event this trigger should activate.",type:"select",select:[["SYSTEM_START","SYSTEM_START: after MistServer boot"],["SYSTEM_STOP","SYSTEM_STOP: right before MistServer shutdown"],["SYSTEM_CONFIG","SYSTEM_CONFIG: after MistServer configurations have changed"],["OUTPUT_START","OUTPUT_START: right after the start command has been send to a protocol"],
["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD","STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],
@ -171,35 +173,36 @@ if(confirm("Are you sure you want to delete this "+a[0]+" trigger?")){mist.data.
$("[name=params]").closest(".UIelement").show();break;default:$("[name=appliesto]").closest(".UIelement").show();$("[name=params]").setval("").closest(".UIelement").hide()}}},{label:"Applies to",pointer:{main:n,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),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",
pointer:{main:n,index:"url"},validate:["required"],type:"str",LTSonly:!0},{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:n,index:"async"},LTSonly:!0},{label:"Parameters",type:"str",help:"The extra data you want this trigger to use.",pointer:{main:n,index:"params"},
LTSonly:!0},{label:"Default response",type:"str",help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:n,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a={handler:n.url,sync:n.async?true:false,streams:typeof n.appliesto=="undefined"?[]:n.appliesto,params:n.params,
"default":n["default"]};n.triggeron in mist.data.config.triggers||(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var pa=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){da();pa.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);d.append(UI.buildUI([{type:"help",
help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){da()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",
DOMfield:pa,help:"Instantly refresh the table below."}]));d.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));z=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(z));var ra=function(a){var c=$("<span>").text(a);switch(a){case "WARN":c.addClass("orange");break;case "ERROR":case "FAIL":c.addClass("red")}return c},da=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-
1][0]&&a.reverse();z.html("");for(var c in a){var b=$("<span>").addClass("content"),d=a[c][2].split("|"),f;for(f in d)b.append($("<span>").text(d[f]));z.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[c][0],"long")).css("white-space","nowrap")).append($("<td>").html(ra(a[c][1])).css("text-align","center")).append($("<td>").html(b).css("text-align","left")))}}};da();break;case "Statistics":var C=$("<span>").text("Loading..");d.append(C);var n={graph:"new"},x=mist.stored.get().graphs?$.extend(!0,
{},mist.stored.get().graphs):{},P={};for(g in mist.data.streams)P[g]=!0;for(g in mist.data.active_streams)P[mist.data.active_streams[g]]=!0;var P=Object.keys(P).sort(),ea=[];for(g in mist.data.config.protocols)ea.push(mist.data.config.protocols[g].connector);ea.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;C.html(UI.buildUI([{type:"help",
help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=C.find(".graph_xaxis"),c=C.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);c.setval("Graph "+(Object.keys(x).length+
1)).closest("label").show()}else{var b=x[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+b+'"]').prop("disabled",false);c.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in x?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:
"default":n["default"]};n.triggeron in mist.data.config.triggers||(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var pa=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){ca();pa.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);d.append(UI.buildUI([{type:"help",
help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){ca()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",
DOMfield:pa,help:"Instantly refresh the table below."}]));d.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));x=$("<tbody>").css("font-size","0.9em");d.append($("<table>").addClass("logs").append(x));var ra=function(a){var c=$("<span>").text(a);switch(a){case "WARN":c.addClass("orange");break;case "ERROR":case "FAIL":c.addClass("red")}return c},ca=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-
1][0]&&a.reverse();x.html("");for(var c in a){var b=$("<span>").addClass("content"),d=a[c][2].split("|"),f;for(f in d)b.append($("<span>").text(d[f]));x.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[c][0],"long")).css("white-space","nowrap")).append($("<td>").html(ra(a[c][1])).css("text-align","center")).append($("<td>").html(b).css("text-align","left")))}}};ca();break;case "Statistics":var C=$("<span>").text("Loading..");d.append(C);var n={graph:"new"},w=mist.stored.get().graphs?$.extend(!0,
{},mist.stored.get().graphs):{},O={};for(g in mist.data.streams)O[g]=!0;for(g in mist.data.active_streams)O[mist.data.active_streams[g]]=!0;var O=Object.keys(O).sort(),da=[];for(g in mist.data.config.protocols)da.push(mist.data.config.protocols[g].connector);da.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;C.html(UI.buildUI([{type:"help",
help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=C.find(".graph_xaxis"),c=C.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);c.setval("Graph "+(Object.keys(w).length+
1)).closest("label").show()}else{var b=w[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+b+'"]').prop("disabled",false);c.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in w?{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:n,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=C.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());
$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=C.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",true);$s.find('input[type=radio][value="total"]').prop("checked",
true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",P],["protocol","The protocol:",ea]],pointer:{main:n,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(n.graph=="new"){a=UI.plot.addGraph(n,c);x[a.id]=a;C.find("input.graph_id").val("");C.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
x[n.graph];var b=UI.plot.datatype.getOptions({datatype:n.datatype,origin:n.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(x)}}]}]));var c=$("<div>").addClass("graph_container");d.append(c);var b=C.find("select.graph_ids");for(a in x){var f=UI.plot.addGraph(x[a],c);b.append($("<option>").text(f.id)).val(f.id);var e=[],g;for(g in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[g].datatype,origin:x[a].datasets[g].origin});e.push(h)}f.datasets=e;x[f.id]=f}b.trigger("change");
UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var fa=$("<table>"),E=$("<table>"),r={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(g in mist.data.capabilities.cpu)e=mist.data.capabilities.cpu[g],r.content.push({header:"CPU #"+(Number(g)+
1),body:[e.model,UI.format.addUnit(UI.format.number(e.mhz),"MHz"),e.cores,e.threads]});g=UI.buildVheaderTable(r);var qa=function(){var a=mist.data.capabilities.mem,c=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(c.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);fa.replaceWith(a);fa=a;c={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(c.one/100),UI.format.number(c.five/100),UI.format.number(c.fifteen/100)]}]};c=UI.buildVheaderTable(c);E.replaceWith(c);E=
c};qa();d.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(fa)).append($("<td>").append(E))).append($("<tr>").append($("<td>").append(g).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){qa()},{capabilities:true})},3E4);break;case "Email for Help":g=$.extend({},mist.data);
true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",O],["protocol","The protocol:",da]],pointer:{main:n,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(n.graph=="new"){a=UI.plot.addGraph(n,c);w[a.id]=a;C.find("input.graph_id").val("");C.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
w[n.graph];var b=UI.plot.datatype.getOptions({datatype:n.datatype,origin:n.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(w)}}]}]));var c=$("<div>").addClass("graph_container");d.append(c);var b=C.find("select.graph_ids");for(a in w){var f=UI.plot.addGraph(w[a],c);b.append($("<option>").text(f.id)).val(f.id);var g=[],e;for(e in w[a].datasets){var h=UI.plot.datatype.getOptions({datatype:w[a].datasets[e].datatype,origin:w[a].datasets[e].origin});g.push(h)}f.datasets=g;w[f.id]=f}b.trigger("change");
UI.plot.go(w);UI.interval.set(function(){UI.plot.go(w)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});d.append("Loading..");return}var ea=$("<table>"),E=$("<table>"),f={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(g in mist.data.capabilities.cpu)e=mist.data.capabilities.cpu[g],f.content.push({header:"CPU #"+(Number(g)+
1),body:[e.model,UI.format.addUnit(UI.format.number(e.mhz),"MHz"),e.cores,e.threads]});g=UI.buildVheaderTable(f);var qa=function(){var a=mist.data.capabilities.mem,c=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(c.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-
a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);ea.replaceWith(a);ea=a;c={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(c.one/100),UI.format.number(c.five/100),UI.format.number(c.fifteen/100)]}]};c=UI.buildVheaderTable(c);E.replaceWith(c);E=
c};qa();d.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(ea)).append($("<td>").append(E))).append($("<tr>").append($("<td>").append(g).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){qa()},{capabilities:true})},3E4);break;case "Email for Help":g=$.extend({},mist.data);
delete g.statistics;delete g.totals;delete g.clients;delete g.capabilities;g=JSON.stringify(g);g="Version: "+mist.data.config.version+"\n\nConfig:\n"+g;n={};d.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},{type:"str",label:"Your name",validate:["required"],pointer:{main:n,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],
pointer:{main:n,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:n,index:"subject"}},{type:"hidden",value:"-",pointer:{main:n,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:n,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:g,pointer:{main:n,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact?skin=plain",
data:n,success:function(a){a=$("<span>").html(a);a.find("script").remove();d.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:d.append($("<p>").text("This tab does not exist."))}d.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";
a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}});!navigator.doNotTrack&&mist.user.loggedin&&d.append($("<img>").attr("src","https://www.google-analytics.com/collect?v=1&tid=UA-32426932-1&cid="+mist.data.config.iid+"&t=pageview&dp="+encodeURIComponent("/MI/"+a)+"&dh=MI."+(mist.data.LTS?"Pro":"OS")).css({width:"1px",height:"1px","min-width":"1px",opacity:0.1,position:"absolute",left:"-1000px"}))}}};"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,c,d){var c=c||{},d=d||{},d=$.extend(true,{timeOut:3E4,sendData:c},d),b={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,b,c);log("Send",$.extend(true,{},c));b={url:mist.user.host,type:"POST",data:{command:JSON.stringify(b)},dataType:"jsonp",crossDomain:true,timeout:d.timeout*1E3,async:true,error:function(b,e){delete mist.user.loggedin;if(!d.hide){switch(e){case "timeout":e=
$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(e).append($("<a>").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")},success:function(b){log("Receive",$.extend(true,{},b),"as reply to",d.sendData);
delete mist.user.loggedin;switch(b.authorize.status){case "OK":if("streams"in b)if(b.streams)if("incomplete list"in b.streams){delete b.streams["incomplete list"];$.extend(mist.data.streams,b.streams)}else mist.data.streams=b.streams;else mist.data.streams={};var e=$.extend({},b),f=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],q;for(q in e)f.indexOf(q)==-1&&delete e[q];$.extend(true,mist.data,e);if("config"in e&&"protocols"in e.config)mist.data.config.protocols=
delete mist.user.loggedin;switch(b.authorize.status){case "OK":if("streams"in b)if(b.streams)if("incomplete list"in b.streams){delete b.streams["incomplete list"];$.extend(mist.data.streams,b.streams)}else mist.data.streams=b.streams;else mist.data.streams={};var e=$.extend({},b),h=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],q;for(q in e)h.indexOf(q)==-1&&delete e[q];$.extend(true,mist.data,e);if("config"in e&&"protocols"in e.config)mist.data.config.protocols=
e.config.protocols;mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));b.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(b.log){e=b.log[b.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+
UI.format.time(e[0])+" ["+e[1]+"] "+e[2])}if("totals"in b){e=function(a,c,b){var d;d=function(){for(var a in b.fields)e[b.fields[a]].push([m,0])};var e={},f;for(f in b.fields)e[b.fields[f]]=[];var g=0,m;if(b.data){if(b.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=b.start*1E3;d()}else m=b.start*1E3;for(f in b.data){if(f==0){m=b.start*1E3;var q=0}else{m=m+b.interval[q][1]*1E3;b.interval[q][0]--;if(b.interval[q][0]<=0){q++;q<b.interval.length-1&&(g=g+2)}}if(g%2==1){d();g--}for(var K in b.data[f])e[b.fields[K]].push([m,
b.data[f][K]]);if(g){d();g--}}if(mist.data.config.time-b.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=c?c.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in b.totals)e(c.totals.streams,
UI.format.time(e[0])+" ["+e[1]+"] "+e[2])}if("totals"in b){e=function(a,c,b){var d;d=function(){for(var a in b.fields)e[b.fields[a]].push([m,0])};var e={},g;for(g in b.fields)e[b.fields[g]]=[];var h=0,m;if(b.data){if(b.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=b.start*1E3;d()}else m=b.start*1E3;for(g in b.data){if(g==0){m=b.start*1E3;var q=0}else{m=m+b.interval[q][1]*1E3;b.interval[q][0]--;if(b.interval[q][0]<=0){q++;q<b.interval.length-1&&(h=h+2)}}if(h%2==1){d();h--}for(var x in b.data[g])e[b.fields[x]].push([m,
b.data[g][x]]);if(h){d();h--}}if(mist.data.config.time-b.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=c?c.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in b.totals)e(c.totals.streams,
c.totals.protocols,b.totals);else for(q in b.totals)e(c.totals[q].streams,c.totals[q].protocols,b.totals[q])}a&&a(b,d);break;case "CHALL":if(b.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=b.authorize.challenge;mist.send(a,c,d);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,
name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete c.authorize;mist.send(a,c,d);break;default:UI.navto("Login")}}};d.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){e.abort()}));var e=$.ajax(b)},inputMatch:function(a,c){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var d in a){var b=
a[d].replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+b+"(?:\\?[^\\?]*)?$","i").test(c))return true}return false},convertBuildOptions:function(a,c){var d=[],b=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var e in b)if(a[b[e]]){d.push($("<h4>").text(UI.format.capital(b[e])+" parameters"));for(var g in a[b[e]]){var m=a[b[e]][g],f={label:UI.format.capital(m.name),pointer:{main:c,index:g},validate:[]};b[e]=="required"&&(!("default"in m)||m["default"]==
"")&&f.validate.push("required");if("default"in m)f.placeholder=m["default"];if("help"in m)f.help=m.help;if("unit"in m)f.unit=m.unit;switch(m.type){case "int":f.type="int";break;case "uint":f.type="int";f.min=0;break;case "debug":f.type="debug";break;case "select":f.type="select";f.select=m.select;break;default:f.type="str"}d.push(f)}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var d=this.get();d[a]=c;mist.send(function(){},{ui_settings:d})},del:function(a){delete mist.data.ui_settings[a];
a[d].replace(/[^\w\s]/g,"\\$&"),b=b.replace(/\\\*/g,".*");if(RegExp("^(?:[a-zA-Z]:)?"+b+"(?:\\?[^\\?]*)?$","i").test(c))return true}return false},convertBuildOptions:function(a,c){var d=[],b=["required","optional"];"desc"in a&&d.push({type:"help",help:a.desc});for(var e in b)if(a[b[e]]){d.push($("<h4>").text(UI.format.capital(b[e])+" parameters"));for(var g in a[b[e]]){var m=a[b[e]][g],h={label:UI.format.capital(m.name),pointer:{main:c,index:g},validate:[]};b[e]=="required"&&(!("default"in m)||m["default"]==
"")&&h.validate.push("required");if("default"in m)h.placeholder=m["default"];if("help"in m)h.help=m.help;if("unit"in m)h.unit=m.unit;switch(m.type){case "int":h.type="int";break;case "uint":h.type="int";h.min=0;break;case "debug":h.type="debug";break;case "select":h.type="select";h.select=m.select;break;default:h.type="str"}d.push(h)}}return d},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,c){var d=this.get();d[a]=c;mist.send(function(){},{ui_settings:d})},del:function(a){delete mist.data.ui_settings[a];
mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}}
$.fn.getval=function(){var a=$(this).data("opts"),c=$(this).val();if(a&&"type"in a)switch(a.type){case "span":c=$(this).html();break;case "checkbox":c=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){c=[];c.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&c.push(a.val())}else c="";break;case "checklist":c=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){c.push($(this).attr("name"))})}return c};
$.fn.setval=function(a){var c=$(this).data("opts");$(this).val(a);if(c&&"type"in c)switch(c.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":c=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";c.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),d;for(d in a)c.values.append(c.prototype.clone(true).val(a[d]));c.blackwhite.trigger("change");break;case "radioselect":if(typeof a==

View file

@ -451,7 +451,7 @@ var UI = {
}
else {
//this value was not entered
delete pointer.main[pointer.index];
pointer.main[pointer.index] = null;
return true; //continue
}
}
@ -2050,6 +2050,7 @@ var UI = {
var $errors = $('<span>').addClass('logs');
var $viewers = $('<span>');
var $servertime = $('<span>');
var $activeproducts = $('<span>').text("Unknown");
var $protocols_on = $('<span>');
var $protocols_off = $('<span>');
@ -2076,11 +2077,12 @@ var UI = {
},{
type: 'span',
label: 'Licensed to',
'default': 'unknown',
pointer: {
main: mist.data.config.license,
index: 'user'
},
value: ("license" in mist.data.config ? mist.data.config.license.name : ""),
LTSonly: true
},{
type: 'span',
label: 'Active products',
value: $activeproducts,
LTSonly: true
},{
type: 'span',
@ -2148,27 +2150,54 @@ var UI = {
}
]));
if (mist.data.LTS) {
function update_update(info) {
if (!('uptodate' in info)) {
$versioncheck.text('Unknown');
function update_update(d) {
function update_progress(d) {
if (!d.update) {
UI.showTab("Overview");
return;
}
var perc = "";
if ("progress" in d.update) {
perc = " ("+d.update.progress+"%)";
}
$versioncheck.text("Updating.."+perc);
setTimeout(function(){
mist.send(function(d){
update_progress(d);
},{update:true});
},5e3);
}
if ((!d.update) || (!('uptodate' in d.update))) {
$versioncheck.text('Unknown, checking..');
setTimeout(function(){
mist.send(function(d){
update_update(d);
},{checkupdate:true});
},5e3);
return;
}
else if (info.error) {
$versioncheck.addClass('red').text(info.error);
else if (d.update.error) {
$versioncheck.addClass('red').text(d.update.error);
return;
}
else if (info.uptodate) {
else if (d.update.uptodate) {
$versioncheck.text('Your version is up to date.').addClass('green');
return;
}
else if (d.update.progress) {
$versioncheck.addClass('orange').removeClass('red').text('Updating..');
update_progress(d);
}
else {
$versioncheck.addClass('red').text('Version outdated!').append(
$('<button>').text('Update').css({'font-size':'1em','margin-left':'1em'}).click(function(){
if (confirm('Are you sure you want to execute a rolling update?')) {
$versioncheck.addClass('orange').removeClass('red').text('Rolling update command sent..');
mist.stored.del('update');
mist.send(function(d){
UI.navto('Overview');
update_progress(d);
},{autoupdate: true});
}
})
@ -2176,18 +2205,45 @@ var UI = {
}
}
if ((!mist.stored.get().update) || ((new Date()).getTime()-mist.stored.get().update.lastchecked > 3600e3)) {
var update = {};
update.lastchecked = (new Date()).getTime();
mist.send(function(d){
mist.stored.set('update',update);
update_update(d.update);
},{checkupdate: true});
}
else {
mist.send(function(d){
update_update(d.update);
},{update: true});
update_update(mist.data);
//show license information
if ("license" in mist.data.config) {
if (("active_products" in mist.data.config.license) && (Object.keys(mist.data.config.license.active_products).length)) {
var $t = $("<table>").css("text-indent","0");
$activeproducts.html($t);
$t.append(
$("<tr>").append(
$("<th>").append("Product")
).append(
$("<th>").append("Updates until")
).append(
$("<th>").append("Use until")
).append(
$("<th>").append("Max. simul. instances")
)
);
for (var i in mist.data.config.license.active_products) {
var p = mist.data.config.license.active_products[i];
$t.append(
$("<tr>").append(
$("<td>").append(p.name)
).append(
$("<td>").append((p.updates_final ? p.updates_final : "&infin;"))
).append(
$("<td>").append(p.use_final)
).append(
$("<td>").append((p.amount ? p.amount : "&infin;"))
)
);
}
}
else {
$activeproducts.text("None.");
}
$activeproducts.append(
$("<a>").text("More details").attr("href","https://shop.mistserver.org/myinvoices").attr("target","_blank")
);
}
}
else {
@ -5399,7 +5455,14 @@ var UI = {
$(a[0]).focus();
return false;
}
})
});
if ((!navigator.doNotTrack) && (mist.user.loggedin)) {
///GA tracking; only if connected
$main.append(
$("<img>").attr("src","https://www.google-analytics.com/collect?v=1&tid=UA-32426932-1&cid="+mist.data.config.iid+"&t=pageview&dp="+encodeURIComponent("/MI/"+tab)+"&dh=MI."+(mist.data.LTS ? "Pro" : "OS")).css({width:"1px",height:"1px","min-width":"1px",opacity:0.1,position:"absolute",left:"-1000px"})
);
}
}
};

View file

@ -74,6 +74,8 @@ namespace Mist {
capa["url_match"].append("/json_$.js");
capa["url_match"].append("/player.js");
capa["url_match"].append("/player.css");
capa["url_match"].append("/videojs.js");
capa["url_match"].append("/dashjs.js");
capa["url_match"].append("/embed_$.js");
capa["url_match"].append("/flashplayer.swf");
capa["url_match"].append("/oldflashplayer.swf");
@ -603,15 +605,11 @@ namespace Mist {
used = true;
}
if (it->asStringRef() == "dashjs"){
#include "playerdash.js.h"
response.append((char*)playerdash_js, (size_t)playerdash_js_len);
#include "dashjs.js.h"
response.append((char*)dash_js, (size_t)dash_js_len);
used = true;
}
if (it->asStringRef() == "videojs"){
#include "playervideo.js.h"
response.append((char*)playervideo_js, (size_t)playervideo_js_len);
#include "videojs.js.h"
response.append((char*)video_js, (size_t)video_js_len);
used = true;
@ -648,6 +646,50 @@ namespace Mist {
#include "mist.css.h"
response.append((char*)mist_css, (size_t)mist_css_len);
H.SetBody(response);
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
if (H.url == "/videojs.js"){
std::string response;
H.Clean();
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.setCORSHeaders();
H.SetHeader("Content-Type", "application/javascript");
if (method == "OPTIONS" || method == "HEAD"){
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
#include "playervideo.js.h"
response.append((char*)playervideo_js, (size_t)playervideo_js_len);
#include "playerhlsvideo.js.h"
response.append((char*)playerhlsvideo_js, (size_t)playerhlsvideo_js_len);
H.SetBody(response);
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
if (H.url == "/dashjs.js"){
std::string response;
H.Clean();
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.setCORSHeaders();
H.SetHeader("Content-Type", "application/javascript");
if (method == "OPTIONS" || method == "HEAD"){
H.SendResponse("200", "OK", myConn);
H.Clean();
return;
}
#include "playerdashlic.js.h"
response.append((char*)playerdashlic_js, (size_t)playerdashlic_js_len);
#include "playerdash.js.h"
response.append((char*)playerdash_js, (size_t)playerdash_js_len);
H.SetBody(response);
H.SendResponse("200", "OK", myConn);
H.Clean();