2018-02-27 16:20:49 +00:00
|
|
|
/// <reference path="chat.ts" />
|
|
|
|
/// <reference path="client.ts" />
|
2018-04-11 15:56:09 +00:00
|
|
|
/// <reference path="Identity.ts" />
|
2018-02-27 16:20:49 +00:00
|
|
|
/// <reference path="utils/modal.ts" />
|
2018-03-07 18:06:52 +00:00
|
|
|
/// <reference path="ui/modal/ModalConnect.ts" />
|
2018-04-16 18:38:35 +00:00
|
|
|
/// <reference path="ui/modal/ModalCreateChannel.ts" />
|
2018-04-30 21:57:21 +00:00
|
|
|
/// <reference path="ui/modal/ModalBanClient.ts" />
|
2018-06-20 17:06:55 +00:00
|
|
|
/// <reference path="ui/modal/ModalYesNo.ts" />
|
2018-04-11 15:56:09 +00:00
|
|
|
/// <reference path="codec/CodecWrapper.ts" />
|
|
|
|
/// <reference path="settings.ts" />
|
2018-04-16 18:38:35 +00:00
|
|
|
/// <reference path="log.ts" />
|
2018-02-27 16:20:49 +00:00
|
|
|
|
2018-04-16 18:38:35 +00:00
|
|
|
let settings: Settings;
|
2018-04-11 15:56:09 +00:00
|
|
|
let globalClient: TSClient;
|
|
|
|
let chat: ChatBox;
|
|
|
|
|
|
|
|
let forumIdentity: TeaForumIdentity;
|
2018-02-27 16:20:49 +00:00
|
|
|
|
2018-10-03 20:04:29 +00:00
|
|
|
const js_render = window.jsrender || $;
|
|
|
|
|
2018-04-18 18:12:10 +00:00
|
|
|
function main() {
|
2018-10-03 20:04:29 +00:00
|
|
|
if(!js_render) {
|
|
|
|
displayCriticalError("Missing jsrender extension!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
js_render.views.settings.allowCode(true);
|
|
|
|
js_render.views.tags("rnd", (argument) => {
|
2018-06-24 11:38:53 +00:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
//http://localhost:63343/Web-Client/index.php?_ijt=omcpmt8b9hnjlfguh8ajgrgolr&default_connect_url=true&default_connect_type=teamspeak&default_connect_url=localhost%3A9987&disableUnloadDialog=1&loader_ignore_age=1
|
2018-04-11 15:56:09 +00:00
|
|
|
AudioController.initializeAudioController();
|
|
|
|
if(!TSIdentityHelper.setup()) { console.error("Could not setup the TeamSpeak identity parser!"); return; }
|
|
|
|
|
2018-04-16 18:38:35 +00:00
|
|
|
settings = new Settings();
|
2018-03-24 22:38:01 +00:00
|
|
|
globalClient = new TSClient();
|
2018-04-11 15:56:09 +00:00
|
|
|
/** Setup the XF forum identity **/
|
2018-04-16 18:38:35 +00:00
|
|
|
if(settings.static("forum_user_data")) {
|
|
|
|
forumIdentity = new TeaForumIdentity(settings.static("forum_user_data"), settings.static("forum_user_sign"));
|
2018-04-11 15:56:09 +00:00
|
|
|
}
|
|
|
|
|
2018-03-24 22:38:01 +00:00
|
|
|
chat = new ChatBox($("#chat"));
|
|
|
|
globalClient.setup();
|
2018-03-10 08:03:29 +00:00
|
|
|
|
2018-04-16 18:38:35 +00:00
|
|
|
|
|
|
|
if(!settings.static(Settings.KEY_DISABLE_UNLOAD_DIALOG, false)) {
|
|
|
|
window.addEventListener("beforeunload", function (event) {
|
|
|
|
if(globalClient.serverConnection && globalClient.serverConnection.connected)
|
|
|
|
event.returnValue = "Are you really sure?<br>You're still connected!";
|
|
|
|
//event.preventDefault();
|
|
|
|
});
|
|
|
|
}
|
2018-03-24 22:38:01 +00:00
|
|
|
//Modals.spawnConnectModal();
|
|
|
|
//Modals.spawnSettingsModal();
|
2018-04-16 18:38:35 +00:00
|
|
|
//Modals.createChannelModal(undefined);
|
2018-03-24 22:38:01 +00:00
|
|
|
|
2018-04-16 18:38:35 +00:00
|
|
|
if(settings.static("default_connect_url")) {
|
2018-05-05 12:58:30 +00:00
|
|
|
switch (settings.static("default_connect_type")) {
|
|
|
|
case "teaforo":
|
2018-06-27 13:53:03 +00:00
|
|
|
if(forumIdentity.valid())
|
2018-05-05 12:58:30 +00:00
|
|
|
globalClient.startConnection(settings.static("default_connect_url"), forumIdentity);
|
|
|
|
else
|
|
|
|
Modals.spawnConnectModal(settings.static("default_connect_url"), IdentitifyType.TEAFORO);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "teamspeak":
|
|
|
|
let connectIdentity = TSIdentityHelper.loadIdentity(settings.global("connect_identity_teamspeak_identity", ""));
|
2018-06-27 13:53:03 +00:00
|
|
|
if(!connectIdentity || !connectIdentity.valid())
|
2018-05-05 12:58:30 +00:00
|
|
|
Modals.spawnConnectModal(settings.static("default_connect_url"), IdentitifyType.TEAMSPEAK);
|
|
|
|
else
|
|
|
|
globalClient.startConnection(settings.static("default_connect_url"), connectIdentity);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Modals.spawnConnectModal(settings.static("default_connect_url"));
|
|
|
|
}
|
2018-04-16 18:38:35 +00:00
|
|
|
}
|
2018-04-30 21:57:21 +00:00
|
|
|
|
|
|
|
/*
|
2018-06-24 11:38:53 +00:00
|
|
|
let tag = $("#tmpl_music_frame").renderTag({
|
|
|
|
//thumbnail: "img/loading_image.svg"
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#music-test").replaceWith(tag);
|
2018-04-30 21:57:21 +00:00
|
|
|
|
2018-05-04 12:45:36 +00:00
|
|
|
//Modals.spawnSettingsModal();
|
2018-06-20 17:06:55 +00:00
|
|
|
/*
|
|
|
|
Modals.spawnYesNo("Are your sure?", "Do you really want to exit?", flag => {
|
|
|
|
console.log("Response: " + flag);
|
|
|
|
})
|
|
|
|
*/
|
2018-09-30 19:50:59 +00:00
|
|
|
|
|
|
|
//Modals.spawnPermissionEdit();
|
2018-04-19 16:42:34 +00:00
|
|
|
}
|
|
|
|
|
2018-08-05 16:59:24 +00:00
|
|
|
app.loadedListener.push(() => {
|
2018-09-25 15:39:38 +00:00
|
|
|
try {
|
|
|
|
main();
|
2018-09-26 13:30:22 +00:00
|
|
|
if(!AudioController.initialized()) {
|
|
|
|
log.info(LogCategory.VOICE, "Initialize audio controller later!");
|
2018-09-25 15:39:38 +00:00
|
|
|
$(document).one('click', event => AudioController.initializeFromGesture());
|
|
|
|
}
|
|
|
|
} catch (ex) {
|
2018-09-26 13:04:56 +00:00
|
|
|
if(ex instanceof ReferenceError)
|
|
|
|
ex = ex.message + ":<br>" + ex.stack;
|
2018-10-04 20:49:20 +00:00
|
|
|
displayCriticalError("Failed to invoke main function:<br>" + ex);
|
2018-09-25 15:39:38 +00:00
|
|
|
}
|
2018-08-05 16:59:24 +00:00
|
|
|
});
|