mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-28 03:50:10 +00:00
Compare commits
2 Commits
62e27c394d
...
a9dc601751
Author | SHA1 | Date | |
---|---|---|---|
a9dc601751 | |||
51e3c37694 |
16
Makefile
16
Makefile
@ -53,6 +53,7 @@ endif
|
|||||||
DEBUG ?= off
|
DEBUG ?= off
|
||||||
ifeq ($(DEBUG), on)
|
ifeq ($(DEBUG), on)
|
||||||
SOURCEMAP := --sourcemap
|
SOURCEMAP := --sourcemap
|
||||||
|
MINIFY :=
|
||||||
TYPECHECK := npx tsc -noEmit --project ts/tsconfig.json
|
TYPECHECK := npx tsc -noEmit --project ts/tsconfig.json
|
||||||
# jank
|
# jank
|
||||||
COPYTS := rm -r $(DATA)/web/js/ts; cp -r tempts $(DATA)/web/js/ts
|
COPYTS := rm -r $(DATA)/web/js/ts; cp -r tempts $(DATA)/web/js/ts
|
||||||
@ -61,6 +62,7 @@ ifeq ($(DEBUG), on)
|
|||||||
else
|
else
|
||||||
LDFLAGS := -s -w $(LDFLAGS)
|
LDFLAGS := -s -w $(LDFLAGS)
|
||||||
SOURCEMAP :=
|
SOURCEMAP :=
|
||||||
|
MINIFY := --minify
|
||||||
COPYTS :=
|
COPYTS :=
|
||||||
TYPECHECK :=
|
TYPECHECK :=
|
||||||
UNCSS := npx tailwindcss -i $(DATA)/web/css/bundle.css -o $(DATA)/bundle.css --content "html/crash.html"
|
UNCSS := npx tailwindcss -i $(DATA)/web/css/bundle.css -o $(DATA)/bundle.css --content "html/crash.html"
|
||||||
@ -118,13 +120,13 @@ typescript:
|
|||||||
scripts/dark-variant.sh tempts/modules
|
scripts/dark-variant.sh tempts/modules
|
||||||
$(info compiling typescript)
|
$(info compiling typescript)
|
||||||
mkdir -p $(DATA)/web/js
|
mkdir -p $(DATA)/web/js
|
||||||
$(ESBUILD) --target=es6 --bundle tempts/admin.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/admin.js --minify
|
$(ESBUILD) --target=es6 --bundle tempts/admin.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/admin.js $(MINIFY)
|
||||||
$(ESBUILD) --target=es6 --bundle tempts/user.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/user.js --minify
|
$(ESBUILD) --target=es6 --bundle tempts/user.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/user.js $(MINIFY)
|
||||||
$(ESBUILD) --target=es6 --bundle tempts/pwr.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/pwr.js --minify
|
$(ESBUILD) --target=es6 --bundle tempts/pwr.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/pwr.js $(MINIFY)
|
||||||
$(ESBUILD) --target=es6 --bundle tempts/pwr-pin.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/pwr-pin.js --minify
|
$(ESBUILD) --target=es6 --bundle tempts/pwr-pin.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/pwr-pin.js $(MINIFY)
|
||||||
$(ESBUILD) --target=es6 --bundle tempts/form.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/form.js --minify
|
$(ESBUILD) --target=es6 --bundle tempts/form.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/form.js $(MINIFY)
|
||||||
$(ESBUILD) --target=es6 --bundle tempts/setup.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/setup.js --minify
|
$(ESBUILD) --target=es6 --bundle tempts/setup.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/setup.js $(MINIFY)
|
||||||
$(ESBUILD) --target=es6 --bundle tempts/crash.ts --outfile=./$(DATA)/crash.js --minify
|
$(ESBUILD) --target=es6 --bundle tempts/crash.ts --outfile=./$(DATA)/crash.js $(MINIFY)
|
||||||
$(COPYTS)
|
$(COPYTS)
|
||||||
|
|
||||||
swagger:
|
swagger:
|
||||||
|
@ -21,7 +21,7 @@ export function toDateString(date: Date): string {
|
|||||||
return date.toLocaleDateString(locale, args1) + " " + date.toLocaleString(locale, args2);
|
return date.toLocaleDateString(locale, args1) + " " + date.toLocaleString(locale, args2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const _get = (url: string, data: Object, onreadystatechange: (req: XMLHttpRequest) => void): void => {
|
export const _get = (url: string, data: Object, onreadystatechange: (req: XMLHttpRequest) => void, noConnectionError: boolean = false): void => {
|
||||||
let req = new XMLHttpRequest();
|
let req = new XMLHttpRequest();
|
||||||
if (window.URLBase) { url = window.URLBase + url; }
|
if (window.URLBase) { url = window.URLBase + url; }
|
||||||
req.open("GET", url, true);
|
req.open("GET", url, true);
|
||||||
@ -30,7 +30,7 @@ export const _get = (url: string, data: Object, onreadystatechange: (req: XMLHtt
|
|||||||
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
||||||
req.onreadystatechange = () => {
|
req.onreadystatechange = () => {
|
||||||
if (req.status == 0) {
|
if (req.status == 0) {
|
||||||
window.notifications.connectionError();
|
if (!noConnectionError) window.notifications.connectionError();
|
||||||
return;
|
return;
|
||||||
} else if (req.status == 401) {
|
} else if (req.status == 401) {
|
||||||
window.notifications.customError("401Error", window.lang.notif("error401Unauthorized"));
|
window.notifications.customError("401Error", window.lang.notif("error401Unauthorized"));
|
||||||
@ -65,7 +65,7 @@ export const _upload = (url: string, formData: FormData): void => {
|
|||||||
req.send(formData);
|
req.send(formData);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const _post = (url: string, data: Object, onreadystatechange: (req: XMLHttpRequest) => void, response?: boolean, statusHandler?: (req: XMLHttpRequest) => void): void => {
|
export const _post = (url: string, data: Object, onreadystatechange: (req: XMLHttpRequest) => void, response?: boolean, statusHandler?: (req: XMLHttpRequest) => void, noConnectionError: boolean = false): void => {
|
||||||
let req = new XMLHttpRequest();
|
let req = new XMLHttpRequest();
|
||||||
req.open("POST", window.URLBase + url, true);
|
req.open("POST", window.URLBase + url, true);
|
||||||
if (response) {
|
if (response) {
|
||||||
@ -76,7 +76,7 @@ export const _post = (url: string, data: Object, onreadystatechange: (req: XMLHt
|
|||||||
req.onreadystatechange = () => {
|
req.onreadystatechange = () => {
|
||||||
if (statusHandler) { statusHandler(req); }
|
if (statusHandler) { statusHandler(req); }
|
||||||
else if (req.status == 0) {
|
else if (req.status == 0) {
|
||||||
window.notifications.connectionError();
|
if (!noConnectionError) window.notifications.connectionError();
|
||||||
return;
|
return;
|
||||||
} else if (req.status == 401) {
|
} else if (req.status == 401) {
|
||||||
window.notifications.customError("401Error", window.lang.notif("error401Unauthorized"));
|
window.notifications.customError("401Error", window.lang.notif("error401Unauthorized"));
|
||||||
@ -86,14 +86,14 @@ export const _post = (url: string, data: Object, onreadystatechange: (req: XMLHt
|
|||||||
req.send(JSON.stringify(data));
|
req.send(JSON.stringify(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
export function _delete(url: string, data: Object, onreadystatechange: (req: XMLHttpRequest) => void): void {
|
export function _delete(url: string, data: Object, onreadystatechange: (req: XMLHttpRequest) => void, noConnectionError: boolean = false): void {
|
||||||
let req = new XMLHttpRequest();
|
let req = new XMLHttpRequest();
|
||||||
req.open("DELETE", window.URLBase + url, true);
|
req.open("DELETE", window.URLBase + url, true);
|
||||||
req.setRequestHeader("Authorization", "Bearer " + window.token);
|
req.setRequestHeader("Authorization", "Bearer " + window.token);
|
||||||
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
||||||
req.onreadystatechange = () => {
|
req.onreadystatechange = () => {
|
||||||
if (req.status == 0) {
|
if (req.status == 0) {
|
||||||
window.notifications.connectionError();
|
if (!noConnectionError) window.notifications.connectionError();
|
||||||
return;
|
return;
|
||||||
} else if (req.status == 401) {
|
} else if (req.status == 401) {
|
||||||
window.notifications.customError("401Error", window.lang.notif("error401Unauthorized"));
|
window.notifications.customError("401Error", window.lang.notif("error401Unauthorized"));
|
||||||
|
@ -88,5 +88,5 @@ export const loadLangSelector = (page: string) => {
|
|||||||
}
|
}
|
||||||
list.innerHTML = innerHTML;
|
list.innerHTML = innerHTML;
|
||||||
}
|
}
|
||||||
});
|
}, true);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user