-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from tillvit/development
Development
- Loading branch information
Showing
14 changed files
with
473 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { UpdatePopup } from "./UpdatePopup" | ||
|
||
export class AppUpdatePopup extends UpdatePopup { | ||
static open(versionName: string, downloadLink: string) { | ||
super.build({ | ||
title: `A new version of the desktop app is available! (${versionName})`, | ||
desc: "Click here to download the new version.", | ||
options: [ | ||
{ | ||
label: "Close", | ||
type: "default", | ||
callback: () => this.close(), | ||
}, | ||
{ | ||
label: "Download", | ||
type: "confirm", | ||
callback: () => { | ||
localStorage.setItem("downloadedVersion", versionName) | ||
nw.require("nw.gui").Shell.openExternal(downloadLink) | ||
this.close() | ||
}, | ||
}, | ||
], | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { UpdatePopup } from "./UpdatePopup" | ||
|
||
export class CoreUpdatePopup extends UpdatePopup { | ||
static open(callback: () => void) { | ||
super.build({ | ||
title: `A new version of the app is available!`, | ||
desc: "Refresh the page to get the new version.", | ||
options: [ | ||
{ | ||
label: "Close", | ||
type: "default", | ||
callback: () => this.close(), | ||
}, | ||
{ | ||
label: "Refresh", | ||
type: "confirm", | ||
callback: () => { | ||
callback() | ||
}, | ||
}, | ||
], | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { UpdatePopup } from "./UpdatePopup" | ||
|
||
export class OfflineUpdatePopup extends UpdatePopup { | ||
static open() { | ||
super.build({ | ||
title: `SMEditor was loaded offline!`, | ||
desc: "You can now use SMEditor without an internet connection.", | ||
options: [], | ||
}) | ||
setTimeout(() => this.close(), 5000) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
interface UpdatePopupOptions { | ||
title: string | ||
desc: string | ||
options: UpdateOption[] | ||
} | ||
|
||
interface UpdateOption { | ||
label: string | ||
callback?: (popup: UpdatePopup) => void | ||
type: "delete" | "confirm" | "default" | ||
} | ||
|
||
export abstract class UpdatePopup { | ||
static popup?: HTMLDivElement | ||
|
||
protected static build(opt: UpdatePopupOptions) { | ||
const popup = document.createElement("div") | ||
popup.classList.add("update-popup") | ||
|
||
const title = document.createElement("div") | ||
title.classList.add("title") | ||
title.innerText = opt.title | ||
|
||
const desc = document.createElement("div") | ||
desc.classList.add("desc") | ||
desc.innerText = opt.desc | ||
|
||
const options = document.createElement("div") | ||
options.classList.add("update-options") | ||
|
||
popup.replaceChildren(title, desc) | ||
|
||
if (opt.options.length > 0) { | ||
for (const o of opt.options) { | ||
const button = document.createElement("button") | ||
button.innerText = o.label | ||
button.onclick = () => { | ||
o.callback?.(this) | ||
} | ||
button.classList.add(o.type) | ||
options.appendChild(button) | ||
} | ||
popup.appendChild(options) | ||
} | ||
this.popup = popup | ||
document.getElementById("popups")?.appendChild(this.popup) | ||
} | ||
|
||
static close() { | ||
if (!this.popup) return | ||
this.popup.classList.add("exiting") | ||
this.popup.style.pointerEvents = "none" | ||
setTimeout(() => this.popup!.remove(), 300) | ||
} | ||
} |
Oops, something went wrong.