From a3827aca5f9d0e021bc94a00e4f022982e4a3db6 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 11 Jul 2023 12:50:36 +0300 Subject: (presentation) Implemented changing label on article mode button and query inside URL when in article mode So you could share a presentation as an article --- src/scripts/presentation.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/scripts') diff --git a/src/scripts/presentation.js b/src/scripts/presentation.js index 8dd4960..484961e 100644 --- a/src/scripts/presentation.js +++ b/src/scripts/presentation.js @@ -115,7 +115,22 @@ function toggleArticleMode() { presentBtn.classList.toggle('nodisplay'); // Toggle presentation.css document.styleSheets.item(3).disabled = !document.styleSheets.item(3).disabled; + + // Add a=y to url when in article mode + var url = window.location.href.substring(0, window.location.href.indexOf('?')); + if (document.styleSheets.item(3).disabled) url += '?a=y'; + url += window.location.href.substr(window.location.href.indexOf('#')); + + window.history.replaceState(history.state, document.title, url); + + // Fix message + if (articleBtn.innerHTML[0] === 'A') + articleBtn.innerHTML = 'Slide' + articleBtn.innerHTML.substr(7); + else + articleBtn.innerHTML = 'Article' + articleBtn.innerHTML.substr(5); } articleBtn.addEventListener('click', toggleArticleMode); window.addEventListener('load', function() { + if (window.location.href.substr(window.location.href.indexOf('?'), 4) === '?a=y') + toggleArticleMode(); }); -- cgit v1.3.1-23-gd82d