Rename airtime_mvc/ to legacy/

This commit is contained in:
jo 2021-10-11 13:43:25 +02:00
parent f0879322c2
commit 3e18d42c8b
1316 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,129 @@
function setWatchedDirEvents() {
$('#storageFolder-selection').serverBrowser({
onSelect: function(path) {
$('#storageFolder').val(path);
},
onLoad: function() {
return $('#storageFolder').val();
},
width: 500,
height: 250,
position: ['center', 'center'],
//knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
knownPaths: [],
imageUrl: 'img/icons/',
systemImageUrl: baseUrl+'css/img/',
handlerUrl: baseUrl+'Preference/server-browse/format/json',
title: $.i18n._('Choose Storage Folder'),
basePath: '',
requestMethod: 'POST',
});
$('#watchedFolder-selection').serverBrowser({
onSelect: function(path) {
$('#watchedFolder').val(path);
},
onLoad: function() {
return $('#watchedFolder').val();
},
width: 500,
height: 250,
position: ['center', 'center'],
//knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
knownPaths: [],
imageUrl: 'img/icons/',
systemImageUrl: baseUrl+'css/img/',
handlerUrl: baseUrl+'Preference/server-browse/format/json',
title: $.i18n._('Choose Folder to Watch'),
basePath: '',
requestMethod: 'POST',
});
$('#storageFolder-ok').click(function(){
var url, chosen;
if(confirm(sprintf($.i18n._("Are you sure you want to change the storage folder?\nThis will remove the files from your %s library!"), PRODUCT_NAME))){
url = baseUrl+"Preference/change-stor-directory";
chosen = $('#storageFolder').val();
$.post(url,
{format: "json", dir: chosen, element: "storageFolder"},
function(json) {
$("#watched-folder-section").empty();
$("#watched-folder-section").append(json.subform);
setWatchedDirEvents();
});
}
else {
$('#storageFolder').val("");
}
});
$('#watchedFolder-ok').click(function(){
var url, chosen;
url = baseUrl+"Preference/reload-watch-directory";
chosen = $('#watchedFolder').val();
$.post(url,
{format: "json", dir: chosen, element: "watchedFolder"},
function(json) {
$("#watched-folder-section").empty();
$("#watched-folder-section").append("<h2>"+$.i18n._("Manage Media Folders")+"</h2>");
$("#watched-folder-section").append(json.subform);
setWatchedDirEvents();
});
});
$('.selected-item').find('.ui-icon-refresh').click(function(){
var folder = $(this).prev().text();
$.get(baseUrl+"Preference/rescan-watch-directory", {format: "json", dir: folder});
});
$('.selected-item').find('.ui-icon-close').click(function(){
if(confirm($.i18n._("Are you sure you want to remove the watched folder?"))){
var row = $(this).parent();
var folder = row.find('#folderPath').text();
url = baseUrl+"Preference/remove-watch-directory";
$.post(url,
{format: "json", dir: folder},
function(json) {
$("#watched-folder-section").empty();
$("#watched-folder-section").append("<h2>"+$.i18n._("Manage Media Folders")+"</h2>");
$("#watched-folder-section").append(json.subform);
setWatchedDirEvents();
});
}
});
}
$(document).ready(function() {
setWatchedDirEvents();
$(".ui-icon-alert").qtip({
content: {
text: $.i18n._("This path is currently not accessible.")
},
position:{
adjust: {
resize: true,
method: "flip flip"
},
at: "right center",
my: "left top",
viewport: $(window)
},
style: {
classes: "ui-tooltip-dark"
},
show: 'mouseover',
hide: 'mouseout'
});
});

View file

@ -0,0 +1,197 @@
function showErrorSections() {
var selector = $("[id$=-settings]");
selector.each(function(i) {
var el = $(this);
var errors = el.find(".errors");
if (errors.length > 0) {
el.show();
$(window).scrollTop(errors.position().top);
}
});
}
function setConfigureMailServerListener() {
var configMailServer = $("#configureMailServer");
configMailServer.click(function(event){
setMailServerInputReadonly();
});
var msRequiresAuth = $("#msRequiresAuth");
msRequiresAuth.click(function(event){
setMsAuthenticationFieldsReadonly($(this));
});
}
function setEnableSystemEmailsListener() {
var enableSystemEmails = $("#enableSystemEmail");
enableSystemEmails.click(function(event){
setSystemFromEmailReadonly();
});
}
function setPodcastAutoSmartblockReadonly() {
var disablePodcastAutomSmartblock = $("#podcastAutoSmartblock-0");
var enablePodcastAutomSmartblock = $("#podcastAutoSmartblock-1");
var podcastOverride = $("#podcastAlbumOverride-1");
if ($(podcastOverride).is(':checked')) {
enablePodcastAutomSmartblock.removeAttr("readonly");
} else {
disablePodcastAutomSmartblock.prop("checked", true);
disablePodcastAutomSmartblock.attr("readonly","readonly");
enablePodcastAutomSmartblock.attr("readonly","readonly");
}
}
function setSystemFromEmailReadonly() {
var enableSystemEmails = $("#enableSystemEmail");
var systemFromEmail = $("#systemEmail");
if ($(enableSystemEmails).is(':checked')) {
systemFromEmail.removeAttr("readonly");
} else {
systemFromEmail.attr("readonly", "readonly");
}
}
function setMailServerInputReadonly() {
var configMailServer = $("#configureMailServer");
var mailServer = $("#mailServer");
var port = $("#port");
var requiresAuthCB = $("#msRequiresAuth");
if (configMailServer.is(':checked')) {
mailServer.removeAttr("readonly");
port.removeAttr("readonly");
requiresAuthCB.parent().show();
} else {
mailServer.attr("readonly", "readonly");
port.attr("readonly", "readonly");
requiresAuthCB.parent().hide();
}
setMsAuthenticationFieldsReadonly(requiresAuthCB);
}
function setTuneInSettingsListener() {
var enableTunein = $("#enable_tunein");
enableTunein.click(function(event){
setTuneInSettingsReadonly();
});
}
function setTuneInSettingsReadonly() {
var enableTunein = $("#enable_tunein");
var stationId = $("#tunein_station_id");
var partnerKey = $("#tunein_partner_key");
var partnerId = $("#tunein_partner_id");
if (enableTunein.is(':checked')) {
stationId.removeAttr("readonly");
partnerKey.removeAttr("readonly");
partnerId.removeAttr("readonly");
} else {
stationId.attr("readonly", "readonly");
partnerKey.attr("readonly", "readonly");
partnerId.attr("readonly", "readonly");
}
}
/*
* Enable/disable mail server authentication fields
*/
function setMsAuthenticationFieldsReadonly(ele) {
var email = $("#email");
var password = $("#ms_password");
var configureMailServer = $("#configureMailServer");
if (ele.is(':checked') && configureMailServer.is(':checked')) {
email.removeAttr("readonly");
password.removeAttr("readonly");
} else if (ele.not(':checked') || configureMailServer.not(':checked')) {
email.attr("readonly", "readonly");
password.attr("readonly", "readonly");
}
}
function removeLogo() {
$.post(baseUrl+'preference/remove-logo', {'csrf_token' : $('#csrf').val()}, function(json){
// Reload without resubmitting the form
location.href = location.href.replace(location.hash,"");
});
}
function deleteAllFiles() {
var resp = confirm($.i18n._("Are you sure you want to delete all the tracks in your library?"))
if (resp) {
$.post(baseUrl+'preference/delete-all-files', {'csrf_token' : $('#csrf').val()}, function(json){
location.reload();
});
}
}
$(document).ready(function() {
$('.collapsible-header').live('click',function() {
$(this).next().toggle('fast');
$(this).toggleClass("closed");
return false;
});
if ($("#tunein-settings").find(".errors").length > 0) {
$(".collapsible-content#tunein-settings").show();
}
/* No longer using AJAX for this form. Zend + our code makes it needlessly hard to deal with. -- Albert
$('#pref_save').live('click', function() {
var data = $('#pref_form').serialize();
var url = baseUrl+'Preference/index';
$.post(url, {format: "json", data: data}, function(json){
$('#content').empty().append(json.html);
setTimeout(removeSuccessMsg, 5000);
showErrorSections();
setMailServerInputReadonly();
setConfigureMailServerListener();
setEnableSystemEmailsListener();
});
});*/
// when an image is uploaded, preview it to the user
var logo = $("#stationLogo"),
preview = $("#logo-img");
logo.change(function(e) {
if (this.files && this.files[0]) {
preview.show();
var reader = new FileReader(); // browser compatibility?
reader.onload = function (e) {
console.log("Reader loaded");
preview.attr('src', e.target.result);
};
// check image size so we don't crash the page trying to render
if (validateImage(this.files[0], logo)) {
// read the image data as though it were a data URI
reader.readAsDataURL(this.files[0]);
} else {
// remove the file element data
$(this).val('').replaceWith($(this).clone(true));
preview.hide();
}
} else {
preview.hide();
}
});
if (preview.attr('src').indexOf('images/') > -1) {
$("#logo-remove-btn").hide();
}
showErrorSections();
setMailServerInputReadonly();
setPodcastAutoSmartblockReadonly();
setSystemFromEmailReadonly();
setConfigureMailServerListener();
setEnableSystemEmailsListener();
setTuneInSettingsReadonly();
setTuneInSettingsListener();
});

View file

@ -0,0 +1,499 @@
function showErrorSections() {
$(".errors").each(function(i){
if($(this).length > 0){
var div = $(this).closest("div")
if(div.attr('class') == "stream-setting-content"){
$(this).closest("div").show();
$(this).closest("fieldset").removeClass('closed');
$(window).scrollTop($(this).closest("div").position().top);
}
}
});
}
function rebuildStreamURL(ele){
var div = ele.closest("div")
host = div.find("input[id$=-host]").val()
port = div.find("input[id$=-port]").val()
mount = div.find("input[id$=-mount]").val()
streamurl = ""
if(div.find("select[id$=-output]").val()=="icecast"){
streamurl = "http://"+host
if($.trim(port) != ""){
streamurl += ":"+port
}
if($.trim(mount) != ""){
streamurl += "/"+mount
}
}else{
streamurl = "http://"+host+":"+port+"/"
}
div.find("#stream_url").html('<a href="' + streamurl + '" target="_blank">' + streamurl + '</a>')
}
function restrictOggBitrate(ele, on){
var div = ele.closest("div")
if(on){
if(parseInt(div.find("select[id$=data-bitrate]").val(),10) < 48){
div.find("select[id$=data-bitrate]").find("option[value='48']").attr("selected","selected");
}
div.find("select[id$=data-bitrate]").find("option[value='24']").attr("disabled","disabled");
div.find("select[id$=data-bitrate]").find("option[value='32']").attr("disabled","disabled");
}else{
div.find("select[id$=data-bitrate]").find("option[value='24']").removeAttr("disabled");
div.find("select[id$=data-bitrate]").find("option[value='32']").removeAttr("disabled");
}
}
function hideForShoutcast(ele){
var div = ele.closest("div")
div.find("#outputMountpoint-label").hide()
div.find("#outputMountpoint-element").hide()
div.find("#outputUser-label").hide()
div.find("#outputUser-element").hide()
div.find("select[id$=data-type]").find("option[value='mp3']").attr('selected','selected');
div.find("select[id$=data-type]").find("option[value='ogg']").attr("disabled","disabled");
div.find("select[id$=data-type]").find("option[value='opus']").attr("disabled","disabled");
restrictOggBitrate(ele, false)
}
function validate(ele,evt) {
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
if ((ele.val().length >= 5 || (key < 48 || key > 57)) && !(key == 8 || key == 9 || key == 13 || key == 37 || key == 39 || key == 46)) {
theEvent.returnValue = false;
if(theEvent.preventDefault) theEvent.preventDefault();
}
}
function showForIcecast(ele){
var div = ele.closest("div");
div.find("#outputMountpoint-label").show();
div.find("#outputMountpoint-element").show();
div.find("#outputUser-label").show();
div.find("#outputUser-element").show();
div.find("select[id$=data-type]").find("option[value='ogg']").removeAttr("disabled");
div.find("select[id$=data-type]").find("option[value='opus']").removeAttr("disabled");
}
function checkLiquidsoapStatus(){
var url = baseUrl+'Preference/get-liquidsoap-status/format/json';
var id = $(this).attr("id");
$.post(url, function(json_obj){
for(var i=0;i<json_obj.length;i++){
var obj = json_obj[i];
var id;
var status;
for(var key in obj){
if(key == "id"){
id = obj[key];
}
if(key == "status"){
status = obj[key];
}
}
var html;
if(status == "OK"){
html = '<div class="stream-status status-good"><p>'+$.i18n._("Connected to the streaming server")+'</p></div>';
}else if(status == "N/A"){
html = '<div class="stream-status status-disabled"><p>'+$.i18n._("The stream is disabled")+'</p></div>';
}else if(status == "waiting"){
html = '<div class="stream-status status-info"><p>'+$.i18n._("Getting information from the server...")+'</p></div>';
}else{
html = '<div class="stream-status status-error"><p>'+$.i18n._("Can not connect to the streaming server")+'</p><p>'+status+'</p></div>';
}
$("#s"+id+"Liquidsoap-error-msg-element").html(html);
}
setTimeout(checkLiquidsoapStatus, 2000);
});
}
function setLiveSourceConnectionOverrideListener(){
$("[id=connection_url_override]").click(function(event){
var url_input = $(this).parent().find("dd[id$='_source_host-element']").children();
url_input.removeAttr("readonly");
$(this).parent().find("div[id$='_dj_connection_url_actions']").show();
event.preventDefault();
});
// set action for "OK" and "X"
var live_dj_actions = $("#live_dj_connection_url_actions");
var live_dj_input = live_dj_actions.parent().find("dd[id$='_source_host-element']").children();
var master_dj_actions = $("#master_dj_connection_url_actions");
var master_dj_input = master_dj_actions.parent().find("dd[id$='_source_host-element']").children();
live_dj_actions.find("#ok").click(function(event){
event.preventDefault();
var url = live_dj_input.val();
live_dj_input.val(url);
live_dj_input.attr("readonly", "readonly");
live_dj_actions.hide();
$.get(baseUrl+"Preference/set-source-connection-url", {format: "json", type: "livedj", url:encodeURIComponent(url), override: 1});
event.preventDefault();
});
live_dj_actions.find("#reset").click(function(event){
event.preventDefault();
var port = $("#show_source_port").val();
var mount = $("#show_source_mount").val();
if (mount.charAt(0) != '/') {
mount = ('/').concat(mount);
}
var url = "http://"+location.hostname+":"+port+mount;
live_dj_input.val(url);
live_dj_input.attr("readonly", "readonly");
live_dj_actions.hide();
$.get(baseUrl+"Preference/set-source-connection-url", {format: "json", type: "livedj", url:encodeURIComponent(url), override: 0});
event.preventDefault();
});
master_dj_actions.find("#ok").click(function(event){
var url = master_dj_input.val();
master_dj_input.val(url);
master_dj_input.attr("readonly", "readonly");
master_dj_actions.hide();
$.get(baseUrl+"Preference/set-source-connection-url", {format: "json", type: "masterdj", url:encodeURIComponent(url), override: 1});
event.preventDefault();
});
master_dj_actions.find("#reset").click(function(event){
var port = $("#master_source_port").val();
var mount = $("#master_source_mount").val();
if (mount.charAt(0) != '/') {
mount = ('/').concat(mount);
}
var url = "http://"+location.hostname+":"+port+mount;
master_dj_input.val(url);
master_dj_input.attr("readonly", "readonly");
master_dj_actions.hide();
$.get(baseUrl+"Preference/set-source-connection-url", {format: "json", type: "masterdj", url:encodeURIComponent(url), override: 0});
event.preventDefault();
});
}
function setupEventListeners() {
// initial stream url
$("dd[id=outputStreamURL-element]").each(function(){
rebuildStreamURL($(this));
})
$("input[id$=-host], input[id$=-port], input[id$=-mount]").keyup(function(){
rebuildStreamURL($(this));
});
$("input[id$=-port]").keypress(function(e){
validate($(this),e);
});
$("select[id$=-output]").change(function(){
rebuildStreamURL($(this));
});
if(!$("#output_sound_device").is(':checked')){
$("select[id=output_sound_device_type]").attr('disabled', 'disabled');
}else{
$("select[id=output_sound_device_type]").removeAttr('disabled');
}
$("#output_sound_device").change(function(){
if($(this).is(':checked')){
$("select[id=output_sound_device_type]").removeAttr('disabled');
}else{
$("select[id=output_sound_device_type]").attr('disabled', 'disabled');
}
});
$("select[id$=data-type]").change(function(){
if($(this).val() == 'ogg'){
restrictOggBitrate($(this), true);
}else{
restrictOggBitrate($(this), false);
}
});
$("select[id$=data-type]").each(function(){
if($(this).val() == 'ogg'){
restrictOggBitrate($(this), true);
}
});
$("select[id$=data-output]").change(function(){
if($(this).val() == 'shoutcast'){
hideForShoutcast($(this));
}else{
showForIcecast($(this));
}
});
$("select[id$=data-output]").each(function(){
if($(this).val() == 'shoutcast'){
hideForShoutcast($(this));
}
});
$('.toggle legend').click(function() {
$(this).parent().toggleClass('closed');
return false;
});
$('.collapsible-header').click(function() {
$(this).next().toggle('fast');
$(this).toggleClass("closed");
return false;
});
setLiveSourceConnectionOverrideListener();
showErrorSections();
checkLiquidsoapStatus();
var userManualAnchorOpen = "<a target='_blank' href='" + USER_MANUAL_URL + "'>";
// qtip for help text
$(".override_help_icon").qtip({
content: {
text: sprintf($.i18n._("If %s is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151."), PRODUCT_NAME)+" "+
sprintf($.i18n._(
"For more details, please read the %s%s Manual%s"), userManualAnchorOpen, PRODUCT_NAME, "</a>")
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
});
$(".icecast_metadata_help_icon").qtip({
content: {
text: $.i18n._("Check this option to enable metadata for OGG streams (stream metadata is the track title, artist, and show name that is displayed in an audio player). VLC and mplayer have a serious bug when playing an OGG/VORBIS stream that has metadata information enabled: they will disconnect from the stream after every song. If you are using an OGG stream and your listeners do not require support for these audio players, then feel free to enable this option.")
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
});
$("#auto_transition_help").qtip({
content: {
text: $.i18n._("Check this box to automatically switch off Master/Show source upon source disconnection.")
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
});
$("#auto_switch_help").qtip({
content: {
text: $.i18n._("Check this box to automatically switch on Master/Show source upon source connection.")
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
});
$(".stream_username_help_icon").qtip({
content: {
text: $.i18n._("If your Icecast server expects a username of 'source', this field can be left blank.")
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
});
$(".admin_username_help_icon").qtip({
content: {
text: $.i18n._("This is the admin username and password for Icecast/SHOUTcast to get listener statistics.")
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
});
$(".master_username_help_icon").qtip({
content: {
text: $.i18n._("If your live streaming client does not ask for a username, this field should be 'source'.")
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
});
$(".stream_type_help_icon").qtip({
content: {
text: sprintf(
$.i18n._("Some stream types require extra configuration. Details about enabling %sAAC+ Support%s or %sOpus Support%s are provided."),
"<a target='_blank' href='https://wiki.sourcefabric.org/x/NgPQ'>",
"</a>",
"<a target='_blank' href='https://wiki.sourcefabric.org/x/KgPQ'>",
"</a>")
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
});
}
function setSliderForReplayGain(){
$( "#slider-range-max" ).slider({
range: "max",
min: -10,
max: 10,
value: $("#rg_modifier_value").html(),
slide: function( event, ui ) {
$( "#replayGainModifier" ).val( ui.value );
$("#rg_modifier_value").html(ui.value);
}
});
$( "#replayGainModifier" ).val( $( "#slider-range-max" ).slider( "value" ) );
}
function setPseudoAdminPassword(s1, s2, s3, s4) {
if (s1) {
$('#s1_data-admin_pass').val('xxxxxx');
}
if (s2) {
$('#s2_data-admin_pass').val('xxxxxx');
}
if (s3) {
$('#s3_data-admin_pass').val('xxxxxx');
}
if (s4) {
$('#s4_data-admin_pass').val('xxxxxx');
}
}
function getAdminPasswordStatus() {
$.ajax({ url: baseUrl+'Preference/get-admin-password-status/format/json', dataType:"json", success:function(data){
setPseudoAdminPassword(data.s1, data.s2, data.s3, data.s4);
}});
}
$(document).ready(function() {
setupEventListeners();
setSliderForReplayGain();
getAdminPasswordStatus();
var s = $("[name^='customStreamSettings']:checked");
$("[id^='stream_save'], [name^='customStreamSettings']").live('click', function() {
var e = $(this);
if (e[0] == s[0]) { return; }
var confirm_pypo_restart_text = $.i18n._("WARNING: This will restart your stream and may cause a short dropout for your listeners!");
if (confirm(confirm_pypo_restart_text)) {
var data = $('#stream_form').serialize();
var url = baseUrl+'Preference/stream-setting';
$.post(url, {format:"json", data: data}, function(json){
$('#content').empty().append(json.html);
if (json.valid) {
window.location.reload();
}
setupEventListeners();
setSliderForReplayGain();
getAdminPasswordStatus();
});
} else {
if (e.prop('checked')) {
if (e[0] != s[0]) {
e.prop('checked', false);
s.prop('checked', true);
}
}
}
});
});