1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

Merge pull request #6822 from iMattPro/ticket/17517

Ticket/17517 Update eslint and lint all phpbb JS files
This commit is contained in:
Marc Alexander
2025-06-29 09:10:40 +02:00
committed by GitHub
14 changed files with 1356 additions and 847 deletions

View File

@@ -1,4 +1,6 @@
/* global phpbb */
/* eslint no-var: 0 */
/* eslint no-unused-vars: 0 */
/**
* phpBB ACP functions
@@ -10,7 +12,7 @@
function parse_document(container)
{
var test = document.createElement('div'),
oldBrowser = (typeof test.style.borderRadius == 'undefined');
oldBrowser = (typeof test.style.borderRadius === 'undefined');
test.remove();
@@ -79,7 +81,7 @@ function parse_document(container)
dfn = cell.attr('data-dfn'),
text = dfn ? dfn : $.trim(cell.text());
if (text == ' ') text = '';
if (text === ' ') text = '';
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
for (i=0; i<colspan; i++) {
@@ -108,7 +110,7 @@ function parse_document(container)
cells = row.children('td'),
column = 0;
if (cells.length == 1) {
if (cells.length === 1) {
row.addClass('big-column');
return;
}
@@ -124,7 +126,7 @@ function parse_document(container)
if ((text.length && text !== '-') || cell.children().length) {
if (headers[column].length) {
cell.prepend($("<dfn>").css('display', 'none').text(headers[column]));
cell.prepend($('<dfn>').css('display', 'none').text(headers[column]));
}
}
else {
@@ -156,7 +158,7 @@ function parse_document(container)
*/
container.find('fieldset dt > span:last-child').each(function() {
var $this = $(this);
if ($this.html() == '&nbsp;') {
if ($this.html() === '&nbsp;') {
$this.addClass('responsive-hide');
}
});
@@ -194,7 +196,7 @@ function parse_document(container)
links.each(function() {
var link = $(this);
maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true)));
})
});
function check() {
var width = $body.width(),
@@ -237,7 +239,7 @@ function parse_document(container)
menu.find('a').click(function() { check(true); });
}
phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), {visibleClass: 'activetab', verticalDirection: 'down'});
phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), { visibleClass: 'activetab', verticalDirection: 'down' });
check(true);
$(window).resize(check);
@@ -262,7 +264,7 @@ function parse_document(container)
$('#questionnaire-form').css('display', 'none');
var $triggerConfiglist = $('#trigger-configlist');
$triggerConfiglist.on('click', function () {
$triggerConfiglist.on('click', function() {
var $configlist = $('#configlist');
$configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden');
$configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row');
@@ -272,8 +274,8 @@ function parse_document(container)
$('#configlist').closest('.send-stats-data-row').addClass('send-stats-data-hidden');
// Do not underline actions icons on hover (could not be done via CSS)
$('.actions a:has(i.acp-icon)').mouseover(function () {
$(this).css("text-decoration", "none");
$('.actions a:has(i.acp-icon)').mouseover(function() {
$(this).css('text-decoration', 'none');
});
// Live update BBCode font icon preview
@@ -296,11 +298,11 @@ function parse_document(container)
const pageIconFont = document.getElementById('bbcode_font_icon');
if (pageIconFont) {
pageIconFont.addEventListener('keyup', function () {
pageIconFont.addEventListener('keyup', function() {
updateIconClass(this.nextElementSibling, this.value);
});
pageIconFont.addEventListener('blur', function () {
pageIconFont.addEventListener('blur', function() {
updateIconClass(this.nextElementSibling, this.value);
});
}

View File

@@ -1,16 +1,17 @@
/* global phpbb, statsData */
/* eslint no-var: 0 */
(function($) { // Avoid conflicts with other libraries
'use strict';
phpbb.prepareSendStats = function () {
phpbb.prepareSendStats = function() {
var $form = $('#acp_help_phpbb');
var $dark = $('#darkenwrapper');
var $loadingIndicator;
$form.on('submit', function (event) {
$form.on('submit', function(event) {
var $this = $(this),
currentTime = Math.floor(new Date().getTime() / 1000),
statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10);
@@ -23,7 +24,7 @@ phpbb.prepareSendStats = function () {
if (!$this.find('input[name=help_send_statistics]').is(':checked') ||
statsTime > currentTime) {
$form.find('input[type=submit]').click();
setTimeout(function () {
setTimeout(function() {
$form.find('input[type=submit]').click();
}, 300);
return;
@@ -74,7 +75,7 @@ phpbb.prepareSendStats = function () {
var $sendStatisticsSuccess = $('<input />', {
type: 'hidden',
name: 'send_statistics_response',
value: JSON.stringify(res)
value: JSON.stringify(res),
});
$sendStatisticsSuccess.appendTo('p.submit-buttons');
@@ -90,7 +91,7 @@ phpbb.prepareSendStats = function () {
data: statsData,
success: returnHandler,
error: errorHandler,
cache: false
cache: false,
}).always(function() {
if ($loadingIndicator && $loadingIndicator.is(':visible')) {
$loadingIndicator.fadeOut(phpbb.alertTime);
@@ -176,7 +177,7 @@ phpbb.addAjaxCallback('generate_vapid_keys', () => {
namedCurve: 'P-256',
},
true,
['deriveKey', 'deriveBits']
[ 'deriveKey', 'deriveBits' ],
);
const privateKeyJwk = await crypto.subtle.exportKey('jwk', keyPair.privateKey);
@@ -187,7 +188,7 @@ phpbb.addAjaxCallback('generate_vapid_keys', () => {
return {
privateKey: privateKeyString,
publicKey: publicKeyString
publicKey: publicKeyString,
};
} catch (error) {
console.error('Error generating keys with SubtleCrypto:', error);
@@ -203,8 +204,8 @@ phpbb.addAjaxCallback('generate_vapid_keys', () => {
const privateKeyInput = document.querySelector('#webpush_vapid_private');
publicKeyInput.value = keyPair.publicKey;
privateKeyInput.value = keyPair.privateKey;
})
})
});
});
/**
* Handler for submitting permissions form in chunks
@@ -230,7 +231,7 @@ function submitPermissions() {
fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id);
}
$.each(fieldsetList, function (key, value) {
$.each(fieldsetList, function(key, value) {
dataSetIndex = Math.floor(key / 5);
var $fieldset = $('fieldset#' + value.id);
if (key % 5 === 0) {
@@ -252,7 +253,7 @@ function submitPermissions() {
permissionSubmitSize = formDataSets.length;
// Add each forum ID to forum ID list to preserve selected forums
$.each($form.find('input[type=hidden][name^=forum_id]'), function (key, value) {
$.each($form.find('input[type=hidden][name^=forum_id]'), function(key, value) {
if (value.name.match(/^forum_id\[([0-9]+)\]$/)) {
forumIds.push(value.value);
}
@@ -286,18 +287,18 @@ function submitPermissions() {
$alertBoxLink.attr('href', $alertBoxLink.attr('href').replace(/(&forum_id\[\]=[0-9]+)/g, ''));
const $previousPageForm = $('<form>').attr({
action: $alertBoxLink.attr('href'),
method: 'post'
method: 'post',
});
$.each(forumIds, function (key, value) {
$.each(forumIds, function(key, value) {
$previousPageForm.append($('<input>').attr({
type: 'text',
name: 'forum_id[]',
value: value
value: value,
}));
});
$alertBoxLink.on('click', function (e) {
$alertBoxLink.on('click', function(e) {
$('body').append($previousPageForm);
e.preventDefault();
$previousPageForm.submit();
@@ -309,19 +310,19 @@ function submitPermissions() {
$alert.find('.alert_close').hide();
if (typeof res.REFRESH_DATA !== 'undefined') {
setTimeout(function () {
setTimeout(function() {
// Create forum to submit using POST. This will prevent
// exceeding the maximum length of URLs
const $form = $('<form>').attr({
action: res.REFRESH_DATA.url.replace(/(&forum_id\[\]=[0-9]+)/g, ''),
method: 'post'
method: 'post',
});
$.each(forumIds, function (key, value) {
$.each(forumIds, function(key, value) {
$form.append($('<input>').attr({
type: 'text',
name: 'forum_id[]',
value: value
value: value,
}));
});
@@ -329,7 +330,7 @@ function submitPermissions() {
// Hide the alert even if we refresh the page, in case the user
// presses the back button.
$dark.fadeOut(phpbb.alertTime, function () {
$dark.fadeOut(phpbb.alertTime, function() {
if (typeof $alert !== 'undefined') {
$alert.hide();
}
@@ -355,7 +356,7 @@ function submitPermissions() {
}
// Create AJAX request for each form data set
$.each(formDataSets, function (key, formData) {
$.each(formDataSets, function(key, formData) {
$.ajax({
url: $form.action,
type: 'POST',
@@ -365,7 +366,7 @@ function submitPermissions() {
'&' + $form.children('input[type=hidden]').serialize() +
'&' + $form.find('input[type=checkbox][name^=inherit]').serialize(),
success: handlePermissionReturn,
error: handlePermissionReturn
error: handlePermissionReturn,
});
});
}
@@ -379,7 +380,7 @@ $('[data-ajax]').each(function() {
phpbb.ajaxify({
selector: this,
refresh: $this.attr('data-refresh') !== undefined,
callback: fn
callback: fn,
});
}
});
@@ -388,11 +389,11 @@ $('[data-ajax]').each(function() {
* Automatically resize textarea
*/
$(function() {
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75});
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), { minHeight: 75 });
var $setPermissionsForm = $('form#set-permissions');
if ($setPermissionsForm.length) {
$setPermissionsForm.on('submit', function (e) {
$setPermissionsForm.on('submit', function(e) {
submitPermissions();
e.preventDefault();
});
@@ -412,7 +413,7 @@ $(function() {
} else {
dateoptionInput.value = this.value;
}
})
});
}
if ($('#acp_help_phpbb')) {

View File

@@ -1,4 +1,8 @@
/* global phpbb */
/* eslint camelcase: 0 */
/* eslint no-undef: 0 */
/* eslint no-unused-vars: 0 */
/* eslint no-var: 0 */
/**
* Hide and show all checkboxes
@@ -372,7 +376,7 @@ function match_role_settings(id) {
* @return {string} The sorted object as a string
*/
function sort_and_stringify(obj) {
return JSON.stringify(Object.keys(obj).sort().reduce(function (result, key) {
return JSON.stringify(Object.keys(obj).sort().reduce(function(result, key) {
result[key] = obj[key];
return result;
}, {}));

View File

@@ -1,4 +1,5 @@
/* global phpbb */
/* eslint no-var: 0 */
/*
javascript for Bubble Tooltips by Alessandro Fulciniti
@@ -24,14 +25,14 @@ var tooltips = [];
* @param {string} headline Text that should appear on top of tooltip
* @param {string} [subId] Sub ID that should only be using tooltips (optional)
*/
phpbb.enableTooltipsSelect = function (id, headline, subId) {
phpbb.enableTooltipsSelect = function(id, headline, subId) {
var $links, hold;
hold = $('<span />', {
id: '_tooltip_container',
css: {
position: 'absolute'
}
position: 'absolute',
},
});
$('body').append(hold);
@@ -42,7 +43,7 @@ phpbb.enableTooltipsSelect = function (id, headline, subId) {
$links = $('.roles-options li', '#' + id);
}
$links.each(function () {
$links.each(function() {
var $this = $(this);
if (subId) {
@@ -61,7 +62,7 @@ phpbb.enableTooltipsSelect = function (id, headline, subId) {
* @param {jQuery} $element Element to prepare for tooltips
* @param {string} headText Text heading to display
*/
phpbb.prepareTooltips = function ($element, headText) {
phpbb.prepareTooltips = function($element, headText) {
var $tooltip, text, $desc, $title;
text = $element.attr('data-title');
@@ -73,8 +74,8 @@ phpbb.prepareTooltips = function ($element, headText) {
$title = $('<span />', {
class: 'top',
css: {
display: 'block'
}
display: 'block',
},
})
.append(document.createTextNode(headText));
@@ -82,15 +83,15 @@ phpbb.prepareTooltips = function ($element, headText) {
class: 'bottom',
html: text,
css: {
display: 'block'
}
display: 'block',
},
});
$tooltip = $('<span />', {
class: 'tooltip',
css: {
display: 'block'
}
display: 'block',
},
})
.append($title)
.append($desc);
@@ -105,7 +106,7 @@ phpbb.prepareTooltips = function ($element, headText) {
*
* @param {object} $element Element passed by .on()
*/
phpbb.showTooltip = function ($element) {
phpbb.showTooltip = function($element) {
var $this = $($element.target);
$('#_tooltip_container').append(tooltips[$this.attr('data-id')]);
phpbb.positionTooltip($this);
@@ -114,7 +115,7 @@ phpbb.showTooltip = function ($element) {
/**
* Hide tooltip
*/
phpbb.hideTooltip = function () {
phpbb.hideTooltip = function() {
var d = document.getElementById('_tooltip_container');
if (d.childNodes.length > 0) {
d.removeChild(d.firstChild);
@@ -126,7 +127,7 @@ phpbb.hideTooltip = function () {
*
* @param {jQuery} $element Tooltip element that should be positioned
*/
phpbb.positionTooltip = function ($element) {
phpbb.positionTooltip = function($element) {
var offset;
$element = $element.parent();
@@ -135,12 +136,12 @@ phpbb.positionTooltip = function ($element) {
if ($('body').hasClass('rtl')) {
$('#_tooltip_container').css({
top: offset.top + 30,
left: offset.left + 255
left: offset.left + 255,
});
} else {
$('#_tooltip_container').css({
top: offset.top + 30,
left: offset.left - 205
left: offset.left - 205,
});
}
};
@@ -148,13 +149,13 @@ phpbb.positionTooltip = function ($element) {
/**
* Prepare roles drop down select
*/
phpbb.prepareRolesDropdown = function () {
phpbb.prepareRolesDropdown = function() {
var $options = $('.roles-options li');
// Display span and hide select
$('.roles-options > span').css('display', 'block');
$('.roles-options > select').hide();
$('.roles-options > input[type=hidden]').each(function () {
$('.roles-options > input[type=hidden]').each(function() {
var $this = $(this);
if ($this.attr('data-name') && !$this.attr('name')) {
@@ -163,7 +164,7 @@ phpbb.prepareRolesDropdown = function () {
});
// Prepare highlighting of select options and settings update
$options.each(function () {
$options.each(function() {
var $this = $(this);
var $rolesOptions = $this.closest('.roles-options');
var $span = $rolesOptions.children('span');
@@ -182,18 +183,18 @@ phpbb.prepareRolesDropdown = function () {
}
// Prepare resetting drop down on form reset
$this.closest('form').on('reset', function () {
$this.closest('form').on('reset', function() {
$span.text($span.attr('data-default'));
$rolesOptions.children('input[type=hidden]')
.val($span.attr('data-default-val'));
});
}
$this.on('mouseover', function () {
$this.on('mouseover', function() {
var $this = $(this);
$options.removeClass('roles-highlight');
$this.addClass('roles-highlight');
}).on('click', function () {
}).on('click', function() {
var $this = $(this);
var $rolesOptions = $this.closest('.roles-options');