From cf87044069713a5080d3345fda55fbfa286f5e50 Mon Sep 17 00:00:00 2001 From: HugoFara Date: Wed, 3 Jan 2024 20:16:02 +0100 Subject: [PATCH] Missing function, fixes style. --- js/pgm.js | 6 +-- src/js/unloadformcheck.js | 80 +++++++++++++++++++-------------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/js/pgm.js b/js/pgm.js index 5095a73f..863a8c21 100644 --- a/js/pgm.js +++ b/js/pgm.js @@ -408,15 +408,15 @@ return getLibreTranslateTranslationBase(text,lang,dest,key=search_params.get('lw * @author andreask7 * @since 1.6.16-fork * @since 2.3.1-fork You should not only include this script to check before unload - * but also call ask_before_exiting once. + * but also call ask_before_exiting once. * @since 2.10.0-fork This file was refactored in a single object, use it instead */ -var DIRTY=0;const lwt_form_check={dirty:!1,isDirtyMessage:function(){if(lwt_form_check.dirty){return'** You have unsaved changes! **'}},makeDirty:function(){lwt_form_check.dirty=!0},resetDirty:function(){lwt_form_check.dirty=!1},tagChanged:function(_,ui){if(!ui.duringInitialization){lwt_form_check.dirty=!0} +let DIRTY=0;const lwt_form_check={dirty:!1,isDirtyMessage:function(){if(lwt_form_check.dirty){return'** You have unsaved changes! **'}},makeDirty:function(){lwt_form_check.dirty=!0},resetDirty:function(){lwt_form_check.dirty=!1},tagChanged:function(_,ui){if(!ui.duringInitialization){lwt_form_check.dirty=!0} return!0},askBeforeExit:function(){$('#termtags').tagit({afterTagAdded:lwt_form_check.tagChanged,afterTagRemoved:lwt_form_check.tagChanged});$('#texttags').tagit({afterTagAdded:lwt_form_check.tagChanged,afterTagRemoved:lwt_form_check.tagChanged});$('input,checkbox,textarea,radio,select').not('#quickmenu').on('change',lwt_form_check.makeDirty);$(':reset,:submit').on('click',lwt_form_check.resetDirty);$(window).on('beforeunload',lwt_form_check.isDirtyMessage)}};function askConfirmIfDirty(){return lwt_form_check.askConfirmIfDirty()} function makeDirty(){return lwt_form_check.makeDirty()} function resetDirty(){return lwt_form_check.resetDirty()} function tagChanged(_,ui){return lwt_form_check.tagChanged(_,ui)} -function ask_before_exiting(){return lwt_form_check.askBeforeExiting()};var stIsIE=!1;sorttable={init:function(){if(arguments.callee.done)return;arguments.callee.done=!0;if(_timer)clearInterval(_timer);if(!document.createElement||!document.getElementsByTagName)return;sorttable.DATE_RE=/^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;forEach(document.getElementsByTagName('table'),function(table){if(table.className.search(/\bsortable\b/)!=-1){sorttable.makeSortable(table)}})},makeSortable:function(table){if(table.getElementsByTagName('thead').length==0){the=document.createElement('thead');the.appendChild(table.rows[0]);table.insertBefore(the,table.firstChild)} +function ask_before_exiting(){return lwt_form_check.askBeforeExit()};var stIsIE=!1;sorttable={init:function(){if(arguments.callee.done)return;arguments.callee.done=!0;if(_timer)clearInterval(_timer);if(!document.createElement||!document.getElementsByTagName)return;sorttable.DATE_RE=/^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;forEach(document.getElementsByTagName('table'),function(table){if(table.className.search(/\bsortable\b/)!=-1){sorttable.makeSortable(table)}})},makeSortable:function(table){if(table.getElementsByTagName('thead').length==0){the=document.createElement('thead');the.appendChild(table.rows[0]);table.insertBefore(the,table.firstChild)} if(table.tHead==null)table.tHead=table.getElementsByTagName('thead')[0];if(table.tHead.rows.length!=1)return;sortbottomrows=[];for(var i=0;i * @since 1.6.16-fork * @since 2.3.1-fork You should not only include this script to check before unload - * but also call ask_before_exiting once. + * but also call ask_before_exiting once. * @since 2.10.0-fork This file was refactored in a single object, use it instead */ @@ -15,7 +15,7 @@ * * @deprecated Since 2.10.0, use lwt_form_check instead */ -var DIRTY = 0; +let DIRTY = 0; /** * Keeps track of a modified form. @@ -25,63 +25,63 @@ const lwt_form_check = { dirty: false, /** - * Check the DIRTY status and ask before leaving. - * - * @returns {string} Confirmation string - */ + * Check the DIRTY status and ask before leaving. + * + * @returns {string} Confirmation string + */ isDirtyMessage: function () { - if (lwt_form_check.dirty) { - return '** You have unsaved changes! **'; - } + if (lwt_form_check.dirty) { + return '** You have unsaved changes! **'; + } }, /** - * Set the DIRTY variable to 1. - */ + * Set the DIRTY variable to 1. + */ makeDirty: function () { lwt_form_check.dirty = true; }, /** - * Set the DIRTY variable to 0. - */ + * Set the DIRTY variable to 0. + */ resetDirty: function () { lwt_form_check.dirty = false; }, /** - * Set DIRTY to 1 if tag object changed. - * - * @param {*} _ An event, unused - * @param {object} ui UI object - * @returns {true} Always return true - */ + * Set DIRTY to 1 if tag object changed. + * + * @param {*} _ An event, unused + * @param {object} ui UI object + * @returns {true} Always return true + */ tagChanged: function (_, ui) { - if (!ui.duringInitialization) { + if (!ui.duringInitialization) { lwt_form_check.dirty = true; - } - return true; + } + return true; }, /** - * Call this function if you want to ask the user - * before exiting the form. - * - * @returns {undefined} - */ + * Call this function if you want to ask the user + * before exiting the form. + * + * @returns {undefined} + */ askBeforeExit: function () { - $('#termtags').tagit({ - afterTagAdded: lwt_form_check.tagChanged, - afterTagRemoved: lwt_form_check.tagChanged - }); - $('#texttags').tagit({ - afterTagAdded: lwt_form_check.tagChanged, - afterTagRemoved: lwt_form_check.tagChanged - }); - $('input,checkbox,textarea,radio,select') - .not('#quickmenu').on('change', lwt_form_check.makeDirty); - $(':reset,:submit').on('click', lwt_form_check.resetDirty); - $(window).on('beforeunload', lwt_form_check.isDirtyMessage); + $('#termtags').tagit({ + afterTagAdded: lwt_form_check.tagChanged, + afterTagRemoved: lwt_form_check.tagChanged + }); + $('#texttags').tagit({ + afterTagAdded: lwt_form_check.tagChanged, + afterTagRemoved: lwt_form_check.tagChanged + }); + $('input,checkbox,textarea,radio,select') + .not('#quickmenu').on('change', lwt_form_check.makeDirty); + $(':reset,:submit').on('click', lwt_form_check.resetDirty); + $(window).on('beforeunload', lwt_form_check.isDirtyMessage); } }; @@ -131,5 +131,5 @@ function tagChanged (_, ui) { * @deprecated Since 2.10.0, use return lwt_form_check.askBeforeExit instead */ function ask_before_exiting () { - return lwt_form_check.askBeforeExiting(); + return lwt_form_check.askBeforeExit(); }