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'); } } });