Fixed js render setup for the client
parent
7100e090ad
commit
41edb6053e
|
@ -1,4 +1,3 @@
|
||||||
import * as moment from "moment";
|
|
||||||
import * as loader from "tc-loader";
|
import * as loader from "tc-loader";
|
||||||
import {settings, Settings} from "tc-shared/settings";
|
import {settings, Settings} from "tc-shared/settings";
|
||||||
import * as profiles from "tc-shared/profiles/ConnectionProfile";
|
import * as profiles from "tc-shared/profiles/ConnectionProfile";
|
||||||
|
@ -31,6 +30,8 @@ import {global_client_actions} from "tc-shared/events/GlobalEvents";
|
||||||
import {FileTransferState, TransferProvider,} from "tc-shared/file/Transfer";
|
import {FileTransferState, TransferProvider,} from "tc-shared/file/Transfer";
|
||||||
import {MenuEntryType, spawn_context_menu} from "tc-shared/ui/elements/ContextMenu";
|
import {MenuEntryType, spawn_context_menu} from "tc-shared/ui/elements/ContextMenu";
|
||||||
import {copy_to_clipboard} from "tc-shared/utils/helpers";
|
import {copy_to_clipboard} from "tc-shared/utils/helpers";
|
||||||
|
import {checkForUpdatedApp} from "tc-shared/update";
|
||||||
|
import {setupJSRender} from "tc-shared/ui/jsrender";
|
||||||
import ContextMenuEvent = JQuery.ContextMenuEvent;
|
import ContextMenuEvent = JQuery.ContextMenuEvent;
|
||||||
import "svg-sprites/client-icons";
|
import "svg-sprites/client-icons";
|
||||||
|
|
||||||
|
@ -45,43 +46,6 @@ import {ConnectRequestData} from "tc-shared/ipc/ConnectHandler";
|
||||||
import "./video-viewer/Controller";
|
import "./video-viewer/Controller";
|
||||||
|
|
||||||
import "./update/UpdaterWeb";
|
import "./update/UpdaterWeb";
|
||||||
import {checkForUpdatedApp} from "tc-shared/update";
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
interface Window {
|
|
||||||
open_connected_question: () => Promise<boolean>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setup_jsrender() : boolean {
|
|
||||||
if(!$.views) {
|
|
||||||
loader.critical_error("Missing jsrender viewer extension!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$.views.settings.allowCode(true);
|
|
||||||
$.views.tags("rnd", (argument) => {
|
|
||||||
let min = parseInt(argument.substr(0, argument.indexOf('~')));
|
|
||||||
let max = parseInt(argument.substr(argument.indexOf('~') + 1));
|
|
||||||
|
|
||||||
return (Math.round(Math.random() * (min + max + 1) - min)).toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
$.views.tags("fmt_date", (...args) => {
|
|
||||||
return moment(args[0]).format(args[1]);
|
|
||||||
});
|
|
||||||
|
|
||||||
$.views.tags("tr", (...args) => {
|
|
||||||
return /* @tr-ignore */ tr(args[0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".jsrender-template").each((idx, _entry) => {
|
|
||||||
if(!$.templates(_entry.id, _entry.innerHTML)) {
|
|
||||||
log.error(LogCategory.GENERAL, tr("Failed to setup cache for js renderer template %s!"), _entry.id);
|
|
||||||
} else
|
|
||||||
log.trace(LogCategory.GENERAL, tr("Successfully loaded jsrender template %s"), _entry.id);
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initialize() {
|
async function initialize() {
|
||||||
try {
|
try {
|
||||||
|
@ -578,7 +542,7 @@ loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
|
||||||
name: "jrendere initialize",
|
name: "jrendere initialize",
|
||||||
function: async () => {
|
function: async () => {
|
||||||
try {
|
try {
|
||||||
if(!setup_jsrender())
|
if(!setupJSRender())
|
||||||
throw "invalid load";
|
throw "invalid load";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loader.critical_error(tr("Failed to setup jsrender"));
|
loader.critical_error(tr("Failed to setup jsrender"));
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as loader from "tc-loader";
|
import * as loader from "tc-loader";
|
||||||
import {Stage} from "tc-loader";
|
import {Stage} from "tc-loader";
|
||||||
import {KeyCode} from "tc-shared/PPTListener";
|
import {KeyCode} from "tc-shared/PPTListener";
|
||||||
|
import * as $ from "jquery";
|
||||||
|
|
||||||
export enum ElementType {
|
export enum ElementType {
|
||||||
HEADER,
|
HEADER,
|
||||||
|
@ -65,7 +66,7 @@ export class ModalProperties {
|
||||||
closeListener: (() => void) | (() => void)[] = () => {};
|
closeListener: (() => void) | (() => void)[] = () => {};
|
||||||
registerCloseListener(listener: () => void) : this {
|
registerCloseListener(listener: () => void) : this {
|
||||||
if(this.closeListener) {
|
if(this.closeListener) {
|
||||||
if($.isArray(this.closeListener))
|
if(Array.isArray(this.closeListener))
|
||||||
this.closeListener.push(listener);
|
this.closeListener.push(listener);
|
||||||
else
|
else
|
||||||
this.closeListener = [this.closeListener, listener];
|
this.closeListener = [this.closeListener, listener];
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import * as loader from "tc-loader";
|
||||||
|
import * as moment from "moment";
|
||||||
|
import * as log from "tc-shared/log";
|
||||||
|
import {LogCategory} from "tc-shared/log";
|
||||||
|
|
||||||
|
export function setupJSRender() : boolean {
|
||||||
|
if(!$.views) {
|
||||||
|
loader.critical_error("Missing jsrender viewer extension!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.views.settings.allowCode(true);
|
||||||
|
$.views.tags("rnd", (argument) => {
|
||||||
|
let min = parseInt(argument.substr(0, argument.indexOf('~')));
|
||||||
|
let max = parseInt(argument.substr(argument.indexOf('~') + 1));
|
||||||
|
|
||||||
|
return (Math.round(Math.random() * (min + max + 1) - min)).toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
$.views.tags("fmt_date", (...args) => {
|
||||||
|
return moment(args[0]).format(args[1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$.views.tags("tr", (...args) => {
|
||||||
|
return /* @tr-ignore */ tr(args[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".jsrender-template").each((idx, _entry) => {
|
||||||
|
if(!$.templates(_entry.id, _entry.innerHTML)) {
|
||||||
|
log.error(LogCategory.GENERAL, tr("Failed to setup cache for js renderer template %s!"), _entry.id);
|
||||||
|
} else
|
||||||
|
log.trace(LogCategory.GENERAL, tr("Successfully loaded jsrender template %s"), _entry.id);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import {findPopoutHandler} from "tc-shared/ui/react-elements/external-modal/Popo
|
||||||
import {Registry} from "tc-shared/events";
|
import {Registry} from "tc-shared/events";
|
||||||
import {WebModalRenderer} from "tc-shared/ui/react-elements/external-modal/PopoutRendererWeb";
|
import {WebModalRenderer} from "tc-shared/ui/react-elements/external-modal/PopoutRendererWeb";
|
||||||
import {ClientModalRenderer} from "tc-shared/ui/react-elements/external-modal/PopoutRendererClient";
|
import {ClientModalRenderer} from "tc-shared/ui/react-elements/external-modal/PopoutRendererClient";
|
||||||
|
import {setupJSRender} from "tc-shared/ui/jsrender";
|
||||||
|
|
||||||
let modalRenderer: ModalRenderer;
|
let modalRenderer: ModalRenderer;
|
||||||
let modalInstance: AbstractModal;
|
let modalInstance: AbstractModal;
|
||||||
|
@ -27,6 +28,8 @@ loader.register_task(Stage.JAVASCRIPT_INITIALIZING, {
|
||||||
await import("tc-shared/proto");
|
await import("tc-shared/proto");
|
||||||
await i18n.initialize();
|
await i18n.initialize();
|
||||||
ipc.setup();
|
ipc.setup();
|
||||||
|
|
||||||
|
setupJSRender();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue