wrapperOpenWindow command

This commit is contained in:
HelloZeroNet 2016-03-19 18:05:08 +01:00
parent 3128b23b6f
commit 99f0407ba2
2 changed files with 28 additions and 0 deletions

View file

@ -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 = $("<span class='message'>"+message.params[1]+"</span>")

View file

@ -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);