This bookmarklet toggles three handy Sitevision functionalities:
Profiling: Displays a table with render times for all portlets and modules on the page, allowing you to evaluate performance.
JSDebug: Disables asset minification and bundling, revealing the original filenames for stylesheets (CSS) and client scripts (JavaScript), useful for pinpointing source files.
Version: Switches the view to the offline version of the page, showing the draft in the CMS without the editor interface. Ideal for previewing unpublished content.
The Version switch is only shown when you are logged in since the offline version requires you to be authenticated.
((window, document)=>{ // Bail early if envision is not found. if(!window.envision){ console.warn('Envision not found. Exiting since most likely not Sitevision.'); return; }
newSwitch({ label:'Profiling', description:'Shows a table with render times of all portlets on page.', changeCallback(instance, e){ updateSearchParam(PROFILING_PARAM,!instance.check()); }, checkCallback(){ const searchParams =getSearchParams();
// Profiling is active if a table exist at the top of body and contains the text "Profiling". returngetElement('body > div:not(.sv-layout) > table')?.textContent.trim().startsWith('Profiling'); } }).appendTo(switchesContainer);
newSwitch({ label:'Javascript Debug', description:'Disables minification and bundling of stylesheets and client scripts.', changeCallback(instance, e){ updateSearchParam(JSDEBUG_PARAM,!instance.check()); }, checkCallback(){ const searchParams =getSearchParams();
// Javascript Debug is deemed to be active if bundle files webapp-assets.js (requires at least one webapp visible) // and sv-template-asset.css (requires at least one css file on page/template). // Will fail if no custom css or webapp exists on the rendered page. return!( getElement('body > script[src$="/webapp-assets.js"]') ||getElement('head > link[href$="sv-template-asset.css"]') ); } }).appendTo(switchesContainer);
// Offline version is only usable by authenticated users. if(document.body.classList.contains('sv-editing-mode')||getElement('body > iframe[src*="/edit-editormenu/"]')){ newSwitch({ label:'Offline verison', description:'View the version used when editing in the Sitevision editor, but without the editor interface.', changeCallback(instance, e){ const searchParams =getSearchParams();
/** * Creates the HTML markup for an envision dialog. * * @param {object} options An object literal with options. * @param {string} options.dialogId A unique html ID for the dialog. * @param {string} options.title * @returns {string} */
/** * Shortcut for Document.getElementById() for improved minification. * * @param {string} id An identifier for an HTMLElement. * @returns {(HTMLElement|null)} */ el(id){ returnDOCUMENT.getElementById(id); }
/** * Initializes the dialog if it hasn't already been initialized. * * @param {(Function|String|HTMLElement)} initialContent * @returns {Dialog} Returns self for chainability. */ init(initialContent){ const dialogId =this.id; const titleId =this.tid;