').data('protocol',index).html(
$('').text(theProtocol.connector)
).append(
$(' ').attr('id','status-of-'+index).html(formatStatus(theProtocol))
).append(
$(' ').text(displayProtocolSettings(theProtocol))
).append(
$(' ').html(
$('').text('Edit').click(function(){
showTab('edit protocol',$(this).parent().parent().data('protocol'))
})
).append(
$('').text('Delete').click(function(){
var protocolID = $(this).parent().parent().data('protocol');
if (confirmDelete('Are you sure you want to delete the protocol "'+settings.settings.config.protocols[protocolID].connector+'"?')) {
settings.settings.config.protocols.splice(protocolID,1);
saveAndReload('protocols');
}
})
)
)
);
}
theInterval = setInterval(function(){
updateProtocols();
},10000);
updateProtocols();
break;
case 'edit protocol':
var objpath;
if (streamName == '_new_') {
$('#page').html(
$('').text('Adding a new protocol')
);
objpath = 'newProtocol';
}
else {
$('#page').html(
$('
').text('Editing protocol "'+settings.settings.config.protocols[streamName].connector+'"')
);
objpath = 'settings.config.protocols['+streamName+']';
}
currentConnectors = [];
for (var index in settings.settings.config.protocols) {
currentConnectors.push(settings.settings.config.protocols[index].connector.replace('.exe',''));
}
var $selectProtocol = $('').attr('id','protocol-connector').attr('objpath',objpath+'.connector').addClass('isSetting').change(function(){
buildProtocolFields($(this).val(),objpath,streamName);
});
$('#page').append(
$('').addClass('input_container').html(
$('
').text('Protocol:').attr('for','protocol-connector').append(
$selectProtocol
)
).append(
$('').addClass('description').attr('id','protocol-description')
).append(
$('
').attr('id','protocol-fields')
).append(
$('
').addClass('enter-to-submit').text('Save').click(function(){
if (streamName == '_new_') {
settings.newProtocol = {};
if (applyInput() === false) { return; }
settings.settings.config.protocols.push(settings.newProtocol);
delete settings.newProtocol;
}
else {
if (applyInput() === false) { return; }
}
saveAndReload('protocols');
})
).append(
$('').text('Cancel').addClass('escape-to-cancel').click(function(){
showTab('protocols');
})
)
);
for (var index in settings.settings.capabilities.connectors) {
$selectProtocol.append(
$('').val(index).text(index)
);
}
if (streamName != '_new_') {
enterSettings();
}
buildProtocolFields($selectProtocol.val(),objpath,streamName);
break;
case 'streams':
var $tbody = $('').attr('id','streams-tbody');
$('#page').html(
$('').addClass('description').html(
'This is an overview of the streams that have been configured on MistServer.
You can sort them by clicking the colomn headers that have symbols and filter them using the checkboxes.
'
)
).append(
$('
').html(
$('
').attr('type','checkbox').attr('id','stream-filter-recorded').attr('checked','checked')
).append(
$('
').text('Show pre-recorded streams ').attr('for','stream-filter-recorded').css('display','inline')
).append(
$(' ').attr('type','checkbox').attr('id','stream-filter-live').attr('checked','checked')
).append(
$('').text('Show live streams').attr('for','stream-filter-live').css('display','inline')
)
).append(
$('').addClass('sortable').html(
$('').html(
$('').html(
$('').addClass('sort-type-string sortdesc').text('Name')
).append(
$(' ').addClass('sort-type-string').text('Type')
).append(
$(' ').addClass('sort-type-int').addClass('align-right').text('Viewers')
).append(
$(' ').addClass('sort-type-string').text('Status')
).append(
$(' ').addClass('dontsort')
).append(
$(' ').addClass('dontsort')
)
)
).append(
$tbody
)
).append(
$('').text('New').click(function(){
showTab('edit stream','_new_');
})
);
$('.sortable').stupidtable();
for (var index in settings.settings.streams) {
var theStream = settings.settings.streams[index];
//backwards compatibility
if ((theStream.source == undefined) && (theStream.channel)) {
theStream.source = theStream.channel.URL;
}
$tbody.append(
$('').data('stream',index).html(
$('').text(index)
).append(
$(' ').addClass('isLive').text(isLive(theStream.source) ? 'Live' : 'Recorded')
).append(
$(' ').attr('id','viewers-of-'+index).text(0).addClass('align-right')
).append(
$(' ').attr('id','status-of-'+index).html(formatStatus(theStream))
).append(
$(' ').html(
$('').text('Embed').click(function(){
showTab('embed',$(this).parent().parent().data('stream'))
})
)
).append(
$('').html(
$('').text('Edit').click(function(){
showTab('edit stream',$(this).parent().parent().data('stream'))
})
).append(
$('').text('Delete').click(function(){
var streamName = $(this).parent().parent().data('stream');
if (confirmDelete('Are you sure you want to delete the stream "'+streamName+'"?')) {
delete settings.settings.streams[streamName];
saveAndReload('streams');
}
})
)
)
);
}
theInterval = setInterval(function(){
updateStreams();
},10000);
updateStreams();
$('#stream-filter-recorded,#stream-filter-live').click(function(){
filterTable();
});
break;
case 'edit stream':
if (streamName == '_new_') {
$('#page').html(
$('').text('Adding a new stream')
);
}
else {
$('#page').html(
$('
').text('Editing stream "'+streamName+'"')
);
}
$('#page').append(
$('
').addClass('input_container').html(
$('
').text('Stream name:').attr('for','settings-streams-'+streamName+'-name').append(
$(' ').attr('type','text').attr('id','settings-streams-'+streamName+'-name').addClass('isSetting').addClass('validate-lowercase-alphanumeric_-firstcharNaN').addClass('validate-required')
)
).append(
$('').text('Source:').attr('for','settings-streams-'+streamName+'-source').attr('title','The path to the stream, usually "/path/to/filename.dtsc" for files or "push://hostname/streamname" for live streams.').append(
$(' ').attr('type','text').attr('id','settings-streams-'+streamName+'-source').addClass('isSetting').addClass('validate-required').keyup(function(){
if(isLive($(this).val())){
$('.live-only').show();
}
else{
$('.live-only').hide();
$('.live-only').children('label').children('input').val('');
}
})
)
).append(
$('').text('Buffer time:').addClass('live-only').attr('for','settings-streams-'+streamName+'-DVR').append(
$('').addClass('unit').text('[ms]')
).append(
$(' ').attr('type','text').attr('id','settings-streams-'+streamName+'-DVR').attr('placeholder','2 keyframes').addClass('isSetting').addClass('').addClass('validate-positive-integer')
)
).append(
$('').text('Record to:').addClass('live-only').addClass('LTS-only').attr('for','settings-streams-'+streamName+'-record').attr('title','The path to the file to record to. Leave this field blank if you do not wish to record to file.').append(
$(' ').attr('type','text').attr('id','settings-streams-'+streamName+'-record').addClass('isSetting')
)
).append(
$('').text('Cut first section:').addClass('live-only').addClass('LTS-only').attr('for','settings-streams-'+streamName+'-cut').attr('title','Remove the first part of a stream.').append(
$('').addClass('unit').text('[ms]')
).append(
$(' ').attr('type','text').attr('id','settings-streams-'+streamName+'-cut').addClass('isSetting').addClass('validate-positive-integer')
)
).append(
$(' ')
).append(
$('').addClass('LTS-only').html(
$('').text('Encrypt this stream')
).append(
$('
').addClass('description').text(
'To enable encryption, the Licene 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) {
settings.settings.streams[streamName] = {};
if (applyInput() === false) { return; }
settings.settings.streams[newName] = settings.settings.streams[streamName];
delete settings.settings.streams[streamName];
}
else {
if (applyInput() === false) { return; }
}
saveAndReload('streams');
})
).append(
$('').text('Cancel').addClass('escape-to-cancel').click(function(){
showTab('streams');
})
)
);
if (streamName != '_new_') {
enterSettings();
}
if(isLive($('#settings-streams-'+streamName+'-source').val())){
$('.live-only').show();
}
else{
$('.live-only').hide();
$('.live-only').children('label').children('input').val('');
}
$('.live-only').each(function(){
var newtitle = [$(this).attr('title'),'Only applies to live streams.']
$(this).attr('title',newtitle.join(' '));
})
break;
case 'embed':
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) {
var embedbase = 'http://'+parseURL(settings.server).host+':'+(httpConnector.port ? httpConnector.port : 8080)+'/';
$('#page').html(
$('