diff options
author | Olivier Hallot <olivier.hallot@libreoffice.org> | 2023-09-25 13:55:57 -0300 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2023-09-26 09:05:22 +0200 |
commit | 0c24f409c31e4ca8a85b6a1486e2c6eaf26942d6 (patch) | |
tree | 052841cb47953aa697e9a379c0c6ac5ef61f4913 /help3xsl | |
parent | 491f223b3e7a1b272d3050fbaa84be897ef45c2d (diff) |
tdf#157360 Local help should not phone home
+ Remove call to matomo TDF server instance when help is local
+ Keep when Help is online.
+ refactor javascript
Change-Id: I285b426531c91ff558c01798f803bf3f89720b1f
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/157255
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Diffstat (limited to 'help3xsl')
-rw-r--r-- | help3xsl/help2.js | 79 | ||||
-rw-r--r-- | help3xsl/online_transform.xsl | 3 | ||||
-rw-r--r-- | help3xsl/tdf_matomo.js | 24 |
3 files changed, 60 insertions, 46 deletions
diff --git a/help3xsl/help2.js b/help3xsl/help2.js index 8bf2810293..df11cb5210 100644 --- a/help3xsl/help2.js +++ b/help3xsl/help2.js @@ -98,20 +98,6 @@ function moduleColor (module) { } } -// Find spans that need the switch treatment and give it to them -var spans = document.querySelectorAll("[class^=switch]"); -var n = spans.length; -for (z = 0; z < n; z++) { - var id = spans[z].getAttribute("id"); - if (id === null) { - continue; - } - else if (id.startsWith("swlnsys")) { - setSystemSpan(spans[z]); - } else { - setApplSpan(spans[z]); - } -} /* add &DbPAR= and &System= to the links in DisplayArea div */ /* skip for object files */ function fixURL(module, system) { @@ -216,33 +202,6 @@ function setupLanguages(page) { } } -// Test, if we are online -if (document.body.getElementsByTagName('meta')) { - var _paq = _paq || []; - /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ - _paq.push(['disableCookies']); - _paq.push(['trackPageView']); - _paq.push(['enableLinkTracking']); - (function() { - var u="//piwik.documentfoundation.org/"; - _paq.push(['setTrackerUrl', u+'piwik.php']); - _paq.push(['setSiteId', '68']); - var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); - })(); - var system = getParameterByName("System"); -} else { - var system = getSystem(); -} - -var module = getParameterByName("DbPAR"); -fixURL(module,system); -moduleColor(module); -var helpID = getParameterByName("HID"); -// only used in xhp pages with <help-id-missing/> tags -var missingElement = document.getElementById("bm_HID2"); -if(missingElement != null){missingElement.innerHTML = helpID;} - function debugInfo(dbg) { if (dbg == null) return; document.getElementById("DEBUG").style.display = "block"; @@ -251,15 +210,43 @@ function debugInfo(dbg) { document.getElementById("bm_HID").innerHTML = "HID is: "+helpID; } +// Find spans that need the switch treatment and give it to them +function impl_Switches(){ + + let spans = document.querySelectorAll("[class^=switch]"); + let n = spans.length; + for (let z = 0; z < n; z++) { + let id = spans[z].getAttribute("id"); + if (id === null) { + continue; + } + else if (id.startsWith("swlnsys")) { + setSystemSpan(spans[z]); + } else { + setApplSpan(spans[z]); + } + } +} +// Main +let module = getParameterByName("DbPAR"); +let system = getParameterByName("System"); +let helpID = getParameterByName("HID"); +impl_Switches(); +fixURL(module,system); +moduleColor(module); +// only used in xhp pages with <help-id-missing/> tags +let missingElement = document.getElementById("bm_HID2"); +if(missingElement != null){missingElement.innerHTML = helpID;} + debugInfo(getParameterByName("Debug")); // Mobile devices need the modules and langs on page load if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) < 960) { - var e = new Event('click'); - var modulesBtn = document.getElementById('modules'); - var langsBtn = document.getElementById('langs'); - var modules = document.getElementById('modules-nav'); - var langs = document.getElementById('langs-nav'); + let e = new Event('click'); + let modulesBtn = document.getElementById('modules'); + let langsBtn = document.getElementById('langs'); + let modules = document.getElementById('modules-nav'); + let langs = document.getElementById('langs-nav'); modules.setAttribute('data-a11y-toggle-open', ''); modulesBtn.dispatchEvent(e); if (langs) { diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl index 856dccbde0..aaa56175d8 100644 --- a/help3xsl/online_transform.xsl +++ b/help3xsl/online_transform.xsl @@ -164,6 +164,9 @@ <script type="text/javascript" src="flexsearch.debug.js"></script> <script type="text/javascript" src="prism.js"></script> <script type="text/javascript" src="help2.js" defer=""></script> + <xsl:if test="$online"> + <script type="text/javascript" src="tdf_matomo.js" defer=""></script> + </xsl:if> <script type="text/javascript" src="a11y-toggle.js" defer=""></script> <script type="text/javascript" src="paginathing.js" defer=""></script> <script type="text/javascript" src="{$lang}/bookmarks.js" defer=""></script> diff --git a/help3xsl/tdf_matomo.js b/help3xsl/tdf_matomo.js new file mode 100644 index 0000000000..fb05d9e188 --- /dev/null +++ b/help3xsl/tdf_matomo.js @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +// Test, if we are online +if (document.body.getElementsByTagName('meta')) { + var _paq = _paq || []; + /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ + _paq.push(['disableCookies']); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="//piwik.documentfoundation.org/"; + _paq.push(['setTrackerUrl', u+'piwik.php']); + _paq.push(['setSiteId', '68']); + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); + })(); +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |