Run pre-commit on legacy code

This commit is contained in:
jo 2021-10-12 11:17:57 +02:00
parent fea11ac752
commit 83b7e4162e
323 changed files with 6126 additions and 6462 deletions

View file

@ -27,7 +27,7 @@ function openAddShowForm(nowOrFuture) {
$('#schedule-record-rebroadcast').hide();
$('#schedule-show-who').hide();
$('#schedule-show-style').hide();
}
$("#schedule-show-what").show(0, function(){
$add_show_name = $("#add_show_name");
@ -101,18 +101,18 @@ function calculateShowColor() {
//$el is DOM element #add-show-form
//form is the new form contents to append to $el
function redrawAddShowForm($el, form) {
//need to clean up the color picker.
$el.find("#schedule-show-style input").each(function(i, el){
var $input = $(this),
var $input = $(this),
colId = $input.data("colorpickerId");
$("#"+colId).remove();
$input.removeData();
});
$el.empty().append(form);
setAddShowEvents($el);
}
@ -121,7 +121,7 @@ function closeAddShowForm(event) {
event.preventDefault();
var $el = $("#add-show-form");
$el.hide();
windowResize();
@ -146,7 +146,7 @@ function startDpSelect(dateText, inst) {
function endDpSelect(dateText, inst) {
var time, date;
time = dateText.split("-");
date = new Date(time[0], time[1] - 1, time[2]);
@ -187,7 +187,7 @@ function findHosts(request, callback) {
noResult[0]['value'] = $("#add_show_hosts_autocomplete").val();
noResult[0]['label'] = $.i18n._("No result found");
noResult[0]['index'] = null;
$.post(url,
{format: "json", term: search},
@ -202,12 +202,12 @@ function findHosts(request, callback) {
}
function beginEditShow(data){
if (data.show_error == true){
alertShowErrorAndReload();
return false;
}
redrawAddShowForm($("#add-show-form"), data.newForm);
toggleAddShowButton();
openAddShowForm(false);
@ -234,11 +234,11 @@ function hashCode(str) { // java String#hashCode
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
return hash;
}
}
function intToRGB(i){
return (padZeroes(((i>>16)&0xFF).toString(16), 2) +
padZeroes(((i>>8)&0xFF).toString(16), 2)+
return (padZeroes(((i>>16)&0xFF).toString(16), 2) +
padZeroes(((i>>8)&0xFF).toString(16), 2)+
padZeroes((i&0xFF).toString(16), 2)
);
}
@ -302,11 +302,11 @@ function setAddShowEvents(form) {
if(!form.find("#add_show_rebroadcast").attr('checked')) {
form.find("#schedule-record-rebroadcast > fieldset:not(:first-child)").hide();
}
// If we're adding a new show or the show has no logo, hide the "Current Logo" element tree
$("[id^=add_show_logo_current]").toggle(($("#add_show_logo_current").attr("src") !== "")
&& ($(".button-bar.bottom").find(".ui-button-text").text() === "Update show"));
var submitButton = $(".button-bar.bottom").find(".add-show-submit");
$("[id^=add_show_instance_description]").toggle(submitButton.attr("data-action") === "edit-repeating-show-instance");
@ -319,7 +319,7 @@ function setAddShowEvents(form) {
form.find("#add_show_repeats").click(function(){
$(this).blur();
form.find("#schedule-show-when > fieldset:last").toggle();
var checkBoxSelected = false;
var days = form.find("#add_show_day_check-element input").each( function() {
var currentCheckBox = $(this).attr("checked");
@ -327,14 +327,14 @@ function setAddShowEvents(form) {
checkBoxSelected = true;
}
});
if (!checkBoxSelected){
var d = getDateFromString(form.find("#add_show_start_date").attr("value"));
if ( d != null)
form.find("#add_show_day_check-"+d.getDay()).attr('checked', true);
}
//must switch rebroadcast displays
if(form.find("#add_show_rebroadcast").attr('checked')) {
@ -356,13 +356,13 @@ function setAddShowEvents(form) {
}
return false;
}
//only display the warning message if a show is being edited
if ($(".button-bar.bottom").find(".ui-button-text").text() === "Update show") {
if ($(this).attr("checked") && $("#show-link-warning").length === 0) {
$(this).parent().after("<ul id='show-link-warning' class='errors'><li>"+$.i18n._("Warning: All other repetitions of this show will have their contents replaced to match the show you selected 'Edit Show' with.")+"</li></ul>");
}
if (!$(this).attr("checked") && $("#show-link-warning").length !== 0) {
$("#show-link-warning").remove();
}
@ -484,7 +484,7 @@ function setAddShowEvents(form) {
at: "right center"
}
});
form.find(".show_autoplaylist_help_icon").qtip({
content: {
text: $.i18n._("Autoloading playlists' contents are added to shows one hour before the show airs. <a target='_blank' href='http://libretime.org/docs/playlists'>More information</a>")
@ -679,7 +679,7 @@ function setAddShowEvents(form) {
select: autoSelect,
delay: 200
});
form.find("#add_show_hosts_autocomplete").keypress(function(e){
if( e.which == 13 ){
return false;
@ -698,13 +698,13 @@ function setAddShowEvents(form) {
$(this).ColorPickerSetColor(this.value);
}
});
// when an image is uploaded, we want to show it to the user
form.find("#add_show_logo").change(function(event) {
if (this.files && this.files[0]) {
$("#add_show_logo_preview").show();
var reader = new FileReader(); // browser compatibility?
reader.onload = function (e) {
$("#add_show_logo_preview")
.attr('src', e.target.result);
@ -723,14 +723,14 @@ function setAddShowEvents(form) {
$("#add_show_logo_preview").hide();
}
});
form.find("#add_show_logo_current_remove").click(function() {
if (confirm($.i18n._('Are you sure you want to delete the current logo?'))) {
var showId = $("#add_show_id").attr("value");
if (showId && $("#add_show_logo_current").attr("src") !== "") {
var action = '/rest/show-image?csrf_token=' + $('#csrf').val() + '&id=' + showId;
$.ajax({
url: action,
data: '',
@ -743,15 +743,15 @@ function setAddShowEvents(form) {
}
}
});
form.find("#add-show-close").click(closeAddShowForm);
form.find(".add-show-submit").click(function(event) {
event.preventDefault();
var addShowButton = $(this);
$('#schedule-add-show').block({
$('#schedule-add-show').block({
message: null,
applyPlatformOpacityRules: false
});
@ -762,10 +762,10 @@ function setAddShowEvents(form) {
if (form.find("#add_show_record").attr("disabled", true)) {
form.find("#add_show_record").attr("disabled", false);
}
var startDateDisabled = false,
startTimeDisabled = false;
// Similarly, we need to re-enable start date and time if they're disabled
if (form.find("#add_show_start_date").prop("disabled") === true) {
form.find("#add_show_start_date").attr("disabled", false);
@ -780,7 +780,7 @@ function setAddShowEvents(form) {
// We need to notify the application if date and time were disabled
data.push({name: 'start_date_disabled', value: startDateDisabled});
data.push({name: 'start_time_disabled', value: startTimeDisabled});
var hosts = $('#add_show_hosts-element input').map(function() {
if($(this).attr("checked")) {
return $(this).val();
@ -796,7 +796,7 @@ function setAddShowEvents(form) {
var start_date = $("#add_show_start_date").val(),
end_date = $("#add_show_end_date").val(),
action = baseUrl+"Schedule/"+String(addShowButton.attr("data-action"));
var image;
if ($('#add_show_logo')[0] && $('#add_show_logo')[0].files
&& $('#add_show_logo')[0].files[0]) {
@ -805,12 +805,12 @@ function setAddShowEvents(form) {
}
$.ajax({
url: action,
url: action,
data: {format: "json", data: data, hosts: hosts, days: days},
success: function(json) {
if (json.showId && image) { // Successfully added the show, and it contains an image to upload
var imageAction = '/rest/show-image?csrf_token=' + $('#csrf').val() + '&id=' + json.showId;
// perform a second xhttprequest in order to send the show image
$.ajax({
url: imageAction,
@ -823,20 +823,20 @@ function setAddShowEvents(form) {
}
$('#schedule-add-show').unblock();
var $addShowForm = $("#add-show-form");
if (json.form) {
redrawAddShowForm($addShowForm, json.form);
$("#add_show_end_date").val(end_date);
$("#add_show_start_date").val(start_date);
showErrorSections();
} else if (json.edit) {
$("#schedule_calendar").removeAttr("style")
.fullCalendar('render');
$addShowForm.hide();
toggleAddShowButton();
$.get(baseUrl+"Schedule/get-form", {format:"json"}, function(json){
@ -858,23 +858,23 @@ function setAddShowEvents(form) {
var regDate = new RegExp(/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/);
var regTime = new RegExp(/^[0-2][0-9]:[0-5][0-9]$/);
// when start date/time changes, set end date/time to start date/time+1 hr
$('#add_show_start_date, #add_show_start_time').bind('input', 'change', function(){
var startDateString = $('#add_show_start_date').val();
var startTimeString = $('#add_show_start_time').val();
if(regDate.test(startDateString) && regTime.test(startTimeString)){
var startDate = startDateString.split('-');
var startTime = startTimeString.split(':');
var startDateTime = new Date(startDate[0], parseInt(startDate[1], 10)-1, startDate[2], startTime[0], startTime[1], 0, 0);
var endDateString = $('#add_show_end_date_no_repeat').val();
var endTimeString = $('#add_show_end_time').val()
var endDate = endDateString.split('-');
var endTime = endTimeString.split(':');
var endDateTime = new Date(endDate[0], parseInt(endDate[1], 10)-1, endDate[2], endTime[0], endTime[1], 0, 0);
if(startDateTime.getTime() >= endDateTime.getTime()){
var duration = $('#add_show_duration').val();
// parse duration
@ -888,13 +888,13 @@ function setAddShowEvents(form) {
}
endDateTime = new Date(startDateTime.getTime() + time);
}
var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2);
var endTimeFormat = pad(endDateTime.getHours(),2) + ':' + pad(endDateTime.getMinutes(),2);
$('#add_show_end_date_no_repeat').val(endDateFormat);
$('#add_show_end_time').val(endTimeFormat);
// calculate duration
var startDateTimeString = startDateString + " " + startTimeString;
var endDateTimeString = $('#add_show_end_date_no_repeat').val() + " " + $('#add_show_end_time').val();
@ -907,7 +907,7 @@ function setAddShowEvents(form) {
$('#add_show_end_date_no_repeat, #add_show_end_time').bind('input', 'change', function(){
var endDateString = $('#add_show_end_date_no_repeat').val();
var endTimeString = $('#add_show_end_time').val()
if(regDate.test(endDateString) && regTime.test(endTimeString)){
var startDateString = $('#add_show_start_date').val();
var startTimeString = $('#add_show_start_time').val();
@ -918,7 +918,7 @@ function setAddShowEvents(form) {
var endDate = endDateString.split('-');
var endTime = endTimeString.split(':');
var endDateTime = new Date(endDate[0], parseInt(endDate[1], 10)-1, endDate[2], endTime[0], endTime[1], 0, 0);
if(startDateTime.getTime() > endDateTime.getTime()){
$('#add_show_end_date_no_repeat').css('background-color', '#F49C9C');
$('#add_show_end_time').css('background-color', '#F49C9C');
@ -926,7 +926,7 @@ function setAddShowEvents(form) {
$('#add_show_end_date_no_repeat').css('background-color', '');
$('#add_show_end_time').css('background-color', '');
}
// calculate duration
var startDateTimeString = startDateString + " " + startTimeString;
var endDateTimeString = endDateString + " " + endTimeString;
@ -940,7 +940,7 @@ function setAddShowEvents(form) {
}else{
$('#custom_auth_div').hide()
}
$('#cb_custom_auth').change(function(){
if($(this).attr('checked')){
$('#custom_auth_div').show()
@ -951,17 +951,17 @@ function setAddShowEvents(form) {
function calculateDuration(startDateTime, endDateTime, timezone){
var loadingIcon = $('#icon-loader-small');
loadingIcon.show();
$.post(
baseUrl+"Schedule/calculate-duration",
{startTime: startDateTime, endTime: endDateTime, timezone: timezone},
baseUrl+"Schedule/calculate-duration",
{startTime: startDateTime, endTime: endDateTime, timezone: timezone},
function(data) {
$('#add_show_duration').val(JSON.parse(data));
loadingIcon.hide();
});
}
// Since Zend's setAttrib won't apply through the wrapper, set accept=image/* here
$("#add_show_logo").prop("accept", "image/*");

View file

@ -369,7 +369,7 @@ function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui
}
//Workaround for cases where FullCalendar handles events over DST
//time changes in a different way than Airtime does.
//time changes in a different way than Airtime does.
//(Airtime preserves show duration, FullCalendar doesn't.)
scheduleRefetchEvents(json);

View file

@ -1,23 +1,23 @@
var AIRTIME = (function(AIRTIME){
var mod;
if (AIRTIME.schedule === undefined) {
AIRTIME.schedule = {};
}
mod = AIRTIME.schedule;
return AIRTIME;
}(AIRTIME || {}));
var serverTimezoneOffset = 0;
function closeDialogCalendar(event, ui) {
$el = $(this);
$el.dialog('destroy');
$el.remove();
//need to refetch the events to update scheduled status.
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
}
@ -51,7 +51,7 @@ function confirmCancelRecordedShow(show_instance_id){
function findViewportDimensions() {
var viewportwidth,
viewportheight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use
// window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') {
@ -70,7 +70,7 @@ function findViewportDimensions() {
viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
viewportheight = document.getElementsByTagName('body')[0].clientHeight;
}
return {
width: viewportwidth,
height: viewportheight-45
@ -189,10 +189,10 @@ function buildScheduleDialog (json, instance_id) {
fnServer.ops.showFilter = 0;
fnServer.ops.showInstanceFilter = instance_id;
fnServer.ops.myShows = 0;
AIRTIME.library.libraryInit();
AIRTIME.showbuilder.builderDataTable();
dialog.dialog('open');
highlightMediaTypeSelector(dialog);
buildTimerange(dialog);
@ -203,15 +203,15 @@ function buildContentDialog (json){
viewport = findViewportDimensions(),
height = viewport.height * 2/3,
width = viewport.width * 4/5;
if (json.show_error == true){
alertShowErrorAndReload();
}
dialog.find("#show_progressbar").progressbar({
value: json.percentFilled
});
dialog.dialog({
autoOpen: false,
title: $.i18n._("Contents of Show") +" '" + json.showTitle + "'",
@ -258,7 +258,7 @@ function createFullCalendar(data){
left: 'prev, next, today',
center: 'title',
right: 'agendaDay, agendaWeek, month'
},
},
defaultView: getTimeScalePreference(data),
slotMinutes: getTimeIntervalPreference(data),
firstDay: data.calendarInit.weekStartDay,
@ -314,7 +314,7 @@ function createFullCalendar(data){
lazyFetching: true,
serverTimestamp: parseInt(data.calendarInit.timestamp, 10),
serverTimezoneOffset: parseInt(data.calendarInit.timezoneOffset, 10),
events: getFullCalendarEvents,
//callbacks (in full-calendar-functions.js)
@ -342,31 +342,31 @@ $(document).ready(function() {
trigger: "left",
ignoreRightClick: true,
className: 'calendar-context-menu',
build: function($el, e) {
var data,
items,
var data,
items,
callback;
data = $el.data("event");
function processMenuItems(oItems) {
//define a schedule callback.
if (oItems.schedule !== undefined) {
callback = function() {
$.post(oItems.schedule.url, {format: "json", id: data.id}, function(json){
buildScheduleDialog(json, data.id);
});
};
oItems.schedule.callback = callback;
}
//define a clear callback.
if (oItems.clear !== undefined) {
callback = function() {
if (confirm($.i18n._("Remove all content?"))) {
$.post(oItems.clear.url, {format: "json", id: data.id}, function(json){
@ -376,13 +376,13 @@ $(document).ready(function() {
};
oItems.clear.callback = callback;
}
//define an edit callback.
if (oItems.edit !== undefined) {
if(oItems.edit.items !== undefined){
var edit = oItems.edit.items;
//edit a single instance
callback = function() {
$.get(edit.instance.url, {format: "json", showId: data.showId, instanceId: data.id, type: "instance"}, function(json){
@ -390,7 +390,7 @@ $(document).ready(function() {
});
};
edit.instance.callback = callback;
//edit this instance and all
callback = function() {
$.get(edit.all.url, {format: "json", showId: data.showId, instanceId: data.id, type: "all"}, function(json){
@ -410,7 +410,7 @@ $(document).ready(function() {
//define a content callback.
if (oItems.content !== undefined) {
callback = function() {
$.get(oItems.content.url, {format: "json", id: data.id}, function(json){
buildContentDialog(json);
@ -418,16 +418,16 @@ $(document).ready(function() {
};
oItems.content.callback = callback;
}
//define a cancel recorded show callback.
if (oItems.cancel_recorded !== undefined) {
callback = function() {
confirmCancelRecordedShow(data.id);
};
oItems.cancel_recorded.callback = callback;
}
//define a view recorded callback.
if (oItems.view_recorded !== undefined) {
callback = function() {
@ -438,23 +438,23 @@ $(document).ready(function() {
};
oItems.view_recorded.callback = callback;
}
//define a cancel callback.
if (oItems.cancel !== undefined) {
callback = function() {
confirmCancelShow(data.id);
};
oItems.cancel.callback = callback;
}
//define a delete callback.
if (oItems.del !== undefined) {
//repeating show multiple delete options
if (oItems.del.items !== undefined) {
var del = oItems.del.items;
//delete a single instance
callback = function() {
$.post(del.single.url, {format: "json", id: data.id}, function(json){
@ -462,15 +462,15 @@ $(document).ready(function() {
});
};
del.single.callback = callback;
//delete this instance and all following instances.
callback = function() {
$.post(del.following.url, {format: "json", id: data.id}, function(json){
scheduleRefetchEvents(json);
});
};
del.following.callback = callback;
del.following.callback = callback;
}
//single show
else {
@ -479,10 +479,10 @@ $(document).ready(function() {
scheduleRefetchEvents(json);
});
};
oItems.del.callback = callback;
oItems.del.callback = callback;
}
}
items = oItems;
}