From 99f0407ba23707774884cd2ad103914044414587 Mon Sep 17 00:00:00 2001 From: HelloZeroNet Date: Sat, 19 Mar 2016 18:05:08 +0100 Subject: [PATCH] wrapperOpenWindow command --- src/Ui/media/Wrapper.coffee | 13 +++++++++++++ src/Ui/media/all.js | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/Ui/media/Wrapper.coffee b/src/Ui/media/Wrapper.coffee index ab613eab..7354575c 100644 --- a/src/Ui/media/Wrapper.coffee +++ b/src/Ui/media/Wrapper.coffee @@ -123,6 +123,8 @@ class Wrapper window.history.replaceState(message.params[0], message.params[1], query) else if cmd == "wrapperGetState" @sendInner {"cmd": "response", "to": message.id, "result": window.history.state} + else if cmd == "wrapperOpenWindow" + @actionOpenWindow(message.params) else # Send to websocket if message.id < 1000000 @ws.send(message) # Pass message to websocket @@ -150,6 +152,17 @@ class Wrapper # - Actions - + actionOpenWindow: (params) -> + if typeof(params) == "string" + w = window.open() + w.opener = null + w.location = params + else + w = window.open(null, params[1]) + w.opener = null + w.location = params[0] + + actionNotification: (message) -> message.params = @toHtmlSafe(message.params) # Escape html body = $(""+message.params[1]+"") diff --git a/src/Ui/media/all.js b/src/Ui/media/all.js index 8e4a406b..cb8e274d 100644 --- a/src/Ui/media/all.js +++ b/src/Ui/media/all.js @@ -908,6 +908,8 @@ jQuery.extend( jQuery.easing, "to": message.id, "result": window.history.state }); + } else if (cmd === "wrapperOpenWindow") { + return this.actionOpenWindow(message.params); } else { if (message.id < 1000000) { return this.ws.send(message); @@ -946,6 +948,19 @@ jQuery.extend( jQuery.easing, return $("body").prepend(elem); }; + Wrapper.prototype.actionOpenWindow = function(params) { + var w; + if (typeof params === "string") { + w = window.open(); + w.opener = null; + return w.location = params; + } else { + w = window.open(null, params[1]); + w.opener = null; + return w.location = params[0]; + } + }; + Wrapper.prototype.actionNotification = function(message) { var body; message.params = this.toHtmlSafe(message.params);