1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-24 06:59:52 +01:00

vueui: make session storage zoom level for current url be standardized

This commit is contained in:
Ivan Velev 2021-09-20 12:31:54 -07:00
parent 0d5fc7034c
commit 180d3f779d
2 changed files with 23 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -71,6 +71,12 @@ export default {
mounted: function() { mounted: function() {
this.init(); this.init();
}, },
computed: {
sessionStorageUrlKey() {
// remove http(s), www and trailing slash
return 'zoom__' + this.config.url.replace(/^https?:\/\/(www\.)?/, '').replace(/\/$/, '');
}
},
methods: { methods: {
gotoPeriod: function(newPeriod/*, initiator*/) { gotoPeriod: function(newPeriod/*, initiator*/) {
if (this.timelineHighlight) { if (this.timelineHighlight) {
@ -84,7 +90,9 @@ export default {
// save current period (aka zoom) // save current period (aka zoom)
// use sessionStorage (not localStorage), as we want this to be a very temporary memory for current page tab/window and no longer; NOTE: it serves when navigating from an "*" query to a specific capture and subsequent reloads // use sessionStorage (not localStorage), as we want this to be a very temporary memory for current page tab/window and no longer; NOTE: it serves when navigating from an "*" query to a specific capture and subsequent reloads
if (window.sessionStorage) { if (window.sessionStorage) {
window.sessionStorage.setItem('zoom__'+this.config.url, newPeriod.fullId); console.log(this.sessionStorageUrlKey);
window.sessionStorage.setItem(this.sessionStorageUrlKey, newPeriod.fullId);
console.log(this.sessionStorageUrlKey);
} }
this.currentPeriod = newPeriod; this.currentPeriod = newPeriod;
} }
@ -107,7 +115,7 @@ export default {
this.setSnapshot(this.config.initialView); this.setSnapshot(this.config.initialView);
} }
if (window.sessionStorage) { if (window.sessionStorage) {
const currentPeriodId = window.sessionStorage.getItem('zoom__'+this.config.url); const currentPeriodId = window.sessionStorage.getItem(this.sessionStorageUrlKey);
if (currentPeriodId) { if (currentPeriodId) {
const newCurrentPeriodFromStorage = this.currentPeriod.findByFullId(currentPeriodId); const newCurrentPeriodFromStorage = this.currentPeriod.findByFullId(currentPeriodId);
if (newCurrentPeriodFromStorage) { if (newCurrentPeriodFromStorage) {