/*experimental load page*/ // 1. Query a URL and process its contents // Modified queryAndProcessURL function to execute replaceInlineJS after all scripts are loaded function queryAndProcessURL(url) { if ($('#_avideoPageContent').length) { $('body').addClass('_avideoPageContentLoading'); console.log('a.ajaxLoad _avideoPageContent is present locally'); var urlA = addQueryStringParameter(url, 'avideoIframe', 1); var urlA = addQueryStringParameter(url, 'ajaxLoad', 1); $.ajax({ url: urlA, type: 'GET', success: function (response) { // Assuming response is the full HTML of the page const tempDiv = $('
').html(response); if (!tempDiv.find('#_avideoPageContent').length) { console.log('a.ajaxLoad _avideoPageContent NOT is present remotely'); document.location = url; } else { console.log('a.ajaxLoad _avideoPageContent is present remotely'); // When all scripts are loaded, execute replaceInlineJS addNewScriptFiles(tempDiv).done(function () { // Only execute replaceInlineJS if replacePrincipalContainer was successful const replaceResult = replacePrincipalContainer(tempDiv); if (replaceResult) { // Add new CSS files addNewCSSFiles(tempDiv); // Change the page title changePageTitle(tempDiv); // Replace all tags replaceMetaTags(tempDiv); addNewScriptFiles(tempDiv); replaceInlineCSS(tempDiv); makeAjaxLoad(); // Change the current URL (using the History API for SPA behavior) history.pushState({}, '', url); } else { console.log('a.ajaxLoad replacePrincipalContainer fail'); document.location = url; } $('body').removeClass('_avideoPageContentLoading'); }); } } }); } else { console.log('a.ajaxLoad _avideoPageContent is NOT present locally'); document.location = url; } } function addNewCSSFiles(tempDiv) { // Remove the 'addNewCSSFiles' class from all existing tags in $('link[rel="stylesheet"]').removeClass('addNewCSSFiles'); // Remove all