style(legacy): format (#2039)

This commit is contained in:
Jonas L 2022-08-10 13:38:19 +02:00 committed by GitHub
parent 7082c9693d
commit 1550d44ac5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
122 changed files with 18369 additions and 15819 deletions

View file

@ -1,129 +1,153 @@
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",
});
$('#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",
});
$('#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;
$('#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();
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" },
$.post(url,
{format: "json", dir: chosen, element: "storageFolder"},
function(json) {
$("#watched-folder-section").empty();
$("#watched-folder-section").append(json.subform);
setWatchedDirEvents();
});
}
else {
$('#storageFolder').val("");
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,
});
});
$('#watchedFolder-ok').click(function(){
var url, chosen;
$(".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/reload-watch-directory";
chosen = $('#watchedFolder').val();
url = baseUrl + "Preference/remove-watch-directory";
$.post(url,
{format: "json", dir: chosen, element: "watchedFolder"},
$.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();
});
});
$('.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();
});
}
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'
});
$(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

@ -1,146 +1,155 @@
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);
}
});
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 configMailServer = $("#configureMailServer");
configMailServer.click(function (event) {
setMailServerInputReadonly();
});
var msRequiresAuth = $("#msRequiresAuth");
msRequiresAuth.click(function(event){
setMsAuthenticationFieldsReadonly($(this));
});
var msRequiresAuth = $("#msRequiresAuth");
msRequiresAuth.click(function (event) {
setMsAuthenticationFieldsReadonly($(this));
});
}
function setEnableSystemEmailsListener() {
var enableSystemEmails = $("#enableSystemEmail");
enableSystemEmails.click(function(event){
setSystemFromEmailReadonly();
});
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");
}
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");
}
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");
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();
}
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);
setMsAuthenticationFieldsReadonly(requiresAuthCB);
}
function setTuneInSettingsListener() {
var enableTunein = $("#enable_tunein");
enableTunein.click(function(event){
setTuneInSettingsReadonly();
});
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");
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");
}
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");
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");
}
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,"");
});
$.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();
});
}
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() {
$(document).ready(function () {
$(".collapsible-header").live("click", function () {
$(this).next().toggle("fast");
$(this).toggleClass("closed");
return false;
});
$('.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();
}
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
/* 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';
@ -155,43 +164,43 @@ $(document).ready(function() {
});
});*/
// 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);
};
// 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();
// 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();
}
});
showErrorSections();
if (preview.attr("src").indexOf("images/") > -1) {
$("#logo-remove-btn").hide();
}
setMailServerInputReadonly();
setPodcastAutoSmartblockReadonly();
setSystemFromEmailReadonly();
setConfigureMailServerListener();
setEnableSystemEmailsListener();
setTuneInSettingsReadonly();
setTuneInSettingsListener();
showErrorSections();
setMailServerInputReadonly();
setPodcastAutoSmartblockReadonly();
setSystemFromEmailReadonly();
setConfigureMailServerListener();
setEnableSystemEmailsListener();
setTuneInSettingsReadonly();
setTuneInSettingsListener();
});

File diff suppressed because it is too large Load diff