From b82d7d3f473372f31dd97c09fc93f7adec72fc84 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 1 Jun 2025 08:41:18 -0700 Subject: [PATCH] [ticket/17517] Revert back to var PHPBB-17517 --- phpBB/adm/style/admin.js | 89 +++--- phpBB/adm/style/ajax.js | 74 ++--- phpBB/adm/style/permissions.js | 87 ++--- phpBB/adm/style/tooltip.js | 39 +-- phpBB/assets/javascript/core.js | 331 ++++++++++---------- phpBB/assets/javascript/editor.js | 100 +++--- phpBB/assets/javascript/installer.js | 152 ++++----- phpBB/assets/javascript/plupload.js | 83 ++--- phpBB/styles/prosilver/template/ajax.js | 105 ++++--- phpBB/styles/prosilver/template/forum_fn.js | 203 ++++++------ 10 files changed, 638 insertions(+), 625 deletions(-) diff --git a/phpBB/adm/style/admin.js b/phpBB/adm/style/admin.js index 0beaafd2e0..97452cba62 100644 --- a/phpBB/adm/style/admin.js +++ b/phpBB/adm/style/admin.js @@ -1,4 +1,5 @@ /* global phpbb */ +/* eslint no-var: 0 */ /** * phpBB3 ACP functions @@ -8,15 +9,15 @@ * Parse document block */ function parseDocument(container) { - const test = document.createElement('div'); + var test = document.createElement('div'); test.remove(); /** * Navigation */ container.find('#menu').each(function() { - const menu = $(this); - const blocks = menu.children('.menu-block'); + var menu = $(this); + var blocks = menu.children('.menu-block'); if (!blocks.length) { return; @@ -24,7 +25,7 @@ function parseDocument(container) { // Set onclick event blocks.children('a.header').click(function() { - const parent = $(this).parent(); + var parent = $(this).parent(); if (!parent.hasClass('active')) { parent.siblings().removeClass('active'); } @@ -45,22 +46,22 @@ function parseDocument(container) { * Responsive tables */ container.find('table').not('.not-responsive').each(function() { - const $this = $(this); - const th = $this.find('thead > tr > th'); - const headers = []; - let totalHeaders = 0; - let i; + var $this = $(this); + var th = $this.find('thead > tr > th'); + var headers = []; + var totalHeaders = 0; + var i; // Find columns $this.find('colgroup:first').children().each(function(i) { - const column = $(this); + var column = $(this); $this.find('td:nth-child(' + (i + 1) + ')').addClass(column.prop('className')); }); // Styles table if ($this.hasClass('styles')) { $this.find('td:first-child[style]').each(function() { - const style = $(this).attr('style'); + var style = $(this).attr('style'); if (style.length) { $(this).parent('tr').attr('style', style.toLowerCase().replace('padding', 'margin')).addClass('responsive-style-row'); } @@ -70,10 +71,10 @@ function parseDocument(container) { // Find each header if (!$this.data('no-responsive-header')) { th.each(function(column) { - const cell = $(this); - let colspan = parseInt(cell.attr('colspan'), 10); - const dfn = cell.attr('data-dfn'); - let text = dfn ? dfn : $.trim(cell.text()); + var cell = $(this); + var colspan = parseInt(cell.attr('colspan'), 10); + var dfn = cell.attr('data-dfn'); + var text = dfn ? dfn : $.trim(cell.text()); if (text === ' ') { text = ''; @@ -93,7 +94,7 @@ function parseDocument(container) { }); } - const headersLength = headers.length; + headersLength = headers.length; // Add header text to each cell as $this.addClass('responsive'); @@ -104,9 +105,9 @@ function parseDocument(container) { } $this.find('tbody > tr').each(function() { - const row = $(this); - const cells = row.children('td'); - let column = 0; + var row = $(this); + var cells = row.children('td'); + var column = 0; if (cells.length === 1) { row.addClass('big-column'); @@ -114,9 +115,9 @@ function parseDocument(container) { } cells.each(function() { - const cell = $(this); - let colspan = parseInt(cell.attr('colspan'), 10); - const text = $.trim(cell.text()); + var cell = $(this); + var colspan = parseInt(cell.attr('colspan'), 10); + var text = $.trim(cell.text()); if (headersLength <= column) { return; @@ -143,7 +144,7 @@ function parseDocument(container) { * Hide empty responsive tables */ container.find('table.responsive > tbody').each(function() { - const items = $(this).children('tr'); + var items = $(this).children('tr'); if (!items.length) { $(this).parent('table:first').addClass('responsive-hide'); } @@ -153,7 +154,7 @@ function parseDocument(container) { * Fieldsets with empty */ container.find('fieldset dt > span:last-child').each(function() { - const $this = $(this); + var $this = $(this); if ($this.html() === ' ') { $this.addClass('responsive-hide'); } @@ -164,7 +165,7 @@ function parseDocument(container) { */ container.find('#sitename_short').each(function() { const $this = this; - const { maxLength } = $this; + const maxLength = $this.maxLength; $this.maxLength = maxLength * 2; $this.addEventListener('input', () => { const inputChars = Array.from($this.value); @@ -178,25 +179,25 @@ function parseDocument(container) { * Responsive tabs */ container.find('#tabs').not('[data-skip-responsive]').each(function() { - const $this = $(this); - const $body = $('body'); - const ul = $this.children(); - const tabs = ul.children().not('[data-skip-responsive]'); - const links = tabs.children('a'); - const item = ul.append('').find('li.responsive-tab'); - const menu = item.find('.dropdown-contents'); - let maxHeight = 0; - let lastWidth = false; - let responsive = false; + var $this = $(this); + var $body = $('body'); + var ul = $this.children(); + var tabs = ul.children().not('[data-skip-responsive]'); + var links = tabs.children('a'); + var item = ul.append('').find('li.responsive-tab'); + var menu = item.find('.dropdown-contents'); + var maxHeight = 0; + var lastWidth = false; + var responsive = false; links.each(function() { - const link = $(this); + var link = $(this); maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true))); }); function check() { - const width = $body.width(); - let height = $this.height(); + var width = $body.width(); + var height = $this.height(); if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) { return; @@ -220,10 +221,10 @@ function parseDocument(container) { item.show(); menu.html(''); - const availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'); - const total = availableTabs.length; - let i; - let tab; + var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'); + var total = availableTabs.length; + var i; + var tab; for (i = total - 1; i >= 0; i--) { tab = availableTabs.eq(i); @@ -265,10 +266,10 @@ function parseDocument(container) { parseDocument($('body')); $('#questionnaire-form').css('display', 'none'); - const $triggerConfiglist = $('#trigger-configlist'); + var $triggerConfiglist = $('#trigger-configlist'); $triggerConfiglist.on('click', function() { - const $configlist = $('#configlist'); + 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'); $(this).find('i').toggleClass('fa-angle-down fa-angle-up'); diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 1f0a2fa623..8707fa321f 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -1,25 +1,25 @@ /* global phpbb, statsData */ +/* eslint no-var: 0 */ (function($) { // Avoid conflicts with other libraries 'use strict'; phpbb.prepareSendStats = function() { - const $form = $('#acp_help_phpbb'); - const $dark = $('#darkenwrapper'); - let $loadingIndicator; + var $form = $('#acp_help_phpbb'); + var $dark = $('#darkenwrapper'); + var $loadingIndicator; $form.on('submit', function(event) { - const $this = $(this); - const currentTime = Math.floor(new Date().getTime() / 1000); - const statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10); + var $this = $(this); + var currentTime = Math.floor(new Date().getTime() / 1000); + var statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10); event.preventDefault(); $this.unbind('submit'); // Skip ajax request if form is submitted too early or send stats // checkbox is not checked - if (!$this.find('input[name=help_send_statistics]').is(':checked') - || statsTime > currentTime) { + if (!$this.find('input[name=help_send_statistics]').is(':checked') || statsTime > currentTime) { $form.find('input[type=submit]').click(); setTimeout(() => { $form.find('input[type=submit]').click(); @@ -36,7 +36,7 @@ } phpbb.clearLoadingTimeout(); - let errorText = ''; + var errorText = ''; if (typeof errorThrown === 'string' && errorThrown.length > 0) { errorText = errorThrown; @@ -71,7 +71,7 @@ $loadingIndicator.fadeOut(phpbb.alertTime); } - const $sendStatisticsSuccess = $('', { + var $sendStatisticsSuccess = $('', { type: 'hidden', name: 'send_statistics_response', value: JSON.stringify(res), @@ -110,8 +110,8 @@ return; } - const $firstTr = $(this).parents('tr'); - const $secondTr = $firstTr.next(); + var $firstTr = $(this).parents('tr'); + var $secondTr = $firstTr.next(); $firstTr.insertAfter($secondTr); }); @@ -121,8 +121,8 @@ return; } - const $secondTr = $(this).parents('tr'); - const $firstTr = $secondTr.prev(); + var $secondTr = $(this).parents('tr'); + var $firstTr = $secondTr.prev(); $secondTr.insertBefore($firstTr); }); @@ -133,8 +133,8 @@ * in the href with "deactivate", and vice versa. */ phpbb.addAjaxCallback('activate_deactivate', function(res) { - const $this = $(this); - let newHref = $this.attr('href'); + var $this = $(this); + var newHref = $this.attr('href'); $this.text(res.text); @@ -211,19 +211,19 @@ * This call will submit permissions forms in chunks of 5 fieldsets. */ function submitPermissions() { - const $form = $('form#set-permissions'); - let fieldsetList = $form.find('fieldset[id^=perm]'); - const formDataSets = []; - let dataSetIndex = 0; - const $submitAllButton = $form.find('input[type=submit][name^=action]')[0]; - const $submitButton = $form.find('input[type=submit][data-clicked=true]')[0]; + var $form = $('form#set-permissions'); + var fieldsetList = $form.find('fieldset[id^=perm]'); + var formDataSets = []; + var dataSetIndex = 0; + var $submitAllButton = $form.find('input[type=submit][name^=action]')[0]; + var $submitButton = $form.find('input[type=submit][data-clicked=true]')[0]; // Set proper start values for handling refresh of page - let permissionSubmitSize = 0; - let permissionRequestCount = 0; - const forumIds = []; - let permissionSubmitFailed = false; - let clearIndicator = true; + var permissionSubmitSize = 0; + var permissionRequestCount = 0; + var forumIds = []; + var permissionSubmitFailed = false; + var clearIndicator = true; if ($submitAllButton !== $submitButton) { fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id); @@ -231,7 +231,7 @@ $.each(fieldsetList, (key, value) => { dataSetIndex = Math.floor(key / 5); - const $fieldset = $('fieldset#' + value.id); + var $fieldset = $('fieldset#' + value.id); if (key % 5 === 0) { formDataSets[dataSetIndex] = $fieldset.find('select:visible, input:not([data-name])').serialize(); } else { @@ -239,7 +239,7 @@ } // Find proper role value - const roleInput = $fieldset.find('input[name^=role][data-name]'); + var roleInput = $fieldset.find('input[name^=role][data-name]'); if (roleInput.val()) { formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + roleInput.val(); } else { @@ -257,7 +257,7 @@ } }); - const $loadingIndicator = phpbb.loadingIndicator(); + var $loadingIndicator = phpbb.loadingIndicator(); /** * Handler for submitted permissions form chunk @@ -266,7 +266,7 @@ */ function handlePermissionReturn(res) { permissionRequestCount++; - const $dark = $('#darkenwrapper'); + var $dark = $('#darkenwrapper'); if (res.S_USER_WARNING) { phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); @@ -276,8 +276,8 @@ if (permissionRequestCount >= permissionSubmitSize) { clearIndicator = true; - const $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - const $alertBoxLink = $alert.find('p.alert_text > a'); + var $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + var $alertBoxLink = $alert.find('p.alert_text > a'); // Create form to submit instead of normal "Back to previous page" link if ($alertBoxLink) { @@ -370,11 +370,11 @@ } $('[data-ajax]').each(function() { - const $this = $(this); - const ajax = $this.attr('data-ajax'); + var $this = $(this); + var ajax = $this.attr('data-ajax'); if (ajax !== 'false') { - const fn = (ajax === 'true') ? null : ajax; + var fn = (ajax === 'true') ? null : ajax; phpbb.ajaxify({ selector: this, refresh: $this.attr('data-refresh') !== undefined, @@ -389,7 +389,7 @@ $(() => { phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), { minHeight: 75 }); - const $setPermissionsForm = $('form#set-permissions'); + var $setPermissionsForm = $('form#set-permissions'); if ($setPermissionsForm.length) { $setPermissionsForm.on('submit', e => { submitPermissions(); diff --git a/phpBB/adm/style/permissions.js b/phpBB/adm/style/permissions.js index a1371ff7d2..1e9fe3798b 100644 --- a/phpBB/adm/style/permissions.js +++ b/phpBB/adm/style/permissions.js @@ -2,15 +2,16 @@ /* eslint camelcase: 0 */ /* eslint no-undef: 0 */ /* eslint no-unused-vars: 0 */ +/* eslint no-var: 0 */ /** * Hide and show all checkboxes * status = true (show boxes), false (hide boxes) */ function display_checkboxes(status) { - const form = document.getElementById('set-permissions'); - const cb = document.getElementsByTagName('input'); - let display; + var form = document.getElementById('set-permissions'); + var cb = document.getElementsByTagName('input'); + var display; if (status) { // show @@ -20,7 +21,7 @@ function display_checkboxes(status) { display = 'none'; } - for (let i = 0; i < cb.length; i++ ) { + for (var i = 0; i < cb.length; i++ ) { if (cb[i].className === 'permissions-checkbox') { cb[i].style.display = display; } @@ -44,8 +45,8 @@ function set_opacity(e, value) { * block_id = id of the element that needs to be toggled */ function toggle_opacity(block_id) { - const cb = document.getElementById('checkbox' + block_id); - const fs = document.getElementById('perm' + block_id); + var cb = document.getElementById('checkbox' + block_id); + var fs = document.getElementById('perm' + block_id); if (cb.checked) { set_opacity(fs, 5); @@ -60,15 +61,15 @@ function toggle_opacity(block_id) { * except_id = id of the element not to hide */ function reset_opacity(status, except_id) { - const perm = document.getElementById('set-permissions'); - const fs = perm.getElementsByTagName('fieldset'); - let opacity = 5; + var perm = document.getElementById('set-permissions'); + var fs = perm.getElementsByTagName('fieldset'); + var opacity = 5; if (status) { opacity = 10; } - for (let i = 0; i < fs.length; i++ ) { + for (var i = 0; i < fs.length; i++ ) { if (fs[i].className !== 'quick') { set_opacity(fs[i], opacity); } @@ -88,7 +89,7 @@ function reset_opacity(status, except_id) { * rb = array of radiobuttons */ function get_radio_status(index, rb) { - for (let i = index; i < rb.length; i += 3 ) { + for (var i = index; i < rb.length; i += 3 ) { if (rb[i].checked !== true) { if (i > index) { // at least one is true, but not all (custom) @@ -111,18 +112,18 @@ function get_radio_status(index, rb) { * quick = If no calculation needed, this contains the colour */ function set_colours(id, init, quick) { - const table = document.getElementById('table' + id); - const tab = document.getElementById('tab' + id); + var table = document.getElementById('table' + id); + var tab = document.getElementById('tab' + id); if (typeof (quick) !== 'undefined') { tab.className = 'permissions-preset-' + quick + ' activetab'; return; } - const rb = table.getElementsByTagName('input'); - let colour = 'custom'; + var rb = table.getElementsByTagName('input'); + var colour = 'custom'; - let status = get_radio_status(0, rb); + var status = get_radio_status(0, rb); if (status === 1) { colour = 'yes'; @@ -154,11 +155,11 @@ function set_colours(id, init, quick) { * block_id = block that is opened */ function init_colours(block_id) { - const block = document.getElementById('advanced' + block_id); - const panels = block.getElementsByTagName('div'); - const tab = document.getElementById('tab' + id); + var block = document.getElementById('advanced' + block_id); + var panels = block.getElementsByTagName('div'); + var tab = document.getElementById('tab' + id); - for (let i = 0; i < panels.length; i++) { + for (var i = 0; i < panels.length; i++) { if (panels[i].className === 'permissions-panel') { set_colours(panels[i].id.replace(/options/, ''), true); } @@ -178,9 +179,9 @@ function swap_options(pmask, fmask, cat, adv, view) { id = pmask + fmask + cat; active_option = active_pmask + active_fmask + active_cat; - const old_tab = document.getElementById('tab' + active_option); - const new_tab = document.getElementById('tab' + id); - const adv_block = document.getElementById('advanced' + pmask + fmask); + var old_tab = document.getElementById('tab' + active_option); + var new_tab = document.getElementById('tab' + id); + var adv_block = document.getElementById('advanced' + pmask + fmask); if (adv_block.style.display === 'block' && adv === true) { phpbb.toggleDisplay('advanced' + pmask + fmask, -1); @@ -244,15 +245,15 @@ function swap_options(pmask, fmask, cat, adv, view) { * id = table ID container, s = status ['y'/'u'/'n'] */ function mark_options(id, s) { - const t = document.getElementById(id); + var t = document.getElementById(id); if (!t) { return; } - const rb = t.getElementsByTagName('input'); + var rb = t.getElementsByTagName('input'); - for (let r = 0; r < rb.length; r++) { + for (var r = 0; r < rb.length; r++) { if (rb[r].id.substr(rb[r].id.length - 1) === s) { rb[r].checked = true; } @@ -260,15 +261,15 @@ function mark_options(id, s) { } function mark_one_option(id, field_name, s) { - const t = document.getElementById(id); + var t = document.getElementById(id); if (!t) { return; } - const rb = t.getElementsByTagName('input'); + var rb = t.getElementsByTagName('input'); - for (let r = 0; r < rb.length; r++) { + for (var r = 0; r < rb.length; r++) { if (rb[r].id.substr(rb[r].id.length - field_name.length - 3, field_name.length) === field_name && rb[r].id.substr(rb[r].id.length - 1) === s) { rb[r].checked = true; } @@ -285,21 +286,21 @@ function mark_one_option(id, field_name, s) { * @returns {void} */ function reset_role(id) { - const t = document.getElementById(id); + var t = document.getElementById(id); if (!t) { return; } // Before resetting the role dropdown, try and match any permission role - const parent = t.parentNode; - const roleId = match_role_settings(id.replace('role', 'perm')); - let text = no_role_assigned; - let index = 0; + var parent = t.parentNode; + var roleId = match_role_settings(id.replace('role', 'perm')); + var text = no_role_assigned; + var index = 0; // If a role permissions was matched, grab that option's value and index if (roleId) { - for (let i = 0; i < t.options.length; i++) { + for (var i = 0; i < t.options.length; i++) { if (parseInt(t.options[i].value, 10) === roleId) { text = t.options[i].text; index = i; @@ -321,7 +322,7 @@ function reset_role(id) { * Load role and set options accordingly */ function set_role_settings(role_id, target_id) { - const settings = role_options[role_id]; + var settings = role_options[role_id]; if (!settings) { return; @@ -330,7 +331,7 @@ function set_role_settings(role_id, target_id) { // Mark all options to no (unset) first... mark_options(target_id, 'u'); - for (const r in settings) { + for (var r in settings) { if (Object.prototype.hasOwnProperty.call(settings, r)) { mark_one_option(target_id, r, (settings[r] === 1) ? 'y' : 'n'); } @@ -344,13 +345,13 @@ function set_role_settings(role_id, target_id) { * @return {number} The permission role identifier */ function match_role_settings(id) { - const fieldset = document.getElementById(id); - const radios = fieldset.getElementsByTagName('input'); - let set = {}; + var fieldset = document.getElementById(id); + var radios = fieldset.getElementsByTagName('input'); + var set = {}; // Iterate over all the radio buttons - for (let i = 0; i < radios.length; i++) { - const matches = radios[i].id.match(/setting\[\d+]\[\d+]\[([a-z_]+)]/); + for (var i = 0; i < radios.length; i++) { + var matches = radios[i].id.match(/setting\[\d+]\[\d+]\[([a-z_]+)]/); // Make sure the name attribute matches, the radio is checked and it is not the "No" (-1) value. if (matches !== null && radios[i].checked && radios[i].value !== '-1') { @@ -362,7 +363,7 @@ function match_role_settings(id) { set = sort_and_stringify(set); // Iterate over the available role options and return the first match - for (const r in role_options) { + for (var r in role_options) { if (sort_and_stringify(role_options[r]) === set) { return parseInt(r, 10); } diff --git a/phpBB/adm/style/tooltip.js b/phpBB/adm/style/tooltip.js index 51aaaafd8c..262eec91ec 100644 --- a/phpBB/adm/style/tooltip.js +++ b/phpBB/adm/style/tooltip.js @@ -1,4 +1,5 @@ /* global phpbb */ +/* eslint no-var: 0 */ /* javascript for Bubble Tooltips by Alessandro Fulciniti @@ -15,7 +16,7 @@ phpBB Development Team: (function($) { // Avoid conflicts with other libraries 'use strict'; - const tooltips = []; + var tooltips = []; /** * Enable tooltip replacements for selects @@ -24,9 +25,9 @@ phpBB Development Team: * @param {string} [subId] Sub ID that should only be using tooltips (optional) */ phpbb.enableTooltipsSelect = function(id, headline, subId) { - let $links; + var $links; - const hold = $('', { + var hold = $('', { id: '_tooltip_container', css: { position: 'absolute', @@ -42,7 +43,7 @@ phpBB Development Team: } $links.each(function() { - const $this = $(this); + var $this = $(this); if (subId) { if ($this.parent().attr('id').substr(0, subId.length) === subId) { @@ -61,13 +62,13 @@ phpBB Development Team: * @param {string} headText Text heading to display */ phpbb.prepareTooltips = function($element, headText) { - const text = $element.attr('data-title'); + var text = $element.attr('data-title'); if (text === null || text.length === 0) { return; } - const $title = $('', { + var $title = $('', { class: 'top', css: { display: 'block', @@ -75,7 +76,7 @@ phpBB Development Team: }) .append(document.createTextNode(headText)); - const $desc = $('', { + var $desc = $('', { class: 'bottom', html: text, css: { @@ -83,7 +84,7 @@ phpBB Development Team: }, }); - const $tooltip = $('', { + var $tooltip = $('', { class: 'tooltip', css: { display: 'block', @@ -103,7 +104,7 @@ phpBB Development Team: * @param {object} $element Element passed by .on() */ phpbb.showTooltip = function($element) { - const $this = $($element.target); + var $this = $($element.target); $('#_tooltip_container').append(tooltips[$this.attr('data-id')]); phpbb.positionTooltip($this); }; @@ -112,7 +113,7 @@ phpBB Development Team: * Hide tooltip */ phpbb.hideTooltip = function() { - const d = document.getElementById('_tooltip_container'); + var d = document.getElementById('_tooltip_container'); if (d.childNodes.length > 0) { d.removeChild(d.firstChild); } @@ -125,7 +126,7 @@ phpBB Development Team: */ phpbb.positionTooltip = function($element) { $element = $element.parent(); - const offset = $element.offset(); + var offset = $element.offset(); if ($('body').hasClass('rtl')) { $('#_tooltip_container').css({ @@ -144,13 +145,13 @@ phpBB Development Team: * Prepare roles drop down select */ phpbb.prepareRolesDropdown = function() { - const $options = $('.roles-options li'); + 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() { - const $this = $(this); + var $this = $(this); if ($this.attr('data-name') && !$this.attr('name')) { $this.attr('name', $this.attr('data-name')); @@ -159,9 +160,9 @@ phpBB Development Team: // Prepare highlighting of select options and settings update $options.each(function() { - const $this = $(this); - const $rolesOptions = $this.closest('.roles-options'); - const $span = $rolesOptions.children('span'); + var $this = $(this); + var $rolesOptions = $this.closest('.roles-options'); + var $span = $rolesOptions.children('span'); // Correctly show selected option if (typeof $this.attr('data-selected') !== 'undefined') { @@ -185,12 +186,12 @@ phpBB Development Team: } $this.on('mouseover', function() { - const $this = $(this); + var $this = $(this); $options.removeClass('roles-highlight'); $this.addClass('roles-highlight'); }).on('click', function() { - const $this = $(this); - const $rolesOptions = $this.closest('.roles-options'); + var $this = $(this); + var $rolesOptions = $this.closest('.roles-options'); // Update settings // eslint-disable-next-line no-undef diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 95e66254c8..c6f0ec8c31 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1,13 +1,14 @@ /* global bbfontstyle */ +/* eslint no-var: 0 */ -const phpbb = {}; +var phpbb = {}; phpbb.alertTime = 100; (function($) { // Avoid conflicts with other libraries 'use strict'; // define a couple constants for keydown functions. - const keymap = { + var keymap = { TAB: 9, ENTER: 13, ESC: 27, @@ -15,9 +16,9 @@ phpbb.alertTime = 100; ARROW_DOWN: 40, }; - const $dark = $('#darkenwrapper'); - let $loadingIndicator; - let phpbbAlertTimer = null; + var $dark = $('#darkenwrapper'); + var $loadingIndicator; + var phpbbAlertTimer = null; phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined'); @@ -54,7 +55,7 @@ phpbb.alertTime = 100; * Show timeout message */ phpbb.showTimeoutMessage = function() { - const $alert = $('#phpbb_alert'); + var $alert = $('#phpbb_alert'); if ($loadingIndicator.is(':visible')) { phpbb.alert($alert.attr('data-l-err'), $alert.attr('data-l-timeout-processing-req')); @@ -93,7 +94,7 @@ phpbb.alertTime = 100; * @returns {object} Returns the div created. */ phpbb.alert = function(title, msg) { - const $alert = $('#phpbb_alert'); + var $alert = $('#phpbb_alert'); $alert.find('.alert_title').html(title); $alert.find('.alert_text').html(msg); @@ -156,7 +157,7 @@ phpbb.alertTime = 100; * @param {bool} fadedark Whether to remove dark background. */ phpbb.alert.close = function($alert, fadedark) { - const $fade = (fadedark) ? $dark : $alert; + var $fade = (fadedark) ? $dark : $alert; $fade.fadeOut(phpbb.alertTime, () => { $alert.hide(); @@ -180,13 +181,13 @@ phpbb.alertTime = 100; * @returns {object} Returns the div created. */ phpbb.confirm = function(msg, callback, fadedark) { - const $confirmDiv = $('#phpbb_confirm'); + var $confirmDiv = $('#phpbb_confirm'); $confirmDiv.find('.alert_text').html(msg); fadedark = typeof fadedark === 'undefined' ? true : fadedark; $(document).on('keydown.phpbb.alert', e => { if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) { - const name = (e.keyCode === keymap.ENTER) ? 'confirm' : 'cancel'; + var name = (e.keyCode === keymap.ENTER) ? 'confirm' : 'cancel'; $('input[name="' + name + '"]').trigger('click'); e.preventDefault(); @@ -195,7 +196,7 @@ phpbb.alertTime = 100; }); $confirmDiv.find('input[type="button"]').one('click.phpbb.confirmbox', function(e) { - const confirmed = this.name === 'confirm'; + var confirmed = this.name === 'confirm'; callback(confirmed); $confirmDiv.find('input[type="button"]').off('click.phpbb.confirmbox'); @@ -217,9 +218,9 @@ phpbb.alertTime = 100; * @returns {object} The object created. */ phpbb.parseQuerystring = function(string) { - const params = {}; - let i; - let split; + var params = {}; + var i; + var split; string = string.split('&'); for (i = 0; i < string.length; i++) { @@ -244,13 +245,13 @@ phpbb.alertTime = 100; * @param {object} options Options. */ phpbb.ajaxify = function(options) { - const $elements = $(options.selector); - let { refresh } = options; - const { callback } = options; - const overlay = typeof options.overlay === 'undefined' ? true : options.overlay; - const isForm = $elements.is('form'); - const isText = $elements.is('input[type="text"], textarea'); - let eventName; + var $elements = $(options.selector); + var refresh = options.refresh; + var callback = options.callback; + var overlay = typeof options.overlay === 'undefined' ? true : options.overlay; + var isForm = $elements.is('form'); + var isText = $elements.is('input[type="text"], textarea'); + var eventName; if (isForm) { eventName = 'submit'; @@ -261,12 +262,12 @@ phpbb.alertTime = 100; } $elements.on(eventName, function(event) { - let action; - let method; - let data; - let submit; - const that = this; - const $this = $(this); + var action; + var method; + var data; + var submit; + var that = this; + var $this = $(this); if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') { return; @@ -281,8 +282,8 @@ phpbb.alertTime = 100; } phpbb.clearLoadingTimeout(); - let responseText; - let errorText = false; + var responseText; + var errorText = false; try { responseText = JSON.parse(jqXHR.responseText); responseText = responseText.message; @@ -313,7 +314,7 @@ phpbb.alertTime = 100; * @param {object} res The object sent back by the server. */ function returnHandler(res) { - let alert; + var alert; phpbb.clearLoadingTimeout(); @@ -380,7 +381,7 @@ phpbb.alertTime = 100; // If the element is a form, POST must be used and some extra data must // be taken from the form. - const runFilter = (typeof options.filter === 'function'); + var runFilter = (typeof options.filter === 'function'); data = {}; if (isForm) { @@ -396,7 +397,7 @@ phpbb.alertTime = 100; }); } } else if (isText) { - const name = $this.attr('data-name') || this.name; + var name = $this.attr('data-name') || this.name; action = $this.attr('data-url').replace('&', '&'); data[name] = this.value; method = 'POST'; @@ -406,13 +407,13 @@ phpbb.alertTime = 100; method = 'GET'; } - const sendRequest = function() { - const dataOverlay = $this.attr('data-overlay'); + var sendRequest = function() { + var dataOverlay = $this.attr('data-overlay'); if (overlay && (typeof dataOverlay === 'undefined' || dataOverlay === 'true')) { phpbb.loadingIndicator(); } - const request = $.ajax({ + var request = $.ajax({ url: action, type: method, data, @@ -440,7 +441,7 @@ phpbb.alertTime = 100; if (isForm) { $elements.find('input:submit').click(function() { - const $this = $(this); + var $this = $(this); // Remove data-clicked attribute from any submit button of form $this.parents('form:first').find('input:submit[data-clicked]').removeAttr('data-clicked'); @@ -522,7 +523,7 @@ phpbb.alertTime = 100; */ phpbb.search.getKeyword = function($input, keyword, multiline) { if (multiline) { - const line = phpbb.search.getKeywordLine($input); + var line = phpbb.search.getKeywordLine($input); keyword = keyword.split('\n').splice(line, 1); } @@ -537,7 +538,7 @@ phpbb.alertTime = 100; * @returns {int} The line number. */ phpbb.search.getKeywordLine = function($textarea) { - const { selectionStart } = $textarea.get(0); + var { selectionStart } = $textarea.get(0); return $textarea.val().substr(0, selectionStart).split('\n').length - 1; }; @@ -551,8 +552,8 @@ phpbb.alertTime = 100; */ phpbb.search.setValue = function($input, value, multiline) { if (multiline) { - const line = phpbb.search.getKeywordLine($input); - const lines = $input.val().split('\n'); + var line = phpbb.search.getKeywordLine($input); + var lines = $input.val().split('\n'); lines[line] = value; value = lines.join('\n'); } @@ -589,14 +590,14 @@ phpbb.alertTime = 100; * @returns {boolean} Returns false. */ phpbb.search.filter = function(data, event, sendRequest) { - const $this = $(this); - const dataName = $this.attr('data-name') === undefined ? $this.attr('name') : $this.attr('data-name'); - const minLength = parseInt($this.attr('data-min-length'), 10); - const searchID = $this.attr('data-results'); - const keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')); - const cache = phpbb.search.cache.get(searchID); - const key = event.keyCode || event.which; - let proceed = true; + var $this = $(this); + var dataName = $this.attr('data-name') === undefined ? $this.attr('name') : $this.attr('data-name'); + var minLength = parseInt($this.attr('data-min-length'), 10); + var searchID = $this.attr('data-results'); + var keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')); + var cache = phpbb.search.cache.get(searchID); + var key = event.keyCode || event.which; + var proceed = true; data[dataName] = keyword; // No need to search if enter was pressed @@ -609,7 +610,7 @@ phpbb.alertTime = 100; clearTimeout(cache.timeout); } - const timeout = setTimeout(function() { + var timeout = setTimeout(function() { // Check min length and existence of cache. if (minLength > keyword.length) { proceed = false; @@ -620,7 +621,7 @@ phpbb.alertTime = 100; } else { // Do we already have results for this? if (cache.results[keyword]) { - const response = { + var response = { keyword, results: cache.results[keyword], }; @@ -660,8 +661,8 @@ phpbb.alertTime = 100; return; } - const searchID = $input.attr('data-results'); - const $container = $(searchID); + var searchID = $input.attr('data-results'); + var $container = $(searchID); if (this.cache.get(searchID).callback) { callback = this.cache.get(searchID).callback; @@ -686,7 +687,7 @@ phpbb.alertTime = 100; * @param {function} callback Optional callback to run when assigning each search result. */ phpbb.search.showResults = function(results, $input, $container, callback) { - const $resultContainer = $('.search-results', $container); + var $resultContainer = $('.search-results', $container); this.clearResults($resultContainer); if (!results.length) { @@ -694,9 +695,9 @@ phpbb.alertTime = 100; return; } - const searchID = $container.attr('id'); - let tpl; - let row; + var searchID = $container.attr('id'); + var tpl; + var row; if (!this.tpl[searchID]) { tpl = $('.search-result-tpl', $container); @@ -754,14 +755,14 @@ phpbb.alertTime = 100; // Rebind it, to ensure the event is 'dynamic'. $input.off('.phpbb.search'); $input.on('keydown.phpbb.search', event => { - const key = event.keyCode || event.which; - const $active = $resultContainer.children('.active'); + var key = event.keyCode || event.which; + var $active = $resultContainer.children('.active'); if (key === keymap.ESC) { phpbb.search.closeResults($input, $container); } else if (key === keymap.ENTER) { if ($active.length) { - const value = $active.find('.search-result > span').text(); + var value = $active.find('.search-result > span').text(); phpbb.search.setValue($input, value, $input.attr('data-multiline')); } @@ -771,8 +772,8 @@ phpbb.alertTime = 100; // Do not submit the form event.preventDefault(); } else if (key === keymap.ARROW_DOWN || key === keymap.ARROW_UP) { - const up = key === keymap.ARROW_UP; - const $children = $resultContainer.children(); + var up = key === keymap.ARROW_UP; + var $children = $resultContainer.children(); if (!$active.length) { if (up) { @@ -805,7 +806,7 @@ phpbb.alertTime = 100; }; $('#phpbb').click(function() { - const $this = $(this); + var $this = $(this); if (!$this.is('.live-search') && !$this.parents().is('.live-search')) { phpbb.search.closeResults($('input, textarea'), $('.live-search')); @@ -834,7 +835,7 @@ phpbb.alertTime = 100; * @param {object} [obj] Optional state object. */ phpbb.history.alterUrl = function(mode, url, title, obj) { - const fn = mode + 'State'; + var fn = mode + 'State'; if (!url || !phpbb.history.isSupported(fn)) { return; @@ -880,10 +881,10 @@ phpbb.alertTime = 100; * user be forced to repick one. */ phpbb.timezoneSwitchDate = function(keepSelection) { - const $timezoneCopy = $('#timezone_copy'); - const $timezone = $('#timezone'); - const $tzDate = $('#tz_date'); - const $tzSelectDateSuggest = $('#tz_select_date_suggest'); + var $timezoneCopy = $('#timezone_copy'); + var $timezone = $('#timezone'); + var $tzDate = $('#tz_date'); + var $tzSelectDateSuggest = $('#tz_select_date_suggest'); if ($timezoneCopy.length === 0) { // We make a backup of the original dropdown, so we can remove optgroups @@ -909,7 +910,7 @@ phpbb.alertTime = 100; $tzSelectDateSuggest.css('display', 'inline'); } - const $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option'); + var $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option'); if ($tzOptions.length === 1) { // If there is only one timezone for the selected date, we just select that automatically. @@ -918,7 +919,7 @@ phpbb.alertTime = 100; } if (typeof keepSelection !== 'undefined' && !keepSelection) { - const $timezoneOptions = $timezone.find('optgroup option'); + var $timezoneOptions = $timezone.find('optgroup option'); if ($timezoneOptions.filter(':selected').length <= 0) { $timezoneOptions.filter(':first').prop('selected', true); } @@ -939,16 +940,16 @@ phpbb.alertTime = 100; */ phpbb.timezonePreselectSelect = function(forceSelector) { // The offset returned here is in minutes and negated. - let offset = (new Date()).getTimezoneOffset(); - let sign = '-'; + var offset = (new Date()).getTimezoneOffset(); + var sign = '-'; if (offset < 0) { sign = '+'; offset = -offset; } - let minutes = offset % 60; - let hours = (offset - minutes) / 60; + var minutes = offset % 60; + var hours = (offset - minutes) / 60; if (hours === 0) { hours = '00'; @@ -965,15 +966,15 @@ phpbb.alertTime = 100; minutes = minutes.toString(); } - const prefix = 'UTC' + sign + hours + ':' + minutes; - const prefixLength = prefix.length; - const selectorOptions = $('option', '#tz_date'); - let i; + var prefix = 'UTC' + sign + hours + ':' + minutes; + var prefixLength = prefix.length; + var selectorOptions = $('option', '#tz_date'); + var i; - const $tzSelectDateSuggest = $('#tz_select_date_suggest'); + var $tzSelectDateSuggest = $('#tz_select_date_suggest'); for (i = 0; i < selectorOptions.length; ++i) { - const option = selectorOptions[i]; + var option = selectorOptions[i]; if (option.value.substring(0, prefixLength) === prefix) { if ($('#tz_date').val() !== option.value && !forceSelector) { @@ -987,7 +988,7 @@ phpbb.alertTime = 100; $tzSelectDateSuggest.css('display', 'none'); } - const suggestion = $tzSelectDateSuggest.attr('data-l-suggestion'); + var suggestion = $tzSelectDateSuggest.attr('data-l-suggestion'); $tzSelectDateSuggest.attr('title', suggestion.replace('%s', option.innerHTML)); $tzSelectDateSuggest.attr('value', suggestion.replace('%s', option.innerHTML.substring(0, 9))); @@ -1030,9 +1031,9 @@ phpbb.alertTime = 100; * current text so that the process can be repeated. */ phpbb.addAjaxCallback('alt_text', function() { - let $anchor; - const updateAll = $(this).data('update-all'); - let altText; + var $anchor; + var updateAll = $(this).data('update-all'); + var altText; if (updateAll !== undefined && updateAll.length) { $anchor = $(updateAll); @@ -1041,7 +1042,7 @@ phpbb.alertTime = 100; } $anchor.each(function() { - const $this = $(this); + var $this = $(this); altText = $this.attr('data-alt-text'); $this.attr('data-alt-text', $.trim($this.text())); $this.attr('title', altText); @@ -1059,10 +1060,10 @@ phpbb.alertTime = 100; * and changes the link itself. */ phpbb.addAjaxCallback('toggle_link', function() { - let $anchor; - const updateAll = $(this).data('update-all'); - let toggleText; - let toggleUrl; + var $anchor; + var updateAll = $(this).data('update-all'); + var toggleText; + var toggleUrl; if (updateAll !== undefined && updateAll.length) { $anchor = $(updateAll); @@ -1071,7 +1072,7 @@ phpbb.alertTime = 100; } $anchor.each(function() { - const $this = $(this); + var $this = $(this); // Toggle link text toggleText = $.trim($this.attr('data-toggle-text')); @@ -1113,7 +1114,7 @@ phpbb.alertTime = 100; */ phpbb.resizeTextArea = function($items, options) { // Configuration - let configuration = { + var configuration = { minWindowHeight: 500, minHeight: 200, maxHeight: 500, @@ -1131,7 +1132,7 @@ phpbb.alertTime = 100; } function resetAutoResize(item) { - const $item = $(item); + var $item = $(item); if ($item.hasClass('auto-resized')) { $(item) .css({ height: '', resize: '' }) @@ -1149,20 +1150,20 @@ phpbb.alertTime = 100; configuration.resizeCallback.call(item, $item); } - const windowHeight = $(window).height(); + var windowHeight = $(window).height(); if (windowHeight < configuration.minWindowHeight) { resetAutoResize(item); return; } - const maxHeight = Math.min( + var maxHeight = Math.min( Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), configuration.maxHeight, ); - const $item = $(item); - const height = parseInt($item.innerHeight(), 10); - const scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; + var $item = $(item); + var height = parseInt($item.innerHeight(), 10); + var scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; if (height < 0) { return; @@ -1202,20 +1203,20 @@ phpbb.alertTime = 100; * @returns {boolean} True if cursor is in bbcode tag */ phpbb.inBBCodeTag = function(textarea, startTags, endTags) { - const start = textarea.selectionStart; - let lastEnd = -1; - let lastStart = -1; - let i; - let index; + var start = textarea.selectionStart; + var lastEnd = -1; + var lastStart = -1; + var i; + var index; if (typeof start !== 'number') { return false; } - const value = textarea.value.toLowerCase(); + var value = textarea.value.toLowerCase(); for (i = 0; i < startTags.length; i++) { - const tagLength = startTags[i].length; + var tagLength = startTags[i].length; if (start >= tagLength) { index = value.lastIndexOf(startTags[i], start - tagLength); lastStart = Math.max(lastStart, index); @@ -1250,9 +1251,9 @@ phpbb.alertTime = 100; */ phpbb.applyCodeEditor = function(textarea) { // list of allowed start and end bbcode code tags, in lower case - const startTags = [ '[code]', '[code=' ]; - const startTagsEnd = ']'; - const endTags = [ '[/code]' ]; + var startTags = [ '[code]', '[code=' ]; + var startTagsEnd = ']'; + var endTags = [ '[/code]' ]; if (!textarea || typeof textarea.selectionStart !== 'number') { return; @@ -1275,17 +1276,17 @@ phpbb.alertTime = 100; * @returns {string} Line of text */ function getLastLine(stripCodeStart) { - const start = textarea.selectionStart; - let { value } = textarea; - let index = value.lastIndexOf('\n', start - 1); + var start = textarea.selectionStart; + var value = textarea.value; + var index = value.lastIndexOf('\n', start - 1); value = value.substring(index + 1, start); if (stripCodeStart) { - for (let i = 0; i < startTags.length; i++) { + for (var i = 0; i < startTags.length; i++) { index = value.lastIndexOf(startTags[i]); if (index >= 0) { - const tagLength = startTags[i].length; + var tagLength = startTags[i].length; value = value.substring(index + tagLength); if (startTags[i].lastIndexOf(startTagsEnd) !== tagLength) { @@ -1309,9 +1310,9 @@ phpbb.alertTime = 100; * @param {string} text Text to append */ function appendText(text) { - const start = textarea.selectionStart; - const end = textarea.selectionEnd; - const { value } = textarea; + var start = textarea.selectionStart; + var end = textarea.selectionEnd; + var value = textarea.value; textarea.value = value.substr(0, start) + text + value.substr(end); textarea.selectionStart = start + text.length; @@ -1319,7 +1320,7 @@ phpbb.alertTime = 100; } $(textarea).data('code-editor', true).on('keydown', event => { - const key = event.keyCode || event.which; + var key = event.keyCode || event.which; // intercept tabs if (key === keymap.TAB @@ -1337,8 +1338,8 @@ phpbb.alertTime = 100; // intercept new line characters if (key === keymap.ENTER) { if (inTag()) { - const lastLine = getLastLine(true); - const code = String(/^\s*/g.exec(lastLine)); + var lastLine = getLastLine(true); + var code = String(/^\s*/g.exec(lastLine)); if (code.length > 0) { appendText('\n' + code); @@ -1389,11 +1390,11 @@ phpbb.alertTime = 100; * This handler is used by phpBB.registerDropdown() and other functions */ phpbb.toggleDropdown = function(event_) { - const $this = $(this); - const options = $this.data('dropdown-options'); - const { parent } = options; - const visible = parent.hasClass('dropdown-visible'); - let direction; + var $this = $(this); + var options = $this.data('dropdown-options'); + var parent = options.parent; + var visible = parent.hasClass('dropdown-visible'); + var direction; if (!visible) { // Prevent link default action @@ -1404,8 +1405,8 @@ phpbb.alertTime = 100; // Figure out direction of dropdown direction = options.direction; - let { verticalDirection } = options; - const offset = $this.offset(); + var verticalDirection = options.verticalDirection; + var offset = $this.offset(); if (direction === 'auto') { if (($(window).width() - $this.outerWidth(true)) / 2 > offset.left) { @@ -1419,8 +1420,8 @@ phpbb.alertTime = 100; .toggleClass(options.rightClass, direction === 'right'); if (verticalDirection === 'auto') { - const height = $(window).height(); - const top = offset.top - $(window).scrollTop(); + var height = $(window).height(); + var top = offset.top - $(window).scrollTop(); verticalDirection = (top < height * 0.7) ? 'down' : 'up'; } @@ -1436,10 +1437,10 @@ phpbb.alertTime = 100; // Check dimensions when showing dropdown // !visible because variable shows state of dropdown before it was toggled if (!visible) { - const windowWidth = $(window).width(); + var windowWidth = $(window).width(); options.dropdown.find('.dropdown-contents').each(function() { - const $this = $(this); + var $this = $(this); $this.css({ marginLeft: 0, @@ -1448,8 +1449,8 @@ phpbb.alertTime = 100; maxWidth: (windowWidth - 4) + 'px', }); - const offset = $this.offset().left; - const width = $this.outerWidth(true); + var offset = $this.offset().left; + var width = $this.outerWidth(true); if (offset < 2) { $this.css('left', (2 - offset) + 'px'); @@ -1460,22 +1461,22 @@ phpbb.alertTime = 100; // Check whether the vertical scrollbar is present. $this.toggleClass('dropdown-nonscroll', this.scrollHeight === $this.innerHeight()); }); - const freeSpace = parent.offset().left - 4; + var freeSpace = parent.offset().left - 4; if (direction === 'left') { options.dropdown.css('margin-left', '-' + freeSpace + 'px'); // Try to position the notification dropdown correctly in RTL-responsive mode if (options.dropdown.hasClass('dropdown-extended')) { - let contentWidth; - const fullFreeSpace = freeSpace + parent.outerWidth(); + var contentWidth; + var fullFreeSpace = freeSpace + parent.outerWidth(); options.dropdown.find('.dropdown-contents').each(function() { contentWidth = parseInt($(this).outerWidth(), 10); $(this).css({ marginLeft: 0, left: 0 }); }); - const maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px'; + var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px'; options.dropdown.css({ width: maxOffset, marginLeft: -maxOffset, @@ -1490,7 +1491,7 @@ phpbb.alertTime = 100; if (arguments.length > 0) { try { // eslint-disable-next-line prefer-rest-params - const e = arguments[0]; + var e = arguments[0]; e.preventDefault(); e.stopPropagation(); } catch { } @@ -1516,7 +1517,7 @@ phpbb.alertTime = 100; * @param {Object} options List of options. Optional. */ phpbb.registerDropdown = function(toggle, dropdown, options) { - let ops = { + var ops = { parent: toggle.parent(), // Parent item to add classes to direction: 'auto', // Direction of dropdown menu. Possible values: auto, left, right verticalDirection: 'auto', // Vertical direction. Possible values: auto, up, down @@ -1549,12 +1550,12 @@ phpbb.alertTime = 100; * @param {int} height Palette cell height. */ phpbb.colorPalette = function(dir, width, height) { - let r; - let g; - let b; - const numberList = new Array(6); - let color = ''; - let html = ''; + var r; + var g; + var b; + var numberList = new Array(6); + var color = ''; + var html = ''; numberList[0] = '00'; numberList[1] = '40'; @@ -1562,7 +1563,7 @@ phpbb.alertTime = 100; numberList[3] = 'BF'; numberList[4] = 'FF'; - const tableClass = (dir === 'h') ? 'horizontal-palette' : 'vertical-palette'; + var tableClass = (dir === 'h') ? 'horizontal-palette' : 'vertical-palette'; html += ''; for (r = 0; r < 5; r++) { @@ -1604,10 +1605,10 @@ phpbb.alertTime = 100; */ phpbb.registerPalette = function(el) { const orientation = el.attr('data-color-palette') || el.attr('data-orientation'); // data-orientation kept for backwards compat. - const height = el.attr('data-height'); - const width = el.attr('data-width'); - const target = el.attr('data-target'); - const bbcode = el.attr('data-bbcode'); + var height = el.attr('data-height'); + var width = el.attr('data-width'); + var target = el.attr('data-target'); + var bbcode = el.attr('data-bbcode'); // Insert the palette HTML into the container. el.html(phpbb.colorPalette(orientation, width, height)); @@ -1620,7 +1621,7 @@ phpbb.alertTime = 100; // Attach event handler when a palette cell is clicked. $(el).on('click', 'a', function(e) { - const color = $(this).attr('data-color'); + var color = $(this).attr('data-color'); if (bbcode) { bbfontstyle('[color=#' + color + ']', '[/color]'); @@ -1646,9 +1647,9 @@ phpbb.alertTime = 100; type = 'block'; } - const $element = $('#' + id); + var $element = $('#' + id); - const display = $element.css('display'); + var display = $element.css('display'); if (!action) { action = (display === '' || display === type) ? -1 : 1; } @@ -1664,8 +1665,8 @@ phpbb.alertTime = 100; */ phpbb.toggleSelectSettings = function(el) { el.children().each(function() { - const $this = $(this); - const $setting = $($this.data('toggle-setting')); + var $this = $(this); + var $setting = $($this.data('toggle-setting')); $setting.toggle($this.is(':selected')); // Disable any input elements that are not visible right now @@ -1685,11 +1686,11 @@ phpbb.alertTime = 100; * @returns function */ phpbb.getFunctionByName = function(functionName) { - const namespaces = functionName.split('.'); - const func = namespaces.pop(); - let context = window; + var namespaces = functionName.split('.'); + var func = namespaces.pop(); + var context = window; - for (let i = 0; i < namespaces.length; i++) { + for (var i = 0; i < namespaces.length; i++) { context = context[namespaces[i]]; } @@ -1725,17 +1726,17 @@ phpbb.alertTime = 100; * Register page dropdowns. */ phpbb.registerPageDropdowns = function() { - const $body = $('body'); + var $body = $('body'); $body.find('.dropdown-container').each(function() { - const $this = $(this); - let $trigger = $this.find('.dropdown-trigger:first'); - let $contents = $this.find('.dropdown'); - const options = { + var $this = $(this); + var $trigger = $this.find('.dropdown-trigger:first'); + var $contents = $this.find('.dropdown'); + var options = { direction: 'auto', verticalDirection: 'auto', }; - let data; + var data; if (!$trigger.length) { data = $this.attr('data-dropdown-trigger'); @@ -1772,7 +1773,7 @@ phpbb.alertTime = 100; // Hide active dropdowns when click event happens outside $body.click(e => { - const $parents = $(e.target).parents(); + var $parents = $(e.target).parents(); if (!$parents.is(phpbb.dropdownVisibleContainers)) { $(phpbb.dropdownHandles).each(phpbb.toggleDropdown); } @@ -1784,7 +1785,7 @@ phpbb.alertTime = 100; */ phpbb.lazyLoadAvatars = () => { $('.avatar[data-src]').each(function() { - const $avatar = $(this); + var $avatar = $(this); $avatar .attr('src', $avatar.data('src')) @@ -1922,7 +1923,7 @@ phpbb.alertTime = 100; // Hide settings that are not selected via select element. $('select[data-togglable-settings]').each(function() { - const $this = $(this); + var $this = $(this); $this.change(() => { phpbb.toggleSelectSettings($this); diff --git a/phpBB/assets/javascript/editor.js b/phpBB/assets/javascript/editor.js index 69ba11f977..dacb33f27a 100644 --- a/phpBB/assets/javascript/editor.js +++ b/phpBB/assets/javascript/editor.js @@ -2,6 +2,10 @@ /* eslint camelcase: 0 */ /* eslint no-undef: 0 */ /* eslint no-unused-vars: 0 */ +/* eslint no-var: 0 */ + +var form_name = 'postform'; +var text_name = 'message'; /** * bbCode control by subBlue design [ www.subBlue.com ] @@ -9,25 +13,25 @@ */ // Startup variables -const imageTag = false; -let theSelection = false; -const bbcodeEnabled = true; +var imageTag = false; +var theSelection = false; +var bbcodeEnabled = true; // Check for Browser & Platform for PC & IE specific bits // More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html -const clientPC = navigator.userAgent.toLowerCase(); // Get client info -const clientVer = parseInt(navigator.appVersion, 10); // Get browser version +var clientPC = navigator.userAgent.toLowerCase(); // Get client info +var clientVer = parseInt(navigator.appVersion, 10); // Get browser version -const is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1)); -const is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1)); -let baseHeight; +var is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1)); +var is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1)); +var baseHeight; /** * Fix a bug involving the TextRange object. From * http://www.frostjedi.com/terra/scripts/demo/caretBug.html */ function initInsertions() { - let doc; + var doc; if (document.forms[form_name]) { doc = document; @@ -35,7 +39,7 @@ function initInsertions() { doc = opener.document; } - const textarea = doc.forms[form_name].elements[text_name]; + var textarea = doc.forms[form_name].elements[text_name]; if (is_ie && typeof (baseHeight) !== 'number') { textarea.focus(); @@ -65,7 +69,7 @@ function bbstyle(bbnumber) { function bbfontstyle(bbopen, bbclose) { theSelection = false; - const textarea = document.forms[form_name].elements[text_name]; + var textarea = document.forms[form_name].elements[text_name]; textarea.focus(); @@ -88,8 +92,8 @@ function bbfontstyle(bbopen, bbclose) { } // The new position for the cursor after adding the bbcode - const caret_pos = getCaretPosition(textarea).start; - const new_pos = caret_pos + bbopen.length; + var caret_pos = getCaretPosition(textarea).start; + var new_pos = caret_pos + bbopen.length; // Open tag insert_text(bbopen + bbclose); @@ -101,7 +105,7 @@ function bbfontstyle(bbopen, bbclose) { textarea.selectionEnd = new_pos; } else if (document.selection) { // IE - const range = textarea.createTextRange(); + var range = textarea.createTextRange(); range.move('character', new_pos); range.select(); storeCaret(textarea); @@ -114,7 +118,7 @@ function bbfontstyle(bbopen, bbclose) { * Insert text at position */ function insert_text(text, spaces, popup) { - let textarea; + var textarea; if (popup) { textarea = opener.document.forms[form_name].elements[text_name]; @@ -129,8 +133,8 @@ function insert_text(text, spaces, popup) { // Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way. // Therefore we simply add a !is_ie here until IE fixes the text-selection completely. if (!isNaN(textarea.selectionStart) && !is_ie) { - const sel_start = textarea.selectionStart; - const sel_end = textarea.selectionEnd; + var sel_start = textarea.selectionStart; + var sel_end = textarea.selectionEnd; mozWrap(textarea, text, ''); textarea.selectionStart = sel_start + text.length; @@ -141,7 +145,7 @@ function insert_text(text, spaces, popup) { storeCaret(textarea); } - const caret_pos = textarea.caretPos; + var caret_pos = textarea.caretPos; caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text; } else { textarea.value += text; @@ -164,10 +168,10 @@ function attachInline(index, filename) { * Add quote text to message */ function addquote(post_id, username, l_wrote, attributes) { - const message_name = 'message_' + post_id; - let theSelection = ''; - let divarea = false; - let i; + var message_name = 'message_' + post_id; + var theSelection = ''; + var divarea = false; + var i; if (l_wrote === undefined) { // Backwards compatibility @@ -217,7 +221,7 @@ function addquote(post_id, username, l_wrote, attributes) { insert_text(generateQuote(theSelection, attributes)); } else { insert_text(username + ' ' + l_wrote + ':\n'); - const lines = split_lines(theSelection); + var lines = split_lines(theSelection); for (i = 0; i < lines.length; i++) { insert_text('> ' + lines[i] + '\n'); } @@ -240,22 +244,22 @@ function addquote(post_id, username, l_wrote, attributes) { */ function generateQuote(text, attributes) { text = text.replace(/^\s+/, '').replace(/\s+$/, ''); - let quote = '[quote'; + var quote = '[quote'; if (attributes.author) { // Add the author as the BBCode's default attribute quote += '=' + formatAttributeValue(attributes.author); delete attributes.author; } - for (const name in attributes) { + for (var name in attributes) { if (Object.hasOwn(attributes, name)) { - const value = attributes[name]; + var value = attributes[name]; quote += ' ' + name + '=' + formatAttributeValue(value.toString()); } } quote += ']'; - const newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : ''; + var newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : ''; quote += newline + text + newline + '[/quote]'; return quote; @@ -277,25 +281,25 @@ function formatAttributeValue(str) { return str; } - const singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\''; - const doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"'; + var singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\''; + var doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"'; return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted; } function split_lines(text) { - const lines = text.split('\n'); - const splitLines = []; - let j = 0; - let i; + var lines = text.split('\n'); + var splitLines = []; + var j = 0; + var i; for (i = 0; i < lines.length; i++) { if (lines[i].length <= 80) { splitLines[j] = lines[i]; j++; } else { - let line = lines[i]; - let splitAt; + var line = lines[i]; + var splitAt; do { splitAt = line.indexOf(' ', 80); @@ -319,14 +323,14 @@ function split_lines(text) { * From http://www.massless.org/mozedit/ */ function mozWrap(txtarea, open, close) { - const selLength = (typeof (txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength; - const selStart = txtarea.selectionStart; - const selEnd = txtarea.selectionEnd; - const { scrollTop } = txtarea; + var selLength = (typeof (txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength; + var selStart = txtarea.selectionStart; + var selEnd = txtarea.selectionEnd; + var scrollTop = txtarea.scrollTop; - const s1 = (txtarea.value).substring(0, selStart); - const s2 = (txtarea.value).substring(selStart, selEnd); - const s3 = (txtarea.value).substring(selEnd, selLength); + var s1 = (txtarea.value).substring(0, selStart); + var s2 = (txtarea.value).substring(selStart, selEnd); + var s3 = (txtarea.value).substring(selEnd, selLength); txtarea.value = s1 + open + s2 + close + s3; txtarea.selectionStart = selStart + open.length; @@ -349,15 +353,15 @@ function storeCaret(textEl) { * Caret Position object */ function caretPosition() { - const start = null; - const end = null; + var start = null; + var end = null; } /** * Get the caret position in an textarea */ function getCaretPosition(txtarea) { - const caretPos = new caretPosition(); + var caretPos = new caretPosition(); // simple Gecko/Opera way if (txtarea.selectionStart || txtarea.selectionStart === 0) { @@ -366,14 +370,14 @@ function getCaretPosition(txtarea) { } else if (document.selection) { // dirty and slow IE way // get current selection - const range = document.selection.createRange(); + var range = document.selection.createRange(); // a new selection of the whole textarea - const range_all = document.body.createTextRange(); + var range_all = document.body.createTextRange(); range_all.moveToElementText(txtarea); // calculate selection start point by moving beginning of range_all to beginning of range - let sel_start; + var sel_start; for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) { range_all.moveStart('character', 1); } diff --git a/phpBB/assets/javascript/installer.js b/phpBB/assets/javascript/installer.js index cf7820b26d..2d8ce0b18b 100644 --- a/phpBB/assets/javascript/installer.js +++ b/phpBB/assets/javascript/installer.js @@ -3,21 +3,23 @@ */ /* eslint no-prototype-builtins: 0 */ +/* eslint no-var: 0 */ + (function($) { // Avoid conflicts with other libraries 'use strict'; // Installer variables - let pollTimer = null; - let nextReadPosition = 0; - let progressBarTriggered = false; - let progressTimer = null; - let currentProgress = 0; - let refreshRequested = false; - let transmissionOver = false; - let statusCount = 0; + var pollTimer = null; + var nextReadPosition = 0; + var progressBarTriggered = false; + var progressTimer = null; + var currentProgress = 0; + var refreshRequested = false; + var transmissionOver = false; + var statusCount = 0; // Template related variables - const $contentWrapper = $('.install-body').find('.main'); + var $contentWrapper = $('.install-body').find('.main'); // Intercept form submits interceptFormSubmit($('#install_install')); @@ -43,15 +45,15 @@ */ function addMessage(type, messages) { // Get message containers - const $errorContainer = $('#error-container'); - const $warningContainer = $('#warning-container'); - const $logContainer = $('#log-container'); + var $errorContainer = $('#error-container'); + var $warningContainer = $('#warning-container'); + var $logContainer = $('#log-container'); - let $title; - let $description; - let $msgElement; - const arraySize = messages.length; - for (let i = 0; i < arraySize; i++) { + var $title; + var $description; + var $msgElement; + var arraySize = messages.length; + for (var i = 0; i < arraySize; i++) { $msgElement = $('
'); $title = $(''); $title.text(messages[i].title); @@ -84,13 +86,13 @@ * Render a download box */ function addDownloadBox(downloadArray) { - const $downloadContainer = $('#download-wrapper'); - let $downloadBox; - let $title; - let $content; - let $link; + var $downloadContainer = $('#download-wrapper'); + var $downloadBox; + var $title; + var $content; + var $link; - for (let i = 0; i < downloadArray.length; i++) { + for (var i = 0; i < downloadArray.length; i++) { $downloadBox = $('
'); $downloadBox.addClass('download-box'); @@ -118,7 +120,7 @@ * Render update files' status */ function addUpdateFileStatus(fileStatus) { - const $statusContainer = $('#file-status-wrapper'); + var $statusContainer = $('#file-status-wrapper'); $statusContainer.html(fileStatus); } @@ -128,9 +130,9 @@ * @param formHtml */ function addForm(formHtml) { - const $formContainer = $('#form-wrapper'); + var $formContainer = $('#form-wrapper'); $formContainer.html(formHtml); - const $form = $('#install_install'); + var $form = $('#install_install'); interceptFormSubmit($form); } @@ -140,16 +142,16 @@ * @param navObj */ function updateNavbarStatus(navObj) { - let navID; - let $stage; - let $stageListItem; - const $active = $('#activemenu'); + var navID; + var $stage; + var $stageListItem; + var $active = $('#activemenu'); if (navObj.hasOwnProperty('finished')) { // This should be an Array - const navItems = navObj.finished; + var navItems = navObj.finished; - for (let i = 0; i < navItems.length; i++) { + for (var i = 0; i < navItems.length; i++) { navID = 'installer-stage-' + navItems[i]; $stage = $('#' + navID); $stageListItem = $stage.parent(); @@ -181,16 +183,16 @@ * @param progressObject */ function setProgress(progressObject) { - let $statusText; - let $progressBar; - let $progressText; - let $progressFiller; - let $progressFillerText; + var $statusText; + var $progressBar; + var $progressText; + var $progressFiller; + var $progressFillerText; if (progressObject.task_name.length) { if (!progressBarTriggered) { // Create progress bar - const $progressBarWrapper = $('#progress-bar-container'); + var $progressBarWrapper = $('#progress-bar-container'); // Create progress bar elements $progressBar = $('
'); @@ -240,9 +242,9 @@ // Set cookies function setCookies(cookies) { - let cookie; + var cookie; - for (let i = 0; i < cookies.length; i++) { + for (var i = 0; i < cookies.length; i++) { // Set cookie name and value cookie = encodeURIComponent(cookies[i].name) + '=' + encodeURIComponent(cookies[i].value); // Set path @@ -256,7 +258,7 @@ if (useAjax) { resetPolling(); - const xhReq = createXhrObject(); + var xhReq = createXhrObject(); xhReq.open('GET', url, true); xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhReq.send(); @@ -274,7 +276,7 @@ */ function parseMessage(messageJSON) { $('#loading_indicator').css('display', 'none'); - let responseObject; + var responseObject; try { responseObject = JSON.parse(messageJSON); @@ -365,14 +367,14 @@ setTimeout(queryInstallerStatus, 5000); } else { $('#loading_indicator').css('display', 'none'); - addMessage('error', - [ { + addMessage('error', [ + { // eslint-disable-next-line no-undef title: installLang.title, // eslint-disable-next-line no-undef description: installLang.msg, - } ], - ); + }, + ]); } } @@ -380,9 +382,9 @@ * Queries the installer's status */ function queryInstallerStatus() { - let url = $(location).attr('pathname'); - let lookUp = 'install/app.php'; - let position = url.indexOf(lookUp); + var url = $(location).attr('pathname'); + var lookUp = 'install/app.php'; + var position = url.indexOf(lookUp); if (position === -1) { lookUp = 'install'; @@ -405,12 +407,12 @@ * @param xhReq XHR object */ function pollContent(xhReq) { - const messages = xhReq.responseText; - const msgSeparator = '}\n\n'; - let unprocessed; - let messageEndIndex; - let endOfMessageIndex; - let message; + var messages = xhReq.responseText; + var msgSeparator = '}\n\n'; + var unprocessed; + var messageEndIndex; + var endOfMessageIndex; + var message; do { unprocessed = messages.substring(nextReadPosition); @@ -428,7 +430,7 @@ $('#loading_indicator').css('display', 'none'); resetPolling(); - const timeoutDetected = !transmissionOver; + var timeoutDetected = !transmissionOver; if (refreshRequested) { refreshRequested = false; @@ -456,7 +458,7 @@ return; } - const $progressBar = $('#progress-bar'); + var $progressBar = $('#progress-bar'); currentProgress++; $progressFillerText.css('width', $progressBar.width()); @@ -471,10 +473,10 @@ * @param progressLimit */ function incrementProgressBar(progressLimit) { - const $progressFiller = $('#progress-bar-filler'); - const $progressFillerText = $('#progress-bar-filler-text'); - const $progressText = $('#progress-bar-text'); - const progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100; + var $progressFiller = $('#progress-bar-filler'); + var $progressFillerText = $('#progress-bar-filler-text'); + var $progressText = $('#progress-bar-text'); + var progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100; currentProgress = Math.floor(progressStart); clearInterval(progressTimer); @@ -510,7 +512,7 @@ function doRefresh() { resetPolling(); - const xhReq = createXhrObject(); + var xhReq = createXhrObject(); xhReq.open('GET', $(location).attr('pathname'), true); xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhReq.send(); @@ -527,47 +529,47 @@ // Clear content $contentWrapper.html(''); - const $header = $('
'); + var $header = $('
'); $header.attr('id', 'header-container'); $contentWrapper.append($header); - const $description = $('
'); + var $description = $('
'); $description.attr('id', 'description-container'); $contentWrapper.append($description); - const $errorContainer = $('
'); + var $errorContainer = $('
'); $errorContainer.attr('id', 'error-container'); $contentWrapper.append($errorContainer); - const $warningContainer = $('
'); + var $warningContainer = $('
'); $warningContainer.attr('id', 'warning-container'); $contentWrapper.append($warningContainer); - const $progressContainer = $('
'); + var $progressContainer = $('
'); $progressContainer.attr('id', 'progress-bar-container'); $contentWrapper.append($progressContainer); - const $logContainer = $('
'); + var $logContainer = $('
'); $logContainer.attr('id', 'log-container'); $contentWrapper.append($logContainer); - const $installerContentWrapper = $('
'); + var $installerContentWrapper = $('
'); $installerContentWrapper.attr('id', 'content-container'); $contentWrapper.append($installerContentWrapper); - const $installerDownloadWrapper = $('
'); + var $installerDownloadWrapper = $('
'); $installerDownloadWrapper.attr('id', 'download-wrapper'); $installerContentWrapper.append($installerDownloadWrapper); - const $updaterFileStatusWrapper = $('
'); + var $updaterFileStatusWrapper = $('
'); $updaterFileStatusWrapper.attr('id', 'file-status-wrapper'); $installerContentWrapper.append($updaterFileStatusWrapper); - const $formWrapper = $('
'); + var $formWrapper = $('
'); $formWrapper.attr('id', 'form-wrapper'); $installerContentWrapper.append($formWrapper); - const $spinner = $('
'); + var $spinner = $('
'); $spinner.attr('id', 'loading_indicator'); $spinner.html(' '); $contentWrapper.append($spinner); @@ -577,7 +579,7 @@ function submitForm($form, $submitBtn) { $form.css('display', 'none'); - const xhReq = createXhrObject(); + var xhReq = createXhrObject(); xhReq.open('POST', $form.attr('action'), true); xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhReq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); @@ -602,7 +604,7 @@ * @returns {*} */ function getFormFields($form, $submitBtn) { - let formData = $form.serialize(); + var formData = $form.serialize(); formData += ((formData.length) ? '&' : '') + encodeURIComponent($submitBtn.attr('name')) + '='; formData += encodeURIComponent($submitBtn.attr('value')); diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index f2f0fb5497..fd8db4de2f 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -1,5 +1,6 @@ /* global phpbb, plupload, attachInline, activateSubPanel */ /* eslint camelcase: 0 */ +/* eslint no-var: 0 */ plupload.addI18n(phpbb.plupload.i18n); phpbb.plupload.ids = []; @@ -53,8 +54,8 @@ phpbb.plupload.ids = []; * begin with 'attachment_data[' */ phpbb.plupload.clearParams = function() { - const obj = phpbb.plupload.uploader.settings.multipart_params; - for (const key in obj) { + var obj = phpbb.plupload.uploader.settings.multipart_params; + for (var key in obj) { if (!Object.prototype.hasOwnProperty.call(obj, key) || key.indexOf('attachment_data[') !== 0) { continue; } @@ -69,7 +70,7 @@ phpbb.plupload.ids = []; * @param {object} obj */ phpbb.plupload.updateMultipartParams = function(obj) { - const { settings } = phpbb.plupload.uploader; + var { settings } = phpbb.plupload.uploader; settings.multipart_params = $.extend(settings.multipart_params, obj); }; @@ -80,10 +81,10 @@ phpbb.plupload.ids = []; * expected by the server */ phpbb.plupload.getSerializedData = function() { - const obj = {}; - for (let i = 0; i < phpbb.plupload.data.length; i++) { - const datum = phpbb.plupload.data[i]; - for (const key in datum) { + var obj = {}; + for (var i = 0; i < phpbb.plupload.data.length; i++) { + var datum = phpbb.plupload.data[i]; + for (var key in datum) { if (!Object.prototype.hasOwnProperty.call(datum, key)) { continue; } @@ -93,7 +94,7 @@ phpbb.plupload.ids = []; } // Insert form data - const $pluploadForm = $(phpbb.plupload.config.form_hook).first(); + var $pluploadForm = $(phpbb.plupload.config.form_hook).first(); obj.creation_time = $pluploadForm.find('input[type=hidden][name="creation_time"]').val(); obj.form_token = $pluploadForm.find('input[type=hidden][name="form_token"]').val(); @@ -108,7 +109,7 @@ phpbb.plupload.ids = []; * @returns {bool|int} Index of the file if exists, otherwise false. */ phpbb.plupload.getIndex = function(attachId) { - const index = $.inArray(Number(attachId), phpbb.plupload.ids); + var index = $.inArray(Number(attachId), phpbb.plupload.ids); return index === -1 ? false : index; }; @@ -124,7 +125,7 @@ phpbb.plupload.ids = []; phpbb.plupload.data = []; phpbb.plupload.data = data; - for (let i = 0; i < data.length; i++) { + for (var i = 0; i < data.length; i++) { phpbb.plupload.ids.push(Number(data[i].attach_id)); } }; @@ -151,7 +152,7 @@ phpbb.plupload.ids = []; * @param {Array} downloadUrl Optional array of download urls to update. */ phpbb.plupload.updateRows = function(downloadUrl) { - for (let i = 0; i < phpbb.plupload.ids.length; i++) { + for (var i = 0; i < phpbb.plupload.ids.length; i++) { phpbb.plupload.updateRow(i, downloadUrl); } }; @@ -165,7 +166,7 @@ phpbb.plupload.ids = []; * @param {object} file Plupload file object for the new attachment. */ phpbb.plupload.insertRow = function(file) { - const row = $(phpbb.plupload.rowTpl); + var row = $(phpbb.plupload.rowTpl); row.attr('id', file.id); row.find('.file-name').html(plupload.xmlEncode(file.name)); @@ -185,13 +186,13 @@ phpbb.plupload.ids = []; * @param {Array} downloadUrl Optional array of download urls to update. */ phpbb.plupload.updateRow = function(index, downloadUrl) { - const attach = phpbb.plupload.data[index]; - const row = $('[data-attach-id="' + attach.attach_id + '"]'); + var attach = phpbb.plupload.data[index]; + var row = $('[data-attach-id="' + attach.attach_id + '"]'); // Add the link to the file if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') { - const url = downloadUrl[index].replace('&', '&'); - const link = $(''); + var url = downloadUrl[index].replace('&', '&'); + var link = $(''); link.attr('href', url).html(attach.real_filename); row.find('.file-name').html(link); @@ -211,12 +212,12 @@ phpbb.plupload.ids = []; phpbb.plupload.updateHiddenData = function(row, attach, index) { row.find('input[type="hidden"]').remove(); - for (const key in attach) { + for (var key in attach) { if (!Object.prototype.hasOwnProperty.call(attach, key)) { continue; } - const input = $('') + var input = $('') .attr('type', 'hidden') .attr('name', 'attachment_data[' + index + '][' + key + ']') .attr('value', attach[key]); @@ -236,7 +237,7 @@ phpbb.plupload.ids = []; phpbb.plupload.deleteFile = function(row, attachId) { // If there's no attach id, then the file hasn't been uploaded. Simply delete the row. if (typeof attachId === 'undefined') { - const file = phpbb.plupload.uploader.getFile(row.attr('id')); + var file = phpbb.plupload.uploader.getFile(row.attr('id')); phpbb.plupload.uploader.removeFile(file); row.slideUp(100, () => { @@ -245,21 +246,21 @@ phpbb.plupload.ids = []; }); } - const index = phpbb.plupload.getIndex(attachId); + var index = phpbb.plupload.getIndex(attachId); row.find('.file-status').toggleClass('file-uploaded file-working'); if (index === false) { return; } - const fields = {}; + var fields = {}; fields['delete_file[' + index + ']'] = 1; - const always = function() { + var always = function() { row.find('.file-status').removeClass('file-working'); }; - const done = function(response) { + var done = function(response) { if (typeof response !== 'object') { return; } @@ -288,7 +289,7 @@ phpbb.plupload.ids = []; phpbb.plupload.handleMaxFilesReached(); if (row.attr('id')) { - const file = phpbb.plupload.uploader.getFile(row.attr('id')); + var file = phpbb.plupload.uploader.getFile(row.attr('id')); phpbb.plupload.uploader.removeFile(file); } @@ -329,8 +330,8 @@ phpbb.plupload.ids = []; */ phpbb.plupload.updateBbcode = function(action, index) { const textarea = $('#message', phpbb.plupload.form); - let text = textarea.val(); - const removal = (action === 'removal'); + var text = textarea.val(); + var removal = (action === 'removal'); // Return if the bbcode isn't used at all. if (text.indexOf('[attachment=') === -1) { @@ -338,21 +339,21 @@ phpbb.plupload.ids = []; } function runUpdate(i) { - const regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g'); + var regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g'); text = text.replace(regex, (_, fileName) => { // Remove the bbcode if the file was removed. if (removal && index === i) { return ''; } - const newIndex = i + ((removal) ? -1 : 1); + var newIndex = i + ((removal) ? -1 : 1); return '[attachment=' + newIndex + ']' + fileName + '[/attachment]'; }); } // Loop forwards when removing and backwards when adding ensures we don't // corrupt the bbcode index. - let i; + var i; if (removal) { for (i = index; i < phpbb.plupload.ids.length; i++) { runUpdate(i); @@ -375,7 +376,7 @@ phpbb.plupload.ids = []; * @returns {Array} The Plupload file objects matching the status. */ phpbb.plupload.getFilesByStatus = function(status) { - const files = []; + var files = []; $.each(phpbb.plupload.uploader.files, (i, file) => { if (file.status === status) { @@ -438,7 +439,7 @@ phpbb.plupload.ids = []; * @param {string} error Error message to present to the user. */ phpbb.plupload.markQueuedFailed = function(error) { - const files = phpbb.plupload.getFilesByStatus(plupload.QUEUED); + var files = phpbb.plupload.getFilesByStatus(plupload.QUEUED); $.each(files, (i, file) => { $('#' + file.id).find('.file-progress').hide(); @@ -511,14 +512,14 @@ phpbb.plupload.ids = []; } }); - const $fileList = $('#file-list'); + var $fileList = $('#file-list'); /** * Insert inline attachment bbcode. */ $fileList.on('click', '.file-inline-bbcode', function(e) { - const attachId = $(this).parents('.attach-row').attr('data-attach-id'); - const index = phpbb.plupload.getIndex(attachId); + var attachId = $(this).parents('.attach-row').attr('data-attach-id'); + var index = phpbb.plupload.getIndex(attachId); attachInline(index, phpbb.plupload.data[index].real_filename); e.preventDefault(); @@ -528,8 +529,8 @@ phpbb.plupload.ids = []; * Delete a file. */ $fileList.on('click', '.file-delete', function(e) { - const row = $(this).parents('.attach-row'); - const attachId = row.attr('data-attach-id'); + var row = $(this).parents('.attach-row'); + var attachId = row.attr('data-attach-id'); phpbb.plupload.deleteFile(row, attachId); e.preventDefault(); @@ -590,7 +591,7 @@ phpbb.plupload.ids = []; return; } - let json = {}; + var json = {}; try { json = $.parseJSON(response.response); } catch { @@ -637,7 +638,7 @@ phpbb.plupload.ids = []; } // Show the file list if there aren't any files currently. - const $fileListContainer = $('#file-list-container'); + var $fileListContainer = $('#file-list-container'); if (!$fileListContainer.is(':visible')) { $fileListContainer.show(100); } @@ -670,9 +671,9 @@ phpbb.plupload.ids = []; * @param {string} response The response string from the server */ phpbb.plupload.uploader.bind('FileUploaded', (up, file, response) => { - let json = {}; - const row = $('#' + file.id); - let error; + var json = {}; + var row = $('#' + file.id); + var error; // Hide the progress indicator. row.find('.file-progress').hide(); diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index c5a0778c8e..24384a117b 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -1,21 +1,22 @@ /* global phpbb */ /* eslint camelcase: 0 */ +/* eslint no-var: 0 */ (function($) { // Avoid conflicts with other libraries 'use strict'; // This callback will mark all forum icons read phpbb.addAjaxCallback('mark_forums_read', function(res) { - const readTitle = res.NO_UNREAD_POSTS; - const unreadTitle = res.UNREAD_POSTS; - const iconsArray = { + var readTitle = res.NO_UNREAD_POSTS; + var unreadTitle = res.UNREAD_POSTS; + var iconsArray = { forum_unread: 'forum_read', forum_unread_subforum: 'forum_read_subforum', forum_unread_locked: 'forum_read_locked', }; $('li.row').find('dl[class*="forum_unread"]').each(function() { - const $this = $(this); + var $this = $(this); $.each(iconsArray, (unreadClass, readClass) => { if ($this.hasClass(unreadClass)) { @@ -46,17 +47,17 @@ * should be updated. Defaults to true. */ phpbb.addAjaxCallback('mark_topics_read', (res, updateTopicLinks) => { - const readTitle = res.NO_UNREAD_POSTS; - const unreadTitle = res.UNREAD_POSTS; - const iconsArray = { + var readTitle = res.NO_UNREAD_POSTS; + var unreadTitle = res.UNREAD_POSTS; + var iconsArray = { global_unread: 'global_read', announce_unread: 'announce_read', sticky_unread: 'sticky_read', topic_unread: 'topic_read', }; - const iconsState = [ '', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine' ]; - const classMap = {}; - const classNames = []; + var iconsState = [ '', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine' ]; + var classMap = {}; + var classNames = []; if (typeof updateTopicLinks === 'undefined') { updateTopicLinks = true; @@ -74,10 +75,10 @@ }); }); - const unreadClassSelectors = '.' + classNames.join(',.'); + var unreadClassSelectors = '.' + classNames.join(',.'); $('li.row').find(unreadClassSelectors).each(function() { - const $this = $(this); + var $this = $(this); $.each(classMap, (unreadClass, readClass) => { if ($this.hasClass(unreadClass)) { $this.removeClass(unreadClass).addClass(readClass); @@ -109,7 +110,7 @@ // This callback will mark a notification read phpbb.addAjaxCallback('notification.mark_read', function(res) { if (typeof res.success !== 'undefined') { - const unreadCount = Number($('#notification-button strong').html()) - 1; + var unreadCount = Number($('#notification-button strong').html()) - 1; phpbb.markNotifications($(this).parent('[data-notification-unread="true"]'), unreadCount); } }); @@ -127,7 +128,7 @@ // Update the notification link to the real URL. $popup.each(function() { - const link = $(this).find('a'); + var link = $(this).find('a'); link.attr('href', link.attr('data-real-url')); }); @@ -140,21 +141,21 @@ } // Update page title - const $title = $('title'); - const originalTitle = $title.text().replace(/(\((\d+)\))/, ''); + var $title = $('title'); + var originalTitle = $title.text().replace(/(\((\d+)\))/, ''); $title.text((unreadCount ? '(' + unreadCount + ')' : '') + originalTitle); }; // This callback finds the post from the delete link, and removes it. phpbb.addAjaxCallback('post_delete', function() { - const $this = $(this); - let postId; + var $this = $(this); + var postId; if ($this.attr('data-refresh') === undefined) { postId = $this[0].href.split('&p=')[1]; - const post = $this.parents('#p' + postId).css('pointer-events', 'none'); + var post = $this.parents('#p' + postId).css('pointer-events', 'none'); if (post.hasClass('bg1') || post.hasClass('bg2')) { - const posts1 = post.nextAll('.bg1'); + var posts1 = post.nextAll('.bg1'); post.nextAll('.bg2').removeClass('bg2').addClass('bg1'); posts1.removeClass('bg1').addClass('bg2'); } @@ -167,7 +168,7 @@ // This callback removes the approve / disapprove div or link. phpbb.addAjaxCallback('post_visibility', function(res) { - const remove = (res.visible) ? $(this) : $(this).parents('.post'); + var remove = (res.visible) ? $(this) : $(this).parents('.post'); $(remove).css('pointer-events', 'none').fadeOut(function() { $(this).remove(); }); @@ -187,7 +188,7 @@ // This handles friend / foe additions removals. phpbb.addAjaxCallback('zebra', res => { - let zebra; + var zebra; if (res.success) { zebra = $('.zebra'); @@ -201,13 +202,13 @@ */ phpbb.addAjaxCallback('vote_poll', function(res) { if (typeof res.success !== 'undefined') { - const poll = $(this).closest('.topic_poll'); - const panel = poll.find('.panel'); - const resultsVisible = poll.find('dl:first-child .resultbar').is(':visible'); - let mostVotes = 0; + var poll = $(this).closest('.topic_poll'); + var panel = poll.find('.panel'); + var resultsVisible = poll.find('dl:first-child .resultbar').is(':visible'); + var mostVotes = 0; // Set min-height to prevent the page from jumping when the content changes - const updatePanelHeight = function(height) { + var updatePanelHeight = function(height) { height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height; panel.css('min-height', height); }; @@ -230,8 +231,8 @@ // Get the votes count of the highest poll option poll.find('[data-poll-option-id]').each(function() { - const option = $(this); - const optionId = option.attr('data-poll-option-id'); + var option = $(this); + var optionId = option.attr('data-poll-option-id'); mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes; }); @@ -240,14 +241,14 @@ // Update each option poll.find('[data-poll-option-id]').each(function() { - const $this = $(this); - const optionId = $this.attr('data-poll-option-id'); - const voted = (typeof res.user_votes[optionId] !== 'undefined'); - const mostVoted = (res.vote_counts[optionId] === mostVotes); - const percent = res.total_votes ? Math.round((res.vote_counts[optionId] / res.total_votes) * 100) : 0; - const percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100); + var $this = $(this); + var optionId = $this.attr('data-poll-option-id'); + var voted = (typeof res.user_votes[optionId] !== 'undefined'); + var mostVoted = (res.vote_counts[optionId] === mostVotes); + var percent = res.total_votes ? Math.round((res.vote_counts[optionId] / res.total_votes) * 100) : 0; + var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100); - const altText = $this.attr('data-alt-text'); + var altText = $this.attr('data-alt-text'); if (voted) { $this.attr('title', $.trim(altText)); } else { @@ -258,9 +259,9 @@ $this.toggleClass('most-votes', mostVoted); // Update the bars - const bar = $this.find('.resultbar div'); - const barTimeLapse = (res.can_vote) ? 500 : 1500; - const newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); + var bar = $this.find('.resultbar div'); + var barTimeLapse = (res.can_vote) ? 500 : 1500; + var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); setTimeout(() => { bar.animate({ width: percentRel + '%' }, 500) @@ -268,7 +269,7 @@ .addClass(newBarClass) .html(res.vote_counts[optionId]); - const percentText = percent ? percent + '%' : res.NO_VOTES; + var percentText = percent ? percent + '%' : res.NO_VOTES; $this.find('.poll_option_percent').html(percentText); }, barTimeLapse); }); @@ -278,7 +279,7 @@ } // Display "Your vote has been cast." message. Disappears after 5 seconds. - const confirmationDelay = (res.can_vote) ? 300 : 900; + var confirmationDelay = (res.can_vote) ? 300 : 900; poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() { if (resultsVisible) { updatePanelHeight(); @@ -294,9 +295,9 @@ resizePanel(500); }, 1500); - const resizePanel = function(time) { - const panelHeight = panel.height(); - const innerHeight = panel.find('.inner').outerHeight(); + var resizePanel = function(time) { + var panelHeight = panel.height(); + var innerHeight = panel.find('.inner').outerHeight(); if (panelHeight !== innerHeight) { panel.css({ minHeight: '', height: panelHeight }) @@ -315,19 +316,19 @@ // Do not follow the link e.preventDefault(); - const $poll = $(this).parents('.topic_poll'); + var $poll = $(this).parents('.topic_poll'); $poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500); $poll.find('.poll_view_results').hide(500); }); $('[data-ajax]').each(function() { - const $this = $(this); - const ajax = $this.attr('data-ajax'); - let filter = $this.attr('data-filter'); + var $this = $(this); + var ajax = $this.attr('data-ajax'); + var filter = $this.attr('data-filter'); if (ajax !== 'false') { - const fn = ajax === 'true' ? null : ajax; + var fn = ajax === 'true' ? null : ajax; filter = filter === undefined ? null : phpbb.getFunctionByName(filter); phpbb.ajaxify({ @@ -354,7 +355,7 @@ // Do not follow the link e.preventDefault(); - const postId = $(this).attr('data-post-id'); + var postId = $(this).attr('data-post-id'); $('#post_content' + postId).show(); $('#profile' + postId).show(); $('#post_hidden' + postId).hide(); @@ -379,7 +380,7 @@ * appropriately changed based on the status of the search panel. */ $('#member_search').click(function() { - const $memberlistSearch = $('#memberlist_search'); + var $memberlistSearch = $('#memberlist_search'); $memberlistSearch.slideToggle('fast'); phpbb.ajaxCallbacks.alt_text.call(this); @@ -418,7 +419,7 @@ * Automatically resize textarea */ $(() => { - const $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)'); + var $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)'); phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 }); phpbb.resizeTextArea($('textarea', '#message-box')); }); diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index ff8acb5f00..ec99e909ef 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -1,6 +1,7 @@ /* global phpbb */ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ +/* eslint no-var:0 */ /** * phpBB3 forum functions @@ -36,10 +37,10 @@ function popup(url, width, height, name) { function pageJump(item) { 'use strict'; - const page = parseInt(item.val(), 10); - const perPage = item.attr('data-per-page'); - const baseUrl = item.attr('data-base-url'); - const startName = item.attr('data-start-name'); + var page = parseInt(item.val(), 10); + var perPage = item.attr('data-per-page'); + var baseUrl = item.attr('data-base-url'); + var startName = item.attr('data-start-name'); if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) { if (baseUrl.indexOf('?') === -1) { @@ -58,7 +59,7 @@ function marklist(id, name, state) { 'use strict'; jQuery('#' + id + ' input[type=checkbox][name]').each(function() { - const $this = jQuery(this); + var $this = jQuery(this); if ($this.attr('name').substr(0, name.length) === name && !$this.prop('disabled')) { $this.prop('checked', state); } @@ -103,11 +104,11 @@ jQuery($ => { 'use strict'; $('.sub-panels').each(function() { - const $childNodes = $('a[data-subpanel]', this); - const panels = $childNodes.map(function() { + var $childNodes = $('a[data-subpanel]', this); + var panels = $childNodes.map(function() { return this.getAttribute('data-subpanel'); }); - const showPanel = this.getAttribute('data-show-panel'); + var showPanel = this.getAttribute('data-show-panel'); if (panels.length) { activateSubPanel(showPanel, panels); @@ -125,8 +126,8 @@ jQuery($ => { function activateSubPanel(p, panels) { 'use strict'; - let i; - let showPanel; + var i; + var showPanel; if (typeof p === 'string') { showPanel = p; @@ -150,16 +151,16 @@ function selectCode(a) { 'use strict'; // Get ID of code block - const e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; - let s; - let r; + var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; + var s; + var r; // Not IE and IE9+ if (window.getSelection) { s = window.getSelection(); // Safari and Chrome if (s.setBaseAndExtent) { - const l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1; + var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1; try { s.setBaseAndExtent(e, 0, e, l); } catch (error) { @@ -195,8 +196,8 @@ function selectCode(a) { } } -let inAutocomplete = false; -let lastKeyEntered = ''; +var inAutocomplete = false; +var lastKeyEntered = ''; /** * Check event key @@ -234,7 +235,7 @@ jQuery($ => { 'use strict'; $('form input[type=text], form input[type=password]').on('keypress', function(e) { - const defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action'); + var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action'); if (!defaultButton || defaultButton.length <= 0) { return true; @@ -259,10 +260,10 @@ jQuery($ => { function insertUser(formId, value) { 'use strict'; - const $form = jQuery(formId); - const formName = $form.attr('data-form-name'); - const fieldName = $form.attr('data-field-name'); - const item = opener.document.forms[formName][fieldName]; + var $form = jQuery(formId); + var formName = $form.attr('data-form-name'); + var fieldName = $form.attr('data-field-name'); + var item = opener.document.forms[formName][fieldName]; if (item.value.length && item.type === 'textarea') { value = item.value + '\n' + value; @@ -294,9 +295,9 @@ function insert_single_user(formId, user) { function parseDocument($container) { 'use strict'; - const test = document.createElement('div'); - const oldBrowser = (typeof test.style.borderRadius === 'undefined'); - const $body = $('body'); + var test = document.createElement('div'); + var oldBrowser = (typeof test.style.borderRadius === 'undefined'); + var $body = $('body'); /** * Reset avatar dimensions when changing URL or EMAIL @@ -309,7 +310,7 @@ function parseDocument($container) { * Pagination */ $container.find('.pagination .page-jump-form :button').click(function() { - const $input = $(this).siblings('input.inputbox'); + var $input = $(this).siblings('input.inputbox'); pageJump($input); }); @@ -321,7 +322,7 @@ function parseDocument($container) { }); $container.find('.pagination .dropdown-trigger').click(function() { - const $dropdownContainer = $(this).parent(); + var $dropdownContainer = $(this).parent(); // Wait a little bit to make sure the dropdown has activated setTimeout(() => { if ($dropdownContainer.hasClass('dropdown-visible')) { @@ -334,27 +335,27 @@ function parseDocument($container) { * Resize navigation (breadcrumbs) block to keep all links on same line */ $container.find('.navlinks').each(function() { - const $this = $(this); - const $left = $this.children().not('.rightside'); - const $right = $this.children('.rightside'); + var $this = $(this); + var $left = $this.children().not('.rightside'); + var $right = $this.children('.rightside'); if ($left.length !== 1 || !$right.length) { return; } function resize() { - let width = 0; - const diff = $left.outerWidth(true) - $left.width(); - const minWidth = Math.max($this.width() / 3, 240); + var width = 0; + var diff = $left.outerWidth(true) - $left.width(); + var minWidth = Math.max($this.width() / 3, 240); $right.each(function() { - const $this = $(this); + var $this = $(this); if ($this.is(':visible')) { width += $this.outerWidth(true); } }); - const maxWidth = $this.width() - width - diff; + var maxWidth = $this.width() - width - diff; $left.css('max-width', Math.floor(Math.max(maxWidth, minWidth)) + 'px'); } @@ -366,25 +367,25 @@ function parseDocument($container) { * Makes breadcrumbs responsive */ $container.find('.breadcrumbs:not([data-skip-responsive])').each(function() { - const $this = $(this); - const $links = $this.find('.crumb'); - const { length } = $links; - const classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ]; - const classesLength = classes.length; - let maxHeight = 0; - let lastWidth = false; - let wrapped = false; + var $this = $(this); + var $links = $this.find('.crumb'); + var { length } = $links; + var classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ]; + var classesLength = classes.length; + var maxHeight = 0; + var lastWidth = false; + var wrapped = false; // Set tooltips $this.find('a').each(function() { - const $link = $(this); + var $link = $(this); $link.attr('title', $link.text()); }); // Function that checks breadcrumbs function check() { - const height = $this.height(); - let width; + var height = $this.height(); + var width; // Test max-width set in code for .navlinks above width = parseInt($this.css('max-width'), 10); @@ -420,8 +421,8 @@ function parseDocument($container) { return; } - for (let i = 0; i < classesLength; i++) { - for (let j = length - 1; j >= 0; j--) { + for (var i = 0; i < classesLength; i++) { + for (var j = length - 1; j >= 0; j--) { $links.eq(j).addClass('wrapped ' + classes[i]); if ($this.height() <= maxHeight) { return; @@ -455,9 +456,9 @@ function parseDocument($container) { * responsive-show-all to list of classes */ $container.find('.topiclist.responsive-show-all > li > dl').each(function() { - const $this = $(this); - let $block = $this.find('dt .responsive-show:last-child'); - let first = true; + var $this = $(this); + var $block = $this.find('dt .responsive-show:last-child'); + var first = true; // Create block that is visible only on mobile devices if ($block.length) { @@ -469,9 +470,9 @@ function parseDocument($container) { // Copy contents of each column $this.find('dd').not('.mark').each(function() { - const column = $(this); - const $children = column.children(); - let html = column.html(); + var column = $(this); + var $children = column.children(); + var html = column.html(); if ($children.length === 1 && $children.text() === column.text()) { html = $children.html(); @@ -491,9 +492,9 @@ function parseDocument($container) { * responsive-show-columns to list of classes */ $container.find('.topiclist.responsive-show-columns').each(function() { - const $list = $(this); - const headers = []; - let headersLength = 0; + var $list = $(this); + var headers = []; + var headersLength = 0; // Find all headers, get contents $list.prev('.topiclist').find('li.header dd').not('.mark').each(function() { @@ -507,9 +508,9 @@ function parseDocument($container) { // Parse each row $list.find('dl').each(function() { - const $this = $(this); - let $block = $this.find('dt .responsive-show:last-child'); - let first = true; + var $this = $(this); + var $block = $this.find('dt .responsive-show:last-child'); + var first = true; // Create block that is visible only on mobile devices if ($block.length) { @@ -521,9 +522,9 @@ function parseDocument($container) { // Copy contents of each column $this.find('dd').not('.mark').each(function(i) { - const column = $(this); - const children = column.children(); - let html = column.html(); + var column = $(this); + var children = column.children(); + var html = column.html(); if (children.length === 1 && children.text() === column.text()) { html = children.html(); @@ -545,18 +546,18 @@ function parseDocument($container) { * Responsive tables */ $container.find('table.table1').not('.not-responsive').each(function() { - const $this = $(this); - const $th = $this.find('thead > tr > th'); - const headers = []; - let totalHeaders = 0; - let i; + var $this = $(this); + var $th = $this.find('thead > tr > th'); + var headers = []; + var totalHeaders = 0; + var i; // Find each header $th.each(function(column) { - const cell = $(this); - let colspan = parseInt(cell.attr('colspan'), 10); - const dfn = cell.attr('data-dfn'); - const text = dfn ? dfn : cell.text(); + var cell = $(this); + var colspan = parseInt(cell.attr('colspan'), 10); + var dfn = cell.attr('data-dfn'); + var text = dfn ? dfn : cell.text(); colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; @@ -571,7 +572,7 @@ function parseDocument($container) { } }); - const headersLength = headers.length; + var headersLength = headers.length; // Add header text to each cell as $this.addClass('responsive'); @@ -582,9 +583,9 @@ function parseDocument($container) { } $this.find('tbody > tr').each(function() { - const row = $(this); - const cells = row.children('td'); - let column = 0; + var row = $(this); + var cells = row.children('td'); + var column = 0; if (cells.length === 1) { row.addClass('big-column'); @@ -592,9 +593,9 @@ function parseDocument($container) { } cells.each(function() { - const cell = $(this); - let colspan = parseInt(cell.attr('colspan'), 10); - const text = $.trim(cell.text()); + var cell = $(this); + var colspan = parseInt(cell.attr('colspan'), 10); + var text = $.trim(cell.text()); if (headersLength <= column) { return; @@ -618,7 +619,7 @@ function parseDocument($container) { * Hide empty responsive tables */ $container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() { - const $items = $(this).children('tr'); + var $items = $(this).children('tr'); if (!$items.length) { $(this).parent('table:first').addClass('responsive-hide'); } @@ -628,24 +629,24 @@ function parseDocument($container) { * Responsive tabs */ $container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() { - const $this = $(this); - const $ul = $this.children(); - const $tabs = $ul.children().not('[data-skip-responsive]'); - const $links = $tabs.children('a'); - const $item = $ul.append('').find('li.responsive-tab'); - const $menu = $item.find('.dropdown-contents'); - let maxHeight = 0; - let lastWidth = false; - let responsive = false; + var $this = $(this); + var $ul = $this.children(); + var $tabs = $ul.children().not('[data-skip-responsive]'); + var $links = $tabs.children('a'); + var $item = $ul.append('').find('li.responsive-tab'); + var $menu = $item.find('.dropdown-contents'); + var maxHeight = 0; + var lastWidth = false; + var responsive = false; $links.each(function() { - const $this = $(this); + var $this = $(this); maxHeight = Math.max(maxHeight, Math.max($this.outerHeight(true), $this.parent().outerHeight(true))); }); function check() { - const width = $body.width(); - let height = $this.height(); + var width = $body.width(); + var height = $this.height(); if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) { return; @@ -668,10 +669,10 @@ function parseDocument($container) { $item.show(); $menu.html(''); - const $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'); - const total = $availableTabs.length; - let i; - let $tab; + var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'); + var total = $availableTabs.length; + var i; + var $tab; for (i = total - 1; i >= 0; i--) { $tab = $availableTabs.eq(i); @@ -690,7 +691,7 @@ function parseDocument($container) { }); } - const $tabLink = $item.find('a.responsive-tab-link'); + var $tabLink = $item.find('a.responsive-tab-link'); phpbb.registerDropdown($tabLink, $item.find('.dropdown'), { visibleClass: 'activetab', }); @@ -703,7 +704,7 @@ function parseDocument($container) { * Hide UCP/MCP navigation if there is only 1 item */ $container.find('#navigation').each(function() { - const $items = $(this).children('ol, ul').children('li'); + var $items = $(this).children('ol, ul').children('li'); if ($items.length === 1) { $(this).addClass('responsive-hide'); } @@ -713,10 +714,10 @@ function parseDocument($container) { * Replace responsive text */ $container.find('[data-responsive-text]').each(function() { - const $this = $(this); - const fullText = $this.text(); - const responsiveText = $this.attr('data-responsive-text'); - let responsive = false; + var $this = $(this); + var fullText = $this.text(); + var responsiveText = $this.attr('data-responsive-text'); + var responsive = false; function check() { if ($(window).width() > 700) {