[gi-docgen/ebassi/devhelp: 2/2] template: Detect DevHelp's user agent
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gi-docgen/ebassi/devhelp: 2/2] template: Detect DevHelp's user agent
- Date: Wed, 7 Apr 2021 13:54:39 +0000 (UTC)
commit a2512f8771daa28e0d8a8fea7bd91603ea57b523
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Apr 7 13:25:47 2021 +0100
template: Detect DevHelp's user agent
For instance: do not bother loading the search index when using DevHelp,
as DevHelp already has its own search functionality. The sidebar is also
not visible, so it won't be possible to search through it.
gidocgen/templates/basic/main.js | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gidocgen/templates/basic/main.js b/gidocgen/templates/basic/main.js
index 46f03fb..4ea9f56 100644
--- a/gidocgen/templates/basic/main.js
+++ b/gidocgen/templates/basic/main.js
@@ -68,6 +68,10 @@ function getSearchInput() {
return document.getElementsByClassName("search-input")[0];
}
+function getSidebar() {
+ return document.getElementsByClassName("sidebar")[0];
+}
+
function getQueryStringParams() {
var params = {};
window.location.search.substring(1).split('&').
@@ -438,6 +442,7 @@ window.addEventListener("load", function() {
var main = document.getElementById("main");
var btnToTop = document.getElementById("btn-to-top");
+ var sidebar = getSidebar();
var searchInput = getSearchInput();
function labelForToggleButton(isCollapsed) {
@@ -553,8 +558,11 @@ window.addEventListener("load", function() {
});
}
- if (window.buildIndex) {
- window.buildIndex('index.json');
+ // Don't bother loading the search index when using DevHelp
+ if (navigator.userAgent.indexOf("DevHelp") === -1) {
+ if (window.buildIndex) {
+ window.buildIndex('index.json');
+ }
}
}, false);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]