diff --git a/js/dashboard.js b/js/dashboard.js index 13c3bf781..bc79c771c 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -22,16 +22,13 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ -$(document).ready(function(){ +$(document).ready(function () { var autoUpgradePanel = $("#autoupgradePhpWarn"); - $(".list-toolbar-btn", autoUpgradePanel).click(function(event) { - + $(".list-toolbar-btn", autoUpgradePanel).click(function (event) { event.preventDefault(); autoUpgradePanel.fadeOut(); - $.post( - $(this).attr("href") - ); + $.post($(this).attr("href")); }); }); diff --git a/js/sentry.js b/js/sentry.js index 6761cccd3..e1e97da3f 100644 --- a/js/sentry.js +++ b/js/sentry.js @@ -24,67 +24,72 @@ */ Sentry.init({ - dsn: "https://eae192966a8d79509154c65c317a7e5d@o298402.ingest.us.sentry.io/4507254110552064", - release: 'v' + input.autoupgrade.version, - beforeSend(event, hint) { - // Only the one we handle via the feedback modal must be sent. - if (!event.tags?.source || event.tags.source !== 'feedbackModal') { - return null; - } - event.request.url = maskSensitiveInfoInUrl(event.request.url, input.adminUrl); + dsn: "https://eae192966a8d79509154c65c317a7e5d@o298402.ingest.us.sentry.io/4507254110552064", + release: "v" + input.autoupgrade.version, + beforeSend(event, hint) { + // Only the one we handle via the feedback modal must be sent. + if (!event.tags?.source || event.tags.source !== "feedbackModal") { + return null; + } + event.request.url = maskSensitiveInfoInUrl( + event.request.url, + input.adminUrl, + ); - hint.attachments = [ - { filename: "log.txt", data: readLogPanel('quickInfo') }, - { filename: "error.txt", data: readLogPanel('infoError') }, - ]; + hint.attachments = [ + { filename: "log.txt", data: readLogPanel("quickInfo") }, + { filename: "error.txt", data: readLogPanel("infoError") }, + ]; - return event; - }, + return event; + }, }); -document.getElementById("submitErrorReport").addEventListener("click", function () { +document + .getElementById("submitErrorReport") + .addEventListener("click", function () { const errorsElements = document.getElementById("infoError"); if (errorsElements) { - const childNodes = errorsElements.childNodes; - let messages = ''; - childNodes.forEach((node) => { - if (node.nodeType === Node.TEXT_NODE) { - messages += node.textContent.trim() + '\n'; - } - }); + const childNodes = errorsElements.childNodes; + let messages = ""; + childNodes.forEach((node) => { + if (node.nodeType === Node.TEXT_NODE) { + messages += node.textContent.trim() + "\n"; + } + }); - const url = maskSensitiveInfoInUrl(window.location.href, input.adminUrl); + const url = maskSensitiveInfoInUrl(window.location.href, input.adminUrl); - Sentry.setTag("url", url); - Sentry.setTag('source', 'feedbackModal'); + Sentry.setTag("url", url); + Sentry.setTag("source", "feedbackModal"); - const eventId = Sentry.captureMessage(messages, "error"); - const userEmail = document.getElementById("userEmail"); - const errorDescription = document.getElementById("errorDescription"); + const eventId = Sentry.captureMessage(messages, "error"); + const userEmail = document.getElementById("userEmail"); + const errorDescription = document.getElementById("errorDescription"); - Sentry.captureUserFeedback({ - event_id: eventId, - email: userEmail.value, - comments: errorDescription.value, - }); + Sentry.captureUserFeedback({ + event_id: eventId, + email: userEmail.value, + comments: errorDescription.value, + }); - // Clean-up - userEmail.value = ""; - errorDescription.value = ""; - Sentry.setTag('source', ''); + // Clean-up + userEmail.value = ""; + errorDescription.value = ""; + Sentry.setTag("source", ""); - $('#errorModal').modal('hide') + $("#errorModal").modal("hide"); } -}); + }); function maskSensitiveInfoInUrl(url, adminFolder) { - let regex = new RegExp(adminFolder, "g"); - url = url.replace(regex, '/********'); + let regex = new RegExp(adminFolder, "g"); + url = url.replace(regex, "/********"); - regex = new RegExp( "token=[^&]*", "i"); - return url.replace(regex, 'token=********'); + regex = new RegExp("token=[^&]*", "i"); + return url.replace(regex, "token=********"); } function readLogPanel(targetPanel) { - return document.getElementById(targetPanel).innerText; + return document.getElementById(targetPanel).innerText; } diff --git a/js/upgrade.js b/js/upgrade.js index 6bffb3909..56c02bf1b 100644 --- a/js/upgrade.js +++ b/js/upgrade.js @@ -1,6 +1,6 @@ -if (typeof input === 'undefined') { +if (typeof input === "undefined") { var input = { - psBaseUri: '/', + psBaseUri: "/", _PS_MODE_DEV_: true, PS_AUTOUP_BACKUP: true, adminUrl: "http://test.com/admin", @@ -9,45 +9,56 @@ if (typeof input === 'undefined') { txtError: [], firstTimeParams: {}, ajaxUpgradeTabExists: true, - currentIndex: 'page.php', + currentIndex: "page.php", tab: input.tab, - channel: 'major', + channel: "major", translation: { confirmDeleteBackup: "Are you sure you want to delete this backup?", - "delete": "Delete", - updateInProgress: "An update is currently in progress... Click \"OK\" to abort.", + delete: "Delete", + updateInProgress: + 'An update is currently in progress... Click "OK" to abort.', upgradingPrestaShop: "Upgrading PrestaShop", upgradeComplete: "Upgrade complete", - upgradeCompleteWithWarnings: "Upgrade complete, but warning notifications has been found.", + upgradeCompleteWithWarnings: + "Upgrade complete, but warning notifications has been found.", startingRestore: "Starting restoration...", restoreComplete: "Restoration complete.", - cannotDownloadFile: "Your server cannot download the file. Please upload it first by ftp in your admin/autoupgrade directory", - jsonParseErrorForAction: "Javascript error (parseJSON) detected for action ", + cannotDownloadFile: + "Your server cannot download the file. Please upload it first by ftp in your admin/autoupgrade directory", + jsonParseErrorForAction: + "Javascript error (parseJSON) detected for action ", endOfProcess: "End of process", - processCancelledCheckForRestore: "Operation canceled. Checking for restoration...", + processCancelledCheckForRestore: + "Operation canceled. Checking for restoration...", confirmRestoreBackup: "Do you want to restore SomeBackupName?", processCancelledWithError: "Operation canceled. An error happened.", - missingAjaxUpgradeTab: "[TECHNICAL ERROR] ajax-upgradetab.php is missing. Please reinstall the module.", - clickToRefreshAndUseNewConfiguration: "Click to refresh the page and use the new configuration", + missingAjaxUpgradeTab: + "[TECHNICAL ERROR] ajax-upgradetab.php is missing. Please reinstall the module.", + clickToRefreshAndUseNewConfiguration: + "Click to refresh the page and use the new configuration", errorDetectedDuring: "Error detected during", - downloadTimeout: "The request exceeded the max_time_limit. Please change your server configuration.", + downloadTimeout: + "The request exceeded the max_time_limit. Please change your server configuration.", seeOrHideList: "See or hide the list", coreFiles: "Core file(s)", mailFiles: "Mail file(s)", translationFiles: "Translation file(s)", linkAndMd5CannotBeEmpty: "Link and MD5 hash cannot be empty", - needToEnterArchiveVersionNumber: "You must enter the full version number of the version you want to upgrade. The full version number can be present in the zip name (ex: 1.7.8.1, 8.0.0).", + needToEnterArchiveVersionNumber: + "You must enter the full version number of the version you want to upgrade. The full version number can be present in the zip name (ex: 1.7.8.1, 8.0.0).", noArchiveSelected: "No archive has been selected.", - needToEnterDirectoryVersionNumber: "You need to enter the version number associated with the directory.", + needToEnterDirectoryVersionNumber: + "You need to enter the version number associated with the directory.", confirmSkipBackup: "Please confirm that you want to skip the backup.", - confirmPreserveFileOptions: "Please confirm that you want to preserve file options.", + confirmPreserveFileOptions: + "Please confirm that you want to preserve file options.", lessOptions: "Less options", moreOptions: "More options (Expert mode)", filesWillBeDeleted: "These files will be deleted", filesWillBeReplaced: "These files will be replaced", noXmlSelected: "No XML file has been selected.", noArchiveAndXmlSelected: "No archive and no XML file have been selected.", - } + }, }; } @@ -68,8 +79,11 @@ function cleanInfo() { function updateInfoStep(msg) { if (msg) { const infoStepElement = $("#infoStep"); - infoStepElement.append(msg + "
"); - infoStepElement.prop({scrollTop: infoStepElement.prop("scrollHeight")}, 1); + infoStepElement.append(msg + '
'); + infoStepElement.prop( + { scrollTop: infoStepElement.prop("scrollHeight") }, + 1, + ); } } @@ -79,13 +93,16 @@ function addError(error) { const infoErrorElement = $("#infoError"); if (Array.isArray(error)) { for (let i = 0; i < error.length; i++) { - infoErrorElement.append(error[i] + "
"); + infoErrorElement.append(error[i] + '
'); } } else { - infoErrorElement.append(error + "
"); + infoErrorElement.append(error + '
'); } // Note: jquery 1.6 makes use of prop() instead of attr() - infoErrorElement.prop({scrollTop: infoErrorElement.prop("scrollHeight")}, 1); + infoErrorElement.prop( + { scrollTop: infoErrorElement.prop("scrollHeight") }, + 1, + ); } } @@ -96,33 +113,38 @@ function addQuickInfo(quickInfo) { if (Array.isArray(quickInfo)) { for (let i = 0; i < quickInfo.length; i++) { - quickInfoElement.append(quickInfo[i] + "
"); + quickInfoElement.append(quickInfo[i] + '
'); } } else { - quickInfoElement.append(quickInfo + "
"); + quickInfoElement.append(quickInfo + '
'); } // Note : jquery 1.6 make uses of prop() instead of attr() - quickInfoElement.prop({scrollTop: quickInfoElement.prop("scrollHeight")}, 1); + quickInfoElement.prop( + { scrollTop: quickInfoElement.prop("scrollHeight") }, + 1, + ); } } // js initialization : prepare upgrade and rollback buttons -$(document).ready(function(){ - - $(".nobootstrap.no-header-toolbar").removeClass("nobootstrap").addClass("bootstrap"); +$(document).ready(function () { + $(".nobootstrap.no-header-toolbar") + .removeClass("nobootstrap") + .addClass("bootstrap"); - $(document).on("click", "a.confirmBeforeDelete", function(e) { + $(document).on("click", "a.confirmBeforeDelete", function (e) { if (!confirm(input.translation.confirmDeleteBackup)) { e.preventDefault(); } }); - $("select[name=channel]").change(function(e) { - $(this).find("option").each(function() { - var $this = $(this); - $("#for-" + $this.attr("id")) - .toggle($this.is(":selected")); - }); + $("select[name=channel]").change(function (e) { + $(this) + .find("option") + .each(function () { + var $this = $(this); + $("#for-" + $this.attr("id")).toggle($this.is(":selected")); + }); refreshChannelInfos(); }); @@ -139,13 +161,13 @@ $(document).ready(function(){ tab: input.tab, action: "getChannelInfo", ajaxMode: "1", - params: {channel: val} + params: { channel: val }, }, - success: function(res, textStatus, jqXHR) { + success: function (res, textStatus, jqXHR) { if (isJsonString(res)) { res = $.parseJSON(res); } else { - res = {nextParams: {status: "error"}}; + res = { nextParams: { status: "error" } }; } var answer = res.nextParams.result; @@ -160,55 +182,56 @@ $(document).ready(function(){ } } }, - error: function(res, textStatus, jqXHR) { + error: function (res, textStatus, jqXHR) { if (textStatus === "timeout" && action === "download") { updateInfoStep(input.translation.cannotDownloadFile); - } - else { + } else { // technical error : no translation needed - $("#checkPrestaShopFilesVersion").html(" Error Unable to check md5 files"); + $("#checkPrestaShopFilesVersion").html( + ' Error Unable to check md5 files', + ); } - } + }, }); } // the following prevents to leave the page at the inappropriate time $.xhrPool = []; - $.xhrPool.abortAll = function() { - $.each(this, function(jqXHR) { - if (jqXHR && (jqXHR.readystate !== 4)) { + $.xhrPool.abortAll = function () { + $.each(this, function (jqXHR) { + if (jqXHR && jqXHR.readystate !== 4) { jqXHR.abort(); } }); }; - $(".upgradestep").click(function(e) { + $(".upgradestep").click(function (e) { e.preventDefault(); // $.scrollTo("#options") }); // set timeout to 120 minutes (before aborting an ajax request) - $.ajaxSetup({timeout:7200000}); + $.ajaxSetup({ timeout: 7200000 }); // prepare available button here, without params ? - prepareNextButton("#upgradeNow",firstTimeParams); + prepareNextButton("#upgradeNow", firstTimeParams); /** * reset rollbackParams js array (used to init rollback button) */ - $("select[name=restoreName]").change(function() { + $("select[name=restoreName]").change(function () { var val = $(this).val(); // show delete button if the value is not 0 if (val != 0) { $("span#buttonDeleteBackup").html( - "
" - + input.translation.delete - + "" + '
' + + input.translation.delete + + "", ); } @@ -234,7 +257,10 @@ $(document).ready(function(){ $("select[name=channel]").change(); if (!input.ajaxUpgradeTabExists) { - $("#checkPrestaShopFilesVersion").html("" + input.translation.missingAjaxUpgradeTab); + $("#checkPrestaShopFilesVersion").html( + '' + + input.translation.missingAjaxUpgradeTab, + ); } }); @@ -243,10 +269,10 @@ function showConfigResult(msg, type) { type = "conf"; } var $configResult = $("#configResult"); - $configResult.html("
" + msg + "
").show(); + $configResult.html('
' + msg + "
").show(); if (type === "conf") { - $configResult.delay(3000).fadeOut("slow", function() { + $configResult.delay(3000).fadeOut("slow", function () { location.reload(); }); } @@ -261,14 +287,12 @@ function afterUpdateConfig(res) { var $oldChannel = $("select[name=channel] option.current"); if (config.channel != $oldChannel.val()) { - var $newChannel = $("select[name=channel] option[value=" + config.channel + "]"); - $oldChannel - .removeClass("current") - .html($oldChannel.html().substr(2)); - - $newChannel - .addClass("current") - .html("* " + $newChannel.html()); + var $newChannel = $( + "select[name=channel] option[value=" + config.channel + "]", + ); + $oldChannel.removeClass("current").html($oldChannel.html().substr(2)); + + $newChannel.addClass("current").html("* " + $newChannel.html()); } if (res.error == 1) { @@ -280,24 +304,25 @@ function afterUpdateConfig(res) { $("#upgradeNow") .unbind() .replaceWith( - "" - + input.translation.clickToRefreshAndUseNewConfiguration - + "" - ); + '' + + input.translation.clickToRefreshAndUseNewConfiguration + + "", + ); } function startProcess(type) { - // hide useless divs, show activity log - $("#informationBlock,#comparisonBlock,#currentConfigurationBlock,#backupOptionsBlock,#upgradeOptionsBlock,#upgradeButtonBlock").slideUp("fast"); + $( + "#informationBlock,#comparisonBlock,#currentConfigurationBlock,#backupOptionsBlock,#upgradeOptionsBlock,#upgradeButtonBlock", + ).slideUp("fast"); $(".autoupgradeSteps a").addClass("button"); $("#activityLogBlock").fadeIn("slow"); - $(window).bind("beforeunload", function(e) { + $(window).bind("beforeunload", function (e) { if (confirm(input.translation.updateInProgress)) { $.xhrPool.abortAll(); $(window).unbind("beforeunload"); @@ -322,9 +347,9 @@ function afterUpgradeNow(res) { $("#upgradeNow") .unbind() .replaceWith( - "" - + input.translation.upgradingPrestaShop - + " ..." + '' + + input.translation.upgradingPrestaShop + + " ...", ); } @@ -393,8 +418,14 @@ function afterBackupDb(res) { if (res.stepDone && input.PS_AUTOUP_BACKUP === true) { $("#restoreBackupContainer").show(); $("select[name=restoreName]") - .append("") - .val('') + .append( + '", + ) + .val("") .change(); } } @@ -419,12 +450,14 @@ function doAjaxRequest(action, nextParams) { token: input.token, tab: input.tab, action: action, - params: nextParams + params: nextParams, }, beforeSend: (jqXHR) => $.xhrPool.push(jqXHR), complete: (jqXHR) => $.xhrPool.pop(), - success: (res, textStatus, jqXHR) => handleRequestSuccess(res, textStatus, jqXHR, action), - error: (jqXHR, textStatus, errorThrown) => handleRequestError(jqXHR, textStatus, errorThrown, action), + success: (res, textStatus, jqXHR) => + handleRequestSuccess(res, textStatus, jqXHR, action), + error: (jqXHR, textStatus, errorThrown) => + handleRequestError(jqXHR, textStatus, errorThrown, action), }); return req; } @@ -432,7 +465,7 @@ function doAjaxRequest(action, nextParams) { function handleRequestSuccess(res, textStatus, jqXHR, action) { $("#pleaseWait").hide(); $("#rollbackForm").show(); - + try { res = $.parseJSON(res); } catch (e) { @@ -445,7 +478,7 @@ function handleRequestSuccess(res, textStatus, jqXHR, action) { updateInfoStep(res.next_desc); if (res.status !== "ok") { - addError( `${input.translation.errorDetectedDuring} [${action}].`); + addError(`${input.translation.errorDetectedDuring} [${action}].`); return; } @@ -461,11 +494,11 @@ function handleRequestSuccess(res, textStatus, jqXHR, action) { } if (res.next !== "") { - // if next is rollback, prepare nextParams with rollbackDbFilename and rollbackFilesFilename - if (res.next === "rollback") { - res.nextParams.restoreName = ""; - } - doAjaxRequest(res.next, res.nextParams); + // if next is rollback, prepare nextParams with rollbackDbFilename and rollbackFilesFilename + if (res.next === "rollback") { + res.nextParams.restoreName = ""; + } + doAjaxRequest(res.next, res.nextParams); } else { // Way To Go, end of upgrade process addQuickInfo(input.translation.endOfProcess); @@ -480,7 +513,7 @@ function handleRequestError(jqXHR, textStatus, errorThrown, action) { if (action === "download") { addError(input.translation.cannotDownloadFile); } else { - addError( `[Server Error] Timeout: ${input.translation.downloadTimeout}`); + addError(`[Server Error] Timeout: ${input.translation.downloadTimeout}`); } } else { try { @@ -489,7 +522,9 @@ function handleRequestError(jqXHR, textStatus, errorThrown, action) { addError(res.nextErrors); updateInfoStep(res.next_desc); } catch (e) { - addError(`[Ajax / Server Error for action: ${action}] textStatus: ${textStatus}, errorThrown: ${errorThrown}, jqXHR: ${jqXHR.responseText}`); + addError( + `[Ajax / Server Error for action: ${action}] textStatus: ${textStatus}, errorThrown: ${errorThrown}, jqXHR: ${jqXHR.responseText}`, + ); } } } @@ -507,25 +542,31 @@ function prepareNextButton(button_selector, nextParams) { } $(button_selector) - .unbind() - .click(function(e) { - e.preventDefault(); - $("#currentlyProcessing").show(); - var action = button_selector.substr(1); - doAjaxRequest(action, nextParams); - }); + .unbind() + .click(function (e) { + e.preventDefault(); + $("#currentlyProcessing").show(); + var action = button_selector.substr(1); + doAjaxRequest(action, nextParams); + }); } // ajax to check md5 files function addModifiedFileList(title, fileList, css_class, container) { - var subList = $(""); + var subList = $(''); - $(fileList).each(function(k, v) { + $(fileList).each(function (k, v) { $(subList).append("
  • " + v + "
  • "); }); $(container) - .append("

    " + title + " (" + fileList.length + ")

    ") + .append( + '

    ' + + title + + " (" + + fileList.length + + ")

    ", + ) .append(subList) .append("
    "); } @@ -541,7 +582,7 @@ function isJsonString(str) { return true; } -$(document).ready(function() { +$(document).ready(function () { $.ajax({ type: "POST", url: input.adminUrl + "/autoupgrade/ajax-upgradetab.php", @@ -552,55 +593,80 @@ $(document).ready(function() { tab: input.tab, action: "checkFilesVersion", ajaxMode: "1", - params: {} + params: {}, }, - success: function(res, textStatus, jqXHR) { + success: function (res, textStatus, jqXHR) { if (isJsonString(res)) { res = $.parseJSON(res); } else { - res = {nextParams: {status: "error"}}; + res = { nextParams: { status: "error" } }; } var answer = res.nextParams; var $checkPrestaShopFilesVersion = $("#checkPrestaShopFilesVersion"); $checkPrestaShopFilesVersion.html(" " + answer.msg + " "); - if (answer.status === "error" || (typeof answer.result === "undefined")) { - $checkPrestaShopFilesVersion.prepend(" "); + if (answer.status === "error" || typeof answer.result === "undefined") { + $checkPrestaShopFilesVersion.prepend( + ' ', + ); } else { $checkPrestaShopFilesVersion - .prepend(" ") - .append("" + input.translation.seeOrHideList + "
    ") - .append("

    "); + .prepend(' ') + .append( + '' + + input.translation.seeOrHideList + + "
    ", + ) + .append('

    '); if (answer.result.core.length) { - addModifiedFileList(input.translation.coreFiles, answer.result.core, "changedImportant", "#changedList"); + addModifiedFileList( + input.translation.coreFiles, + answer.result.core, + "changedImportant", + "#changedList", + ); } if (answer.result.mail.length) { - addModifiedFileList(input.translation.mailFiles, answer.result.mail, "changedNotice", "#changedList"); + addModifiedFileList( + input.translation.mailFiles, + answer.result.mail, + "changedNotice", + "#changedList", + ); } if (answer.result.translation.length) { - addModifiedFileList(input.translation.translationFiles, answer.result.translation, "changedNotice", "#changedList"); + addModifiedFileList( + input.translation.translationFiles, + answer.result.translation, + "changedNotice", + "#changedList", + ); } - $("#toggleChangedList").bind("click", function(e) { + $("#toggleChangedList").bind("click", function (e) { e.preventDefault(); $("#changedList").toggle(); }); - $('body').on().on("click", '.toggleSublist', function(e) { - e.preventDefault(); - $(this).parent().next().toggle(); - }); + $("body") + .on() + .on("click", ".toggleSublist", function (e) { + e.preventDefault(); + $(this).parent().next().toggle(); + }); } }, - error: function(res, textStatus, jqXHR) { + error: function (res, textStatus, jqXHR) { if (textStatus === "timeout" && action === "download") { updateInfoStep(input.translation.cannotDownloadFile); } else { // technical error : no translation needed - $("#checkPrestaShopFilesVersion").html(" Error: Unable to check md5 files"); + $("#checkPrestaShopFilesVersion").html( + ' Error: Unable to check md5 files', + ); } - } + }, }); $.ajax({ @@ -613,70 +679,90 @@ $(document).ready(function() { tab: input.tab, action: "compareReleases", ajaxMode: "1", - params: {} + params: {}, }, - success: function(res, textStatus, jqXHR) { + success: function (res, textStatus, jqXHR) { if (isJsonString(res)) { res = $.parseJSON(res); } else { - res = {nextParams: {status: "error"}}; + res = { nextParams: { status: "error" } }; } var answer = res.nextParams; var $checkPrestaShopModifiedFiles = $("#checkPrestaShopModifiedFiles"); $checkPrestaShopModifiedFiles.html(" " + answer.msg + " "); if (answer.status === "error" || typeof answer.result === "undefined") { - $checkPrestaShopModifiedFiles.prepend(" "); + $checkPrestaShopModifiedFiles.prepend( + ' ', + ); } else { $checkPrestaShopModifiedFiles - .prepend(" ") - .append(""+input.translation.seeOrHideList+"
    ") - .append("

    "); + .prepend(' ') + .append( + '' + + input.translation.seeOrHideList + + "
    ", + ) + .append('

    '); if (answer.result.deleted.length) { - addModifiedFileList(input.translation.filesWillBeDeleted, answer.result.deleted, "diffImportant", "#diffList"); + addModifiedFileList( + input.translation.filesWillBeDeleted, + answer.result.deleted, + "diffImportant", + "#diffList", + ); } if (answer.result.modified.length) { - addModifiedFileList(input.translation.filesWillBeReplaced, answer.result.modified, "diffImportant", "#diffList"); + addModifiedFileList( + input.translation.filesWillBeReplaced, + answer.result.modified, + "diffImportant", + "#diffList", + ); } - $("#toggleDiffList").bind("click", function(e) { + $("#toggleDiffList").bind("click", function (e) { e.preventDefault(); $("#diffList").toggle(); }); - $('body').on().on("click", '.toggleSublist', function(e) { - e.preventDefault(); - // this=a, parent=h3, next=ul - $(this).parent().next().toggle(); - }); + $("body") + .on() + .on("click", ".toggleSublist", function (e) { + e.preventDefault(); + // this=a, parent=h3, next=ul + $(this).parent().next().toggle(); + }); } }, - error: function(res, textStatus, jqXHR) { + error: function (res, textStatus, jqXHR) { if (textStatus === "timeout" && action === "download") { updateInfoStep(input.translation.cannotDownloadFile); } else { // technical error : no translation needed - $("#checkPrestaShopFilesVersion").html(" Error: Unable to check md5 files"); + $("#checkPrestaShopFilesVersion").html( + ' Error: Unable to check md5 files', + ); } - } + }, }); }); // -- END // advanced/normal mode -function switch_to_advanced(){ +function switch_to_advanced() { $("input[name=btn_adv]").val(input.translation.lessOptions); $("#advanced").show(); } -function switch_to_normal(){ +function switch_to_normal() { $("input[name=btn_adv]").val(input.translation.moreOptions); $("#advanced").hide(); } -$("input[name=btn_adv]").click(function(e) { +$("input[name=btn_adv]").click(function (e) { if ($("#advanced:visible").length) { switch_to_normal(); } else { @@ -684,88 +770,108 @@ $("input[name=btn_adv]").click(function(e) { } }); -$(document).ready(function() { - $("input[name|=submitConf], input[name=submitConf-channel]").bind("click", function(e) { - - var params = {}; - var $newChannel = $("select[name=channel] option:selected").val(); - var $oldChannel = $("select[name=channel] option.current").val(); - - $oldChannel = ""; - - if ($oldChannel != $newChannel) { - var validChannels = [ - "major", - "minor", - "rc", - "beta", - "alpha" - ]; - if (validChannels.indexOf($newChannel) !== -1) { - params.channel = $newChannel; - } +$(document).ready(function () { + $("input[name|=submitConf], input[name=submitConf-channel]").bind( + "click", + function (e) { + var params = {}; + var $newChannel = $("select[name=channel] option:selected").val(); + var $oldChannel = $("select[name=channel] option.current").val(); - if ($newChannel === "private") { - if (($("input[name=private_release_link]").val() == "") || ($("input[name=private_release_md5]").val() == "")) { - showConfigResult(input.translation.linkAndMd5CannotBeEmpty, "error"); - return false; - } - params.channel = "private"; - params.private_release_link = $("input[name=private_release_link]").val(); - params.private_release_md5 = $("input[name=private_release_md5]").val(); - if ($("input[name=private_allow_major]").is(":checked")) { - params.private_allow_major = 1; - } else { - params.private_allow_major = 0; + $oldChannel = ""; + + if ($oldChannel != $newChannel) { + var validChannels = ["major", "minor", "rc", "beta", "alpha"]; + if (validChannels.indexOf($newChannel) !== -1) { + params.channel = $newChannel; } - } else if ($newChannel === "archive") { - var archive_prestashop = $("select[name=archive_prestashop]").val(); - var archive_xml = $("select[name=archive_xml]").val(); - if (!archive_prestashop && !archive_xml) { - showConfigResult(input.translation.noArchiveAndXmlSelected, "error"); - return false; - } else if (!archive_prestashop) { - showConfigResult(input.translation.noArchiveSelected, "error"); - return false; - } else if (!archive_xml) { - showConfigResult(input.translation.noXmlSelected, "error"); - return false; + + if ($newChannel === "private") { + if ( + $("input[name=private_release_link]").val() == "" || + $("input[name=private_release_md5]").val() == "" + ) { + showConfigResult( + input.translation.linkAndMd5CannotBeEmpty, + "error", + ); + return false; + } + params.channel = "private"; + params.private_release_link = $( + "input[name=private_release_link]", + ).val(); + params.private_release_md5 = $( + "input[name=private_release_md5]", + ).val(); + if ($("input[name=private_allow_major]").is(":checked")) { + params.private_allow_major = 1; + } else { + params.private_allow_major = 0; + } + } else if ($newChannel === "archive") { + var archive_prestashop = $("select[name=archive_prestashop]").val(); + var archive_xml = $("select[name=archive_xml]").val(); + if (!archive_prestashop && !archive_xml) { + showConfigResult( + input.translation.noArchiveAndXmlSelected, + "error", + ); + return false; + } else if (!archive_prestashop) { + showConfigResult(input.translation.noArchiveSelected, "error"); + return false; + } else if (!archive_xml) { + showConfigResult(input.translation.noXmlSelected, "error"); + return false; + } + params.channel = "archive"; + params.archive_prestashop = archive_prestashop; + params.archive_xml = archive_xml; + } else if ($newChannel === "directory") { + params.channel = "directory"; + params.directory_prestashop = $( + "select[name=directory_prestashop] option:selected", + ).val(); + let directory_num = $("input[name=directory_num]").val(); + if (directory_num == "" || !directory_num.match(versionNumberRegex)) { + showConfigResult( + input.translation.needToEnterDirectoryVersionNumber, + "error", + ); + return false; + } + params.directory_num = $("input[name=directory_num]").val(); } - params.channel = "archive"; - params.archive_prestashop = archive_prestashop; - params.archive_xml = archive_xml; - } else if ($newChannel === "directory") { - params.channel = "directory"; - params.directory_prestashop = $("select[name=directory_prestashop] option:selected").val(); - let directory_num = $("input[name=directory_num]").val(); - if (directory_num == "" || !directory_num.match(versionNumberRegex)) { - showConfigResult(input.translation.needToEnterDirectoryVersionNumber, "error"); + } + // note: skipBackup is currently not used + if ($(this).attr("name") == "submitConf-skipBackup") { + var skipBackup = $("input[name=submitConf-skipBackup]:checked").length; + if (skipBackup == 0 || confirm(input.translation.confirmSkipBackup)) { + params.skip_backup = $( + "input[name=submitConf-skipBackup]:checked", + ).length; + } else { + $("input[name=submitConf-skipBackup]:checked").removeAttr("checked"); return false; } - params.directory_num = $("input[name=directory_num]").val(); - } - } - // note: skipBackup is currently not used - if ($(this).attr("name") == "submitConf-skipBackup") { - var skipBackup = $("input[name=submitConf-skipBackup]:checked").length; - if (skipBackup == 0 || confirm(input.translation.confirmSkipBackup)) { - params.skip_backup = $("input[name=submitConf-skipBackup]:checked").length; - } else { - $("input[name=submitConf-skipBackup]:checked").removeAttr("checked"); - return false; } - } - // note: preserveFiles is currently not used - if ($(this).attr("name") == "submitConf-preserveFiles") { - var preserveFiles = $("input[name=submitConf-preserveFiles]:checked").length; - if (confirm(input.translation.confirmPreserveFileOptions)) { - params.preserve_files = $("input[name=submitConf-preserveFiles]:checked").length; - } else { - $("input[name=submitConf-skipBackup]:checked").removeAttr("checked"); - return false; + // note: preserveFiles is currently not used + if ($(this).attr("name") == "submitConf-preserveFiles") { + var preserveFiles = $( + "input[name=submitConf-preserveFiles]:checked", + ).length; + if (confirm(input.translation.confirmPreserveFileOptions)) { + params.preserve_files = $( + "input[name=submitConf-preserveFiles]:checked", + ).length; + } else { + $("input[name=submitConf-skipBackup]:checked").removeAttr("checked"); + return false; + } } - } - var res = doAjaxRequest("updateConfig", params); - }); + var res = doAjaxRequest("updateConfig", params); + }, + ); });