From 0b7a24fbd69d35d4d5600dfa2f5777f87a4ba6d5 Mon Sep 17 00:00:00 2001
From: Riccardo Balbo
Date: Wed, 3 Jan 2024 19:24:10 +0100
Subject: [PATCH] Always open in popup when possible
---
src/assets/app/index.html | 5 ++++
src/assets/index.html | 57 +++++++++++++++++++++++++++++++++++----
2 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/src/assets/app/index.html b/src/assets/app/index.html
index 4799697..40e6279 100644
--- a/src/assets/app/index.html
+++ b/src/assets/app/index.html
@@ -15,6 +15,11 @@
+
diff --git a/src/assets/index.html b/src/assets/index.html
index 2ae7a1c..80ac6ac 100644
--- a/src/assets/index.html
+++ b/src/assets/index.html
@@ -37,6 +37,7 @@
box-sizing: border-box;
flex-shrink: 1;
}
+
html,
body {
margin: 0;
@@ -247,7 +248,7 @@
}
function openPopupLandscape() {
- window.open(
+ return window.open(
"/app/index.html",
"_blank",
"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=900,height=600,screenX=200,screenY=200",
@@ -255,7 +256,7 @@
}
function openPopupPortrait() {
- window.open(
+ return window.open(
"/app/index.html",
"_blank",
"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=800,screenX=200,screenY=200",
@@ -263,7 +264,53 @@
}
function openBlank() {
- window.open("/app/index.html", "_blank");
+ return window.open("/app/index.html", "_blank");
+ }
+
+ function openSame() {
+ document.location.href = "/app/index.html";
+ }
+
+ async function openAuto() {
+ try {
+ const launchBtn = document.querySelector("#launch");
+ if (!launchBtn.getAttribute("originText")) {
+ launchBtn.setAttribute("originText", launchBtn.innerText);
+ }
+ launchBtn.innerText = "Launching...";
+ } catch (e) {
+ console.log(e);
+ }
+ let popup;
+ try {
+ if (window.innerWidth > 1000) {
+ popup = openPopupLandscape();
+ await new Promise((res, rej) => {
+ setTimeout(() => {
+ res();
+ }, 4000);
+ });
+ if (!popup || popup.closed || typeof popup.closed == "undefined") {
+ popup = undefined;
+ }
+ if (popup && (!popup.isOpen || !popup.isOpen())) {
+ popup = undefined;
+ }
+ }
+ } catch (e) {
+ console.log(e);
+ popup = undefined;
+ }
+ if (!popup) {
+ openSame();
+ }
+
+ try {
+ const launchBtn = document.querySelector("#launch");
+ launchBtn.innerText = launchBtn.getAttribute("originText") || "Launch";
+ } catch (e) {
+ console.log(e);
+ }
}
@@ -294,7 +341,7 @@ Liquid in the browser
-
+
@@ -310,7 +357,7 @@
Liquid in the browser
-
+