').append($path)
)
).append(
$folder_contents
)
);
var path = $('#settings-streams-'+streamName+'-source').val();
path = path.split(seperator);
path.pop();
path = path.join(seperator);
$(this).hide();
doBrowse(path);
})
)
).append(
$('').text('Input options')
).append(
$inputoptions
).append(
$(' ')
).append(
$('').addClass('LTS-only').html(
$('').text('Encrypt this stream')
).append(
$('
').addClass('description').text(
'To enable encryption, the Licence Acquisition URL must be entered, as well as either the content key or the key ID and seed.'
)
).append(
$('
').text('Licence Acquisition URL:').attr('for','settings-streams-'+streamName+'-la_url').append(
$(' ').attr('type','text').attr('id','settings-streams-'+streamName+'-la_url').addClass('isSetting')
)
).append(
$(' ')
).append(
$('').text('Content key:').attr('for','settings-streams-'+streamName+'-contentkey').append(
$(' ').attr('type','text').attr('id','settings-streams-'+streamName+'-contentkey').addClass('isSetting')
)
).append(
$('').text('- or -').addClass('description')
).append(
$('').text('Key ID:').attr('for','settings-treams-'+streamName+'-keyid').append(
$(' ').attr('type','text').attr('id','settings-streams-'+streamName+'-keyid').addClass('isSetting')
)
).append(
$('').text('Key seed:').attr('for','settings-streams-'+streamName+'-keyseed').append(
$(' ').attr('type','text').attr('id','settings-streams-'+streamName+'-keyseed').addClass('isSetting')
)
)
).append(
$('').addClass('enter-to-submit').text('Save').click(function(){
var newName = $('#settings-streams-'+streamName+'-name').val();
if (streamName != newName) {
if (!settings.settings.streams) { settings.settings.streams = {}; }
settings.settings.streams[streamName] = {};
if (applyInput() === false) { return; }
settings.settings.streams[newName] = settings.settings.streams[streamName];
delete settings.settings.streams[streamName];
}
else {
var filename = $('#settings-streams-'+streamName+'-record').val()
if ((filename != '') && (typeof filename != 'undefined')) {
filename = filename.split('.');
if (filename[filename.length-1] != 'dtsc') {
filename.push('dtsc');
}
$('#settings-streams-'+streamName+'-record').val(filename.join('.'));
}
if (applyInput() === false) { return; }
}
saveAndReload('streams');
})
).append(
$('').text('Cancel').addClass('escape-to-cancel').click(function(){
showTab('streams');
})
)
);
if (streamName != '_new_') {
enterSettings();
}
$source.trigger('keyup');
break;
case 'preview':
var httpConnector = false;
for (var index in settings.settings.config.protocols) {
if ((settings.settings.config.protocols[index].connector == 'HTTP') || (settings.settings.config.protocols[index].connector == 'HTTP.exe')) {
httpConnector = settings.settings.config.protocols[index];
}
}
if (httpConnector) {
$('#page').html(
$('').addClass('table').html(
$('
').addClass('row').html(
$('
').addClass('cell').attr('id','liststreams').addClass('menu').css('vertical-align','top')
).append(
$('
').addClass('cell').attr('id','subpage').css('padding-left','1em')
)
)
);
var embedbase = 'http://'+parseURL(settings.server).host+':'+(httpConnector.port ? httpConnector.port : 8080)+'/';
for (var s in settings.settings.streams) {
if (!streamName) {
streamName = s;
}
$('#liststreams').append(
$('
').addClass('button').text(settings.settings.streams[s].name).click(function(){
buildstreamembed($(this).text(),embedbase);
})
);
}
buildstreamembed(streamName,embedbase);
}
else {
$('#page').html(
$('
').addClass('description').addClass('red').text('Could not find a HTTP connector. Please add one on the "Protocols" page.')
);
}
break;
case 'limits':
var $tbody = $('
');
$('#page').html(
$('').addClass('LTS-only').html(
$('
').addClass('description').text('This is an overview of the limits that have been configured on MistServer.')
).append(
$('
').html(
$('').html(
$('').html(
$('').text('Applies to')
).append(
$(' ').text('Type')
).append(
$(' ').text('Name')
).append(
$(' ').text('Value')
).append(
$(' ')
)
)
).append(
$tbody
)
).append(
$('').text('New').click(function(){
showTab('edit limit','_new_');
})
)
);
for (var index in settings.settings.config.limits) {
$tbody.append(
$('').data('limit',['server',index]).html(
$('').text('The whole server')
).append(
$(' ').text(settings.settings.config.limits[index].type)
).append(
$(' ').text(limitShortToLong(settings.settings.config.limits[index].name))
).append(
$(' ').html(limitValueFormat(settings.settings.config.limits[index]))
).append(
$(' ').html(
$('').text('Edit').click(function(){
showTab('edit limit',$(this).parent().parent().data('limit'));
})
).append(
$('').text('Delete').click(function(){
if (confirmDelete('Are you sure you want to delete the limit "Server: '+limitShortToLong(settings.settings.config.limits[index].name)+'"')) {
var which = $(this).parent().parent().data('limit')
delete settings.settings.config.limits[which[1]];
saveAndReload('limits');
}
})
)
)
);
}
for (var stream in settings.settings.streams) {
for (var index in settings.settings.streams[stream].limits) {
$tbody.append(
$('').data('limit',['stream-'+stream,index]).html(
$('').text('The stream "'+stream+'"')
).append(
$(' ').text(settings.settings.streams[stream].limits[index].type)
).append(
$(' ').text(limitShortToLong(settings.settings.streams[stream].limits[index].name))
).append(
$(' ').html(limitValueFormat(settings.settings.streams[stream].limits[index]))
).append(
$(' ').html(
$('').text('Edit').click(function(){
showTab('edit limit',$(this).parent().parent().data('limit'));
})
).append(
$('').text('Delete').click(function(){
var which = $(this).parent().parent().data('limit');
var stream = which[0].replace('stream-','');
if (confirmDelete('Are you sure you want to delete the limit "Stream "'+stream+'": '+limitShortToLong(settings.settings.streams[stream].limits[which[1]].name)+'"')) {
delete settings.settings.streams[stream].limits[which[1]];
saveAndReload('limits');
}
})
)
)
);
}
}
break;
case 'edit limit':
var objpath;
if (streamName == '_new_') {
$('#page').html(
$('').text('Adding a new limit')
)
objpath = 'settings.newlimit[0]';
}
else {
if (streamName[0] == 'server') {
objpath = 'settings.config.limits';
$('#page').html(
$('
').html('Editing server limit "').append(
$('').attr('id','limit-name-tag')
).append('"')
)
}
else {
objpath = 'settings.streams.'+streamName[0].replace('stream-','')+'.limits';
$('#page').html(
$('').html('Editing stream "'+streamName[0].replace('stream-','')+'" limit "').append(
$('').attr('id','limit-name-tag')
).append('"')
);
}
objpath += '['+streamName[1]+']';
}
var $appliesto = $('').attr('id','limit-applies-to').html(
$('').val('server').text('The whole server')
);
$('#page').append(
$('').addClass('input_container').html(
$('
').text('Applies to:').attr('for','limit-applies-to').append(
$appliesto
)
).append(
$('').text('Type:').attr('for','limit-type').append(
$('').attr('id','limit-type').attr('objpath',objpath+'.type').addClass('isSetting').html(
$('').val('soft').text('Soft')
).append(
$(' ').val('hard').text('Hard')
)
)
).append(
$('').addClass('description').text(
'The server will not allow a hard limit to be passed. A soft limit can be used to set alerts.'
)
).append(
$('
').text('Name:').attr('for','limit-name').append(
$('').attr('id','limit-name').attr('objpath',objpath+'.name').addClass('isSetting').html(
$('').val('kbps_max').text(limitShortToLong('kbps_max'))
).append(
$(' ').val('users').text(limitShortToLong('users'))
).append(
$(' ').val('geo').text(limitShortToLong('geo'))
).append(
$(' ').val('host').text(limitShortToLong('host'))
).change(function(){
changeLimitName();
})
)
).append(
$('').text('Value:').attr('id','limit-value-label').attr('for','limit-value').append(
$('').addClass('unit').text('[bytes/s]')
).append(
$(' ').attr('type','text').attr('id','limit-value').attr('objpath',objpath+'.value').addClass('validate-required').addClass('isSetting')
)
).append(
$('').attr('id','detailed-settings').css('overflow','hidden')
).append(
$('
').text('Save').addClass('enter-to-submit').click(function(){
if (streamName == '_new_') {
settings.settings.newlimit = [{}];
}
if (applyInput() === false) { return; }
moveLimit($('#limit-applies-to').val(),streamName,objpath);
saveAndReload('limits');
})
).append(
$('').text('Cancel').addClass('escape-to-cancel').click(function(){
showTab('limits');
})
)
);
enterSettings();
$("#limit-name-tag").text(limitShortToLong($('#limit-name').val()));
changeLimitName($('#limit-value').val());
for (var index in settings.settings.streams) {
$appliesto.append(
$('').val('stream-'+index).text('The stream "'+index+'"')
);
}
if (streamName != '_new_') {
if (streamName[0] == 'config') {
$appliesto.val('_server_');
}
else {
$appliesto.val('stream-'+streamName[1]);
}
}
break;
case 'conversion':
$('#page').html(
$('').text('Current conversions:')
);
if (settings.settings.conversion.status) {
var $tbody = $('
');
$('#page').append(
$('').html(
$('').html(
$('').html(
$('').text('Start time')
).append(
$(' ').text('Message')
).append(
$(' ').text('Details')
)
)
).append($tbody)
);
for (var index in settings.settings.conversion.status) {
var $details = $('');
if (settings.settings.conversion.status[index].details) {
$details.append(
$('').html(
$('').text('Input file:')
).append(
$(' ').text(settings.settings.conversion.status[index].details.input)
)
).append(
$(' ').html(
$('').text('Output file:')
).append(
$(' ').text(settings.settings.conversion.status[index].details.output)
)
).append(
$(' ').html(
$('').text('Encoder:')
).append(
$(' ').text(settings.settings.conversion.status[index].details.encoder)
)
);
if (settings.settings.conversion.status[index].details.video) {
$details.append(
$(' ').html(
$('').text('Video included').attr('colspan',2)
)
);
for (var s in settings.settings.conversion.status[index].details.video) {
$details.append(
$(' ').html(
$('').text('Video '+s+':')
).append(
$(' ').text(settings.settings.conversion.status[index].details.video[s])
)
)
}
}
if (settings.settings.conversion.status[index].details.audio) {
$details.append(
$(' ').html(
$('').text('Audio included').attr('colspan',2)
)
);
for (var s in settings.settings.conversion.status[index].details.audio) {
$details.append(
$(' ').html(
$('').text('Audio '+s+':')
).append(
$(' ').text(settings.settings.conversion.status[index].details.audio[s])
)
)
}
}
}
$tbody.append(
$(' ').html(
$('').text(formatDateLong(Number(index.replace('c_',''))/1000))
).append(
$(' ').html(formatConversionStatus(settings.settings.conversion.status[index])).attr('id','conversion-status-of-'+index)
).append(
$(' ').html($details)
)
)
}
}
else {
$('#page').append(
$('').text('None.')
);
}
$('#page').append(
$('').text('New').click(function(){
showTab('new conversion');
})
).append(
$('').text('Clear list').click(function(){
if (confirmDelete('Are you sure you want to clear the conversion list?')) {
settings.settings.conversion.clear = true;
saveAndReload('conversion');
}
})
);
if (settings.settings.conversion.status) {
theInterval = setInterval(function(){
updateConversions();
},10000);
updateConversions();
}
break;
case 'new conversion':
$('#page').html(
$('').text('New conversion')
).append(
$('
').addClass('input_container').html(
$('
').addClass('description').text('This page can be used to add a new conversion instruction.')
).append(
$('
').addClass('description').text('First, specify the directory that contains the file you wish to convert. Then click the "Search for input files"-button to scan it for files.')
).append(
$('
').text('Directory:').attr('for','conversion-query').append(
$(' ').attr('type','text').attr('id','conversion-query').val(defaults.conversion.inputdir).attr('placeholder','/path/to/directory')
)
).append(
$('').text('Search for input files').addClass('enter-to-submit').click(function(){
conversionDirQuery($('#conversion-query').val(),objpath);
})
).append(
$('').attr('id','query-status').addClass('description').css('display','inline-block').css('margin-top','12px')
)
).append(
$('').attr('id','conversion-input-file').addClass('input_container')
).append(
$('
').attr('id','conversion-details').addClass('input_container')
);
break;
case 'logs':
$('#page').append(
$('
').html(
$(' ').attr('type','checkbox').attr('id','logs-refresh').click(function(){
if ($(this).is(':checked')) {
defaults.logRefreshing[0] = true;
theInterval = setInterval(function(){
getData(function(data){
settings.settings.log = data.log;
$('#logs-table').remove();
$('#page').append(buildLogsTable());
});
},$('#logs-refresh-every').val());
getData(function(data){
settings.settings.log = data.log;
$('#logs-table').remove();
$('#page').append(buildLogsTable());
});
}
else {
defaults.logRefreshing[0] = false;
clearInterval(theInterval);
}
})
).append(
$('').text(' Refresh logs every ')
).append(
$('').attr('id','logs-refresh-every').append(
$('').val(10000).text('10 seconds')
).append(
$(' ').val(30000).text('30 seconds')
).append(
$(' ').val(60000).text('minute')
).append(
$(' ').val(300000).text('5 minutes')
).append(
$(' ').val(600000).text('10 minutes')
).append(
$(' ').val(1800000).text('30 minutes')
).change(function(){
defaults.logRefreshing[1] = $(this).val();
if ($('#logs-refresh').is(':checked')) {
clearInterval(theInterval);
theInterval = setInterval(function(){
getData(function(data){
settings.settings.log = data.log;
$('#logs-table').remove();
$('#page').append(buildLogsTable());
});
},$(this).val());
}
else {
clearInterval(theInterval);
}
})
)
).append(
$('').text('Purge logs').click(function(){
settings.settings.clearstatlogs = true;
saveAndReload('logs');
})
).append(
buildLogsTable()
);
getData(function(data){
settings.settings.log = data.log;
$('#logs-table').remove();
$('#page').append(buildLogsTable());
});
//load values for the check- and selectbox and start the interval if applicable
if (defaults.logRefreshing[0]) {
$('#logs-refresh').attr('checked','checked');
theInterval = setInterval(function(){
getData(function(data){
settings.settings.log = data.log;
$('#logs-table').remove();
$('#page').append(buildLogsTable());
});
},defaults.logRefreshing[1]);
}
$('#logs-refresh-every').val(defaults.logRefreshing[1]);
break;
case 'statistics':
var graphs = {};
var plot;
$('#page').html(
$('').addClass('description').text('Here, you can select all kinds of data, and view them in a graph.')
).append(
$('
').addClass('input_container').html(
$('
').text('Select the data to display')
).append(
$('').text('Add to graph:').append(
$('').attr('id','graphid').html(
$('').text('New graph').val('new')
).change(function(){
if ($(this).val() == 'new') {
$('#graphtype').removeAttr('disabled');
}
else {
$('#graphtype').attr('disabled','disabled');
//set to correct type
}
})
)
).append(
$('').text('Graph x-axis type:').append(
$('').attr('id','graphtype').html(
$('').text('Time line').val('time')
/*).append(
$(' ').text('Map').val('coords') not yet */
).change(function(){
$('#dataset option').hide();
$('#dataset option.axis_'+$(this).val()).show();
$('#dataset').val( $('#dataset option.axis_'+$(this).val()).first().val());
})
)
).append(
$('').text('Select data set:').append(
$('').attr('id','dataset').html(
$('').text('Viewers').val('clients').addClass('axis_time')
).append(
$(' ').text('Bandwidth (up)').val('upbps').addClass('axis_time')
).append(
$(' ').text('Bandwidth (down)').val('downbps').addClass('axis_time')
).append(
$(' ').text('% CPU').val('cpuload').addClass('axis_time')
).append(
$(' ').text('Memory load').val('memload').addClass('axis_time')
).append(
$(' ').text('Viewer location (LTS only)').val('coords').addClass('axis_coords')
).change(function(){
switch ($(this).val()) {
case 'clients':
$('#dataset-details .replace-dataset').text('amount of viewers');
$('#dataset-details').show();
break;
case 'upbps':
$('#dataset-details .replace-dataset').text('bandwidth (up)');
$('#dataset-details').show();
break;
case 'downbps':
$('#dataset-details .replace-dataset').text('bandwidth (down)');
$('#dataset-details').show();
break;
default:
$('#dataset-details').hide();
}
})
)
).append(
$('').attr('id','dataset-details').addClass('checklist').css({
'padding':'0.5em 0 0 40%',
'font-size':'0.9em'
}).html('Show
amount of viewers for:').append(
$('
').text('The total').prepend(
$(' ').attr('type','radio').attr('name','cumutype').attr('checked','checked').val('all')
)
).append(
$('').text('The stream ').append(
$('').addClass('stream cumuval')
).prepend(
$(' ').attr('type','radio').attr('name','cumutype').val('stream')
)
).append(
$('').text('The protocol ').append(
$('').addClass('protocol cumuval')
).prepend(
$(' ').attr('type','radio').attr('name','cumutype').val('protocol')
)
)
).append(
$('').text('Add data set').click(function(){
//the graph
if ($('#graphid').val() == 'new') {
var graph = {};
graph.id = $('#graphid').val();
graph.type = $('#graphtype').val();
graph.id = 'graph_'+($('#graphcontainer .graph').length+1);
graph.datasets = [];
graphs[graph.id] = graph;
$('#graphcontainer').append(
$('').attr('id',graph.id).addClass('graph-item').html(
$('
').addClass('legend')
).append(
$('
').addClass('graph')
)
);
$('#graphid').append(
$('
').text(graph.id)
).val(graph.id).trigger('change');
}
else {
var graph = graphs[$('#graphid').val()];
}
//the dataset itself
var d = {
display: true,
type: $('#dataset').val(),
label: '',
yaxistype: 'amount',
data: [],
lines: { show: true },
points: { show: false }
};
switch (d.type) {
case 'cpuload':
d.label = 'CPU load';
d.yaxistype = 'percentage';
break;
case 'memload':
d.label = 'Memory load';
d.yaxistype = 'percentage';
break;
case 'upbps':
case 'downbps':
case 'clients':
d.cumutype = $('#dataset-details input[name=cumutype]:checked').val();
d.yaxistype = 'bytespersec';
if (d.cumutype == 'all') {
switch (d.type) {
case 'clients':
d.label = 'Total viewers';
d.yaxistype = 'amount';
break;
case 'upbps':
d.label = 'Total bandwidth (up)';
break;
case 'downbps':
d.label = 'Total bandwidth (down)';
break;
}
}
else {
var which = $('#dataset-details .cumuval.'+d.cumutype).val();
if (d.cumutype == 'stream') {
d.stream = which;
}
else if (d.cumutype == 'protocol') {
d.protocol = which;
}
switch (d.type) {
case 'clients':
d.label = 'Viewers ('+which+')';
d.yaxistype = 'amount';
break;
case 'upbps':
d.label = 'Bandwidth (up) ('+which+')';
break;
case 'downbps':
d.label = 'Bandwidth (down) ('+which+')';
break;
}
}
break;
case 'coords':
d.cumutype = $('#dataset-details input[name=cumutype]:checked').val();
if (d.cumutype == 'all') {
var which = 'all';
}
else {
var which = $('#dataset-details .cumuval.'+d.cumutype).val();
}
d.label = 'Viewer location ('+which+')';
break;
}
graph.datasets.push(d);
getPlotData(graphs);
})
)/*.append(
$('').text('Switch data display type').css('clear','both')
).append(
$('').text('Show data in a:').append(
$('').html(
$('').text('graph')
).append(
$(' ').text('table')
)
)
)*/
).append(
$('').attr('id','graphcontainer')
);
for (var i in settings.settings.streams) {
$('#dataset-details .cumuval.stream').append(
$('
').text(settings.settings.streams[i].name).val(i)
);
}
for (var i in settings.settings.config.protocols) {
$('#dataset-details .cumuval.protocol').append(
$(' ').text(settings.settings.config.protocols[i].connector)
);
}
$('#graphtype').trigger('change');
var lastitem = null;
var $tooltip = $('').attr('id','tooltip');
$('body').append($tooltip);
$('.graph').live('plothover',function(e,pos,item){
if (item) {
var pos;
if (item.pageX > ($(window).width() / 2)) {
pos.left = 'auto';
pos.right = $(window).width() - item.pageX + 8+'px';
}
else {
pos.left = item.pageX + 8+'px';
pos.right = 'auto';
}
if (item.pageY > ($(window).height() / 2)) {
pos.top = 'auto';
pos.bottom = $(window).height() - item.pageY + 8+'px';
}
else {
pos.top = item.pageY + 8+'px';
pos.bottom = 'auto';
}
$tooltip.css({
'left': pos.left,
'top': pos.top,
'right': pos.right,
'bottom': pos.bottom
}).html(
$('
').text(item.series.label).prepend(
$('
').css({
'background-color': item.series.color,
'width': '20px',
'height': '20px',
'display': 'inline-block',
'margin': '0 0.5em'
})
)
).append(
$('
').html(
$('').html(
$('').text('Time:')
).append(
$(' ').text(item.series.xaxis.tickFormatter(item.datapoint[0],item.series.xaxis))
)
).append(
$(' ').html(
$('').text(item.series.label+':')
).append(
$(' ').text(item.series.yaxis.tickFormatter(item.datapoint[1],item.series.yaxis))
)
)
).fadeIn();
}
else {
$('#tooltip').hide();
}
});
theInterval = setInterval(function(){
getPlotData(graphs);
},10000);
break;
case 'server stats':
var $cont = $('').addClass('input_container');
getData(function(d){
settings.settings.capabilities = d.capabilities;
$cont.append(
$('
').text('CPU')
);
for (var index in settings.settings.capabilities.cpu) {
if (settings.settings.capabilities.cpu.length > 1) {
$cont.append(
$('').text('CPU '+index+1)
);
}
for (var property in settings.settings.capabilities.cpu[index]) {
$cont.append(
$('').text(property.charAt(0).toUpperCase()+property.slice(1)+':').append(
$('').text(seperateThousands(settings.settings.capabilities.cpu[index][property],' '))
)
);
}
}
if (settings.settings.capabilities.mem) {
$cont.append(
$('').text('Memory')
).append(
$('').text('Physical memory:').append(
$('').attr('id','stats-physical-memory')
)
).append(
$('').text('Swap memory:').append(
$('').attr('id','stats-swap-memory')
)
);
}
if (settings.settings.capabilities.load) {
$cont.append(
$('').text('Loading average')
).append(
$('').text('Loading averages:').append(
$('').attr('id','stats-loading')
)
);
}
fillServerstatsTables(settings.settings);
theInterval = setInterval(function(){
updateServerstats();
},10000);
updateServerstats();
},{capabilities:{}});
$('#page').html($cont);
break;
case 'email for help':
var config = $.extend({},settings.settings);
delete config.statistics;
config = JSON.stringify(config);
config = 'Version: '+settings.settings.config.version+"\n\nConfig:\n"+config;
$('#page').html(
$('').addClass('description').html(
'You can use this form to email MistServer support if you\'re having difficulties.
'
).append(
'A copy of your server config file will automatically be included.'
)
).append(
$('
').addClass('input_container').html(
$('