Skip to content

Commit

Permalink
Examples in same window
Browse files Browse the repository at this point in the history
  • Loading branch information
DirkThalheim committed Feb 5, 2019
1 parent e894d13 commit 44e809d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions examples/resources/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ var linksList = [

var examplesDiv = document.getElementById('bkgwebmap-examples-main');

if (window.location.hash !== '') {
var pageName = window.location.hash;
examplesDiv.appendChild(findExamplePage(pageName));
var url = new URL(window.location);
var page = url.searchParams.get('id');
if (page != null) {
examplesDiv.appendChild(findExamplePage(page));
} else {
examplesDiv.appendChild(createLinks());
}
Expand All @@ -249,11 +250,11 @@ function createLinks() {
linksList = linksList.sort(function(a,b) {return a.title.localeCompare(b.title);});

for (var i = 0; i < linksList.length; i++) {
url = window.location + '#' + linksList[i].filename;
url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?id=' + linksList[i].filename;

link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('target', '_blank');
link.setAttribute('target', '_self');

span1 = document.createElement('span');
span1.className = 'bkgwebmap-examples-title';
Expand Down Expand Up @@ -318,7 +319,7 @@ function findExamplePage(pageName) {
var pageFound = false;
var page;
for (var i = 0; i < linksList.length; i++) {
if (pageName === '#' + linksList[i].filename) {
if (pageName === linksList[i].filename) {
pageFound = true;
page = linksList[i];
}
Expand Down

0 comments on commit 44e809d

Please sign in to comment.