diff --git a/content/completion.js b/content/completion.js index 3e70fd1e..658e090c 100644 --- a/content/completion.js +++ b/content/completion.js @@ -1063,13 +1063,10 @@ function Completion() //{{{ sidebar: function sidebar(filter) { - var menu = document.getElementById("viewSidebarMenu"); - var nodes = []; + let menu = document.getElementById("viewSidebarMenu"); + let panels = Array.map(menu.childNodes, function (n) [n.label, ""]); - for (let i = 0; i < menu.childNodes.length; i++) - nodes.push([menu.childNodes[i].label, ""]); - - return [0, this.filter(nodes, filter)]; + return [0, this.filter(panels, filter)]; }, stylesheet: function stylesheet(filter) diff --git a/content/vimperator.js b/content/vimperator.js index ec6ad584..e2e6e969 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -322,22 +322,24 @@ const config = { //{{{ { args = args.string; - // do nothing if the requested sidebar is already open + // focus if the requested sidebar is already open if (document.getElementById("sidebar-title").value == args) { - document.getElementById("sidebar-box").contentWindow.focus(); + document.getElementById("sidebar-box").focus(); return; } - var menu = document.getElementById("viewSidebarMenu"); - for (let i = 0; i < menu.childNodes.length; i++) + let menu = document.getElementById("viewSidebarMenu"); + + for (let [,panel] in Iterator(menu.childNodes)) { - if (menu.childNodes[i].label == args) + if (panel.label == args) { - menu.childNodes[i].doCommand(); + panel.doCommand(); return; } } + liberator.echoerr("No sidebar " + args + " found"); }, {