fix problems reported by eslint

This commit is contained in:
Tilman Kranz 2024-11-10 15:08:12 +01:00 committed by Tilman Kranz
parent 8e6b09583d
commit 36773fe342
2 changed files with 35 additions and 21 deletions

10
eslint.config.js Normal file
View File

@ -0,0 +1,10 @@
// eslint.config.js
export default [
{
rules: {
semi: "error",
"prefer-const": "error"
}
}
];

View File

@ -118,7 +118,7 @@ var MyPlayer = function(_args) {
"3g2": "video/3gpp2", "3g2": "video/3gpp2",
"7z": "application/x-7z-compressed" "7z": "application/x-7z-compressed"
}[extension] || "application/octet-stream"; }[extension] || "application/octet-stream";
} };
var args = (typeof(_args)==='undefined') var args = (typeof(_args)==='undefined')
? defaultArgs ? defaultArgs
@ -141,7 +141,7 @@ var MyPlayer = function(_args) {
$(args.audio).css({ $(args.audio).css({
'height': '500px', 'height': '500px',
}); });
} };
var readId3 = function() { var readId3 = function() {
$(args.element).find('ul.mejs li').each(function(i, track){ $(args.element).find('ul.mejs li').each(function(i, track){
@ -149,30 +149,34 @@ var MyPlayer = function(_args) {
$(track).prepend('<span class="ajaxLoader">&nbsp;</span>&nbsp;'); $(track).prepend('<span class="ajaxLoader">&nbsp;</span>&nbsp;');
ID3.loadTags(url, function() { jsmediatags.read(url, {
var tags = ID3.getAllTags(url); onSuccess: function(tag) {
var tags = tag.tags;
var track_title;
if(typeof(tags.title)!='undefined') { if(typeof(tags.title)!='undefined')
var track_title = tags.title; track_title = tags.title;
else
track_title = url;
if(typeof(tags.artist)!='undefined') if(typeof(tags.artist)!='undefined')
track_title = tags.artist + ' - ' + track_title; track_title = tags.artist + ' - ' + track_title;
$(args.element).find('ul.mejs li').each(function(j, _track){ $(args.element).find('ul.mejs li').each(function(j, _track){
if(i==j) if(i==j)
$(_track).html(track_title); $(_track).html(track_title);
}); });
} }
}); });
}); });
} };
var playerCreated = function() { var playerCreated = function() {
restoreParams(); restoreParams();
if(args.id3) if(args.id3)
readId3(); readId3();
} };
var createPlayer = function() { var createPlayer = function() {
player = new MediaElementPlayer( player = new MediaElementPlayer(
@ -186,7 +190,7 @@ var MyPlayer = function(_args) {
'The player is currently detached.'+ 'The player is currently detached.'+
'</p>' '</p>'
); );
} };
var param = function(name) { var param = function(name) {
var query = window.location.search.substring(1); var query = window.location.search.substring(1);
@ -200,7 +204,7 @@ var MyPlayer = function(_args) {
} }
return false; return false;
} };
var setupDetach = function() { var setupDetach = function() {
if(!args.detachable) if(!args.detachable)
@ -224,7 +228,7 @@ var MyPlayer = function(_args) {
$("iframe",top.document).height(20); $("iframe",top.document).height(20);
return false; return false;
} };
if(param('popup')==false) { if(param('popup')==false) {
$('.mejs-controls').append( $('.mejs-controls').append(
@ -255,7 +259,7 @@ var MyPlayer = function(_args) {
'currentTime='+currentTime+'&'+ 'currentTime='+currentTime+'&'+
'volume='+volume+'&'+ 'volume='+volume+'&'+
'trackNo='+trackNo 'trackNo='+trackNo
) );
}); });
} }
else { else {
@ -265,9 +269,9 @@ var MyPlayer = function(_args) {
$("iframe", opener.top.document).height(windowHeight); $("iframe", opener.top.document).height(windowHeight);
$('.mejs-audio', opener.document).show(); $('.mejs-audio', opener.document).show();
$('.playerDetached', opener.document).hide(); $('.playerDetached', opener.document).hide();
} };
} }
} };
var restoreParams = function() { var restoreParams = function() {
if(!detached) if(!detached)
@ -289,7 +293,7 @@ var MyPlayer = function(_args) {
if(paused) if(paused)
player.pause(); player.pause();
} };
if(param('popup')!==false) { if(param('popup')!==false) {
detached = true; detached = true;
@ -413,5 +417,5 @@ var MyPlayer = function(_args) {
$(args.element).append('<p>Unsupported mode "'+args.mode+'"</p>'); $(args.element).append('<p>Unsupported mode "'+args.mode+'"</p>');
failed = true; failed = true;
} }
} };