collection fixes:
- default to pages tab if story not available - fix location bar
This commit is contained in:
+8
-6
@@ -198,6 +198,10 @@ class Coll extends LitElement
|
||||
...this.tabData, view
|
||||
};
|
||||
}
|
||||
|
||||
if (!this.hasStory && this.tabData.view === "story") {
|
||||
this.tabData.view = "pages";
|
||||
}
|
||||
}
|
||||
|
||||
onTabClick(event) {
|
||||
@@ -646,21 +650,19 @@ class Coll extends LitElement
|
||||
}
|
||||
|
||||
navigateTo(value) {
|
||||
if (value.startsWith("http://") || value.startsWith("https://")) {
|
||||
this.url = value;
|
||||
this._replaceLoc = !this._locUpdateNeeded;
|
||||
this._locUpdateNeeded = true;
|
||||
let data;
|
||||
|
||||
if (value.startsWith("http://") || value.startsWith("https://")) {
|
||||
data = {url: value, view: "replay"};
|
||||
} else {
|
||||
let data;
|
||||
if (!value.startsWith(RWP_SCHEME)) {
|
||||
data = {query: value, view: "pages"};
|
||||
} else {
|
||||
data = this._stringToParams(value);
|
||||
}
|
||||
//this.dispatchEvent(new CustomEvent("coll-tab-nav", {detail: {replaceLoc: false, data}}));
|
||||
this.updateTabData(data);
|
||||
}
|
||||
this.updateTabData(data);
|
||||
}
|
||||
|
||||
_stringToParams(value) {
|
||||
|
||||
@@ -635,7 +635,7 @@ const ae=new WeakMap,oe=v(e=>t=>{if(!(t instanceof T))throw new Error("unsafeSVG
|
||||
`}
|
||||
</nav>
|
||||
</section>
|
||||
`}onCopy(e,t){return e.preventDefault(),e.stopPropagation(),navigator.clipboard.writeText(t),!1}}customElements.define("wr-coll-index",We);var Ve=i(97),Ke=i.n(Ve),Ze=i(58),Je=i.n(Ze),Ye=i(98),Qe=i.n(Ye),Xe=i(99),et=i.n(Xe),tt=i(59),it=i.n(tt),at=i(60),ot=i.n(at),rt=i(61),nt=i.n(rt),st=i(100),lt=i.n(st);class ct extends ie{constructor(){super(),this.sourceUrl=null,this.inited=!1,this.isLoading=!1,this.baseApiPrefix="./wabac/api",this.baseReplayPrefix="./wabac",this.apiPrefix="",this.replayPrefix="",this.coll="",this.collInfo=null,this._replaceLoc=!1,this._locUpdateNeeded=!1,this._locationHash="",this.tabData={},this.url="",this.ts="",this.tabNames=["pages","story","resources","replay"],this.menuActive=!1,this.hasStory=!1,this.editable=!1}static get properties(){return{inited:{type:Boolean},sourceUrl:{type:String},loadInfo:{type:Object,attribute:!1},collInfo:{type:Object,attribute:!1},coll:{type:String},hasStory:{type:Boolean},isLoading:{type:Boolean},tabData:{type:Object,attribute:!1},url:{type:String},ts:{type:String},isFullscreen:{type:Boolean},menuActive:{type:Boolean},embed:{type:String},editable:{type:Boolean}}}firstUpdated(){this.inited=!0,window.addEventListener("hashchange",e=>this.onHashChange(e)),this.addEventListener("fullscreenchange",e=>{this.isFullscreen=!!document.fullscreenElement})}updated(e){if(e.has("sourceUrl")&&this.doUpdateInfo(),e.has("tabData")){if(!this.collInfo||!this.collInfo.coll)return;Object.keys(this.tabData).forEach(e=>!this.tabData[e]&&delete this.tabData[e]);const t="#"+new URLSearchParams(this.tabData).toString();if("replay"!==this.tabData.view&&(this.url="search://"+decodeURIComponent(this._paramsToString(this.tabData))),t!==this._locationHash){if(this._locationHash=t,this._replaceLoc||0===Object.keys(e.get("tabData")).length){const e=new URL(window.location.href);e.hash=this._locationHash,window.history.replaceState({},"",e.href),this._replaceLoc=!1}else window.location.hash=this._locationHash;this.embed&&window.parent!==window&&window.parent.postMessage(this.tabData,"*")}this._locUpdateNeeded=!1}}async doUpdateInfo(){let e=this.loadInfo&&this.loadInfo.customColl;if(!e){e=(await $e(this.sourceUrl)).coll}this.coll=e;const t=this.baseApiPrefix+"/"+e,i=this.baseReplayPrefix+"/"+e,a=await fetch(t+"?all=1");if(200!=a.status)return void(this.collInfo={});const o=await a.json();this.collInfo={apiPrefix:t,replayPrefix:i,coll:e,...o},this.collInfo.title||(this.collInfo.title=this.collInfo.filename),this.hasStory=this.collInfo.desc||this.collInfo.lists.length,this.dispatchEvent(new CustomEvent("coll-loaded",{detail:{collInfo:this.collInfo,alreadyLoaded:!0}})),this.onHashChange()}onCollLoaded(e){this.doUpdateInfo(),this.loadInfo=null,this.dispatchEvent(new CustomEvent("coll-loaded",{detail:{sourceUrl:this.sourceUrl,collInfo:this.collInfo}}))}onHashChange(e){const t=window.location.hash;if(t&&t!==this._locationHash&&(this.tabData=Object.fromEntries(new URLSearchParams(t.slice(1)).entries()),this._locationHash=t),this.collInfo.coll&&!this.tabNames.includes(this.tabData.view)){const e=this.hasStory?"story":this.collInfo.pages.length?"pages":"resources";this.tabData={...this.tabData,view:e}}}onTabClick(e){e.preventDefault();const t=e.currentTarget.getAttribute("href");return this.tabData={...this.tabData,view:t.slice(1)},!1}onCollTabNav(e){e.target.id===this.tabData.view&&this.updateTabData(e.detail.data,e.detail.replaceLoc)}updateTabData(e,t=!1){this.tabData={view:this.tabData.view,...e},this.tabData.url&&(this.url=this.tabData.url||""),this.tabData.ts&&(this.ts=this.tabData.ts||""),this._replaceLoc=!this._locUpdateNeeded&&t,this._locUpdateNeeded=!0}static get styles(){return be(ee`
|
||||
`}onCopy(e,t){return e.preventDefault(),e.stopPropagation(),navigator.clipboard.writeText(t),!1}}customElements.define("wr-coll-index",We);var Ve=i(97),Ke=i.n(Ve),Ze=i(58),Je=i.n(Ze),Ye=i(98),Qe=i.n(Ye),Xe=i(99),et=i.n(Xe),tt=i(59),it=i.n(tt),at=i(60),ot=i.n(at),rt=i(61),nt=i.n(rt),st=i(100),lt=i.n(st);class ct extends ie{constructor(){super(),this.sourceUrl=null,this.inited=!1,this.isLoading=!1,this.baseApiPrefix="./wabac/api",this.baseReplayPrefix="./wabac",this.apiPrefix="",this.replayPrefix="",this.coll="",this.collInfo=null,this._replaceLoc=!1,this._locUpdateNeeded=!1,this._locationHash="",this.tabData={},this.url="",this.ts="",this.tabNames=["pages","story","resources","replay"],this.menuActive=!1,this.hasStory=!1,this.editable=!1}static get properties(){return{inited:{type:Boolean},sourceUrl:{type:String},loadInfo:{type:Object,attribute:!1},collInfo:{type:Object,attribute:!1},coll:{type:String},hasStory:{type:Boolean},isLoading:{type:Boolean},tabData:{type:Object,attribute:!1},url:{type:String},ts:{type:String},isFullscreen:{type:Boolean},menuActive:{type:Boolean},embed:{type:String},editable:{type:Boolean}}}firstUpdated(){this.inited=!0,window.addEventListener("hashchange",e=>this.onHashChange(e)),this.addEventListener("fullscreenchange",e=>{this.isFullscreen=!!document.fullscreenElement})}updated(e){if(e.has("sourceUrl")&&this.doUpdateInfo(),e.has("tabData")){if(!this.collInfo||!this.collInfo.coll)return;Object.keys(this.tabData).forEach(e=>!this.tabData[e]&&delete this.tabData[e]);const t="#"+new URLSearchParams(this.tabData).toString();if("replay"!==this.tabData.view&&(this.url="search://"+decodeURIComponent(this._paramsToString(this.tabData))),t!==this._locationHash){if(this._locationHash=t,this._replaceLoc||0===Object.keys(e.get("tabData")).length){const e=new URL(window.location.href);e.hash=this._locationHash,window.history.replaceState({},"",e.href),this._replaceLoc=!1}else window.location.hash=this._locationHash;this.embed&&window.parent!==window&&window.parent.postMessage(this.tabData,"*")}this._locUpdateNeeded=!1}}async doUpdateInfo(){let e=this.loadInfo&&this.loadInfo.customColl;if(!e){e=(await $e(this.sourceUrl)).coll}this.coll=e;const t=this.baseApiPrefix+"/"+e,i=this.baseReplayPrefix+"/"+e,a=await fetch(t+"?all=1");if(200!=a.status)return void(this.collInfo={});const o=await a.json();this.collInfo={apiPrefix:t,replayPrefix:i,coll:e,...o},this.collInfo.title||(this.collInfo.title=this.collInfo.filename),this.hasStory=this.collInfo.desc||this.collInfo.lists.length,this.dispatchEvent(new CustomEvent("coll-loaded",{detail:{collInfo:this.collInfo,alreadyLoaded:!0}})),this.onHashChange()}onCollLoaded(e){this.doUpdateInfo(),this.loadInfo=null,this.dispatchEvent(new CustomEvent("coll-loaded",{detail:{sourceUrl:this.sourceUrl,collInfo:this.collInfo}}))}onHashChange(e){const t=window.location.hash;if(t&&t!==this._locationHash&&(this.tabData=Object.fromEntries(new URLSearchParams(t.slice(1)).entries()),this._locationHash=t),this.collInfo.coll&&!this.tabNames.includes(this.tabData.view)){const e=this.hasStory?"story":this.collInfo.pages.length?"pages":"resources";this.tabData={...this.tabData,view:e}}this.hasStory||"story"!==this.tabData.view||(this.tabData.view="pages")}onTabClick(e){e.preventDefault();const t=e.currentTarget.getAttribute("href");return this.tabData={...this.tabData,view:t.slice(1)},!1}onCollTabNav(e){e.target.id===this.tabData.view&&this.updateTabData(e.detail.data,e.detail.replaceLoc)}updateTabData(e,t=!1){this.tabData={view:this.tabData.view,...e},this.tabData.url&&(this.url=this.tabData.url||""),this.tabData.ts&&(this.ts=this.tabData.ts||""),this._replaceLoc=!this._locUpdateNeeded&&t,this._locUpdateNeeded=!0}static get styles(){return be(ee`
|
||||
.icon {
|
||||
vertical-align: text-top;
|
||||
}
|
||||
@@ -925,7 +925,7 @@ const ae=new WeakMap,oe=v(e=>t=>{if(!(t instanceof T))throw new Error("unsafeSVG
|
||||
class="${a?"":"is-hidden"}">
|
||||
</wr-coll-replay>
|
||||
`:""}
|
||||
`}onKeyDown(e){"Esc"!==e.key&&"Escape"!==e.key||(e.target.value=this.url)}onMenu(e){e.stopPropagation(),this.menuActive=!this.menuActive,this.menuActive&&document.addEventListener("click",()=>{this.menuActive=!1},{once:!0})}onFullscreenToggle(){this.menuActive=!1,this.isFullscreen?document.exitFullscreen():this.requestFullscreen()}onGoBack(){this.menuActive=!1,window.history.back()}onGoForward(){this.menuActive=!1,window.history.forward()}onGoPages(e){e.preventDefault(),this.tabData&&"replay"===this.tabData.view&&this.updateTabData({view:"pages"})}onReAuthed(e){this.reauthWait=(async()=>{const t=e.detail.headers;await fetch(this.collInfo.apiPrefix+"/updateAuth",{method:"POST",body:JSON.stringify({headers:t})});this.showAuth&&(this.onRefresh(null,!0),this.showAuth=!1)})()}async onPurgeCache(e){e.preventDefault();const t=await fetch(""+this.collInfo.apiPrefix,{method:"DELETE"});200===t.status&&window.parent?window.parent.location.reload():console.warn("purge failed: "+t.status)}onSubmit(e){e.preventDefault();const t=this.renderRoot.querySelector("input").value;return this.navigateTo(t),!1}navigateTo(e){if(e.startsWith("http://")||e.startsWith("https://"))this.url=e,this._replaceLoc=!this._locUpdateNeeded,this._locUpdateNeeded=!0;else{let t;t=e.startsWith("search://")?this._stringToParams(e):{query:e,view:"pages"},this.updateTabData(t)}}_stringToParams(e){const t=new URLSearchParams(e.slice("search://".length)),i={};for(const e of["query","view","currList","currMime","urlSearchType"])t.has(e)&&(i[e]=t.get(e));return i}_paramsToString(e){const t=new URLSearchParams;for(const i of["query","view","currList","currMime","urlSearchType"])i in e&&t.set(i,e[i]);return t.toString()}onRefresh(e,t){if(e&&e.preventDefault(),this.menuActive=!1,"replay"===this.tabData.view){const e=this.renderRoot.querySelector("wr-coll-replay");e&&e.refresh()}else window.location.reload()}}customElements.define("wr-coll",ct);
|
||||
`}onKeyDown(e){"Esc"!==e.key&&"Escape"!==e.key||(e.target.value=this.url)}onMenu(e){e.stopPropagation(),this.menuActive=!this.menuActive,this.menuActive&&document.addEventListener("click",()=>{this.menuActive=!1},{once:!0})}onFullscreenToggle(){this.menuActive=!1,this.isFullscreen?document.exitFullscreen():this.requestFullscreen()}onGoBack(){this.menuActive=!1,window.history.back()}onGoForward(){this.menuActive=!1,window.history.forward()}onGoPages(e){e.preventDefault(),this.tabData&&"replay"===this.tabData.view&&this.updateTabData({view:"pages"})}onReAuthed(e){this.reauthWait=(async()=>{const t=e.detail.headers;await fetch(this.collInfo.apiPrefix+"/updateAuth",{method:"POST",body:JSON.stringify({headers:t})});this.showAuth&&(this.onRefresh(null,!0),this.showAuth=!1)})()}async onPurgeCache(e){e.preventDefault();const t=await fetch(""+this.collInfo.apiPrefix,{method:"DELETE"});200===t.status&&window.parent?window.parent.location.reload():console.warn("purge failed: "+t.status)}onSubmit(e){e.preventDefault();const t=this.renderRoot.querySelector("input").value;return this.navigateTo(t),!1}navigateTo(e){let t;t=e.startsWith("http://")||e.startsWith("https://")?{url:e,view:"replay"}:e.startsWith("search://")?this._stringToParams(e):{query:e,view:"pages"},this.updateTabData(t)}_stringToParams(e){const t=new URLSearchParams(e.slice("search://".length)),i={};for(const e of["query","view","currList","currMime","urlSearchType"])t.has(e)&&(i[e]=t.get(e));return i}_paramsToString(e){const t=new URLSearchParams;for(const i of["query","view","currList","currMime","urlSearchType"])i in e&&t.set(i,e[i]);return t.toString()}onRefresh(e,t){if(e&&e.preventDefault(),this.menuActive=!1,"replay"===this.tabData.view){const e=this.renderRoot.querySelector("wr-coll-replay");e&&e.refresh()}else window.location.reload()}}customElements.define("wr-coll",ct);
|
||||
/**
|
||||
* @license
|
||||
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||||
|
||||
@@ -292,8 +292,8 @@
|
||||
"@xtuc/long" "4.2.2"
|
||||
|
||||
"@webrecorder/wabac@github:webrecorder/wabac.js":
|
||||
version "2.0.4"
|
||||
resolved "https://codeload.github.com/webrecorder/wabac.js/tar.gz/f1b848c45428bf1a4bdbdc6551f690acc235e558"
|
||||
version "2.0.5"
|
||||
resolved "https://codeload.github.com/webrecorder/wabac.js/tar.gz/036de761b37fea0e19c0fc2a860eadad31b839a5"
|
||||
dependencies:
|
||||
brotli "github:foliojs/brotli.js"
|
||||
fast-xml-parser "^3.15.1"
|
||||
|
||||
Reference in New Issue
Block a user