From 644337184c43da5f4a3434cc7cadc2606c01b99f Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 31 Jul 2022 13:37:10 -0600 Subject: [PATCH 1/2] Remove Google Analytics and cookie consent --- .../jsdoc/api/template/static/scripts/main.js | 22 +++--- config/jsdoc/api/template/tmpl/layout.tmpl | 57 -------------- examples/templates/example.html | 75 +++---------------- 3 files changed, 20 insertions(+), 134 deletions(-) diff --git a/config/jsdoc/api/template/static/scripts/main.js b/config/jsdoc/api/template/static/scripts/main.js index a94b8bb419..b21d56431a 100644 --- a/config/jsdoc/api/template/static/scripts/main.js +++ b/config/jsdoc/api/template/static/scripts/main.js @@ -275,28 +275,28 @@ $(function () { }); // warn about outdated version - var currentVersion = document.getElementById('package-version').innerHTML; - var packageUrl = 'https://raw.githubusercontent.com/openlayers/openlayers.github.io/build/package.json'; + const currentVersion = document.getElementById('package-version').innerHTML; + const packageUrl = 'https://raw.githubusercontent.com/openlayers/openlayers.github.io/build/package.json'; fetch(packageUrl).then(function(response) { return response.json(); }).then(function(json) { - var latestVersion = json.version; + const latestVersion = json.version; document.getElementById('latest-version').innerHTML = latestVersion; - var url = window.location.href; - var branchSearch = url.match(/\/([^\/]*)\/apidoc\//); - var cookieText = 'dismissed=-' + latestVersion + '-'; - var dismissed = document.cookie.indexOf(cookieText) != -1; + const url = window.location.href; + const branchSearch = url.match(/\/([^\/]*)\/apidoc\//); + const storageKey = 'dismissed=-' + latestVersion; + const dismissed = localStorage.getItem(storageKey) === 'true'; if (branchSearch && !dismissed && /^v[0-9\.]*$/.test(branchSearch[1]) && currentVersion != latestVersion) { - var link = url.replace(branchSearch[0], '/latest/apidoc/'); + const link = url.replace(branchSearch[0], '/latest/apidoc/'); fetch(link, {method: 'head'}).then(function(response) { - var a = document.getElementById('latest-link'); + const a = document.getElementById('latest-link'); a.href = response.status == 200 ? link : '../../latest/apidoc/'; }); - var latestCheck = document.getElementById('latest-check'); + const latestCheck = document.getElementById('latest-check'); latestCheck.style.display = ''; document.getElementById('latest-dismiss').onclick = function() { latestCheck.style.display = 'none'; - document.cookie = cookieText; + localStorage.setItem(storageKey, 'true'); } } }); diff --git a/config/jsdoc/api/template/tmpl/layout.tmpl b/config/jsdoc/api/template/tmpl/layout.tmpl index 6f338d4664..5c6f1ef00f 100644 --- a/config/jsdoc/api/template/tmpl/layout.tmpl +++ b/config/jsdoc/api/template/tmpl/layout.tmpl @@ -5,63 +5,6 @@ var version = obj.packageInfo.version; - - - - - - - OpenLayers v<?js= version ?> API - <?js= title ?> diff --git a/examples/templates/example.html b/examples/templates/example.html index 145aee08b9..9d0017d922 100644 --- a/examples/templates/example.html +++ b/examples/templates/example.html @@ -4,64 +4,7 @@ - - - - - - - @@ -238,27 +181,27 @@ modal.find('.modal-body').html(content); }); - var packageUrl = 'https://raw.githubusercontent.com/openlayers/openlayers.github.io/build/package.json'; + const packageUrl = 'https://raw.githubusercontent.com/openlayers/openlayers.github.io/build/package.json'; fetch(packageUrl).then(function(response) { return response.json(); }).then(function(json) { - var latestVersion = json.version; + const latestVersion = json.version; document.getElementById('latest-version').innerHTML = latestVersion; - var url = window.location.href; - var branchSearch = url.match(/\/([^\/]*)\/examples\//); - var cookieText = 'dismissed=-' + latestVersion + '-'; - var dismissed = document.cookie.indexOf(cookieText) != -1; + const url = window.location.href; + const branchSearch = url.match(/\/([^\/]*)\/examples\//); + const storageKey = 'ol-dismissed=-' + latestVersion; + const dismissed = localStorage.getItem(storageKey) === 'true'; if (branchSearch && !dismissed && /^v[0-9\.]*$/.test(branchSearch[1]) && '{{ olVersion }}' != latestVersion) { var link = url.replace(branchSearch[0], '/latest/examples/'); fetch(link, {method: 'head'}).then(function(response) { - var a = document.getElementById('latest-link'); + const a = document.getElementById('latest-link'); a.href = response.status == 200 ? link : '../../latest/examples/'; }); - var latestCheck = document.getElementById('latest-check'); + const latestCheck = document.getElementById('latest-check'); latestCheck.style.display = ''; document.getElementById('latest-dismiss').onclick = function() { latestCheck.style.display = 'none'; - document.cookie = cookieText; + localStorage.setItem(storageKey, 'true'); } } }); From 8cb423d1d1b5df798fe52616999cbc11a264af28 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 31 Jul 2022 14:01:31 -0600 Subject: [PATCH 2/2] Avoid uncaught type error --- config/jsdoc/api/template/static/scripts/main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/jsdoc/api/template/static/scripts/main.js b/config/jsdoc/api/template/static/scripts/main.js index b21d56431a..881d20d1a4 100644 --- a/config/jsdoc/api/template/static/scripts/main.js +++ b/config/jsdoc/api/template/static/scripts/main.js @@ -87,8 +87,10 @@ $(function () { manualToggles = {}; const lastTerm = search.lastSearchTerm; search.lastSearchTerm = undefined; - const fa = currentItem.querySelector('.title > .fa'); - fa.classList.add('no-transition'); + if (currentItem) { + const fa = currentItem.querySelector('.title > .fa'); + fa.classList.add('no-transition'); + } doSearch(lastTerm || ''); // Transfer manual toggle state to newly loaded current node