Skip to content

Commit

Permalink
Lints JS code with ESLint, reviewed manually.
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoFara committed Jan 3, 2024
1 parent 09e31a7 commit 562b76a
Show file tree
Hide file tree
Showing 7 changed files with 1,012 additions and 1,049 deletions.
178 changes: 88 additions & 90 deletions js/pgm.js

Large diffs are not rendered by default.

218 changes: 107 additions & 111 deletions src/js/audio_controller.js
Original file line number Diff line number Diff line change
@@ -1,128 +1,124 @@
/**
* All the function to make an audio controller in do_text_header.php
*
*
* @license Unlicense
*/


/*
* An audio controller.
* An audio controller.
*/
const lwt_audio_controller = {
/**
* Change the position of the audio player head.
*
* @param {Number} position New player head
*/
newPosition: function (position) {
$("#jquery_jplayer_1").jPlayer("playHead", position);
},

setNewPlayerSeconds: function () {
const newval = $("#backtime :selected").val();
do_ajax_save_setting('currentplayerseconds', newval);
},

setNewPlaybackRate: function () {
const newval = $("#playbackrate :selected").val();
do_ajax_save_setting('currentplaybackrate', newval);
$("#jquery_jplayer_1").jPlayer("option","playbackRate", newval * 0.1);
},

setCurrentPlaybackRate: function () {
const val = $("#playbackrate :selected").val();
$("#jquery_jplayer_1").jPlayer("option","playbackRate", val * 0.1);
},

clickSingle: function () {
$("#jquery_jplayer_1").off('bind', $.jPlayer.event.ended + ".jp-repeat");
$("#do-single").addClass('hide');
$("#do-repeat").removeClass('hide');
do_ajax_save_setting('currentplayerrepeatmode','0');
},

clickRepeat: function () {
$("#jquery_jplayer_1")
.on('bind', $.jPlayer.event.ended + ".jp-repeat", function() {
$("#jquery_jplayer_1").jPlayer("play");
});
$("#do-repeat").addClass('hide');
$("#do-single").removeClass('hide');
do_ajax_save_setting('currentplayerrepeatmode','1');
},

clickBackward: function () {
const t = parseInt($("#playTime").text(), 10);
const b = parseInt($("#backtime").val(), 10);
let nt = t - b;
let st = 'pause';
if (nt < 0)
nt = 0;
if (!$('#jquery_jplayer_1').data().jPlayer.status.paused)
st = 'play';
$("#jquery_jplayer_1").jPlayer(st, nt);
},

clickForward: function () {
const t = parseInt($("#playTime").text(), 10);
const b = parseInt($("#backtime").val(), 10);
const nt = t + b;
let st = 'pause';
if (!$('#jquery_jplayer_1').data().jPlayer.status.paused)
st = 'play';
$("#jquery_jplayer_1").jPlayer(st, nt);
},

clickSlower: function () {
const val = parseFloat($("#pbvalue").text()) - 0.1;
if (val >= 0.5) {
$("#pbvalue").text(val.toFixed(1)).css({'color': '#BBB'})
.animate({color: '#888'},150,function() {});
$("#jquery_jplayer_1").jPlayer("playbackRate", val);
}
},

clickFaster: function () {
const val = parseFloat($("#pbvalue").text()) + 0.1;
if (val <= 4.0){
$("#pbvalue").text(val.toFixed(1)).css({'color': '#BBB'})
.animate({color: '#888'},150,function() {});
$("#jquery_jplayer_1").jPlayer("playbackRate", val);
}
},

setStdSpeed: function () {
$("#playbackrate").val(10);
lwt_audio_controller.setNewPlaybackRate();
},

setSlower: function () {
let val = $("#playbackrate :selected").val();
if (val > 5) {
val--;
$("#playbackrate").val(val);
lwt_audio_controller.setNewPlaybackRate();
}
},

setFaster: function () {
let val = $("#playbackrate :selected").val();
if (val < 15) {
val++;
$("#playbackrate").val(val);
lwt_audio_controller.setNewPlaybackRate();
}
},
/**
* Change the position of the audio player head.
*
* @param {Number} position New player head
*/
newPosition: function (position) {
$('#jquery_jplayer_1').jPlayer('playHead', position);
},

setNewPlayerSeconds: function () {
const newval = $('#backtime :selected').val();
do_ajax_save_setting('currentplayerseconds', newval);
},

setNewPlaybackRate: function () {
const newval = $('#playbackrate :selected').val();
do_ajax_save_setting('currentplaybackrate', newval);
$('#jquery_jplayer_1').jPlayer('option', 'playbackRate', newval * 0.1);
},

setCurrentPlaybackRate: function () {
const val = $('#playbackrate :selected').val();
$('#jquery_jplayer_1').jPlayer('option', 'playbackRate', val * 0.1);
},

clickSingle: function () {
$('#jquery_jplayer_1').off('bind', $.jPlayer.event.ended + '.jp-repeat');
$('#do-single').addClass('hide');
$('#do-repeat').removeClass('hide');
do_ajax_save_setting('currentplayerrepeatmode', '0');
},

clickRepeat: function () {
$('#jquery_jplayer_1')
.on('bind', $.jPlayer.event.ended + '.jp-repeat', function () {
$('#jquery_jplayer_1').jPlayer('play');
});
$('#do-repeat').addClass('hide');
$('#do-single').removeClass('hide');
do_ajax_save_setting('currentplayerrepeatmode', '1');
},

clickBackward: function () {
const t = parseInt($('#playTime').text(), 10);
const b = parseInt($('#backtime').val(), 10);
let nt = t - b;
let st = 'pause';
if (nt < 0) { nt = 0; }
if (!$('#jquery_jplayer_1').data().jPlayer.status.paused) { st = 'play'; }
$('#jquery_jplayer_1').jPlayer(st, nt);
},

clickForward: function () {
const t = parseInt($('#playTime').text(), 10);
const b = parseInt($('#backtime').val(), 10);
const nt = t + b;
let st = 'pause';
if (!$('#jquery_jplayer_1').data().jPlayer.status.paused) { st = 'play'; }
$('#jquery_jplayer_1').jPlayer(st, nt);
},

clickSlower: function () {
const val = parseFloat($('#pbvalue').text()) - 0.1;
if (val >= 0.5) {
$('#pbvalue').text(val.toFixed(1)).css({ color: '#BBB' })
.animate({ color: '#888' }, 150, function () {});
$('#jquery_jplayer_1').jPlayer('playbackRate', val);
}
},

clickFaster: function () {
const val = parseFloat($('#pbvalue').text()) + 0.1;
if (val <= 4.0) {
$('#pbvalue').text(val.toFixed(1)).css({ color: '#BBB' })
.animate({ color: '#888' }, 150, function () {});
$('#jquery_jplayer_1').jPlayer('playbackRate', val);
}
},

setStdSpeed: function () {
$('#playbackrate').val(10);
lwt_audio_controller.setNewPlaybackRate();
},

setSlower: function () {
let val = $('#playbackrate :selected').val();
if (val > 5) {
val--;
$('#playbackrate').val(val);
lwt_audio_controller.setNewPlaybackRate();
}
},

setFaster: function () {
let val = $('#playbackrate :selected').val();
if (val < 15) {
val++;
$('#playbackrate').val(val);
lwt_audio_controller.setNewPlaybackRate();
}
}

}

/**
* Change the position of the audio player head.
*
*
* @param {Number} p New player head
*
*
* @deprecated Since LWT 2.9.1, use lwt_audio_controller.newPosition
*/
function new_pos(p) {
return lwt_audio_controller.newPosition(p);
function new_pos (p) {
return lwt_audio_controller.newPosition(p);
}
Loading

0 comments on commit 562b76a

Please sign in to comment.