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));
|
||||
} else if(typeof(object) === "object") {
|
||||
if(object instanceof jQuery)
|
||||
if(object instanceof $)
|
||||
return [object];
|
||||
return this.formatElement("<unknwon 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_box").keypress(event => {
|
||||
if(event.keyCode == JQuery.Key.Enter && !event.shiftKey) {
|
||||
if(event.keyCode == $.Key.Enter && !event.shiftKey) {
|
||||
this.onSend();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -169,12 +169,19 @@ class TSClient {
|
|||
console.error("Could not connect to remote host! Exception");
|
||||
console.error(data);
|
||||
|
||||
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();
|
||||
if(native_client) {
|
||||
createErrorModal(
|
||||
"Could not connect",
|
||||
"Could not connect to remote host (Connection refused)"
|
||||
).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;
|
||||
case DisconnectReason.CONNECTION_CLOSED:
|
||||
console.error("Lost connection to remote server!");
|
||||
|
|
|
@ -17,6 +17,37 @@ let chat: ChatBox;
|
|||
let forumIdentity: TeaForumIdentity;
|
||||
|
||||
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() {
|
||||
if(!js_render) {
|
||||
|
@ -45,12 +76,8 @@ function main() {
|
|||
globalClient.setup();
|
||||
|
||||
|
||||
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();
|
||||
});
|
||||
if(!settings.static(Settings.KEY_DISABLE_UNLOAD_DIALOG, false) && !native_client) {
|
||||
|
||||
}
|
||||
//Modals.spawnConnectModal();
|
||||
//Modals.spawnSettingsModal();
|
||||
|
@ -95,6 +122,11 @@ function main() {
|
|||
*/
|
||||
|
||||
//Modals.spawnPermissionEdit();
|
||||
|
||||
setup_close();
|
||||
$(window).on('resize', () => {
|
||||
globalClient.channelTree.handle_resized();
|
||||
});
|
||||
}
|
||||
|
||||
app.loadedListener.push(() => {
|
||||
|
@ -109,4 +141,4 @@ app.loadedListener.push(() => {
|
|||
ex = ex.message + ":<br>" + ex.stack;
|
||||
displayCriticalError("Failed to invoke main function:<br>" + ex);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -403,6 +403,10 @@ class ChannelEntry {
|
|||
);
|
||||
}
|
||||
|
||||
handle_frame_resized() {
|
||||
this.__updateChannelName();
|
||||
}
|
||||
|
||||
private __updateChannelName() {
|
||||
this._formatedChannelName = undefined;
|
||||
parseType:
|
||||
|
@ -437,12 +441,16 @@ class ChannelEntry {
|
|||
|
||||
if(this._channelAlign == "*") {
|
||||
let lastSuccess = "";
|
||||
let index = 0;
|
||||
let index = 6;
|
||||
|
||||
let name = this.formatedChannelName();
|
||||
while(index-- > 0)
|
||||
name = name + name;
|
||||
channelName.text(name);
|
||||
do {
|
||||
channelName.text((lastSuccess = channelName.text()) + this.formatedChannelName());
|
||||
console.log(channelName.parent().width() + " : " + channelName.width() + " : " + channelName.innerWidth() + " : " + channelName.outerWidth());
|
||||
} while (channelName.parent().width() >= channelName.width() && ++index < 255);
|
||||
if(index == 255) console.warn(LogCategory.CHANNEL, "Repeating spacer took too much repeats!");
|
||||
channelName.text(name = name + name);
|
||||
} while (channelName.parent().width() >= channelName.width() && ++index < 64);
|
||||
if(index == 64) console.warn(LogCategory.CHANNEL, "Repeating spacer took too much repeats!");
|
||||
if(lastSuccess.length > 0) {
|
||||
channelName.text(lastSuccess);
|
||||
self.addClass("c");
|
||||
|
|
|
@ -28,6 +28,8 @@ class ChannelTree {
|
|||
_this.showContextMenu(event.pageX, event.pageY);
|
||||
});
|
||||
}
|
||||
|
||||
this.htmlTree.on('resize', this.handle_resized.bind(this));
|
||||
}
|
||||
|
||||
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