diff --git a/shared/js/chat.ts b/shared/js/chat.ts index 66a7ea41..52e78472 100644 --- a/shared/js/chat.ts +++ b/shared/js/chat.ts @@ -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(""); } 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; } diff --git a/shared/js/client.ts b/shared/js/client.ts index 55abf53d..4d87f3a5 100644 --- a/shared/js/client.ts +++ b/shared/js/client.ts @@ -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)
" + - "If you're sure that the remote host is up, than you may not allow unsigned certificates.
" + - "Click here 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)
" + + "If you're sure that the remote host is up, than you may not allow unsigned certificates.
" + + "Click here to accept the remote certificate" + ).open(); + } break; case DisconnectReason.CONNECTION_CLOSED: console.error("Lost connection to remote server!"); diff --git a/shared/js/main.ts b/shared/js/main.ts index dc4c9585..d2a13742 100644 --- a/shared/js/main.ts +++ b/shared/js/main.ts @@ -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?
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?
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 + ":
" + ex.stack; displayCriticalError("Failed to invoke main function:
" + ex); } -}); \ No newline at end of file +}); diff --git a/shared/js/ui/channel.ts b/shared/js/ui/channel.ts index 2bf2e65d..3411cb4d 100644 --- a/shared/js/ui/channel.ts +++ b/shared/js/ui/channel.ts @@ -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"); diff --git a/shared/js/ui/view.ts b/shared/js/ui/view.ts index 8cceaa39..93d52985 100644 --- a/shared/js/ui/view.ts +++ b/shared/js/ui/view.ts @@ -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(); + } } \ No newline at end of file