Skip to content

Commit

Permalink
BUILD
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 22, 2022
1 parent c32c8b0 commit fc96cc8
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 102 deletions.
Original file line number Diff line number Diff line change
@@ -1,63 +1,66 @@

function addNextButton() {
var id = 'rxdb-custon-next-button';
function runAddingNextButtons() {

var alreadyThere = document.querySelector('#' + id);
if (alreadyThere) {
console.log('custom next button already there.');
return;
}

var block = document.querySelector('.normal.markdown-section');
console.dir(block);
function addNextButton() {
var id = 'rxdb-custon-next-button';

var alreadyThere = document.querySelector('#' + id);
if (alreadyThere) {
return;
}
console.log('custom next button NOT already there.');


var block = document.querySelector('.normal.markdown-section');
console.dir(block);

var path = window.location.pathname;
var page = path.split('/').pop();
console.log('page: ' + page);

var path = window.location.pathname;
var page = path.split('/').pop();
console.log('page: ' + page);
var chapters = document.querySelectorAll('.chapter');
var dataPaths = [];
chapters.forEach(function (chapter) {
var dataPath = chapter.dataset.path;
if (dataPath) {
dataPaths.push(dataPath);
}
});

var chapters = document.querySelectorAll('.chapter');
var dataPaths = [];
chapters.forEach(function (chapter) {
var dataPath = chapter.dataset.path;
if (dataPath) {
dataPaths.push(dataPath);
var lastIndex = dataPaths.lastIndexOf(page);
console.dir('dataPaths:');
console.dir(dataPaths);
var nextPath = dataPaths[lastIndex + 1];
console.log('nexdtPath: ' + nextPath);
if (!nextPath) {
return;
}
});

var lastIndex = dataPaths.lastIndexOf(page);
console.dir('dataPaths:');
console.dir(dataPaths);
var nextPath = dataPaths[lastIndex + 1];
console.log('nexdtPath: ' + nextPath);
if (!nextPath) {
return;
}

var hr = document.createElement('hr');
block.appendChild(hr);

console.log('# Add next button');
var span = document.createElement('p');
span.id = id;
span.innerHTML = 'If you are new to RxDB, you should continue ';
var link = document.createElement('a');
link.href = nextPath;
link.innerHTML = 'here';
span.appendChild(link);
block.appendChild(span);
}
var hr = document.createElement('hr');
block.appendChild(hr);

console.log('# Add next button');
var span = document.createElement('p');
span.id = id;
span.innerHTML = 'If you are new to RxDB, you should continue ';
var link = document.createElement('a');
link.href = nextPath;
link.innerHTML = 'here';
span.appendChild(link);
block.appendChild(span);
}

addNextButton();
addNextButton();

/**
* Gitbook does a strange page change handling,
* so we have to re-run on history state changes.
*/
history.pushState = function () {
console.log('history.pushState()');
setTimeout(function () {
/**
* Gitbook does a strange page change handling,
* so we have to re-run the function
* because listening to history changes did not work.
*/
setInterval(function () {
addNextButton();
}, 100);
};


}
runAddingNextButtons();
105 changes: 54 additions & 51 deletions docs/next-button.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,66 @@

function addNextButton() {
var id = 'rxdb-custon-next-button';
function runAddingNextButtons() {

var alreadyThere = document.querySelector('#' + id);
if (alreadyThere) {
console.log('custom next button already there.');
return;
}

var block = document.querySelector('.normal.markdown-section');
console.dir(block);
function addNextButton() {
var id = 'rxdb-custon-next-button';

var alreadyThere = document.querySelector('#' + id);
if (alreadyThere) {
return;
}
console.log('custom next button NOT already there.');


var block = document.querySelector('.normal.markdown-section');
console.dir(block);

var path = window.location.pathname;
var page = path.split('/').pop();
console.log('page: ' + page);

var path = window.location.pathname;
var page = path.split('/').pop();
console.log('page: ' + page);
var chapters = document.querySelectorAll('.chapter');
var dataPaths = [];
chapters.forEach(function (chapter) {
var dataPath = chapter.dataset.path;
if (dataPath) {
dataPaths.push(dataPath);
}
});

var chapters = document.querySelectorAll('.chapter');
var dataPaths = [];
chapters.forEach(function (chapter) {
var dataPath = chapter.dataset.path;
if (dataPath) {
dataPaths.push(dataPath);
var lastIndex = dataPaths.lastIndexOf(page);
console.dir('dataPaths:');
console.dir(dataPaths);
var nextPath = dataPaths[lastIndex + 1];
console.log('nexdtPath: ' + nextPath);
if (!nextPath) {
return;
}
});

var lastIndex = dataPaths.lastIndexOf(page);
console.dir('dataPaths:');
console.dir(dataPaths);
var nextPath = dataPaths[lastIndex + 1];
console.log('nexdtPath: ' + nextPath);
if (!nextPath) {
return;
}

var hr = document.createElement('hr');
block.appendChild(hr);

console.log('# Add next button');
var span = document.createElement('p');
span.id = id;
span.innerHTML = 'If you are new to RxDB, you should continue ';
var link = document.createElement('a');
link.href = nextPath;
link.innerHTML = 'here';
span.appendChild(link);
block.appendChild(span);
}
var hr = document.createElement('hr');
block.appendChild(hr);

console.log('# Add next button');
var span = document.createElement('p');
span.id = id;
span.innerHTML = 'If you are new to RxDB, you should continue ';
var link = document.createElement('a');
link.href = nextPath;
link.innerHTML = 'here';
span.appendChild(link);
block.appendChild(span);
}

addNextButton();
addNextButton();

/**
* Gitbook does a strange page change handling,
* so we have to re-run on history state changes.
*/
history.pushState = function () {
console.log('history.pushState()');
setTimeout(function () {
/**
* Gitbook does a strange page change handling,
* so we have to re-run the function
* because listening to history changes did not work.
*/
setInterval(function () {
addNextButton();
}, 100);
};


}
runAddingNextButtons();

0 comments on commit fc96cc8

Please sign in to comment.