Archived
1
0

Move login JS to a separate file

Mostly so the base URL resolution code can be shared.
This commit is contained in:
Asher 2020-08-04 15:03:11 -05:00
parent de568d446b
commit 751a5ea3ad
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
4 changed files with 14 additions and 7 deletions

View File

@ -21,6 +21,7 @@ main() {
--public-url "." \ --public-url "." \
--out-dir dist \ --out-dir dist \
$([[ $MINIFY ]] || echo --no-minify) \ $([[ $MINIFY ]] || echo --no-minify) \
src/browser/login.ts \
src/browser/register.ts \ src/browser/register.ts \
src/browser/serviceWorker.ts src/browser/serviceWorker.ts
} }

View File

@ -164,7 +164,11 @@ class Watcher {
private createBundler(out = "dist"): Bundler { private createBundler(out = "dist"): Bundler {
return new Bundler( return new Bundler(
[path.join(this.rootPath, "src/browser/register.ts"), path.join(this.rootPath, "src/browser/serviceWorker.ts")], [
path.join(this.rootPath, "src/browser/login.ts"),
path.join(this.rootPath, "src/browser/register.ts"),
path.join(this.rootPath, "src/browser/serviceWorker.ts"),
],
{ {
outDir: path.join(this.rootPath, out), outDir: path.join(this.rootPath, out),
cacheDir: path.join(this.rootPath, ".cache"), cacheDir: path.join(this.rootPath, ".cache"),

View File

@ -47,10 +47,5 @@
</div> </div>
</body> </body>
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/register.js"></script> <script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/register.js"></script>
<script> <script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/login.js"></script>
const parts = window.location.pathname.replace(/^\//g, "").split("/")
parts[parts.length - 1] = "{{BASE}}"
const url = new URL(window.location.origin + "/" + parts.join("/"))
document.getElementById("base").value = url.pathname
</script>
</html> </html>

View File

@ -0,0 +1,7 @@
import { getOptions } from "../../common/util"
const options = getOptions()
const el = document.getElementById("base") as HTMLInputElement
if (el) {
el.value = options.base
}