1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-10-18 17:10:11 +00:00

Compare commits

..

No commits in common. "d51a6abb02af96cad804ea341b49742f0053aac6" and "3e73d16cce77bc0ae877629c2a3304673d0be7fe" have entirely different histories.

33 changed files with 45 additions and 128 deletions

1
.gitignore vendored
View File

@ -13,4 +13,3 @@ server.key
server.pem server.pem
server.crt server.crt
instructions-debian.txt instructions-debian.txt
cl.md

View File

@ -276,16 +276,7 @@
<span class="ml-1 chev"></span> <span class="ml-1 chev"></span>
</span> </span>
<div class="dropdown-display"> <div class="dropdown-display">
<div class="card ~neutral !low"> <div class="card ~neutral !low" id="lang-list">
<label class="switch pb-1">
<input type="radio" name="lang-time" id="lang-12h">
<span>{{ .strings.time12h }}</span>
</label>
<label class="switch pb-1">
<input type="radio" name="lang-time" id="lang-24h">
<span>{{ .strings.time24h }}</span>
</label>
<div id="lang-list"></div>
</div> </div>
</div> </div>
</span> </span>

View File

@ -5,7 +5,6 @@
window.invalidPassword = "{{ .strings.reEnterPasswordInvalid }}"; window.invalidPassword = "{{ .strings.reEnterPasswordInvalid }}";
window.URLBase = "{{ .urlBase }}"; window.URLBase = "{{ .urlBase }}";
window.code = "{{ .code }}"; window.code = "{{ .code }}";
window.language = "{{ .langName }}";
window.messages = JSON.parse({{ .notifications }}); window.messages = JSON.parse({{ .notifications }});
window.confirmation = {{ .confirmation }}; window.confirmation = {{ .confirmation }};
window.userExpiryEnabled = {{ .userExpiry }}; window.userExpiryEnabled = {{ .userExpiry }};

View File

@ -266,10 +266,10 @@
</label> </label>
<div> <div>
<label class="row switch pb-1"> <label class="row switch pb-1">
<input type="radio" name="email-24h" value="true" checked><span>{{ .lang.Strings.time24h }}</span> <input type="radio" name="email-24h" value="true" checked><span>{{ .lang.Email.time24h }}</span>
</label> </label>
<label class="row switch pb-1"> <label class="row switch pb-1">
<input type="radio" name="email-24h" value="false"><span>{{ .lang.Strings.time12h }}</span> <input type="radio" name="email-24h" value="false"><span>{{ .lang.Email.time12h }}</span>
</label> </label>
</div> </div>
</div> </div>

View File

@ -1,5 +0,0 @@
{
"meta": {
"name": "English (GB)"
}
}

View File

@ -12,8 +12,6 @@
"error": "Fehler", "error": "Fehler",
"copy": "Kopieren", "copy": "Kopieren",
"theme": "Thema", "theme": "Thema",
"time24h": "24h-Format",
"time12h": "12h-Format",
"copied": "Kopiert" "copied": "Kopiert"
} }
} }

View File

@ -12,8 +12,6 @@
"error": "Σφάλμα", "error": "Σφάλμα",
"copy": "Αντιγραφή", "copy": "Αντιγραφή",
"theme": "Θέμα", "theme": "Θέμα",
"time24h": "24 Ώρες",
"time12h": "12 Ώρες",
"copied": "Αντιγράφηκε" "copied": "Αντιγράφηκε"
} }
} }

View File

@ -1,5 +0,0 @@
{
"meta": {
"name": "English (GB)"
}
}

View File

@ -12,8 +12,6 @@
"error": "Error", "error": "Error",
"copy": "Copy", "copy": "Copy",
"copied": "Copied", "copied": "Copied",
"time24h": "24h Time",
"time12h": "12h Time",
"theme": "Theme" "theme": "Theme"
} }
} }

View File

@ -12,8 +12,6 @@
"success": "Succès", "success": "Succès",
"error": "Erreur", "error": "Erreur",
"copy": "Copier", "copy": "Copier",
"time24h": "Temps 24h",
"time12h": "Temps 12h",
"theme": "Thème" "theme": "Thème"
} }
} }

View File

@ -11,8 +11,6 @@
"success": "Sukses", "success": "Sukses",
"error": "Error", "error": "Error",
"copy": "Salin", "copy": "Salin",
"time24h": "Waktu 24 jam",
"time12h": "Waktu 12 jam",
"theme": "Tema" "theme": "Tema"
} }
} }

View File

@ -12,8 +12,6 @@
"error": "Fout", "error": "Fout",
"copy": "Kopiëer", "copy": "Kopiëer",
"theme": "Thema", "theme": "Thema",
"time24h": "24u-formaat",
"time12h": "12u-formaat",
"copied": "Gekopieerd" "copied": "Gekopieerd"
} }
} }

View File

@ -12,8 +12,6 @@
"error": "Erro", "error": "Erro",
"copy": "Copiar", "copy": "Copiar",
"theme": "Tema", "theme": "Tema",
"time24h": "Horário 24h",
"time12h": "Horário 12h",
"copied": "Copiado" "copied": "Copiado"
} }
} }

View File

@ -11,8 +11,6 @@
"success": "Lyckades", "success": "Lyckades",
"error": "Fel", "error": "Fel",
"copy": "Kopiera", "copy": "Kopiera",
"time24h": "24 timmarsklocka",
"time12h": "12 timmarsklocka",
"theme": "Tema" "theme": "Tema"
} }
} }

View File

@ -1,5 +0,0 @@
{
"meta": {
"name": "English (GB)"
}
}

View File

@ -1,5 +0,0 @@
{
"meta": {
"name": "English (GB)"
}
}

View File

@ -82,6 +82,8 @@
"senderName": "Absendername", "senderName": "Absendername",
"dateFormat": "Datumsformat", "dateFormat": "Datumsformat",
"dateFormatNotice": "Datum folgt dem strftime-Format. Für weitere Informationen, besuche {n}.", "dateFormatNotice": "Datum folgt dem strftime-Format. Für weitere Informationen, besuche {n}.",
"time24h": "24h-Format",
"time12h": "12h-Format",
"encryption": "Verschlüsselung", "encryption": "Verschlüsselung",
"mailgunApiURL": "API-URL" "mailgunApiURL": "API-URL"
}, },

View File

@ -82,6 +82,8 @@
"senderName": "Ονομα αποστολέα", "senderName": "Ονομα αποστολέα",
"dateFormat": "Μορφή ημερομηνίας", "dateFormat": "Μορφή ημερομηνίας",
"dateFormatNotice": "Η ημερομηνία ακολουθεί τη μορφή strftime. Για περισσότερες πληροφορίες, επισκεφτείτε το {n}.", "dateFormatNotice": "Η ημερομηνία ακολουθεί τη μορφή strftime. Για περισσότερες πληροφορίες, επισκεφτείτε το {n}.",
"time24h": "24 Ώρες",
"time12h": "12 Ώρες",
"encryption": "Κρυπτογράφηση", "encryption": "Κρυπτογράφηση",
"mailgunApiURL": "Διεύθυνση API" "mailgunApiURL": "Διεύθυνση API"
}, },

View File

@ -1,5 +0,0 @@
{
"meta": {
"name": "English (GB)"
}
}

View File

@ -89,6 +89,8 @@
"senderName": "Sender Name", "senderName": "Sender Name",
"dateFormat": "Date Format", "dateFormat": "Date Format",
"dateFormatNotice": "Date follows the strftime format. For more info, visit {n}.", "dateFormatNotice": "Date follows the strftime format. For more info, visit {n}.",
"time24h": "24h Time",
"time12h": "12h Time",
"encryption": "Encryption", "encryption": "Encryption",
"mailgunApiURL": "API URL" "mailgunApiURL": "API URL"
}, },

View File

@ -82,6 +82,8 @@
"senderName": "Nom de l'envoyeur", "senderName": "Nom de l'envoyeur",
"dateFormat": "Format de la date", "dateFormat": "Format de la date",
"dateFormatNotice": "La date suis le format srtftime. Pour plus d'informations, consultez {n}.", "dateFormatNotice": "La date suis le format srtftime. Pour plus d'informations, consultez {n}.",
"time24h": "Temps 24h",
"time12h": "Temps 12h",
"encryption": "Chiffrement", "encryption": "Chiffrement",
"mailgunApiURL": "URL de l'API" "mailgunApiURL": "URL de l'API"
}, },

View File

@ -82,6 +82,8 @@
"senderName": "Nama Pengirim", "senderName": "Nama Pengirim",
"dateFormat": "Format Tanggal", "dateFormat": "Format Tanggal",
"dateFormatNotice": "Tanggal mengikuti format strftime. Untuk info lebih lanjut, kunjungi {n}.", "dateFormatNotice": "Tanggal mengikuti format strftime. Untuk info lebih lanjut, kunjungi {n}.",
"time24h": "Waktu 24 jam",
"time12h": "Waktu 12 jam",
"encryption": "Enkripsi", "encryption": "Enkripsi",
"mailgunApiURL": "URL API" "mailgunApiURL": "URL API"
}, },

View File

@ -82,6 +82,8 @@
"senderName": "Naam afzender", "senderName": "Naam afzender",
"dateFormat": "Datumformaat", "dateFormat": "Datumformaat",
"dateFormatNotice": "Datum volgend het strftime formaat. Meer info op {n}.", "dateFormatNotice": "Datum volgend het strftime formaat. Meer info op {n}.",
"time24h": "24u-formaat",
"time12h": "12u-formaat",
"encryption": "Versleuteling", "encryption": "Versleuteling",
"mailgunApiURL": "API-URL" "mailgunApiURL": "API-URL"
}, },

View File

@ -82,6 +82,8 @@
"senderName": "Nome do remetente", "senderName": "Nome do remetente",
"dateFormat": "Formato da Data", "dateFormat": "Formato da Data",
"dateFormatNotice": "A data segue o formato strftime. Para obter mais informações, visite {n}.", "dateFormatNotice": "A data segue o formato strftime. Para obter mais informações, visite {n}.",
"time24h": "Horário 24h",
"time12h": "Horário 12h",
"encryption": "Encriptação", "encryption": "Encriptação",
"mailgunApiURL": "API URL" "mailgunApiURL": "API URL"
}, },

View File

@ -82,6 +82,8 @@
"senderName": "Avsändarens namn", "senderName": "Avsändarens namn",
"dateFormat": "Datumformat", "dateFormat": "Datumformat",
"dateFormatNotice": "Datum följer strftime-formatet. Mer information finns på {n}.", "dateFormatNotice": "Datum följer strftime-formatet. Mer information finns på {n}.",
"time24h": "24 timmarsklocka",
"time12h": "12 timmarsklocka",
"encryption": "Kryptering", "encryption": "Kryptering",
"mailgunApiURL": "API URL" "mailgunApiURL": "API URL"
}, },

View File

@ -144,14 +144,11 @@ func patchLang(english, other *langSection) {
} }
func patchQuantityStrings(english, other *map[string]quantityString) { func patchQuantityStrings(english, other *map[string]quantityString) {
if *other == nil {
*other = map[string]quantityString{}
}
for n, ev := range *english { for n, ev := range *english {
qs, ok := (*other)[n] qs, ok := (*other)[n]
if !ok { if !ok {
(*other)[n] = ev (*other)[n] = ev
continue return
} else if qs.Singular == "" { } else if qs.Singular == "" {
qs.Singular = ev.Singular qs.Singular = ev.Singular
} else if (*other)[n].Plural == "" { } else if (*other)[n].Plural == "" {
@ -432,8 +429,6 @@ func (st *Storage) loadLangEmail(filesystems ...fs.FS) error {
patchLang(&english.UserDeleted, &lang.UserDeleted) patchLang(&english.UserDeleted, &lang.UserDeleted)
patchLang(&english.InviteEmail, &lang.InviteEmail) patchLang(&english.InviteEmail, &lang.InviteEmail)
patchLang(&english.WelcomeEmail, &lang.WelcomeEmail) patchLang(&english.WelcomeEmail, &lang.WelcomeEmail)
patchLang(&english.EmailConfirmation, &lang.EmailConfirmation)
patchLang(&english.UserExpired, &lang.UserExpired)
} }
st.lang.Email[index] = lang st.lang.Email[index] = lang
return nil return nil

View File

@ -1,5 +1,5 @@
import { Modal } from "./modules/modal.js"; import { Modal } from "./modules/modal.js";
import { _get, _post, toggleLoader, toDateString } from "./modules/common.js"; import { _get, _post, toggleLoader } from "./modules/common.js";
import { loadLangSelector } from "./modules/lang.js"; import { loadLangSelector } from "./modules/lang.js";
interface formWindow extends Window { interface formWindow extends Window {
@ -46,7 +46,7 @@ if (window.userExpiryEnabled) {
time.setDate(time.getDate() + window.userExpiryDays); time.setDate(time.getDate() + window.userExpiryDays);
time.setHours(time.getHours() + window.userExpiryHours); time.setHours(time.getHours() + window.userExpiryHours);
time.setMinutes(time.getMinutes() + window.userExpiryMinutes); time.setMinutes(time.getMinutes() + window.userExpiryMinutes);
messageEl.textContent = window.userExpiryMessage.replace("{date}", toDateString(time)); messageEl.textContent = window.userExpiryMessage.replace("{date}", time.toDateString() + " " + time.toLocaleTimeString());
setTimeout(calculateTime, 1000); setTimeout(calculateTime, 1000);
}; };
calculateTime(); calculateTime();

View File

@ -83,7 +83,7 @@ class user implements User {
set last_active(unix: number) { set last_active(unix: number) {
this._lastActiveUnix = unix; this._lastActiveUnix = unix;
if (unix == 0) { if (unix == 0) {
this._lastActive.textContent == "n/a"; this._lastActive.textContent == "";
} else { } else {
this._lastActive.textContent = toDateString(new Date(unix*1000)); this._lastActive.textContent = toDateString(new Date(unix*1000));
} }
@ -142,11 +142,6 @@ class user implements User {
}; };
this.update(user); this.update(user);
document.addEventListener("timefmt-change", () => {
this.expiry = this.expiry;
this.last_active = this.last_active;
});
} }
private _updateEmail = () => { private _updateEmail = () => {

View File

@ -7,24 +7,10 @@ export function createEl(html: string): HTMLElement {
} }
export function toDateString(date: Date): string { export function toDateString(date: Date): string {
const locale = window.language || (window as any).navigator.userLanguage || window.navigator.language; return date.toLocaleDateString() + " " + date.toLocaleString([], {
const t12 = document.getElementById("lang-12h") as HTMLInputElement;
const t24 = document.getElementById("lang-24h") as HTMLInputElement;
let args1 = {};
let args2 = {
hour: "2-digit", hour: "2-digit",
minute: "2-digit" minute: "2-digit"
}; })
if (t12 && t24) {
if (t12.checked) {
args1["hour12"] = true;
args2["hour12"] = true;
} else if (t24.checked) {
args1["hour12"] = false;
args2["hour12"] = false;
}
}
return date.toLocaleDateString(locale, args1) + " " + date.toLocaleString(locale, args2);
} }
export function serializeForm(id: string): Object { export function serializeForm(id: string): Object {

View File

@ -363,10 +363,6 @@ export class DOMInvite implements Invite {
this.update(invite); this.update(invite);
document.addEventListener("profileLoadEvent", () => { this.loadProfiles(); }, false); document.addEventListener("profileLoadEvent", () => { this.loadProfiles(); }, false);
document.addEventListener("timefmt-change", () => {
this.created = this.created;
this.usedBy = this.usedBy;
});
} }
update = (invite: Invite) => { update = (invite: Invite) => {

View File

@ -47,28 +47,7 @@ export class lang implements Lang {
} }
} }
export const loadLangSelector = (page: string) => { export const loadLangSelector = (page: string) => _get("/lang/" + page, null, (req: XMLHttpRequest) => {
if (page == "admin") {
const ev = new CustomEvent("timefmt-change");
const setTimefmt = (fmt: string) => {
document.dispatchEvent(ev);
localStorage.setItem("timefmt", fmt);
};
const t12 = document.getElementById("lang-12h") as HTMLInputElement;
t12.onchange = () => setTimefmt("12h");
const t24 = document.getElementById("lang-24h") as HTMLInputElement;
t24.onchange = () => setTimefmt("24h");
const preference = localStorage.getItem("timefmt");
if (preference == "12h") {
t12.checked = true;
t24.checked = false;
} else if (preference == "24h") {
t24.checked = true;
t12.checked = false;
}
}
_get("/lang/" + page, null, (req: XMLHttpRequest) => {
if (req.readyState == 4) { if (req.readyState == 4) {
if (req.status != 200) { if (req.status != 200) {
document.getElementById("lang-dropdown").remove(); document.getElementById("lang-dropdown").remove();
@ -82,4 +61,7 @@ export const loadLangSelector = (page: string) => {
list.innerHTML = innerHTML; list.innerHTML = innerHTML;
} }
}); });
};

View File

@ -8,7 +8,7 @@ interface updateDTO {
export class Updater implements updater { export class Updater implements updater {
private _update: Update; private _update: Update;
private _date: number; private _date: Date;
updateAvailable = false; updateAvailable = false;
checkForUpdates = (run?: (req: XMLHttpRequest) => void) => _get("/config/update", null, (req: XMLHttpRequest) => { checkForUpdates = (run?: (req: XMLHttpRequest) => void) => _get("/config/update", null, (req: XMLHttpRequest) => {
@ -26,10 +26,10 @@ export class Updater implements updater {
} }
} }
}); });
get date(): number { return this._date; } get date(): number { return Math.floor(this._date.getTime() / 1000); }
set date(unix: number) { set date(unix: number) {
this._date = unix; this._date = new Date(unix * 1000);
document.getElementById("update-date").textContent = toDateString(new Date(this._date * 1000)); document.getElementById("update-date").textContent = toDateString(this._date);
} }
get description(): string { return this._update.description; } get description(): string { return this._update.description; }

View File

@ -221,7 +221,6 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
"userExpiryHours": inv.UserHours, "userExpiryHours": inv.UserHours,
"userExpiryMinutes": inv.UserMinutes, "userExpiryMinutes": inv.UserMinutes,
"userExpiryMessage": app.storage.lang.Form[lang].Strings.get("yourAccountIsValidUntil"), "userExpiryMessage": app.storage.lang.Form[lang].Strings.get("yourAccountIsValidUntil"),
"langName": lang,
}) })
} }