-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c32c8b0
commit fc96cc8
Showing
2 changed files
with
108 additions
and
102 deletions.
There are no files selected for viewing
105 changes: 54 additions & 51 deletions
105
docs/gitbook/gitbook-plugin-scripts/9bc541ba5d318730a5b44c9770ae18fc-next-button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |