Fixed some native client bugs
This commit is contained in:
parent
d02983408c
commit
1c67d6a682
5 changed files with 74 additions and 20 deletions
|
@ -24,7 +24,7 @@ namespace MessageHelper {
|
||||||
|
|
||||||
return this.htmlEscape(object).map((entry, idx, array) => $.spawn("a").css("display", (idx == 0 || idx + 1 == array.length ? "inline" : "") + "block").html(entry));
|
return this.htmlEscape(object).map((entry, idx, array) => $.spawn("a").css("display", (idx == 0 || idx + 1 == array.length ? "inline" : "") + "block").html(entry));
|
||||||
} else if(typeof(object) === "object") {
|
} else if(typeof(object) === "object") {
|
||||||
if(object instanceof jQuery)
|
if(object instanceof $)
|
||||||
return [object];
|
return [object];
|
||||||
return this.formatElement("<unknwon object>");
|
return this.formatElement("<unknwon object>");
|
||||||
} else if(typeof(object) === "function") return this.formatElement(object());
|
} else if(typeof(object) === "function") return this.formatElement(object());
|
||||||
|
@ -295,7 +295,7 @@ class ChatBox {
|
||||||
|
|
||||||
this.htmlTag.find(".input button").click(this.onSend.bind(this));
|
this.htmlTag.find(".input button").click(this.onSend.bind(this));
|
||||||
this.htmlTag.find(".input_box").keypress(event => {
|
this.htmlTag.find(".input_box").keypress(event => {
|
||||||
if(event.keyCode == JQuery.Key.Enter && !event.shiftKey) {
|
if(event.keyCode == $.Key.Enter && !event.shiftKey) {
|
||||||
this.onSend();
|
this.onSend();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,12 +169,19 @@ class TSClient {
|
||||||
console.error("Could not connect to remote host! Exception");
|
console.error("Could not connect to remote host! Exception");
|
||||||
console.error(data);
|
console.error(data);
|
||||||
|
|
||||||
createErrorModal(
|
if(native_client) {
|
||||||
"Could not connect",
|
createErrorModal(
|
||||||
"Could not connect to remote host (Connection refused)<br>" +
|
"Could not connect",
|
||||||
"If you're sure that the remote host is up, than you may not allow unsigned certificates.<br>" +
|
"Could not connect to remote host (Connection refused)"
|
||||||
"Click <a href='" + this.certAcceptUrl() + "'>here</a> to accept the remote certificate"
|
).open();
|
||||||
).open();
|
} else {
|
||||||
|
createErrorModal(
|
||||||
|
"Could not connect",
|
||||||
|
"Could not connect to remote host (Connection refused)<br>" +
|
||||||
|
"If you're sure that the remote host is up, than you may not allow unsigned certificates.<br>" +
|
||||||
|
"Click <a href='" + this.certAcceptUrl() + "'>here</a> to accept the remote certificate"
|
||||||
|
).open();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DisconnectReason.CONNECTION_CLOSED:
|
case DisconnectReason.CONNECTION_CLOSED:
|
||||||
console.error("Lost connection to remote server!");
|
console.error("Lost connection to remote server!");
|
||||||
|
|
|
@ -17,6 +17,37 @@ let chat: ChatBox;
|
||||||
let forumIdentity: TeaForumIdentity;
|
let forumIdentity: TeaForumIdentity;
|
||||||
|
|
||||||
const js_render = window.jsrender || $;
|
const js_render = window.jsrender || $;
|
||||||
|
const native_client = window.require !== undefined;
|
||||||
|
|
||||||
|
function setup_close() {
|
||||||
|
if(settings.static(Settings.KEY_DISABLE_UNLOAD_DIALOG, false)) return;
|
||||||
|
|
||||||
|
window.onbeforeunload = event => {
|
||||||
|
if(!globalClient.serverConnection || !globalClient.serverConnection.connected) return;
|
||||||
|
|
||||||
|
if(!native_client) {
|
||||||
|
event.returnValue = "Are you really sure?<br>You're still connected!";
|
||||||
|
} else {
|
||||||
|
event.preventDefault();
|
||||||
|
event.returnValue = "question";
|
||||||
|
|
||||||
|
const {remote} = require('electron');
|
||||||
|
const dialog = remote.dialog;
|
||||||
|
|
||||||
|
dialog.showMessageBox(remote.getCurrentWindow(), {
|
||||||
|
type: 'question',
|
||||||
|
buttons: ['Yes', 'No'],
|
||||||
|
title: 'Confirm',
|
||||||
|
message: 'Are you really sure?\nYou\'re still connected!'
|
||||||
|
}, choice => {
|
||||||
|
if(choice === 0) {
|
||||||
|
window.onbeforeunload = undefined;
|
||||||
|
remote.getCurrentWindow().close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
if(!js_render) {
|
if(!js_render) {
|
||||||
|
@ -45,12 +76,8 @@ function main() {
|
||||||
globalClient.setup();
|
globalClient.setup();
|
||||||
|
|
||||||
|
|
||||||
if(!settings.static(Settings.KEY_DISABLE_UNLOAD_DIALOG, false)) {
|
if(!settings.static(Settings.KEY_DISABLE_UNLOAD_DIALOG, false) && !native_client) {
|
||||||
window.addEventListener("beforeunload", function (event) {
|
|
||||||
if(globalClient.serverConnection && globalClient.serverConnection.connected)
|
|
||||||
event.returnValue = "Are you really sure?<br>You're still connected!";
|
|
||||||
//event.preventDefault();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
//Modals.spawnConnectModal();
|
//Modals.spawnConnectModal();
|
||||||
//Modals.spawnSettingsModal();
|
//Modals.spawnSettingsModal();
|
||||||
|
@ -95,6 +122,11 @@ function main() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Modals.spawnPermissionEdit();
|
//Modals.spawnPermissionEdit();
|
||||||
|
|
||||||
|
setup_close();
|
||||||
|
$(window).on('resize', () => {
|
||||||
|
globalClient.channelTree.handle_resized();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.loadedListener.push(() => {
|
app.loadedListener.push(() => {
|
||||||
|
@ -109,4 +141,4 @@ app.loadedListener.push(() => {
|
||||||
ex = ex.message + ":<br>" + ex.stack;
|
ex = ex.message + ":<br>" + ex.stack;
|
||||||
displayCriticalError("Failed to invoke main function:<br>" + ex);
|
displayCriticalError("Failed to invoke main function:<br>" + ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -403,6 +403,10 @@ class ChannelEntry {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_frame_resized() {
|
||||||
|
this.__updateChannelName();
|
||||||
|
}
|
||||||
|
|
||||||
private __updateChannelName() {
|
private __updateChannelName() {
|
||||||
this._formatedChannelName = undefined;
|
this._formatedChannelName = undefined;
|
||||||
parseType:
|
parseType:
|
||||||
|
@ -437,12 +441,16 @@ class ChannelEntry {
|
||||||
|
|
||||||
if(this._channelAlign == "*") {
|
if(this._channelAlign == "*") {
|
||||||
let lastSuccess = "";
|
let lastSuccess = "";
|
||||||
let index = 0;
|
let index = 6;
|
||||||
|
|
||||||
|
let name = this.formatedChannelName();
|
||||||
|
while(index-- > 0)
|
||||||
|
name = name + name;
|
||||||
|
channelName.text(name);
|
||||||
do {
|
do {
|
||||||
channelName.text((lastSuccess = channelName.text()) + this.formatedChannelName());
|
channelName.text(name = name + name);
|
||||||
console.log(channelName.parent().width() + " : " + channelName.width() + " : " + channelName.innerWidth() + " : " + channelName.outerWidth());
|
} while (channelName.parent().width() >= channelName.width() && ++index < 64);
|
||||||
} while (channelName.parent().width() >= channelName.width() && ++index < 255);
|
if(index == 64) console.warn(LogCategory.CHANNEL, "Repeating spacer took too much repeats!");
|
||||||
if(index == 255) console.warn(LogCategory.CHANNEL, "Repeating spacer took too much repeats!");
|
|
||||||
if(lastSuccess.length > 0) {
|
if(lastSuccess.length > 0) {
|
||||||
channelName.text(lastSuccess);
|
channelName.text(lastSuccess);
|
||||||
self.addClass("c");
|
self.addClass("c");
|
||||||
|
|
|
@ -28,6 +28,8 @@ class ChannelTree {
|
||||||
_this.showContextMenu(event.pageX, event.pageY);
|
_this.showContextMenu(event.pageX, event.pageY);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.htmlTree.on('resize', this.handle_resized.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
showContextMenu(x: number, y: number, on_close: () => void = undefined) {
|
showContextMenu(x: number, y: number, on_close: () => void = undefined) {
|
||||||
|
@ -307,4 +309,9 @@ class ChannelTree {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_resized() {
|
||||||
|
for(let channel of this.channels)
|
||||||
|
channel.handle_frame_resized();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue