1234567891011121314151617181920212223242526272829303132333435363738 |
- // fonctionnalité pour accéder directement à une page voulue
- if (debug) console.log('start jumpToPage');
- (function() {
- let uiContent = document.querySelector('.uiContent');
- let jumpToPageContainer = document.createElement('div');
- jumpToPageContainer.classList.add('jumpToPage');
- let jumpToPageTitle = document.createElement('div');
- jumpToPageTitle.innerText = "Aller à la page"
- let userInput = document.createElement('input');
- userInput.setAttribute('type', 'text');
- userInput.addEventListener('keydown', function(event) {
- if (event.key === "Enter") {
- jumpToPage(this.value);
- userInput.value = "";
- }
- });
- jumpToPageContainer.append(jumpToPageTitle);
- jumpToPageContainer.append(userInput);
- uiContent.append(jumpToPageContainer);
- function jumpToPage(pageNumber) {
- if (/^\d+$/.test(pageNumber)) {
- pageNumber = parseInt(pageNumber);
- let pagesArray = document.querySelectorAll('.pagedjs_page')
- if (pageNumber <= pagesArray.length) {
- pagesArray[pageNumber - 1].scrollIntoView({ behavior: "smooth", block: "start" });
- }
- }
- }
- })();
- if (debug) console.log('end jumpToPage');
|