progressive publish timeout based on filesize, better tracker error log, content.json viewport support, wrapperSetViewport wrapperapi command support, escape wrapper notification

This commit is contained in:
HelloZeroNet 2015-02-10 00:08:25 +01:00
parent 3b22be5091
commit bccd246f71
5 changed files with 65 additions and 18 deletions

View file

@ -67,6 +67,8 @@ class Wrapper
@actionWrapperConfirm(message)
else if cmd == "wrapperPrompt" # Prompt input
@actionWrapperPrompt(message)
else if cmd == "wrapperSetViewport" # Set the viewport
@actionSetViewport(message)
else # Send to websocket
@ws.send(message) # Pass message to websocket
@ -108,10 +110,20 @@ class Wrapper
return false
body.append(button)
@notifications.add("notification-#{message.id}", "ask", body)
actionSetViewport: (message) ->
@log "actionSetViewport", message
if $("#viewport").length > 0
$("#viewport").attr("content", @toHtmlSafe message.params)
else
$('<meta name="viewport" id="viewport">').attr("content", @toHtmlSafe message.params).appendTo("head")
# EOF actions
onOpenWebsocket: (e) =>
@ws.cmd "channelJoin", {"channel": "siteChanged"} # Get info on modifications
@log "onOpenWebsocket", @inner_ready, @wrapperWsInited
@ -200,8 +212,14 @@ class Wrapper
@site_info = site_info
toHtmlSafe: (unsafe) ->
return unsafe
toHtmlSafe: (values) ->
if values not instanceof Array then values = [values] # Convert to array if its not
for value, i in values
value = String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') # Escape
value = value.replace(/&lt;([\/]{0,1}(br|b|u|i))&gt;/g, "<$1>") # Unescape b, i, u, br tags
values[i] = value
return values
log: (args...) ->

View file

@ -799,6 +799,8 @@ jQuery.extend( jQuery.easing,
return this.actionWrapperConfirm(message);
} else if (cmd === "wrapperPrompt") {
return this.actionWrapperPrompt(message);
} else if (cmd === "wrapperSetViewport") {
return this.actionSetViewport(message);
} else {
return this.ws.send(message);
}
@ -862,6 +864,15 @@ jQuery.extend( jQuery.easing,
return this.notifications.add("notification-" + message.id, "ask", body);
};
Wrapper.prototype.actionSetViewport = function(message) {
this.log("actionSetViewport", message);
if ($("#viewport").length > 0) {
return $("#viewport").attr("content", this.toHtmlSafe(message.params));
} else {
return $('<meta name="viewport" id="viewport">').attr("content", this.toHtmlSafe(message.params)).appendTo("head");
}
};
Wrapper.prototype.onOpenWebsocket = function(e) {
this.ws.cmd("channelJoin", {
"channel": "siteChanged"
@ -974,8 +985,18 @@ jQuery.extend( jQuery.easing,
return this.site_info = site_info;
};
Wrapper.prototype.toHtmlSafe = function(unsafe) {
return unsafe;
Wrapper.prototype.toHtmlSafe = function(values) {
var i, value, _i, _len;
if (!(values instanceof Array)) {
values = [values];
}
for (i = _i = 0, _len = values.length; _i < _len; i = ++_i) {
value = values[i];
value = String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
value = value.replace(/&lt;([\/]{0,1}(br|b|u|i))&gt;/g, "<$1>");
values[i] = value;
}
return values;
};
Wrapper.prototype.log = function() {