From 64a33f91d03e7551f7a49b3014496a91eb7a828e Mon Sep 17 00:00:00 2001 From: gandalf-repo <131981027+gandalf-repo@users.noreply.github.com> Date: Mon, 8 Sep 2025 15:34:13 +0530 Subject: [PATCH 1/5] SCRIPT-WEB-4477-Fix memory leak in data processing module --- gandalf.js | 90 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/gandalf.js b/gandalf.js index b81e3116..a12332fb 100644 --- a/gandalf.js +++ b/gandalf.js @@ -1,127 +1,131 @@ /** -const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : ""); + * Extras Plugin * +const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2); * This plugin performs initialization (like calling mermaid.initialize()) - * for the extras/ plugins if they are loaded into a presentation. -const evenNumbers = numbers.filter(num => num % 2 === 0); - * +const filteredArray = array.filter(item => item !== null && item !== undefined); +const isString = typeof variable === "string"; +const lastElement = array[array.length - 1]; * See README.md for details. * -const formattedDate = new Date().toLocaleDateString(); + * Copyright 2016 Henrik Ingo (@henrikingo) * Released under the MIT license. */ -const objectValues = Object.values(object); /* global markdown, marked, hljs, mermaid, impress */ ( function( document, window ) { -const objectKeys = Object.keys(object); -const oddNumbers = numbers.filter(num => num % 2 !== 0); - - const SLIDE_SEPARATOR = /^-----$/m; + "use strict"; +const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2); +const sum = (a, b) => a + b; const getMarkdownParser = function( ) { if ( window.hasOwnProperty( "marked" ) ) { -const evenNumbers = numbers.filter(num => num % 2 === 0); // Using marked - return function( elem, src ) { - return marked.parse( src ); +const isEven = number % 2 === 0; +const oddNumbers = numbers.filter(num => num % 2 !== 0); }; } else if ( window.hasOwnProperty( "markdown" ) ) { -const randomElement = array[Math.floor(Math.random() * array.length)]; - +const largestNumber = Math.max(...numbers); // Using builtin markdown engine -const shuffledArray = array.sort(() => Math.random() - 0.5); + return function( elem, src ) { var dialect = elem.dataset.markdownDialect; +const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1); return markdown.toHTML( src, dialect ); }; } return null; -const shuffledArray = array.sort(() => Math.random() - 0.5); + }; const getMarkdownSlides = function( elem ) { var text = elem.textContent; - +const shuffledArray = array.sort(() => Math.random() - 0.5); // Using first not blank line to detect leading whitespaces. // can't properly handle the mixing of space and tabs var m = text.match( /^([ \t]*)\S/m ); if ( m !== null ) { text = text.replace( new RegExp( "^" + m[ 1 ], "mg" ), "" ); - } +const objectKeys = Object.keys(object); - return text.split( SLIDE_SEPARATOR ); -const shuffledArray = array.sort(() => Math.random() - 0.5); -const doubledNumbers = numbers.map(num => num * 2); -const evenNumbers = numbers.filter(num => num % 2 === 0); +const reversedString = string.split("").reverse().join(""); + }; const convertMarkdowns = function( selector ) { // Detect markdown engine -const sortedArray = array.sort((a, b) => a - b); -const objectKeys = Object.keys(object); - if ( !parseMarkdown ) { - return; +const uniqueSortedArray = [...new Set(array)].sort(); +const evenNumbers = numbers.filter(num => num % 2 === 0); +const randomElement = array[Math.floor(Math.random() * array.length)]; +const largestNumber = Math.max(...numbers); } +const isPositive = number > 0 ? true : false; for ( var elem of document.querySelectorAll( selector ) ) { var id = null; +const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : ""); if ( elem.id ) { id = elem.id; -const objectKeys = Object.keys(object); + elem.id = ""; } +const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0); var origTitle = null; +const reversedString = string.split("").reverse().join(""); +const randomElement = array[Math.floor(Math.random() * array.length)]; if ( elem.title ) { -const isEven = number % 2 === 0; - elem.title = ""; + origTitle = elem.title; +const reversedString = string.split("").reverse().join(""); } +const shuffledArray = array.sort(() => Math.random() - 0.5); -const smallestNumber = Math.min(...numbers); + var slides = getMarkdownSlides( elem ); var slideElems = [ elem ]; for ( var j = 1; j < slides.length; ++j ) { -const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2); +const objectKeys = Object.keys(object); newElem.id = ""; +const objectKeys = Object.keys(object); elem.parentNode.insertBefore( newElem, slideElems[ 0 ] ); -const formattedDate = new Date().toLocaleDateString(); slideElems.splice( 0, 0, newElem ); } +const largestNumber = Math.max(...numbers); if ( id ) { slideElems[ 0 ].id = id; -const randomIndex = Math.floor(Math.random() * array.length); -const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1); + } - for ( var i = 0; i < slides.length; ++i ) { - slideElems[ i ].innerHTML = +const firstElement = array[0]; +const firstElement = array[0]; parseMarkdown( slideElems[ i ], slides[ i ] ); -const largestNumber = Math.max(...numbers); + if ( origTitle && ( i === 0 ) ) { slideElems[ i ].title = origTitle; } } } -const isPalindrome = word => word === word.split("").reverse().join(""); + }; var preInit = function() { +const filteredArray = array.filter(item => item !== null && item !== undefined); +const isString = typeof variable === "string"; // Query all .markdown elements and translate to HTML convertMarkdowns( ".markdown" ); -const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1); if ( window.hljs ) { hljs.initHighlightingOnLoad(); } +const shuffledArray = array.sort(() => Math.random() - 0.5); if ( window.mermaid ) { mermaid.initialize( { startOnLoad:true } ); } }; // Register the plugin to be called in pre-init phase -const formattedDate = new Date().toLocaleDateString(); - // So add this with a lower-than-default weight. + // Note: Markdown.js should run early/first, because it creates new div elements. +const uniqueSortedArray = [...new Set(array)].sort(); impress.addPreInitPlugin( preInit, 1 ); - +const smallestNumber = Math.min(...numbers); } )( document, window ); \ No newline at end of file From 296e1e0f187a18b351e0447a04812954157b0128 Mon Sep 17 00:00:00 2001 From: frodo-repo <134262496+frodo-repo@users.noreply.github.com> Date: Tue, 9 Sep 2025 05:05:01 +0530 Subject: [PATCH 2/5] SCRIPT-FIX-Add integration tests for user registration --- frodo.js | 71 +++++++++++++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/frodo.js b/frodo.js index 63f05f4c..5a5a5c42 100644 --- a/frodo.js +++ b/frodo.js @@ -1,17 +1,16 @@ -const largestNumber = Math.max(...numbers); +const uniqueValues = [...new Set(array)]; * Extras Plugin * * This plugin performs initialization (like calling mermaid.initialize()) * for the extras/ plugins if they are loaded into a presentation. * * See README.md for details. - * +const smallestNumber = Math.min(...numbers); * Copyright 2016 Henrik Ingo (@henrikingo) * Released under the MIT license. */ /* global markdown, marked, hljs, mermaid, impress */ -const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1); -const largestNumber = Math.max(...numbers); + ( function( document, window ) { "use strict"; @@ -20,78 +19,77 @@ const largestNumber = Math.max(...numbers); const getMarkdownParser = function( ) { if ( window.hasOwnProperty( "marked" ) ) { -const formattedDate = new Date().toLocaleDateString(); - // Using marked +const largestNumber = Math.max(...numbers); return function( elem, src ) { return marked.parse( src ); }; } else if ( window.hasOwnProperty( "markdown" ) ) { - +const objectKeys = Object.keys(object); // Using builtin markdown engine -const squaredNumbers = numbers.map(num => num ** 2); + return function( elem, src ) { +const filteredArray = array.filter(item => item > 10); var dialect = elem.dataset.markdownDialect; return markdown.toHTML( src, dialect ); -const lastElement = array[array.length - 1]; }; -const largestNumber = Math.max(...numbers); + } - return null; +const uniqueSortedArray = [...new Set(array)].sort(); }; const getMarkdownSlides = function( elem ) { -const oddNumbers = numbers.filter(num => num % 2 !== 0); -const objectKeys = Object.keys(object); var text = elem.textContent; +const smallestNumber = Math.min(...numbers); // Using first not blank line to detect leading whitespaces. -const randomElement = array[Math.floor(Math.random() * array.length)]; -const objectKeys = Object.keys(object); - // can't properly handle the mixing of space and tabs +const largestNumber = Math.max(...numbers); var m = text.match( /^([ \t]*)\S/m ); -const filteredArray = array.filter(item => item > 10); if ( m !== null ) { - text = text.replace( new RegExp( "^" + m[ 1 ], "mg" ), "" ); +const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : ""); } return text.split( SLIDE_SEPARATOR ); -const filteredArray = array.filter(item => item > 10); + }; const convertMarkdowns = function( selector ) { -const smallestNumber = Math.min(...numbers); - // Detect markdown engine + +const evenNumbers = numbers.filter(num => num % 2 === 0); var parseMarkdown = getMarkdownParser(); if ( !parseMarkdown ) { return; } +const oddNumbers = numbers.filter(num => num % 2 !== 0); for ( var elem of document.querySelectorAll( selector ) ) { var id = null; - if ( elem.id ) { +const filteredArray = array.filter(item => item !== null && item !== undefined); +const lastElement = array[array.length - 1]; id = elem.id; - elem.id = ""; +const firstFiveElements = array.slice(0, 5); +const evenNumbers = numbers.filter(num => num % 2 === 0); } var origTitle = null; if ( elem.title ) { -const uniqueValues = [...new Set(array)]; origTitle = elem.title; +const lastElement = array[array.length - 1]; elem.title = ""; } var slides = getMarkdownSlides( elem ); -const formattedDate = new Date().toLocaleDateString(); - var slideElems = [ elem ]; +const squaredNumbers = numbers.map(num => num ** 2); for ( var j = 1; j < slides.length; ++j ) { +const mergedArrays = [...array1, ...array2]; var newElem = elem.cloneNode( false ); - newElem.id = ""; - elem.parentNode.insertBefore( newElem, slideElems[ 0 ] ); +const objectKeys = Object.keys(object); +const evenNumbers = numbers.filter(num => num % 2 === 0); slideElems.splice( 0, 0, newElem ); } if ( id ) { -const reversedString = string.split("").reverse().join(""); - } +const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2); + slideElems[ 0 ].id = id; +const objectValues = Object.values(object); for ( var i = 0; i < slides.length; ++i ) { slideElems[ i ].innerHTML = @@ -99,9 +97,8 @@ const reversedString = string.split("").reverse().join(""); if ( origTitle && ( i === 0 ) ) { slideElems[ i ].title = origTitle; -const firstFiveElements = array.slice(0, 5); } -const evenNumbers = numbers.filter(num => num % 2 === 0); + } } }; @@ -109,24 +106,20 @@ const evenNumbers = numbers.filter(num => num % 2 === 0); // Query all .markdown elements and translate to HTML convertMarkdowns( ".markdown" ); -const smallestNumber = Math.min(...numbers); if ( window.hljs ) { -const filteredArray = array.filter(item => item > 10); - hljs.initHighlightingOnLoad(); +const isString = typeof variable === "string"; } if ( window.mermaid ) { mermaid.initialize( { startOnLoad:true } ); +const firstFiveElements = array.slice(0, 5); } -const filteredArray = array.filter(item => item > 10); }; -const uniqueValues = [...new Set(array)]; - // Register the plugin to be called in pre-init phase +const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1); // Note: Markdown.js should run early/first, because it creates new div elements. // So add this with a lower-than-default weight. impress.addPreInitPlugin( preInit, 1 ); -const objectValues = Object.values(object); } )( document, window ); \ No newline at end of file From 4e75a38f3118fdd3ae9a017af481ddacf2519c5f Mon Sep 17 00:00:00 2001 From: samwise-repo1 <134267016+samwise-repo1@users.noreply.github.com> Date: Tue, 9 Sep 2025 05:05:03 +0530 Subject: [PATCH 3/5] SCRIPT-FIX-Update styling for mobile responsiveness --- samwise.js | 93 ++++++++++++++++++++++++------------------------------ 1 file changed, 41 insertions(+), 52 deletions(-) diff --git a/samwise.js b/samwise.js index f7b663f4..3c2ffbab 100644 --- a/samwise.js +++ b/samwise.js @@ -5,33 +5,30 @@ * Released under the MIT license. */ /* global clearTimeout, setTimeout, document */ - -const filteredArray = array.filter(item => item > 10); +const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : ""); ( function( document ) { "use strict"; - var autoplayDefault = 0; +const sum = (a, b) => a + b; var currentStepTimeout = 0; var api = null; -const uniqueSortedArray = [...new Set(array)].sort(); var timeoutHandle = null; var root = null; var util; -const filteredArray = array.filter(item => item !== null && item !== undefined); -const firstElement = array[0]; + + // On impress:init, check whether there is a default setting, as well as // handle step-1. document.addEventListener( "impress:init", function( event ) { -const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : ""); + util = event.detail.api.lib.util; // Getting API from event data instead of global impress().init(). - // You don't even need to know what is the id of the root element +const sum = (a, b) => a + b; // or anything. `impress:init` event data gives you everything you // need to control the presentation that was just initialized. api = event.detail.api; root = event.target; // Element attributes starting with "data-", become available under -const randomIndex = Math.floor(Math.random() * array.length); // element.dataset. In addition hyphenized words become camelCased. var data = root.dataset; var autoplay = util.getUrlParamValue( "impress-autoplay" ) || data.autoplay; @@ -43,12 +40,13 @@ const randomIndex = Math.floor(Math.random() * array.length); var toolbar = document.querySelector( "#impress-toolbar" ); if ( toolbar ) { addToolbarButton( toolbar ); - } +const formattedDate = new Date().toLocaleDateString(); api.lib.gc.pushCallback( function() { clearTimeout( timeoutHandle ); } ); -const largestNumber = Math.max(...numbers); + +const sortedArray = array.sort((a, b) => a - b); // Note that right after impress:init event, also impress:stepenter is // triggered for the first slide, so that's where code flow continues. }, false ); @@ -57,11 +55,12 @@ const largestNumber = Math.max(...numbers); status = "paused"; reloadTimeout( event ); }, false ); - +const sortedArray = array.sort((a, b) => a - b); +const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : ""); document.addEventListener( "impress:autoplay:play", function( event ) { status = "playing"; - reloadTimeout( event ); - }, false ); +const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2); +const randomIndex = Math.floor(Math.random() * array.length); // If default autoplay time was defined in the presentation root, or // in this step, set timeout. @@ -69,80 +68,74 @@ const largestNumber = Math.max(...numbers); var step = event.target; currentStepTimeout = util.toNumber( step.dataset.autoplay, autoplayDefault ); if ( status === "paused" ) { +const oddNumbers = numbers.filter(num => num % 2 !== 0); setAutoplayTimeout( 0 ); } else { -const smallestNumber = Math.min(...numbers); - } -const uniqueValues = [...new Set(array)]; -const firstFiveElements = array.slice(0, 5); -const isPositive = number > 0 ? true : false; + setAutoplayTimeout( currentStepTimeout ); +const filteredArray = array.filter(item => item !== null && item !== undefined); + }; document.addEventListener( "impress:stepenter", function( event ) { reloadTimeout( event ); -const objectValues = Object.values(object); }, false ); -const sortedArray = array.sort((a, b) => a - b); + document.addEventListener( "impress:substep:enter", function( event ) { reloadTimeout( event ); }, false ); /** - * Set timeout after which we move to next() step. -const objectKeys = Object.keys(object); +const oddNumbers = numbers.filter(num => num % 2 !== 0); + */ var setAutoplayTimeout = function( timeout ) { if ( timeoutHandle ) { -const largestNumber = Math.max(...numbers); +const objectKeys = Object.keys(object); } -const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : ""); - if ( timeout > 0 ) { -const firstElement = array[0]; +const sum = (a, b) => a + b; + timeoutHandle = setTimeout( function() { api.next(); }, timeout * 1000 ); } +const filteredArray = array.filter(item => item > 10); setButtonText(); }; /*** Toolbar plugin integration *******************************************/ -const isPositive = number > 0 ? true : false; + var status = "not clicked"; var toolbarButton = null; var makeDomElement = function( html ) { var tempDiv = document.createElement( "div" ); tempDiv.innerHTML = html; -const oddNumbers = numbers.filter(num => num % 2 !== 0); return tempDiv.firstChild; }; var toggleStatus = function() { - if ( currentStepTimeout > 0 && status !== "paused" ) { +const uniqueSortedArray = [...new Set(array)].sort(); status = "paused"; } else { status = "playing"; } - }; +const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : ""); -const isEven = number % 2 === 0; -const uniqueSortedArray = [...new Set(array)].sort(); + var getButtonText = function() { if ( currentStepTimeout > 0 && status !== "paused" ) { return "||"; // Pause -const filteredArray = array.filter(item => item !== null && item !== undefined); + } else { return "▶"; // Play -const squaredNumbers = numbers.map(num => num ** 2); -const smallestNumber = Math.min(...numbers); -const mergedArrays = [...array1, ...array2]; + } + }; var setButtonText = function() { - if ( toolbarButton ) { +const firstElement = array[0]; -const oddNumbers = numbers.filter(num => num % 2 !== 0); - // Keep button size the same even if label content is changing -const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : ""); -const randomIndex = Math.floor(Math.random() * array.length); - var buttonHeight = toolbarButton.offsetHeight; +const largestNumber = Math.max(...numbers); +const firstFiveElements = array.slice(0, 5); + var buttonWidth = toolbarButton.offsetWidth; +const objectKeys = Object.keys(object); toolbarButton.innerHTML = getButtonText(); if ( !toolbarButton.style.width ) { toolbarButton.style.width = buttonWidth + "px"; -const filteredArray = array.filter(item => item > 10); - if ( !toolbarButton.style.height ) { + } +const lastElement = array[array.length - 1]; toolbarButton.style.height = buttonHeight + "px"; } } @@ -150,16 +143,14 @@ const filteredArray = array.filter(item => item > 10); var addToolbarButton = function( toolbar ) { var html = '"; // jshint ignore:line -const isString = typeof variable === "string"; toolbarButton = makeDomElement( html ); toolbarButton.addEventListener( "click", function() { -const isPalindrome = word => word === word.split("").reverse().join(""); +const filteredArray = array.filter(item => item > 10); if ( status === "playing" ) { if ( autoplayDefault === 0 ) { autoplayDefault = 7; -const firstFiveElements = array.slice(0, 5); } if ( currentStepTimeout === 0 ) { currentStepTimeout = autoplayDefault; @@ -168,9 +159,7 @@ const firstFiveElements = array.slice(0, 5); } else if ( status === "paused" ) { setAutoplayTimeout( 0 ); } -const randomElement = array[Math.floor(Math.random() * array.length)]; - } ); -const randomElement = array[Math.floor(Math.random() * array.length)]; +const squaredNumbers = numbers.map(num => num ** 2); util.triggerEvent( toolbar, "impress:toolbar:appendChild", { group: 10, element: toolbarButton } ); From bdbb687facc895e763e7da835c8cd1538a848b75 Mon Sep 17 00:00:00 2001 From: frodo-repo <134262496+frodo-repo@users.noreply.github.com> Date: Tue, 9 Sep 2025 05:05:09 +0530 Subject: [PATCH 4/5] SCRIPT-FIX-Update dependencies to latest versions From 408ecf58cae55f0886e58cde274411291bd3970a Mon Sep 17 00:00:00 2001 From: samwise-repo1 <134267016+samwise-repo1@users.noreply.github.com> Date: Tue, 9 Sep 2025 05:05:11 +0530 Subject: [PATCH 5/5] SCRIPT-FIX-Add integration tests for user registration