Merge wrapper

This commit is contained in:
shortcutme 2020-01-04 16:54:20 +01:00
parent 76e4b75c2d
commit 0dbcec8092
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -625,7 +625,8 @@ $.extend( $.easing,
(function() { (function() {
var Loading; var Loading,
slice = [].slice;
Loading = (function() { Loading = (function() {
function Loading(wrapper) { function Loading(wrapper) {
@ -640,7 +641,7 @@ $.extend( $.easing,
if (this.timer_hide) { if (this.timer_hide) {
clearInterval(this.timer_hide); clearInterval(this.timer_hide);
} }
return RateLimit(200, function() { return RateLimit(500, function() {
return $(".progressbar").css({ return $(".progressbar").css({
"transform": "scaleX(" + (parseInt(percent * 100) / 100) + ")" "transform": "scaleX(" + (parseInt(percent * 100) / 100) + ")"
}).css("opacity", "1").css("display", "block"); }).css("opacity", "1").css("display", "block");
@ -648,7 +649,7 @@ $.extend( $.easing,
}; };
Loading.prototype.hideProgress = function() { Loading.prototype.hideProgress = function() {
console.log("hideProgress"); this.log("hideProgress");
return this.timer_hide = setTimeout(((function(_this) { return this.timer_hide = setTimeout(((function(_this) {
return function() { return function() {
return $(".progressbar").css({ return $(".progressbar").css({
@ -666,6 +667,7 @@ $.extend( $.easing,
Loading.prototype.showTooLarge = function(site_info) { Loading.prototype.showTooLarge = function(site_info) {
var button, line; var button, line;
this.log("Displaying large site confirmation");
if ($(".console .button-setlimit").length === 0) { if ($(".console .button-setlimit").length === 0) {
line = this.printLine("Site size: <b>" + (parseInt(site_info.settings.size / 1024 / 1024)) + "MB</b> is larger than default allowed " + (parseInt(site_info.size_limit)) + "MB", "warning"); line = this.printLine("Site size: <b>" + (parseInt(site_info.settings.size / 1024 / 1024)) + "MB</b> is larger than default allowed " + (parseInt(site_info.size_limit)) + "MB", "warning");
button = $("<a href='#Set+limit' class='button button-setlimit'>" + ("Open site and set size limit to " + site_info.next_size_limit + "MB") + "</a>"); button = $("<a href='#Set+limit' class='button button-setlimit'>" + ("Open site and set size limit to " + site_info.next_size_limit + "MB") + "</a>");
@ -711,7 +713,7 @@ $.extend( $.easing,
}; };
Loading.prototype.hideScreen = function() { Loading.prototype.hideScreen = function() {
console.log("hideScreen"); this.log("hideScreen");
if (!$(".loadingscreen").hasClass("done")) { if (!$(".loadingscreen").hasClass("done")) {
if (this.screen_visible) { if (this.screen_visible) {
$(".loadingscreen").addClass("done").removeLater(2000); $(".loadingscreen").addClass("done").removeLater(2000);
@ -759,6 +761,12 @@ $.extend( $.easing,
return line; return line;
}; };
Loading.prototype.log = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return console.log.apply(console, ["[Loading]"].concat(slice.call(args)));
};
return Loading; return Loading;
})(); })();
@ -901,7 +909,6 @@ $.extend( $.easing,
}).call(this); }).call(this);
/* ---- Wrapper.coffee ---- */ /* ---- Wrapper.coffee ---- */
@ -1550,6 +1557,7 @@ $.extend( $.easing,
if (url_post == null) { if (url_post == null) {
url_post = ""; url_post = "";
} }
this.log("Reload");
current_url = window.location.toString().replace(/#.*/g, ""); current_url = window.location.toString().replace(/#.*/g, "");
if (url_post) { if (url_post) {
if (current_url.indexOf("?") > 0) { if (current_url.indexOf("?") > 0) {
@ -1665,6 +1673,7 @@ $.extend( $.easing,
Wrapper.prototype.onPageLoad = function(e) { Wrapper.prototype.onPageLoad = function(e) {
var ref; var ref;
this.log("onPageLoad");
this.inner_loaded = true; this.inner_loaded = true;
if (!this.inner_ready) { if (!this.inner_ready) {
this.sendInner({ this.sendInner({
@ -1706,18 +1715,14 @@ $.extend( $.easing,
var ref; var ref;
_this.address = site_info.address; _this.address = site_info.address;
_this.setSiteInfo(site_info); _this.setSiteInfo(site_info);
if (site_info.settings.size > site_info.size_limit * 1024 * 1024) { if (site_info.settings.size > site_info.size_limit * 1024 * 1024 && !_this.loading.screen_visible) {
if (_this.loading.screen_visible) { _this.displayConfirm("Site is larger than allowed: " + ((site_info.settings.size / 1024 / 1024).toFixed(1)) + "MB/" + site_info.size_limit + "MB", "Set limit to " + site_info.next_size_limit + "MB", function() {
_this.loading.showTooLarge(site_info); return _this.ws.cmd("siteSetLimit", [site_info.next_size_limit], function(res) {
} else { if (res === "ok") {
_this.displayConfirm("Site is larger than allowed: " + ((site_info.settings.size / 1024 / 1024).toFixed(1)) + "MB/" + site_info.size_limit + "MB", "Set limit to " + site_info.next_size_limit + "MB", function() { return _this.notifications.add("size_limit", "done", "Site storage limit modified!", 5000);
return _this.ws.cmd("siteSetLimit", [site_info.next_size_limit], function(res) { }
if (res === "ok") {
return _this.notifications.add("size_limit", "done", "Site storage limit modified!", 5000);
}
});
}); });
} });
} }
if (((ref = site_info.content) != null ? ref.title : void 0) != null) { if (((ref = site_info.content) != null ? ref.title : void 0) != null) {
window.document.title = site_info.content.title + " - ZeroNet"; window.document.title = site_info.content.title + " - ZeroNet";
@ -1741,7 +1746,7 @@ $.extend( $.easing,
} }
if (site_info.content) { if (site_info.content) {
window.document.title = site_info.content.title + " - ZeroNet"; window.document.title = site_info.content.title + " - ZeroNet";
this.log("Required file done, setting title to", window.document.title); this.log("Required file " + window.file_inner_path + " done, setting title to", window.document.title);
} }
if (!window.show_loadingscreen) { if (!window.show_loadingscreen) {
this.notifications.add("modified", "info", "New version of this page has just released.<br>Reload to see the modified content."); this.notifications.add("modified", "info", "New version of this page has just released.<br>Reload to see the modified content.");
@ -1781,11 +1786,16 @@ $.extend( $.easing,
} }
} }
if (this.loading.screen_visible && this.inner_loaded && site_info.settings.size < site_info.size_limit * 1024 * 1024 && site_info.settings.size > 0) { if (this.loading.screen_visible && this.inner_loaded && site_info.settings.size < site_info.size_limit * 1024 * 1024 && site_info.settings.size > 0) {
this.log("Loading screen visible, but inner loaded");
this.loading.hideScreen(); this.loading.hideScreen();
} }
if ((site_info != null ? (ref = site_info.settings) != null ? ref.own : void 0 : void 0) && (site_info != null ? (ref1 = site_info.settings) != null ? ref1.modified : void 0 : void 0) !== ((ref2 = this.site_info) != null ? (ref3 = ref2.settings) != null ? ref3.modified : void 0 : void 0)) { if ((site_info != null ? (ref = site_info.settings) != null ? ref.own : void 0 : void 0) && (site_info != null ? (ref1 = site_info.settings) != null ? ref1.modified : void 0 : void 0) !== ((ref2 = this.site_info) != null ? (ref3 = ref2.settings) != null ? ref3.modified : void 0 : void 0)) {
this.updateModifiedPanel(); this.updateModifiedPanel();
} }
if (this.loading.screen_visible && site_info.settings.size > site_info.size_limit * 1024 * 1024) {
this.log("Site too large");
this.loading.showTooLarge(site_info);
}
this.site_info = site_info; this.site_info = site_info;
return this.event_site_info.resolve(); return this.event_site_info.resolve();
}; };
@ -1927,6 +1937,8 @@ $.extend( $.easing,
if (reload == null) { if (reload == null) {
reload = true; reload = true;
} }
this.log("setSizeLimit: " + size_limit + ", reload: " + reload);
this.inner_loaded = false;
this.ws.cmd("siteSetLimit", [size_limit], (function(_this) { this.ws.cmd("siteSetLimit", [size_limit], (function(_this) {
return function(res) { return function(res) {
if (res !== "ok") { if (res !== "ok") {
@ -1984,6 +1996,7 @@ $.extend( $.easing,
}).call(this); }).call(this);
/* ---- WrapperZeroFrame.coffee ---- */ /* ---- WrapperZeroFrame.coffee ---- */