Skip to content

Commit

Permalink
Optimisation pour les PWA
Browse files Browse the repository at this point in the history
  • Loading branch information
LGD-Fr committed Jun 18, 2024
1 parent 05e52ed commit 8002d8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const mutations = {
const displayMode = myStorage.getItem('displayMode')
if (displayMode === 'onePage' || displayMode === 'twoPages')
state.displayMode = displayMode
state.showNavBar = !(myStorage.getItem('showNavBar') === 'false')
const z = myStorage.getItem('zoom')
if (z) {
zoom = parseInt(z)
Expand All @@ -172,6 +173,7 @@ const mutations = {
*/
toggleNavBar (state) {
state.showNavBar = !state.showNavBar
myStorage.setItem('showNavBar', state.showNavBar)
},
/**
* Display with one or two pages.
Expand Down Expand Up @@ -618,6 +620,7 @@ const getters = {
const hash = `#/${state.currentBook}/${state.currentPage}`
window.location.hash = hash
CANONICAL_NODE.setAttribute('href', `${CANONICAL}/${hash}`)
myStorage.setItem('lastLocationHash', hash)
return hash
},
/**
Expand Down Expand Up @@ -659,7 +662,10 @@ const actions = {
.then(response => response.json())
.then(indexData => {
var currentBook = indexData.default
var currentPage = null
var currentPage = null
if (location.hash === '') {
locationHash = myStorage.getItem('lastLocationHash')
}
if (locationHash && (m = locationHash.match(/#\/(.+)\/(.+)/))) {
locationBook = m[1]
if (indexData.books.find(a => a[0] === locationBook)) {
Expand Down Expand Up @@ -818,6 +824,11 @@ fetchXHR(`${UI_ENV.uiPath}/ui.html`)
window.addEventListener('keydown', this.keyListener)
},
mounted () {
if (window.matchMedia('(display-mode: standalone)').matches) {
let button = document.getElementById('newTabButton')
if (button)
button.parentNode.removeChild(button)
}
// Sets up the swipe navigation.
const swipeElement = document.getElementById('hammer');
if (swipeElement == null)
Expand Down
2 changes: 1 addition & 1 deletion ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@

 

<button onclick="window.open(window.location, '_blank').focus()"
<button id="newTabButton" onclick="window.open(window.location, '_blank').focus()"
title="Ouvrir un nouvel onglet (o|t)">

📑
Expand Down

0 comments on commit 8002d8e

Please sign in to comment.