config: start adding path parameters
to change the urls of the admin page, the my account page and of invites. Seems to work, but need to check all the code over and test.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Modal } from "../modules/modal.js";
|
||||
import { _get, _post, toggleLoader, addLoader, removeLoader } from "../modules/common.js";
|
||||
|
||||
interface formWindow extends Window {
|
||||
interface formWindow extends GlobalWindow {
|
||||
invalidPassword: string;
|
||||
successModal: Modal;
|
||||
telegramModal: Modal;
|
||||
|
||||
@@ -6,6 +6,8 @@ import { DiscordUser, newDiscordSearch } from "../modules/discord.js";
|
||||
import { Search, SearchConfiguration, QueryType, SearchableItem } from "../modules/search.js";
|
||||
import { HiddenInputField } from "./ui.js";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
const dateParser = require("any-date-parser");
|
||||
|
||||
interface User {
|
||||
|
||||
@@ -3,6 +3,8 @@ import { Search, SearchConfiguration, QueryType, SearchableItem } from "../modul
|
||||
import { accountURLEvent } from "../modules/accounts.js";
|
||||
import { inviteURLEvent } from "../modules/invites.js";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
export interface activity {
|
||||
id: string;
|
||||
type: string;
|
||||
@@ -52,8 +54,8 @@ export class Activity implements activity, SearchableItem {
|
||||
link = link.split(split)[0];
|
||||
}
|
||||
if (link.slice(-1) != "/") { link += "/"; }
|
||||
// FIXME: I should probably just be using window.URLBase, but incase thats not right, i'll put this warning here
|
||||
if (link != window.URLBase) console.error(`URL Bases don't match: "${link}" != "${window.URLBase}"`);
|
||||
// FIXME: I should probably just be using window.pages.Base, but incase thats not right, i'll put this warning here
|
||||
if (link != window.pages.Base) console.error(`URL Bases don't match: "${link}" != "${window.pages.Base}"`);
|
||||
return link;
|
||||
})(); */
|
||||
|
||||
@@ -66,17 +68,17 @@ export class Activity implements activity, SearchableItem {
|
||||
}
|
||||
|
||||
_genUserLink = (): string => {
|
||||
return `<a role="link" tabindex="0" class="hover:underline cursor-pointer activity-pseudo-link-user" data-id="${this._act.user_id}" href="${window.URLBase}/accounts?user=${this._act.user_id}">${this._genUserText()}</a>`;
|
||||
return `<a role="link" tabindex="0" class="hover:underline cursor-pointer activity-pseudo-link-user" data-id="${this._act.user_id}" href="${window.pages.Base}${window.pages.Admin}/accounts?user=${this._act.user_id}">${this._genUserText()}</a>`;
|
||||
}
|
||||
|
||||
_genSrcUserLink = (): string => {
|
||||
return `<a role="link" tabindex="0" class="hover:underline cursor-pointer activity-pseudo-link-user" data-id="${this._act.user_id}" href="${window.URLBase}/accounts?user=${this._act.source}">${this._genSrcUserText()}</a>`;
|
||||
return `<a role="link" tabindex="0" class="hover:underline cursor-pointer activity-pseudo-link-user" data-id="${this._act.user_id}" href="${window.pages.Base}${window.pages.Admin}/accounts?user=${this._act.source}">${this._genSrcUserText()}</a>`;
|
||||
}
|
||||
|
||||
private _renderInvText = (): string => { return `<span class="font-medium font-mono">${this.value || this.invite_code || "???"}</span>`; }
|
||||
|
||||
private _genInvLink = (): string => {
|
||||
return `<a role="link" tabindex="0" class="hover:underline cursor-pointer activity-pseudo-link-invite" data-id="${this.invite_code}" href="${window.URLBase}/?invite=${this.invite_code}">${this._renderInvText()}</a>`;
|
||||
return `<a role="link" tabindex="0" class="hover:underline cursor-pointer activity-pseudo-link-invite" data-id="${this.invite_code}" href="${window.pages.Base}${window.pages.Admin}/?invite=${this.invite_code}">${this._renderInvText()}</a>`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
declare var window: Window;
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
export function toDateString(date: Date): string {
|
||||
const locale = window.language || (window as any).navigator.userLanguage || window.navigator.language;
|
||||
@@ -23,7 +23,7 @@ export function toDateString(date: Date): string {
|
||||
|
||||
export const _get = (url: string, data: Object, onreadystatechange: (req: XMLHttpRequest) => void, noConnectionError: boolean = false): void => {
|
||||
let req = new XMLHttpRequest();
|
||||
if (window.URLBase) { url = window.URLBase + url; }
|
||||
if (window.pages) { url = window.pages.Base + url; }
|
||||
req.open("GET", url, true);
|
||||
req.responseType = 'json';
|
||||
req.setRequestHeader("Authorization", "Bearer " + window.token);
|
||||
@@ -42,7 +42,7 @@ export const _get = (url: string, data: Object, onreadystatechange: (req: XMLHtt
|
||||
|
||||
export const _download = (url: string, fname: string): void => {
|
||||
let req = new XMLHttpRequest();
|
||||
if (window.URLBase) { url = window.URLBase + url; }
|
||||
if (window.pages) { url = window.pages.Base + url; }
|
||||
req.open("GET", url, true);
|
||||
req.responseType = 'blob';
|
||||
req.setRequestHeader("Authorization", "Bearer " + window.token);
|
||||
@@ -58,7 +58,7 @@ export const _download = (url: string, fname: string): void => {
|
||||
|
||||
export const _upload = (url: string, formData: FormData): void => {
|
||||
let req = new XMLHttpRequest();
|
||||
if (window.URLBase) { url = window.URLBase + url; }
|
||||
if (window.pages) { url = window.pages.Base + url; }
|
||||
req.open("POST", url, true);
|
||||
req.setRequestHeader("Authorization", "Bearer " + window.token);
|
||||
// req.setRequestHeader('Content-Type', 'multipart/form-data');
|
||||
@@ -67,7 +67,8 @@ export const _upload = (url: string, formData: FormData): 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();
|
||||
req.open("POST", window.URLBase + url, true);
|
||||
if (window.pages) { url = window.pages.Base + url; }
|
||||
req.open("POST", url, true);
|
||||
if (response) {
|
||||
req.responseType = 'json';
|
||||
}
|
||||
@@ -88,7 +89,8 @@ export const _post = (url: string, data: Object, onreadystatechange: (req: XMLHt
|
||||
|
||||
export function _delete(url: string, data: Object, onreadystatechange: (req: XMLHttpRequest) => void, noConnectionError: boolean = false): void {
|
||||
let req = new XMLHttpRequest();
|
||||
req.open("DELETE", window.URLBase + url, true);
|
||||
if (window.pages) { url = window.pages.Base + url; }
|
||||
req.open("DELETE", url, true);
|
||||
req.setRequestHeader("Authorization", "Bearer " + window.token);
|
||||
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
||||
req.onreadystatechange = () => {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import {addLoader, removeLoader, _get} from "../modules/common.js";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
export interface DiscordUser {
|
||||
name: string;
|
||||
avatar_url: string;
|
||||
|
||||
@@ -2,6 +2,8 @@ import { _get, _post, _delete, toClipboard, toggleLoader, toDateString } from ".
|
||||
import { DiscordUser, newDiscordSearch } from "../modules/discord.js";
|
||||
import { reloadProfileNames } from "../modules/profiles.js";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
class DOMInvite implements Invite {
|
||||
updateNotify = (checkbox: HTMLInputElement) => {
|
||||
let state: { [code: string]: { [type: string]: boolean } } = {};
|
||||
@@ -66,7 +68,7 @@ class DOMInvite implements Invite {
|
||||
codeLink = codeLink.split(split)[0];
|
||||
}
|
||||
if (codeLink.slice(-1) != "/") { codeLink += "/"; }
|
||||
this._codeLink = codeLink + "invite/" + code;
|
||||
this._codeLink = codeLink + window.pages.Form + "/" + code;
|
||||
const linkEl = this._codeArea.querySelector("a") as HTMLAnchorElement;
|
||||
if (this.label == "") {
|
||||
linkEl.textContent = code.replace(/-/g, '-');
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
import { Modal } from "../modules/modal.js";
|
||||
import { toggleLoader, _post, unicodeB64Encode } from "../modules/common.js";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
export class Login {
|
||||
loggedIn: boolean = false;
|
||||
private _modal: Modal;
|
||||
@@ -14,7 +16,7 @@ export class Login {
|
||||
|
||||
constructor(modal: Modal, endpoint: string, appearance: string) {
|
||||
this._endpoint = endpoint;
|
||||
this._url = window.URLBase + endpoint;
|
||||
this._url = window.pages.Base + endpoint;
|
||||
if (this._url[this._url.length-1] != '/') this._url += "/";
|
||||
|
||||
this._modal = modal;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
declare var window: Window;
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
export class Modal implements Modal {
|
||||
modal: HTMLElement;
|
||||
|
||||
@@ -73,6 +73,7 @@ export class PageManager {
|
||||
}
|
||||
|
||||
loadPage (p: Page) {
|
||||
console.log("loading page with", p.name || this.defaultName, p.title, p.url + window.location.search);
|
||||
window.history.pushState(p.name || this.defaultName, p.title, p.url + window.location.search);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { _get, _post, _delete, toggleLoader } from "../modules/common.js";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
export const profileLoadEvent = new CustomEvent("profileLoadEvent");
|
||||
export const reloadProfileNames = (then?: () => void) => _get("/profiles/names", null, (req: XMLHttpRequest) => {
|
||||
if (req.readyState != 4) return;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const dateParser = require("any-date-parser");
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
export interface QueryType {
|
||||
name: string;
|
||||
description?: string;
|
||||
|
||||
@@ -2,6 +2,8 @@ import { _get, _post, _delete, _download, _upload, toggleLoader, addLoader, remo
|
||||
import { Marked } from "@ts-stack/markdown";
|
||||
import { stripMarkdown } from "../modules/stripmd.js";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
const toBool = (s: string): boolean => {
|
||||
let b = Boolean(s);
|
||||
if (s == "false") b = false;
|
||||
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
import { PageManager, Page } from "../modules/pages.js";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
export interface Tab {
|
||||
page: Page;
|
||||
tabEl: HTMLDivElement;
|
||||
@@ -38,7 +40,7 @@ export class Tabs implements Tabs {
|
||||
tab.page = {
|
||||
name: tabID,
|
||||
title: document.title, /*FIXME: Get actual names from translations*/
|
||||
url: window.URLBase + "/" + url,
|
||||
url: url,
|
||||
show: () => {
|
||||
tab.buttonEl.classList.add("active", "~urge");
|
||||
tab.tabEl.classList.remove("unfocused");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { _get, _post, toggleLoader, toDateString } from "../modules/common.js";
|
||||
import { Marked, Renderer } from "@ts-stack/markdown";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
interface updateDTO {
|
||||
new: boolean;
|
||||
update: Update;
|
||||
|
||||
Reference in New Issue
Block a user