From 73dc69605b014119219817e8d741760e6e2d0486 Mon Sep 17 00:00:00 2001 From: Tamas Kocsis Date: Mon, 21 Sep 2020 18:26:55 +0200 Subject: [PATCH] Merge sidebar js, css --- plugins/Sidebar/media/all.css | 3 +- plugins/Sidebar/media/all.js | 63 ++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/plugins/Sidebar/media/all.css b/plugins/Sidebar/media/all.css index 741169f3..056d7e89 100644 --- a/plugins/Sidebar/media/all.css +++ b/plugins/Sidebar/media/all.css @@ -128,9 +128,10 @@ .sidebar .link-right { color: white; text-decoration: none; border-bottom: 1px solid #666; text-transform: uppercase; } .sidebar .link-right:hover { border-color: #CCC; } .sidebar .link-right:active { background-color: #444 } +.sidebar .link-outline { outline: 1px solid #eee6; padding: 2px 13px; border-bottom: none; font-size: 80%; } /* SIDEBAR */ -.sidebar-container { width: 100%; height: 100%; overflow: hidden; position: fixed; z-index: 2; } +.sidebar-container { width: 100%; height: 100%; overflow: hidden; position: fixed; top: 0px; z-index: 2;} .sidebar { background-color: #212121; position: fixed; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden ; right: -1200px; height: 100%; width: 1200px; } /*box-shadow: inset 0px 0px 10px #000*/ .sidebar .content { margin: 30px; font-family: "Segoe UI Light", "Segoe UI", "Helvetica Neue"; color: white; width: 375px; height: 300px; font-weight: 200; -webkit-transition: all 1s; -moz-transition: all 1s; -o-transition: all 1s; -ms-transition: all 1s; transition: all 1s ; opacity: 0 } .sidebar-container.loaded .content { opacity: 1; -webkit-transform: none ; -moz-transform: none ; -o-transform: none ; -ms-transform: none ; transform: none } diff --git a/plugins/Sidebar/media/all.js b/plugins/Sidebar/media/all.js index ff7e3cc3..88d6abf0 100644 --- a/plugins/Sidebar/media/all.js +++ b/plugins/Sidebar/media/all.js @@ -114,12 +114,12 @@ })(this); $(window).on("hashchange", (function(_this) { return function() { - if (window.top.location.hash === "#ZeroNet:Console") { + if (window.top.location.hash.startsWith("#ZeroNet:Console")) { return _this.open(); } }; })(this)); - if (window.top.location.hash === "#ZeroNet:Console") { + if (window.top.location.hash.startsWith("#ZeroNet:Console")) { setTimeout(((function(_this) { return function() { return _this.open(); @@ -151,12 +151,17 @@ tab_type = ref[j]; tab = $("", { href: "#", - "data-filter": tab_type.filter + "data-filter": tab_type.filter, + "data-title": tab_type.title }).text(tab_type.title); if (tab_type.filter === this.tab_active) { tab.addClass("active"); } tab.on("click", this.handleTabClick); + if (window.top.location.hash.endsWith(tab_type.title)) { + this.log("Triggering click on", tab); + tab.trigger("click"); + } this.tabs.append(tab); } this.container.on("mousedown touchend touchcancel", (function(_this) { @@ -342,6 +347,7 @@ $("a", this.tabs).removeClass("active"); elem.addClass("active"); this.changeFilter(this.tab_active); + window.top.location.hash = "#ZeroNet:Console:" + elem.data("title"); return false; }; @@ -353,6 +359,7 @@ }).call(this); + /* ---- Menu.coffee ---- */ @@ -435,6 +442,40 @@ }).call(this); +/* ---- Prototypes.coffee ---- */ + + +(function() { + String.prototype.startsWith = function(s) { + return this.slice(0, s.length) === s; + }; + + String.prototype.endsWith = function(s) { + return s === '' || this.slice(-s.length) === s; + }; + + String.prototype.capitalize = function() { + if (this.length) { + return this[0].toUpperCase() + this.slice(1); + } else { + return ""; + } + }; + + String.prototype.repeat = function(count) { + return new Array(count + 1).join(this); + }; + + window.isEmpty = function(obj) { + var key; + for (key in obj) { + return false; + } + return true; + }; + +}).call(this); + /* ---- RateLimit.coffee ---- */ @@ -1104,7 +1145,20 @@ window.initScrollable = function () { })(this)); this.tag.find("#checkbox-owned").off("click touchend").on("click touchend", (function(_this) { return function() { - return _this.wrapper.ws.cmd("siteSetOwned", [_this.tag.find("#checkbox-owned").is(":checked")]); + var owned; + owned = _this.tag.find("#checkbox-owned").is(":checked"); + return _this.wrapper.ws.cmd("siteSetOwned", [owned], function(res_set_owned) { + _this.log("Owned", owned); + if (owned) { + return _this.wrapper.ws.cmd("siteRecoverPrivatekey", [], function(res_recover) { + if (res_recover === "ok") { + return _this.wrapper.notifications.add("recover", "done", "Private key recovered from master seed", 5000); + } else { + return _this.log("Unable to recover private key: " + res_recover.error); + } + }); + } + }); }; })(this)); this.tag.find("#checkbox-autodownloadoptional").off("click touchend").on("click touchend", (function(_this) { @@ -1370,7 +1424,6 @@ window.initScrollable = function () { }).call(this); - /* ---- morphdom.js ---- */