diff options
| author | luccioman <luccioman@users.noreply.github.com> | 2017-09-16 10:13:09 +0200 |
|---|---|---|
| committer | luccioman <luccioman@users.noreply.github.com> | 2017-09-16 10:13:09 +0200 |
| commit | 18412dca2173bdd6e88c2daf60f3f7de2fbba79f (patch) | |
| tree | 174b0173ebcf52ca1b09bcd49d912f736722a869 /htroot/js | |
| parent | 9049a926a511edea53f6b2622c06fcc50b96f2d7 (diff) | |
Handle JS refreshing of belatedly added search navigators
Diffstat (limited to 'htroot/js')
| -rw-r--r-- | htroot/js/yacysort.js | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/htroot/js/yacysort.js b/htroot/js/yacysort.js index 6090ce856..fcb4f3f7b 100644 --- a/htroot/js/yacysort.js +++ b/htroot/js/yacysort.js @@ -159,13 +159,19 @@ var processSidebarNavProtocols = function(navProtocolsOld, navProtocolsNew) { } ); }; -// TODO: test this function -// This is for sidebar items that are <ul> elements with the "menugroup" class. -var processSidebarMenuGroup = function(listOld, listNew) { +/** + * Refresh a navigator list element with the "menugroup" class. + * @param parentSidebar the parent navigators side bar currently displayed + * @param listOld the old navigator list + * @param listNew the new navigator list + */ +var processSidebarMenuGroup = function(parentSidebar, listOld, listNew) { if ( $(listNew).length === 1) { if ( $(listOld).length < 1) { - if(logEnabled) { - console.warn("listOld doesn't exist, so can't replace it with listNew."); + /* List old doesn't exist : insert it at the beginning of the list */ + var allNavs = parentSidebar.find(".nav.nav-sidebar.menugroup"); + if(allNavs.length > 0) { + listNew.insertBefore(allNavs[0]); } return; } @@ -194,23 +200,6 @@ var processSidebar = function(data) { var oldSidebar = $("#sidebar"); var newSidebar = $('<div class="col-sm-4 col-md-3 sidebar" id="sidebar">\n\n' + data + '\n\n</div>'); - /* - if( old_sidebar.html() == data ) { - if(logEnabled) { - console.log("Sidebar unchanged."); - } - return; - } - */ - /* - if( $.trim(old_sidebar.html()) == $.trim(data) ) { - if(logEnabled) { - console.log("Sidebar unchanged."); - } - return; - } - */ - //else if( $.trim(old_sidebar.html()) == $.trim("") ) { if( oldSidebar.children().length === 0 ) { if(logEnabled) { console.log("Initializing sidebar..."); @@ -247,21 +236,16 @@ var processSidebar = function(data) { // TODO: nav-dates - // domains (AKA providers) - // TODO: test hosts - processSidebarMenuGroup($("#nav-hosts"), newSidebar.find("#nav-hosts")); + // hosts (AKA providers) + processSidebarMenuGroup(oldSidebar, $("#nav-hosts"), newSidebar.find("#nav-hosts")); - // TODO: test languages - processSidebarMenuGroup($("#nav-languages"), newSidebar.find("#nav-languages")); + processSidebarMenuGroup(oldSidebar, $("#nav-languages"), newSidebar.find("#nav-languages")); - // TODO: test authors - processSidebarMenuGroup($("#nav-authors"), newSidebar.find("#nav-authors")); + processSidebarMenuGroup(oldSidebar, $("#nav-authors"), newSidebar.find("#nav-authors")); - // TODO: test Wiki Name Space - processSidebarMenuGroup($("#nav-namespace"), newSidebar.find("#nav-namespace")); + processSidebarMenuGroup(oldSidebar, $("#nav-namespace"), newSidebar.find("#nav-namespace")); - // TODO: test filetype - processSidebarMenuGroup($("#nav-filetype"), newSidebar.find("#nav-filetype")); + processSidebarMenuGroup(oldSidebar, $("#nav-filetype"), newSidebar.find("#nav-filetype")); // TODO: navs |
