1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-05 10:49:37 +02:00

Fix some info level issues in codacy

This commit is contained in:
Phyks (Lucas Verney) 2016-06-20 14:46:23 +02:00
parent 5ab1ed2e93
commit e6eda3850c
5 changed files with 76 additions and 75 deletions

View file

@ -23,17 +23,17 @@ $(document).ready(function () {
// Enable caching of AJAX responses, including script and jsonp // Enable caching of AJAX responses, including script and jsonp
cache: true cache: true
}); });
$('#notification').click(function() { $("#notification").click(function() {
clearNotification(); clearNotification();
}); });
}); });
function initTabs() function initTabs()
{ {
$('.default_hidden').hide(); $(".default_hidden").hide();
$("#tabs li").click(function() { $("#tabs li").click(function() {
$("#tabs li").removeClass('tab_active'); $("#tabs li").removeClass("tab_active");
$(this).addClass("tab_active"); $(this).addClass("tab_active");
$(".tab_content").hide(); $(".tab_content").hide();
var selected_tab = $(this).find("a").attr("href"); var selected_tab = $(this).find("a").attr("href");
@ -46,16 +46,16 @@ function initTabs()
$(function() { $(function() {
var rightmenu = $("#rightbar"); var rightmenu = $("#rightbar");
var pos = rightmenu.offset(); var pos = rightmenu.offset();
if (rightmenu.hasClass('rightbar-float')) { if (rightmenu.hasClass("rightbar-float")) {
$(window).scroll(function() { $(window).scroll(function() {
var rightsubmenu = $("#rightbar .submenu"); var rightsubmenu = $("#rightbar .submenu");
if ($(this).scrollTop() > (pos.top)) { if ($(this).scrollTop() > (pos.top)) {
rightmenu.addClass('fixedrightbar'); rightmenu.addClass("fixedrightbar");
rightsubmenu.addClass('fixedrightbarsubmenu'); rightsubmenu.addClass("fixedrightbarsubmenu");
} }
else if ($(this).scrollTop() <= pos.top && rightmenu.hasClass('fixedrightbar')) { else if ($(this).scrollTop() <= pos.top && rightmenu.hasClass("fixedrightbar")) {
rightmenu.removeClass('fixedrightbar'); rightmenu.removeClass("fixedrightbar");
rightsubmenu.removeClass('fixedrightbarsubmenu'); rightsubmenu.removeClass("fixedrightbarsubmenu");
} }
else { else {
rightmenu.offset({ left: pos.left, top: pos.top }); rightmenu.offset({ left: pos.left, top: pos.top });
@ -78,14 +78,14 @@ function flipField(field) {
// updateText // updateText
// Changes the specified elements innards. Used for the catalog mojo fluff. // Changes the specified elements innards. Used for the catalog mojo fluff.
function updateText(field, value) { function updateText(field, value) {
$('#'+field).html(value); $("#"+field).html(value);
} }
// toggleVisible // toggleVisible
// Toggles display type between block and none. Used for ajax loading div. // Toggles display type between block and none. Used for ajax loading div.
function toggleVisible(element) { function toggleVisible(element) {
var target = $('#' + element); var target = $("#" + element);
if (target.is(':visible')) { if (target.is(":visible")) {
target.hide(); target.hide();
} else { } else {
target.show(); target.show();
@ -99,13 +99,13 @@ function displayNotification(message, timeout) {
} }
if (message) { if (message) {
if ($('#webplayer').css('display') !== 'block') { if ($("#webplayer").css("display") !== "block") {
$('#notification').css('bottom', '20px'); $("#notification").css("bottom", "20px");
} else { } else {
$('#notification').css('bottom', '120px'); $("#notification").css("bottom", "120px");
} }
$('#notification-content').html(message); $("#notification-content").html(message);
$('#notification').removeClass('notification-out'); $("#notification").removeClass("notification-out");
notificationTimeout = setTimeout(function() { notificationTimeout = setTimeout(function() {
clearNotification(); clearNotification();
}, timeout); }, timeout);
@ -115,7 +115,7 @@ function displayNotification(message, timeout) {
function clearNotification() { function clearNotification() {
clearTimeout(notificationTimeout); clearTimeout(notificationTimeout);
notificationTimeout = null; notificationTimeout = null;
$('#notification').addClass("notification-out"); $("#notification").addClass("notification-out");
} }
// delayRun // delayRun
@ -136,7 +136,7 @@ function delayRun(element, time, method, page, source) {
// IE issue fixed by Spocky, we have to use the iframe for Democratic Play & // IE issue fixed by Spocky, we have to use the iframe for Democratic Play &
// Localplay, which don't actually prompt for a new file // Localplay, which don't actually prompt for a new file
function reloadUtil(target) { function reloadUtil(target) {
$('#util_iframe').prop('src', target); $("#util_iframe").prop("src", target);
} }
function reloadDivUtil(target) { function reloadDivUtil(target) {

View file

@ -29,7 +29,7 @@ function loadContentPage(url)
.fadeOut(200, function() { .fadeOut(200, function() {
$.get(url, function (data, status, jqXHR) { $.get(url, function (data, status, jqXHR) {
loadContentData(data, status, jqXHR); loadContentData(data, status, jqXHR);
}, 'html'); }, "html");
}); });
} }
@ -41,16 +41,16 @@ function sse_worker(url) {
eval(event.data); eval(event.data);
}; };
sseSource.onopen = function() { sseSource.onopen = function() {
displayNotification('Connected through Server-Sent Events, processing...', 5000); displayNotification("Connected through Server-Sent Events, processing...", 5000);
}; };
sseSource.onerror = function() { sseSource.onerror = function() {
displayNotification('Server-Sent Events connection error. Re-connection...', 5000); displayNotification("Server-Sent Events connection error. Re-connection...", 5000);
}; };
} else { } else {
// Server-Sent Events not supported, call the update in ajax and the output result // Server-Sent Events not supported, call the update in ajax and the output result
$.get(url + '&html=1', function (data) { $.get(url + "&html=1", function (data) {
$("#guts").append(data); $("#guts").append(data);
}, 'html') }, "html")
} }
} }
@ -62,7 +62,7 @@ function stop_sse_worker() {
} }
function display_sse_error(error) { function display_sse_error(error) {
displayNotification('ERROR: ' + error, 10000); displayNotification("ERROR: " + error, 10000);
} }
$(function() { $(function() {
@ -88,11 +88,11 @@ $(function() {
$("body").delegate("form", "submit", function(e) { $("body").delegate("form", "submit", function(e) {
// We do not support ajax post with files or login form, neither specific target // We do not support ajax post with files or login form, neither specific target
var $file = $(this).find("input[type=file]"); var $file = $(this).find("input[type=file]");
if ($(this).attr('name') !== 'login' && $(this).attr('name') !== 'export' && (!$file || !$file.val() || $file.val() === "") && ($(this).attr('target') === undefined || $(this).attr('target') === '')) { if ($(this).attr("name") !== "login" && $(this).attr("name") !== "export" && (!$file || !$file.val() || $file.val() === "") && ($(this).attr("target") === undefined || $(this).attr("target") === "")) {
var postData = $(this).serializeArray(); var postData = $(this).serializeArray();
var formURL = $(this).attr("action"); var formURL = $(this).attr("action");
if (formURL.indexOf('javascript:') !== 0) { if (formURL.indexOf("javascript:") !== 0) {
$.ajax( $.ajax(
{ {
url : formURL, url : formURL,
@ -114,14 +114,14 @@ $(function() {
} }
}); });
$(window).bind('hashchange', function(){ $(window).bind("hashchange", function(){
newHash = window.location.hash.substring(1); newHash = window.location.hash.substring(1);
if (newHash && newHash.indexOf("prettyPhoto") != 0 && newHash.indexOf(".php") > -1) { if (newHash && newHash.indexOf("prettyPhoto") != 0 && newHash.indexOf(".php") > -1) {
loadContentPage(jsWebPath + '/' + newHash); loadContentPage(jsWebPath + "/" + newHash);
return false; return false;
}; };
}); });
$(window).trigger('hashchange'); $(window).trigger("hashchange");
}); });

View file

@ -11,8 +11,8 @@ jPlayerPlaylist.prototype._createListItem = function(media) {
attrClass += '" '; attrClass += '" ';
var listItem = "<li" + attrClass + " name=\"" + $(jplaylist.cssSelector.playlist + " ul li").length + "\" " + var listItem = "<li" + attrClass + " name=\"" + $(jplaylist.cssSelector.playlist + " ul li").length + "\" " +
"data-poster=\"" + media['poster'] + "\" data-media_id=\"" + media['media_id'] + "\" data-album_id=\"" + media['album_id'] + "\" data-artist_id=\"" + media['artist_id'] + "\" " + "data-poster=\"" + media.poster + "\" data-media_id=\"" + media.media_id + "\" data-album_id=\"" + media.album_id + "\" data-artist_id=\"" + media.artist_id + "\" " +
"data-replaygain_track_gain=\"" + media['replaygain_track_gain'] + "\" data-replaygain_track_peak=\"" + media['replaygain_track_peak'] + "\" data-replaygain_album_gain=\"" + media['replaygain_album_gain'] + "\" data-replaygain_album_peak=\"" + media['replaygain_album_peak'] + "\"" + "data-replaygain_track_gain=\"" + media.replaygain_track_gain + "\" data-replaygain_track_peak=\"" + media.replaygain_track_peak + "\" data-replaygain_album_gain=\"" + media.replaygain_album_gain + "\" data-replaygain_album_peak=\"" + media.replaygain_album_peak + "\"" +
"><div>"; "><div>";
// Create image // Create image
@ -131,8 +131,9 @@ jPlayerPlaylist.prototype.scan = function() {
var replace = []; var replace = [];
var maxName = 0; // maximum value that name attribute assumes. var maxName = 0; // maximum value that name attribute assumes.
$.each($(this.cssSelector.playlist + " ul li"), function(index, value) { $.each($(this.cssSelector.playlist + " ul li"), function(index, value) {
if ($(value).attr('name') > maxName) if ($(value).attr('name') > maxName) {
maxName = parseInt($(value).attr('name')); maxName = parseInt($(value).attr('name'));
}
}); });
var diffCount = maxName + 1 != $(this.cssSelector.playlist + " ul li").length; // Flag that marks if the number of "ul li" elements doesn't match the name attribute counting. var diffCount = maxName + 1 != $(this.cssSelector.playlist + " ul li").length; // Flag that marks if the number of "ul li" elements doesn't match the name attribute counting.

View file

@ -180,10 +180,10 @@ var SearchRow = {
} }
}); });
if (type['widget'][0] == 'subtypes') { if (type.widget[0] == 'subtypes') {
var $select = SearchRow.createSelect({ var $select = SearchRow.createSelect({
name: 'rule_' + targetID + '_subtype' name: 'rule_' + targetID + '_subtype'
}, type['subtypes']); }, type.subtypes);
$(this).after($select); $(this).after($select);
} }
else { else {
@ -218,7 +218,7 @@ var SearchRow = {
if (type['widget'][0] == 'subtypes') { if (type['widget'][0] == 'subtypes') {
var $input = SearchRow.createSelect({ var $input = SearchRow.createSelect({
name: 'rule_' + ruleNumber + '_subtype' name: 'rule_' + ruleNumber + '_subtype'
}, type['subtypes'], subtype); }, type.subtypes, subtype);
return $input[0]; return $input[0];
} }
} }

View file

@ -35,7 +35,7 @@ function showFilters(element) {
var closeplaylist; var closeplaylist;
function showPlaylistDialog(e, item_type, item_ids) { function showPlaylistDialog(e, item_type, item_ids) {
$("#playlistdialog").dialog("close"); $('#playlistdialog').dialog('close');
var parent = this; var parent = this;
parent.itemType = item_type; parent.itemType = item_type;
@ -51,7 +51,7 @@ function showPlaylistDialog(e, item_type, item_ids) {
height: 100, height: 100,
autoOpen: false, autoOpen: false,
position: { position: {
my: "left+10 top", my: 'left+10 top',
of: e of: e
}, },
open: function () { open: function () {
@ -67,24 +67,24 @@ function showPlaylistDialog(e, item_type, item_ids) {
close: function (e) { close: function (e) {
$(document).unbind('click'); $(document).unbind('click');
$(this).empty(); $(this).empty();
$(this).dialog("destroy"); $(this).dialog('destroy');
} }
}); });
$("#playlistdialog").dialog("open"); $('#playlistdialog').dialog('open');
closeplaylist = 0; closeplaylist = 0;
} }
function overlayclickclose() { function overlayclickclose() {
if (closeplaylist) { if (closeplaylist) {
$("#playlistdialog").dialog("close"); $('#playlistdialog').dialog('close');
} }
closeplaylist = 1; closeplaylist = 1;
} }
function handlePlaylistAction(url, id) { function handlePlaylistAction(url, id) {
ajaxPut(url, id); ajaxPut(url, id);
$("#playlistdialog").dialog("close"); $('#playlistdialog').dialog('close');
} }
function createNewPlaylist(title, url, id) { function createNewPlaylist(title, url, id) {
@ -101,7 +101,7 @@ function createNewPlaylist(title, url, id) {
var closebroadcasts; var closebroadcasts;
function showBroadcastsDialog(e) { function showBroadcastsDialog(e) {
$("#broadcastsdialog").dialog("close"); $('#broadcastsdialog').dialog('close');
var parent = this; var parent = this;
parent.contentUrl = jsAjaxServer + '/ajax.server.php?page=player&action=show_broadcasts'; parent.contentUrl = jsAjaxServer + '/ajax.server.php?page=player&action=show_broadcasts';
@ -116,7 +116,7 @@ function showBroadcastsDialog(e) {
height: 70, height: 70,
autoOpen: false, autoOpen: false,
position: { position: {
my: "left-180 top", my: 'left-180 top',
of: e of: e
}, },
open: function () { open: function () {
@ -132,24 +132,24 @@ function showBroadcastsDialog(e) {
close: function (e) { close: function (e) {
$(document).unbind('click'); $(document).unbind('click');
$(this).empty(); $(this).empty();
$(this).dialog("destroy"); $(this).dialog('destroy');
} }
}); });
$("#broadcastsdialog").dialog("open"); $('#broadcastsdialog').dialog('open');
closebroadcasts = 0; closebroadcasts = 0;
} }
function broverlayclickclose() { function broverlayclickclose() {
if (closebroadcasts) { if (closebroadcasts) {
$("#broadcastsdialog").dialog("close"); $('#broadcastsdialog').dialog('close');
} }
closebroadcasts = 1; closebroadcasts = 1;
} }
function handleBroadcastAction(url, id) { function handleBroadcastAction(url, id) {
ajaxPut(url, id); ajaxPut(url, id);
$("#broadcastsdialog").dialog("close"); $('#broadcastsdialog').dialog('close');
} }
/************************************************************/ /************************************************************/
@ -158,7 +158,7 @@ function handleBroadcastAction(url, id) {
var closeshare; var closeshare;
function showShareDialog(e, object_type, object_id) { function showShareDialog(e, object_type, object_id) {
$("#sharedialog").dialog("close"); $('#sharedialog').dialog('close');
var parent = this; var parent = this;
parent.contentUrl = jsAjaxServer + '/ajax.server.php?page=browse&action=get_share_links&object_type=' + object_type + '&object_id=' + object_id; parent.contentUrl = jsAjaxServer + '/ajax.server.php?page=browse&action=get_share_links&object_type=' + object_type + '&object_id=' + object_id;
@ -173,7 +173,7 @@ function showShareDialog(e, object_type, object_id) {
height: 90, height: 90,
autoOpen: false, autoOpen: false,
position: { position: {
my: "left+10 top", my: 'left+10 top',
of: e of: e
}, },
open: function () { open: function () {
@ -189,24 +189,24 @@ function showShareDialog(e, object_type, object_id) {
close: function (e) { close: function (e) {
$(document).unbind('click'); $(document).unbind('click');
$(this).empty(); $(this).empty();
$(this).dialog("destroy"); $(this).dialog('destroy');
} }
}); });
$("#sharedialog").dialog("open"); $('#sharedialog').dialog('open');
closeshare = 0; closeshare = 0;
} }
function shoverlayclickclose(e) { function shoverlayclickclose(e) {
if (closeshare) { if (closeshare) {
$("#sharedialog").dialog("close"); $('#sharedialog').dialog('close');
} }
closeshare = 1; closeshare = 1;
} }
function handleShareAction(url) { function handleShareAction(url) {
window.open(url); window.open(url);
$("#sharedialog").dialog("close"); $('#sharedialog').dialog('close');
} }
@ -271,7 +271,7 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
type: 'POST', type: 'POST',
data: $(parent.editFormId).serializeArray(), data: $(parent.editFormId).serializeArray(),
success: function (resp) { success: function (resp) {
$("#editdialog").dialog("close"); $('#editdialog').dialog('close');
if (parent.refreshRowPrefix != '') { if (parent.refreshRowPrefix != '') {
var new_id = $.trim(resp.lastChild.textContent); var new_id = $.trim(resp.lastChild.textContent);
@ -285,7 +285,7 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
// Reload only table // Reload only table
$('#' + parent.refreshRowPrefix + parent.editId).load(url, function() { $('#' + parent.refreshRowPrefix + parent.editId).load(url, function() {
// Update the current row identifier with new id // Update the current row identifier with new id
$('#' + parent.refreshRowPrefix + parent.editId).attr("id", parent.refreshRowPrefix + new_id); $('#' + parent.refreshRowPrefix + parent.editId).attr('id', parent.refreshRowPrefix + new_id);
}); });
} else { } else {
var reloadp = window.location; var reloadp = window.location;
@ -297,12 +297,12 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
} }
}, },
error: function(resp) { error: function(resp) {
$("#editdialog").dialog("close"); $('#editdialog').dialog('close');
} }
}); });
} }
this.dialog_buttons[jsCancelTitle] = function() { this.dialog_buttons[jsCancelTitle] = function() {
$("#editdialog").dialog("close"); $('#editdialog').dialog('close');
} }
$(parent.editDialogId).dialog({ $(parent.editDialogId).dialog({
@ -312,11 +312,11 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
resizable: false, resizable: false,
width: 666, width: 666,
autoOpen: false, autoOpen: false,
show: { effect: "fade", duration: 400 }, show: { effect: 'fade', duration: 400 },
open: function () { open: function () {
$(this).load(parent.contentUrl, function() { $(this).load(parent.contentUrl, function() {
if ($('#edit_tags').length > 0) { if ($('#edit_tags').length > 0) {
$("#edit_tags").tagit({ $('#edit_tags').tagit({
allowSpaces: true, allowSpaces: true,
singleField: true, singleField: true,
singleFieldDelimiter: ',', singleFieldDelimiter: ',',
@ -324,7 +324,7 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
}); });
} }
if ($('#edit_labels').length > 0) { if ($('#edit_labels').length > 0) {
$("#edit_labels").tagit({ $('#edit_labels').tagit({
allowSpaces: true, allowSpaces: true,
singleField: true, singleField: true,
singleFieldDelimiter: ',', singleFieldDelimiter: ',',
@ -335,16 +335,16 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
}, },
close: function (e) { close: function (e) {
$(this).empty(); $(this).empty();
$(this).dialog("destroy"); $(this).dialog('destroy');
}, },
buttons: dialog_buttons buttons: dialog_buttons
}); });
$("#editdialog").dialog("open"); $('#editdialog').dialog('open');
} }
$(window).resize(function() { $(window).resize(function() {
$("#editdialog").dialog("option", "position", {my: "center", at: "center", of: window}); $('#editdialog').dialog('option', 'position', {my: 'center', at: 'center', of: window});
}); });
function check_inline_song_edit(type, song) { function check_inline_song_edit(type, song) {
@ -395,7 +395,7 @@ function submitNewItemsOrder(itemId, tableid, rowPrefix, updateUrl, refreshActio
var row = table.rows[i]; var row = table.rows[i];
if (row.id != '') { if (row.id != '') {
var songid = row.id.replace(rowPrefix, ''); var songid = row.id.replace(rowPrefix, '');
finalOrder += songid + ";" finalOrder += songid + ';'
} }
} }
@ -434,7 +434,7 @@ function geolocate_user() {
if(navigator.geolocation) { if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(geolocate_user_callback); navigator.geolocation.getCurrentPosition(geolocate_user_callback);
} else { } else {
console.error("This browser does not support geolocation"); console.error('This browser does not support geolocation');
} }
} }