diff --git a/plugins/Sidebar/media/Console.coffee b/plugins/Sidebar/media/Console.coffee index 724ebb94..d5a83346 100644 --- a/plugins/Sidebar/media/Console.coffee +++ b/plugins/Sidebar/media/Console.coffee @@ -20,10 +20,10 @@ class Console extends Class handleMessageWebsocket_original(message) $(window).on "hashchange", => - if window.top.location.hash == "#ZeroNet:Console" + if window.top.location.hash.startsWith("#ZeroNet:Console") @open() - if window.top.location.hash == "#ZeroNet:Console" + if window.top.location.hash.startsWith("#ZeroNet:Console") setTimeout (=> @open()), 10 createHtmltag: -> @@ -58,10 +58,13 @@ class Console extends Class @container.appendTo(document.body) @tag = @container.find(".console") for tab_type in @tab_types - tab = $("", {href: "#", "data-filter": tab_type.filter}).text(tab_type.title) + tab = $("", {href: "#", "data-filter": tab_type.filter, "data-title": tab_type.title}).text(tab_type.title) if tab_type.filter == @tab_active tab.addClass("active") tab.on("click", @handleTabClick) + if window.top.location.hash.endsWith(tab_type.title) + @log "Triggering click on", tab + tab.trigger("click") @tabs.append(tab) @container.on "mousedown touchend touchcancel", (e) => @@ -192,6 +195,7 @@ class Console extends Class $("a", @tabs).removeClass("active") elem.addClass("active") @changeFilter(@tab_active) + window.top.location.hash = "#ZeroNet:Console:" + elem.data("title") return false window.Console = Console diff --git a/plugins/Sidebar/media/Prototypes.coffee b/plugins/Sidebar/media/Prototypes.coffee new file mode 100644 index 00000000..a9edd255 --- /dev/null +++ b/plugins/Sidebar/media/Prototypes.coffee @@ -0,0 +1,9 @@ +String::startsWith = (s) -> @[...s.length] is s +String::endsWith = (s) -> s is '' or @[-s.length..] is s +String::capitalize = -> if @.length then @[0].toUpperCase() + @.slice(1) else "" +String::repeat = (count) -> new Array( count + 1 ).join(@) + +window.isEmpty = (obj) -> + for key of obj + return false + return true