summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Hallot <olivier.hallot@libreoffice.org>2023-09-25 13:55:57 -0300
committerMichael Stahl <michael.stahl@allotropia.de>2023-09-27 12:44:22 +0200
commitc10e043fdaf6ed01727d99dfa3bcccd49ba9c527 (patch)
treeed05eda72cb35191dbcb498cabf927d5059a8e07
parentLibreOffice 7.6 video (diff)
downloadhelp-c10e043fdaf6ed01727d99dfa3bcccd49ba9c527.tar.gz
help-c10e043fdaf6ed01727d99dfa3bcccd49ba9c527.zip
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> (cherry picked from commit 0c24f409c31e4ca8a85b6a1486e2c6eaf26942d6) Reviewed-on: https://gerrit.libreoffice.org/c/help/+/157221 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--CustomTarget_html.mk6
-rw-r--r--Package_html_dynamic.mk1
-rw-r--r--help3xsl/help2.js79
-rw-r--r--help3xsl/online_transform.xsl3
-rw-r--r--help3xsl/tdf_matomo.js24
5 files changed, 67 insertions, 46 deletions
diff --git a/CustomTarget_html.mk b/CustomTarget_html.mk
index e73ea160e0..ac3f21956a 100644
--- a/CustomTarget_html.mk
+++ b/CustomTarget_html.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_CustomTarget_register_targets,helpcontent2/help3xsl,\
languages.js \
default.css \
help2.js \
+ $(if $(HELP_ONLINE),tdf_matomo.js) \
$(foreach lang,$(gb_HELP_LANGS),\
$(lang)/bookmarks.js \
$(lang)/contents.js \
@@ -331,4 +332,9 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/help2.js : \
$(BUILDDIR)/config_host.mk
sed -e "s/%PRODUCTNAME/$(gb_PRODUCTNAME_JS)/g" $< > $@
+$(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/tdf_matomo.js : \
+ $(SRCDIR)/helpcontent2/help3xsl/tdf_matomo.js
+ mkdir -p $(dir $@)
+ cp $(SRCDIR)/helpcontent2/help3xsl/tdf_matomo.js $@
+
# vim: set noet sw=4 ts=4:
diff --git a/Package_html_dynamic.mk b/Package_html_dynamic.mk
index 6e23cf892e..b7d3e8082f 100644
--- a/Package_html_dynamic.mk
+++ b/Package_html_dynamic.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_Package_add_files,helpcontent2_html_dynamic,$(LIBO_SHARE_HELP_F
languages.js \
default.css \
help2.js \
+ $(if $(HELP_ONLINE),tdf_matomo.js) \
))
# vim: set noet sw=4 ts=4:
diff --git a/help3xsl/help2.js b/help3xsl/help2.js
index 728453134b..0d2f0524a1 100644
--- a/help3xsl/help2.js
+++ b/help3xsl/help2.js
@@ -95,20 +95,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) {
@@ -213,33 +199,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";
@@ -248,15 +207,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: */