Make the loading content text better and much less hacky, also revert ExtensionMetadata type name back from IExtensionMetadata.
This commit is contained in:
parent
f2fcf29317
commit
2fc7f56b47
7 changed files with 26 additions and 21 deletions
|
|
@ -51,7 +51,9 @@
|
||||||
return window.__uv$config.decodeUrl(frame.contentWindow!.location.href.split("/service/")[1]);
|
return window.__uv$config.decodeUrl(frame.contentWindow!.location.href.split("/service/")[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadContent(): Promise<void> {
|
async function loadProxyContent(): Promise<void> {
|
||||||
|
const loadingContent = document.getElementById("loading-content") as HTMLElement;
|
||||||
|
if (loadingContent) loadingContent.style.opacity = "1";
|
||||||
await initTransport();
|
await initTransport();
|
||||||
// The setTimeout is because service workers are a little silly and can take a while longer to register despite .then being called, which causes a bug on the first load.
|
// The setTimeout is because service workers are a little silly and can take a while longer to register despite .then being called, which causes a bug on the first load.
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
|
@ -80,8 +82,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const loadingContent = document.getElementById("loading-content") as HTMLElement;
|
|
||||||
if (loadingContent) loadingContent.style.opacity = "1";
|
|
||||||
|
|
||||||
const iframe = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
const iframe = document.getElementById("proxy-frame") as HTMLIFrameElement;
|
||||||
const topbar = document.getElementById("top-bar") as HTMLDivElement;
|
const topbar = document.getElementById("top-bar") as HTMLDivElement;
|
||||||
|
|
@ -173,11 +174,9 @@
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
await TransportMgr.updateTransport();
|
await TransportMgr.updateTransport();
|
||||||
setTimeout(() => {
|
loadProxyContent();
|
||||||
loadContent();
|
|
||||||
}, 200);
|
|
||||||
}
|
}
|
||||||
window.loadFormContent = loadContent;
|
window.loadFormContent = loadProxyContent;
|
||||||
|
|
||||||
function isUrl(val = "") {
|
function isUrl(val = "") {
|
||||||
if (/^http(s?):\/\//.test(val) || (val.includes(".") && val.substr(0, 1) !== " ")) return true;
|
if (/^http(s?):\/\//.test(val) || (val.includes(".") && val.substr(0, 1) !== " ")) return true;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
store.getAll().onsuccess = (event) => {
|
store.getAll().onsuccess = (event) => {
|
||||||
const result = (event.target as IDBRequest).result;
|
const result = (event.target as IDBRequest).result;
|
||||||
if (result) {
|
if (result) {
|
||||||
result.forEach((extension: IExtensionMetadata) => {
|
result.forEach((extension: ExtensionMetadata) => {
|
||||||
if (extension.type === "theme" && extension.themeName) {
|
if (extension.type === "theme" && extension.themeName) {
|
||||||
// Load theme CSS
|
// Load theme CSS
|
||||||
loadStyleFromAtob(atob(extension.scriptCopy!));
|
loadStyleFromAtob(atob(extension.scriptCopy!));
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ Array.from(installButtons).forEach((btn) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
async function getMarketplaceObj(slug: string): Promise<IExtensionMetadata> {
|
async function getMarketplaceObj(slug: string): Promise<ExtensionMetadata> {
|
||||||
const manifest = extManifest[slug];
|
const manifest = extManifest[slug];
|
||||||
if (manifest.type === "page") {
|
if (manifest.type === "page") {
|
||||||
return manifest;
|
return manifest;
|
||||||
|
|
@ -87,7 +87,7 @@ async function getMarketplaceObj(slug: string): Promise<IExtensionMetadata> {
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installExtension(ext: IExtensionMetadata, slug: string): Promise<InstallReturn> {
|
async function installExtension(ext: ExtensionMetadata, slug: string): Promise<InstallReturn> {
|
||||||
return new Promise<InstallReturn>((resolve, reject) => {
|
return new Promise<InstallReturn>((resolve, reject) => {
|
||||||
const request = IDBManager.GetIDB();
|
const request = IDBManager.GetIDB();
|
||||||
const transaction = request.transaction("InstalledExtensions", "readwrite");
|
const transaction = request.transaction("InstalledExtensions", "readwrite");
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,7 @@ const { title, optionalPreloads } = Astro.props;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 2.5rem;
|
font-size: 2.5rem;
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
.title-desc {
|
.title-desc {
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ export function getStaticPaths() {
|
||||||
<section id="proxy-input">
|
<section id="proxy-input">
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
<form class="url-input-form" id="url-input-form">
|
<form class="url-input-form" id="url-input-form">
|
||||||
|
<div id="loading-content">Loading Content...</div>
|
||||||
<Input className="url-input" inputName="url" placeholder={t("menu.search")} defaultStyles={false} transition:persist autocomplete="off" />
|
<Input className="url-input" inputName="url" placeholder={t("menu.search")} defaultStyles={false} transition:persist autocomplete="off" />
|
||||||
<div id="search-suggestions"></div>
|
<div id="search-suggestions"></div>
|
||||||
<div id="loading-content">Loading...</div>
|
|
||||||
</form>
|
</form>
|
||||||
<div id="top-bar">
|
<div id="top-bar">
|
||||||
<div class="top-bar-left">
|
<div class="top-bar-left">
|
||||||
|
|
@ -78,9 +78,7 @@ export function getStaticPaths() {
|
||||||
searchSuggestions.innerHTML = "";
|
searchSuggestions.innerHTML = "";
|
||||||
data.map((suggestion: Suggestion) => {
|
data.map((suggestion: Suggestion) => {
|
||||||
const suggestionElement = document.createElement("div");
|
const suggestionElement = document.createElement("div");
|
||||||
// For some reason css classes weren't working T^T.
|
suggestionElement.classList.add("search-suggestion");
|
||||||
suggestionElement.style.cursor = "pointer";
|
|
||||||
suggestionElement.style.marginTop = "5px";
|
|
||||||
suggestionElement.innerText = suggestion.phrase;
|
suggestionElement.innerText = suggestion.phrase;
|
||||||
suggestionElement.addEventListener("click", async () => {
|
suggestionElement.addEventListener("click", async () => {
|
||||||
urlInput.value = suggestion.phrase;
|
urlInput.value = suggestion.phrase;
|
||||||
|
|
@ -160,21 +158,28 @@ export function getStaticPaths() {
|
||||||
border-bottom-right-radius: 15px;
|
border-bottom-right-radius: 15px;
|
||||||
transition: 250ms ease-in-out;
|
transition: 250ms ease-in-out;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
height: 240px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border: 3px solid var(--text-color);
|
border: 3px solid var(--text-color);
|
||||||
box-shadow: 10px 10px 20px var(--dropdown-background-color);
|
box-shadow: 10px 10px 20px var(--dropdown-background-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.search-suggestion {
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-suggestion:last-child {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
#loading-content {
|
#loading-content {
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
position: relative;
|
position: relative;
|
||||||
/* hack */
|
|
||||||
top: -325px;
|
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: 250ms ease-in-out;
|
transition: .25s ease-in-out;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.faq-title {
|
.faq-title {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export const getStaticPaths = () => {
|
||||||
<div class="marketplace-ext-grid">
|
<div class="marketplace-ext-grid">
|
||||||
{
|
{
|
||||||
Object.keys(marketplace).map((mp_item) => {
|
Object.keys(marketplace).map((mp_item) => {
|
||||||
const item = (marketplace as { [key: string]: IExtensionMetadata })[mp_item];
|
const item = (marketplace as ExtensionMetadataJSON)[mp_item];
|
||||||
const slug = mp_item;
|
const slug = mp_item;
|
||||||
return (
|
return (
|
||||||
<div class="marketplace-item" data-slug={slug}>
|
<div class="marketplace-item" data-slug={slug}>
|
||||||
|
|
|
||||||
4
src/types.d.ts
vendored
4
src/types.d.ts
vendored
|
|
@ -32,7 +32,7 @@ type Extension = {
|
||||||
- type: The type of extension, see ExtType.
|
- type: The type of extension, see ExtType.
|
||||||
- themeName: The name of the theme that goes in the data attribute
|
- themeName: The name of the theme that goes in the data attribute
|
||||||
*/
|
*/
|
||||||
interface IExtensionMetadata {
|
interface ExtensionMetadata {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
version: string;
|
version: string;
|
||||||
|
|
@ -46,7 +46,7 @@ interface IExtensionMetadata {
|
||||||
themeName?: string;
|
themeName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExtensionMetadataJSON = Record<string, IExtensionMetadata>;
|
type ExtensionMetadataJSON = Record<string, ExtensionMetadata>;
|
||||||
|
|
||||||
type InstallReturn = {
|
type InstallReturn = {
|
||||||
code: EXT_RETURN;
|
code: EXT_RETURN;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue