version 0.2.7, plugin system, multiuser plugin for zeroproxies, reworked imports, cookie parse, stats moved to plugin, usermanager class, dont generate site auth on listing, multiline notifications, allow server side prompt from user, update script keep plugins disabled status
This commit is contained in:
parent
3b8d49207e
commit
78f97dcbe8
26 changed files with 789 additions and 308 deletions
|
@ -33,7 +33,7 @@ class Notifications
|
|||
$(".notification-icon", elem).html("i")
|
||||
|
||||
if typeof(body) == "string"
|
||||
$(".body", elem).html(body)
|
||||
$(".body", elem).html("<span class='message'>"+body+"</span>")
|
||||
else
|
||||
$(".body", elem).html("").append(body)
|
||||
|
||||
|
@ -49,9 +49,11 @@ class Notifications
|
|||
# Animate
|
||||
width = elem.outerWidth()
|
||||
if not timeout then width += 20 # Add space for close button
|
||||
if elem.outerHeight() > 55 then elem.addClass("long")
|
||||
elem.css({"width": "50px", "transform": "scale(0.01)"})
|
||||
elem.animate({"scale": 1}, 800, "easeOutElastic")
|
||||
elem.animate({"width": width}, 700, "easeInOutCubic")
|
||||
$(".body", elem).cssLater("box-shadow", "0px 0px 5px rgba(0,0,0,0.1)", 1000)
|
||||
|
||||
# Close button
|
||||
$(".close", elem).on "click", =>
|
||||
|
|
|
@ -42,6 +42,9 @@ class Wrapper
|
|||
@sendInner message # Pass message to inner frame
|
||||
else if cmd == "notification" # Display notification
|
||||
@notifications.add("notification-#{message.id}", message.params[0], message.params[1], message.params[2])
|
||||
else if cmd == "prompt" # Prompt input
|
||||
@displayPrompt message.params[0], message.params[1], message.params[2], (res) =>
|
||||
@ws.response message.id, res
|
||||
else if cmd == "setSiteInfo"
|
||||
@sendInner message # Pass to inner frame
|
||||
if message.params.address == window.address # Current page
|
||||
|
@ -63,18 +66,19 @@ class Wrapper
|
|||
@sendInner {"cmd": "wrapperOpenedWebsocket"}
|
||||
@wrapperWsInited = true
|
||||
else if cmd == "wrapperNotification" # Display notification
|
||||
message.params = @toHtmlSafe(message.params) # Escape html
|
||||
@notifications.add("notification-#{message.id}", message.params[0], message.params[1], message.params[2])
|
||||
@actionNotification(message)
|
||||
else if cmd == "wrapperConfirm" # Display confirm message
|
||||
@actionWrapperConfirm(message)
|
||||
@actionConfirm(message)
|
||||
else if cmd == "wrapperPrompt" # Prompt input
|
||||
@actionWrapperPrompt(message)
|
||||
@actionPrompt(message)
|
||||
else if cmd == "wrapperSetViewport" # Set the viewport
|
||||
@actionSetViewport(message)
|
||||
else if cmd == "wrapperReload" # Reload current page
|
||||
@actionReload(message)
|
||||
else if cmd == "wrapperGetLocalStorage"
|
||||
@actionGetLocalStorage(message)
|
||||
else if cmd == "wrapperSetLocalStorage"
|
||||
@actionSetLocalStorage(message)
|
||||
@actionSetLocalStorage(message)
|
||||
else # Send to websocket
|
||||
if message.id < 1000000
|
||||
@ws.send(message) # Pass message to websocket
|
||||
|
@ -84,46 +88,58 @@ class Wrapper
|
|||
|
||||
# - Actions -
|
||||
|
||||
actionWrapperConfirm: (message, cb=false) ->
|
||||
actionNotification: (message) ->
|
||||
message.params = @toHtmlSafe(message.params) # Escape html
|
||||
if message.params[1] then caption = message.params[1] else caption = "ok"
|
||||
@wrapperConfirm message.params[0], caption, =>
|
||||
@sendInner {"cmd": "response", "to": message.id, "result": "boom"} # Response to confirm
|
||||
return false
|
||||
body = $("<span class='message'>"+message.params[1]+"</span>")
|
||||
@notifications.add("notification-#{message.id}", message.params[0], body, message.params[2])
|
||||
|
||||
|
||||
wrapperConfirm: (message, caption, cb) ->
|
||||
body = $("<span>"+message+"</span>")
|
||||
|
||||
displayConfirm: (message, caption, cb) ->
|
||||
body = $("<span class='message'>"+message+"</span>")
|
||||
button = $("<a href='##{caption}' class='button button-#{caption}'>#{caption}</a>") # Add confirm button
|
||||
button.on "click", cb
|
||||
body.append(button)
|
||||
@notifications.add("notification-#{caption}", "ask", body)
|
||||
|
||||
|
||||
|
||||
actionWrapperPrompt: (message) ->
|
||||
actionConfirm: (message, cb=false) ->
|
||||
message.params = @toHtmlSafe(message.params) # Escape html
|
||||
if message.params[1] then type = message.params[1] else type = "text"
|
||||
caption = "OK"
|
||||
if message.params[1] then caption = message.params[1] else caption = "ok"
|
||||
@displayConfirm message.params[0], caption, =>
|
||||
@sendInner {"cmd": "response", "to": message.id, "result": "boom"} # Response to confirm
|
||||
return false
|
||||
|
||||
body = $("<span>"+message.params[0]+"</span>")
|
||||
|
||||
|
||||
displayPrompt: (message, type, caption, cb) ->
|
||||
body = $("<span class='message'>"+message+"</span>")
|
||||
|
||||
input = $("<input type='#{type}' class='input button-#{type}'/>") # Add input
|
||||
input.on "keyup", (e) => # Send on enter
|
||||
if e.keyCode == 13
|
||||
button.trigger "click" # Response to confirm
|
||||
|
||||
body.append(input)
|
||||
|
||||
button = $("<a href='##{caption}' class='button button-#{caption}'>#{caption}</a>") # Add confirm button
|
||||
button.on "click", => # Response on button click
|
||||
@sendInner {"cmd": "response", "to": message.id, "result": input.val()} # Response to confirm
|
||||
cb input.val()
|
||||
return false
|
||||
body.append(button)
|
||||
|
||||
@notifications.add("notification-#{message.id}", "ask", body)
|
||||
|
||||
|
||||
actionPrompt: (message) ->
|
||||
message.params = @toHtmlSafe(message.params) # Escape html
|
||||
if message.params[1] then type = message.params[1] else type = "text"
|
||||
caption = "OK"
|
||||
|
||||
@displayPrompt message.params[0], type, caption, (res) =>
|
||||
@sendInner {"cmd": "response", "to": message.id, "result": res} # Response to confirm
|
||||
|
||||
|
||||
|
||||
actionSetViewport: (message) ->
|
||||
@log "actionSetViewport", message
|
||||
if $("#viewport").length > 0
|
||||
|
@ -132,6 +148,16 @@ class Wrapper
|
|||
$('<meta name="viewport" id="viewport">').attr("content", @toHtmlSafe message.params).appendTo("head")
|
||||
|
||||
|
||||
reload: (url_post="") ->
|
||||
if url_post
|
||||
if window.location.toString().indexOf("?") > 0
|
||||
window.location += "&"+url_post
|
||||
else
|
||||
window.location += "?"+url_post
|
||||
else
|
||||
window.location.reload()
|
||||
|
||||
|
||||
actionGetLocalStorage: (message) ->
|
||||
data = localStorage.getItem "site.#{window.address}"
|
||||
if data then data = JSON.parse(data)
|
||||
|
|
|
@ -33,21 +33,28 @@ a { color: black }
|
|||
|
||||
/* Notification */
|
||||
|
||||
.notifications { position: absolute; top: 0px; right: 85px; display: inline-block; z-index: 999; white-space: nowrap }
|
||||
.notifications { position: absolute; top: 0px; right: 80px; display: inline-block; z-index: 999; white-space: nowrap }
|
||||
.notification {
|
||||
position: relative; float: right; clear: both; margin: 10px; height: 50px; box-sizing: border-box; overflow: hidden; backface-visibility: hidden; perspective: 1000px;
|
||||
background-color: white; color: #4F4F4F; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; /*border: 1px solid rgba(210, 206, 205, 0.2)*/
|
||||
position: relative; float: right; clear: both; margin: 10px; box-sizing: border-box; overflow: hidden; backface-visibility: hidden; perspective: 1000px; padding-bottom: 5px;
|
||||
color: #4F4F4F; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; /*border: 1px solid rgba(210, 206, 205, 0.2)*/
|
||||
}
|
||||
.notification-icon {
|
||||
display: block; width: 50px; height: 50px; position: absolute; float: left; z-index: 1;
|
||||
text-align: center; background-color: #e74c3c; line-height: 45px; vertical-align: bottom; font-size: 40px; color: white;
|
||||
}
|
||||
.notification .body { max-width: 420px; padding-left: 68px; padding-right: 17px; height: 50px; vertical-align: middle; display: table-cell }
|
||||
.notification .body {
|
||||
max-width: 420px; padding-left: 14px; padding-right: 60px; height: 40px; vertical-align: middle; display: table;
|
||||
background-color: white; left: 50px; top: 0px; position: relative; padding-top: 5px; padding-bottom: 5px;
|
||||
}
|
||||
.notification.long .body { padding-top: 10px; padding-bottom: 10px }
|
||||
.notification .message { display: table-cell; vertical-align: middle }
|
||||
|
||||
.notification.visible { max-width: 350px }
|
||||
|
||||
.notification .close { position: absolute; top: 0px; right: 0px; font-size: 19px; line-height: 13px; color: #DDD; padding: 7px; text-decoration: none }
|
||||
.notification .close:hover { color: black }
|
||||
.notification .close:active, .notification .close:focus { color: #AF3BFF }
|
||||
.notification small { color: #AAA }
|
||||
.body-white .notification { box-shadow: 0px 1px 9px rgba(0,0,0,0.1) }
|
||||
|
||||
/* Notification types */
|
||||
|
|
|
@ -38,21 +38,28 @@ a { color: black }
|
|||
|
||||
/* Notification */
|
||||
|
||||
.notifications { position: absolute; top: 0px; right: 85px; display: inline-block; z-index: 999; white-space: nowrap }
|
||||
.notifications { position: absolute; top: 0px; right: 80px; display: inline-block; z-index: 999; white-space: nowrap }
|
||||
.notification {
|
||||
position: relative; float: right; clear: both; margin: 10px; height: 50px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; overflow: hidden; backface-visibility: hidden; -webkit-perspective: 1000px; -moz-perspective: 1000px; -o-perspective: 1000px; -ms-perspective: 1000px; perspective: 1000px ;
|
||||
background-color: white; color: #4F4F4F; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; /*border: 1px solid rgba(210, 206, 205, 0.2)*/
|
||||
position: relative; float: right; clear: both; margin: 10px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box ; overflow: hidden; backface-visibility: hidden; -webkit-perspective: 1000px; -moz-perspective: 1000px; -o-perspective: 1000px; -ms-perspective: 1000px; perspective: 1000px ; padding-bottom: 5px;
|
||||
color: #4F4F4F; font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; /*border: 1px solid rgba(210, 206, 205, 0.2)*/
|
||||
}
|
||||
.notification-icon {
|
||||
display: block; width: 50px; height: 50px; position: absolute; float: left; z-index: 1;
|
||||
text-align: center; background-color: #e74c3c; line-height: 45px; vertical-align: bottom; font-size: 40px; color: white;
|
||||
}
|
||||
.notification .body { max-width: 420px; padding-left: 68px; padding-right: 17px; height: 50px; vertical-align: middle; display: table-cell }
|
||||
.notification .body {
|
||||
max-width: 420px; padding-left: 14px; padding-right: 60px; height: 40px; vertical-align: middle; display: table;
|
||||
background-color: white; left: 50px; top: 0px; position: relative; padding-top: 5px; padding-bottom: 5px;
|
||||
}
|
||||
.notification.long .body { padding-top: 10px; padding-bottom: 10px }
|
||||
.notification .message { display: table-cell; vertical-align: middle }
|
||||
|
||||
.notification.visible { max-width: 350px }
|
||||
|
||||
.notification .close { position: absolute; top: 0px; right: 0px; font-size: 19px; line-height: 13px; color: #DDD; padding: 7px; text-decoration: none }
|
||||
.notification .close:hover { color: black }
|
||||
.notification .close:active, .notification .close:focus { color: #AF3BFF }
|
||||
.notification small { color: #AAA }
|
||||
.body-white .notification { -webkit-box-shadow: 0px 1px 9px rgba(0,0,0,0.1) ; -moz-box-shadow: 0px 1px 9px rgba(0,0,0,0.1) ; -o-box-shadow: 0px 1px 9px rgba(0,0,0,0.1) ; -ms-box-shadow: 0px 1px 9px rgba(0,0,0,0.1) ; box-shadow: 0px 1px 9px rgba(0,0,0,0.1) }
|
||||
|
||||
/* Notification types */
|
||||
|
|
|
@ -149,7 +149,6 @@
|
|||
}).call(this);
|
||||
|
||||
|
||||
|
||||
/* ---- src/Ui/media/lib/jquery.cssanim.js ---- */
|
||||
|
||||
|
||||
|
@ -247,7 +246,6 @@ jQuery.fx.step.scale = function(fx) {
|
|||
}).call(this);
|
||||
|
||||
|
||||
|
||||
/* ---- src/Ui/media/lib/jquery.easing.1.3.js ---- */
|
||||
|
||||
|
||||
|
@ -542,7 +540,6 @@ jQuery.extend( jQuery.easing,
|
|||
}).call(this);
|
||||
|
||||
|
||||
|
||||
/* ---- src/Ui/media/Notifications.coffee ---- */
|
||||
|
||||
|
||||
|
@ -593,7 +590,7 @@ jQuery.extend( jQuery.easing,
|
|||
$(".notification-icon", elem).html("i");
|
||||
}
|
||||
if (typeof body === "string") {
|
||||
$(".body", elem).html(body);
|
||||
$(".body", elem).html("<span class='message'>" + body + "</span>");
|
||||
} else {
|
||||
$(".body", elem).html("").append(body);
|
||||
}
|
||||
|
@ -610,6 +607,9 @@ jQuery.extend( jQuery.easing,
|
|||
if (!timeout) {
|
||||
width += 20;
|
||||
}
|
||||
if (elem.outerHeight() > 55) {
|
||||
elem.addClass("long");
|
||||
}
|
||||
elem.css({
|
||||
"width": "50px",
|
||||
"transform": "scale(0.01)"
|
||||
|
@ -620,6 +620,7 @@ jQuery.extend( jQuery.easing,
|
|||
elem.animate({
|
||||
"width": width
|
||||
}, 700, "easeInOutCubic");
|
||||
$(".body", elem).cssLater("box-shadow", "0px 0px 5px rgba(0,0,0,0.1)", 1000);
|
||||
$(".close", elem).on("click", (function(_this) {
|
||||
return function() {
|
||||
_this.close(elem);
|
||||
|
@ -725,7 +726,6 @@ jQuery.extend( jQuery.easing,
|
|||
}).call(this);
|
||||
|
||||
|
||||
|
||||
/* ---- src/Ui/media/Wrapper.coffee ---- */
|
||||
|
||||
|
||||
|
@ -786,6 +786,12 @@ jQuery.extend( jQuery.easing,
|
|||
}
|
||||
} else if (cmd === "notification") {
|
||||
return this.notifications.add("notification-" + message.id, message.params[0], message.params[1], message.params[2]);
|
||||
} else if (cmd === "prompt") {
|
||||
return this.displayPrompt(message.params[0], message.params[1], message.params[2], (function(_this) {
|
||||
return function(res) {
|
||||
return _this.ws.response(message.id, res);
|
||||
};
|
||||
})(this));
|
||||
} else if (cmd === "setSiteInfo") {
|
||||
this.sendInner(message);
|
||||
if (message.params.address === window.address) {
|
||||
|
@ -812,14 +818,15 @@ jQuery.extend( jQuery.easing,
|
|||
return this.wrapperWsInited = true;
|
||||
}
|
||||
} else if (cmd === "wrapperNotification") {
|
||||
message.params = this.toHtmlSafe(message.params);
|
||||
return this.notifications.add("notification-" + message.id, message.params[0], message.params[1], message.params[2]);
|
||||
return this.actionNotification(message);
|
||||
} else if (cmd === "wrapperConfirm") {
|
||||
return this.actionWrapperConfirm(message);
|
||||
return this.actionConfirm(message);
|
||||
} else if (cmd === "wrapperPrompt") {
|
||||
return this.actionWrapperPrompt(message);
|
||||
return this.actionPrompt(message);
|
||||
} else if (cmd === "wrapperSetViewport") {
|
||||
return this.actionSetViewport(message);
|
||||
} else if (cmd === "wrapperReload") {
|
||||
return this.actionReload(message);
|
||||
} else if (cmd === "wrapperGetLocalStorage") {
|
||||
return this.actionGetLocalStorage(message);
|
||||
} else if (cmd === "wrapperSetLocalStorage") {
|
||||
|
@ -833,7 +840,23 @@ jQuery.extend( jQuery.easing,
|
|||
}
|
||||
};
|
||||
|
||||
Wrapper.prototype.actionWrapperConfirm = function(message, cb) {
|
||||
Wrapper.prototype.actionNotification = function(message) {
|
||||
var body;
|
||||
message.params = this.toHtmlSafe(message.params);
|
||||
body = $("<span class='message'>" + message.params[1] + "</span>");
|
||||
return this.notifications.add("notification-" + message.id, message.params[0], body, message.params[2]);
|
||||
};
|
||||
|
||||
Wrapper.prototype.displayConfirm = function(message, caption, cb) {
|
||||
var body, button;
|
||||
body = $("<span class='message'>" + message + "</span>");
|
||||
button = $("<a href='#" + caption + "' class='button button-" + caption + "'>" + caption + "</a>");
|
||||
button.on("click", cb);
|
||||
body.append(button);
|
||||
return this.notifications.add("notification-" + caption, "ask", body);
|
||||
};
|
||||
|
||||
Wrapper.prototype.actionConfirm = function(message, cb) {
|
||||
var caption;
|
||||
if (cb == null) {
|
||||
cb = false;
|
||||
|
@ -844,7 +867,7 @@ jQuery.extend( jQuery.easing,
|
|||
} else {
|
||||
caption = "ok";
|
||||
}
|
||||
return this.wrapperConfirm(message.params[0], caption, (function(_this) {
|
||||
return this.displayConfirm(message.params[0], caption, (function(_this) {
|
||||
return function() {
|
||||
_this.sendInner({
|
||||
"cmd": "response",
|
||||
|
@ -856,25 +879,9 @@ jQuery.extend( jQuery.easing,
|
|||
})(this));
|
||||
};
|
||||
|
||||
Wrapper.prototype.wrapperConfirm = function(message, caption, cb) {
|
||||
var body, button;
|
||||
body = $("<span>" + message + "</span>");
|
||||
button = $("<a href='#" + caption + "' class='button button-" + caption + "'>" + caption + "</a>");
|
||||
button.on("click", cb);
|
||||
body.append(button);
|
||||
return this.notifications.add("notification-" + caption, "ask", body);
|
||||
};
|
||||
|
||||
Wrapper.prototype.actionWrapperPrompt = function(message) {
|
||||
var body, button, caption, input, type;
|
||||
message.params = this.toHtmlSafe(message.params);
|
||||
if (message.params[1]) {
|
||||
type = message.params[1];
|
||||
} else {
|
||||
type = "text";
|
||||
}
|
||||
caption = "OK";
|
||||
body = $("<span>" + message.params[0] + "</span>");
|
||||
Wrapper.prototype.displayPrompt = function(message, type, caption, cb) {
|
||||
var body, button, input;
|
||||
body = $("<span class='message'>" + message + "</span>");
|
||||
input = $("<input type='" + type + "' class='input button-" + type + "'/>");
|
||||
input.on("keyup", (function(_this) {
|
||||
return function(e) {
|
||||
|
@ -887,11 +894,7 @@ jQuery.extend( jQuery.easing,
|
|||
button = $("<a href='#" + caption + "' class='button button-" + caption + "'>" + caption + "</a>");
|
||||
button.on("click", (function(_this) {
|
||||
return function() {
|
||||
_this.sendInner({
|
||||
"cmd": "response",
|
||||
"to": message.id,
|
||||
"result": input.val()
|
||||
});
|
||||
cb(input.val());
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
|
@ -899,6 +902,26 @@ jQuery.extend( jQuery.easing,
|
|||
return this.notifications.add("notification-" + message.id, "ask", body);
|
||||
};
|
||||
|
||||
Wrapper.prototype.actionPrompt = function(message) {
|
||||
var caption, type;
|
||||
message.params = this.toHtmlSafe(message.params);
|
||||
if (message.params[1]) {
|
||||
type = message.params[1];
|
||||
} else {
|
||||
type = "text";
|
||||
}
|
||||
caption = "OK";
|
||||
return this.displayPrompt(message.params[0], type, caption, (function(_this) {
|
||||
return function(res) {
|
||||
return _this.sendInner({
|
||||
"cmd": "response",
|
||||
"to": message.id,
|
||||
"result": res
|
||||
});
|
||||
};
|
||||
})(this));
|
||||
};
|
||||
|
||||
Wrapper.prototype.actionSetViewport = function(message) {
|
||||
this.log("actionSetViewport", message);
|
||||
if ($("#viewport").length > 0) {
|
||||
|
@ -908,6 +931,21 @@ jQuery.extend( jQuery.easing,
|
|||
}
|
||||
};
|
||||
|
||||
Wrapper.prototype.reload = function(url_post) {
|
||||
if (url_post == null) {
|
||||
url_post = "";
|
||||
}
|
||||
if (url_post) {
|
||||
if (window.location.toString().indexOf("?") > 0) {
|
||||
return window.location += "&" + url_post;
|
||||
} else {
|
||||
return window.location += "?" + url_post;
|
||||
}
|
||||
} else {
|
||||
return window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
Wrapper.prototype.actionGetLocalStorage = function(message) {
|
||||
var data;
|
||||
data = localStorage.getItem("site." + window.address);
|
||||
|
@ -1116,4 +1154,4 @@ jQuery.extend( jQuery.easing,
|
|||
|
||||
window.wrapper = new Wrapper(ws_url);
|
||||
|
||||
}).call(this);
|
||||
}).call(this);
|
Loading…
Add table
Add a link
Reference in a new issue