mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 03:14:00 +00:00
Start the panel's app at the first view instead of the default place
This commit is contained in:
1 parent
5b555d7708
commit
282efac862
1 file changed
+9
-2
@@ -221,9 +221,16 @@ function panelHtml(appOrigin) {
|
|||||||
* styles and markup are copied in, and its scripts run here with the app
|
* styles and markup are copied in, and its scripts run here with the app
|
||||||
* in inline embed mode.
|
* in inline embed mode.
|
||||||
*/
|
*/
|
||||||
async function startApp() {
|
async function startApp(url) {
|
||||||
window.GEV_EMBED_INLINE = true;
|
window.GEV_EMBED_INLINE = true;
|
||||||
redirectRequests();
|
redirectRequests();
|
||||||
|
// Start at the first view, as its link would, instead of the default
|
||||||
|
// place; the app reads the view from this page's address.
|
||||||
|
try {
|
||||||
|
history.replaceState(null, '', location.href.split('#')[0] + new URL(url).hash);
|
||||||
|
} catch {
|
||||||
|
// The view still arrives once the app is ready.
|
||||||
|
}
|
||||||
const response = await fetch(APP_ORIGIN + '/?embed=1');
|
const response = await fetch(APP_ORIGIN + '/?embed=1');
|
||||||
if (!response.ok) throw new Error('the app answered ' + response.status);
|
if (!response.ok) throw new Error('the app answered ' + response.status);
|
||||||
const page = new DOMParser().parseFromString(await response.text(), 'text/html');
|
const page = new DOMParser().parseFromString(await response.text(), 'text/html');
|
||||||
@@ -256,7 +263,7 @@ function panelHtml(appOrigin) {
|
|||||||
if (started) return;
|
if (started) return;
|
||||||
started = true;
|
started = true;
|
||||||
status.textContent = "Loading God's Eye View…";
|
status.textContent = "Loading God's Eye View…";
|
||||||
startApp().catch((error) => {
|
startApp(url).catch((error) => {
|
||||||
status.textContent =
|
status.textContent =
|
||||||
"God's Eye View could not load here: " + (error && error.message) + '.';
|
"God's Eye View could not load here: " + (error && error.message) + '.';
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user