publik.js: don't include any wcs if there is more than one (#7479)

This commit is contained in:
Frédéric Péters 2015-06-06 13:39:51 +02:00
parent df9793d68f
commit 7997a2fab9
1 changed files with 15 additions and 14 deletions

View File

@ -26,25 +26,13 @@ $(function() {
if (service.data === undefined || service.data.length == 0) {
return;
}
if (service.service_id == 'wcs' && service.uniq === false) {
/* as wcs comes with many menu entries, if it's not the only instance
* in the environment, we only insert all the items if it's the
* currently active site.
*/
var that_hostname = $('<a>').attr('href', service.backoffice_menu_url)[0].hostname;
var this_hostname = window.location.hostname;
if (that_hostname != this_hostname) {
more_entries.push({
title: service.title,
url: service.data[0].url});
return;
}
}
$(service.data).each(function(idx, element) {
var li = $('<li><a href="#">' + element.label + '</a></li>').appendTo(menu_links);
$(li).find('a').attr('href', element.url);
if (element.icon !== undefined) {
$(li).find('a').addClass('icon-' + element.icon);
} else if (element.slug !== undefined) {
$(li).find('a').addClass('icon-' + element.slug);
}
if (window.location.href.indexOf(element.url) == 0) {
$(li).addClass('active');
@ -63,12 +51,25 @@ $(function() {
COMBO_KNOWN_SERVICES = JSON.parse(window.sessionStorage.hobo_environment);
create_menu_items();
} else {
var this_hostname = window.location.hostname;
$(COMBO_KNOWN_SERVICES).each(function(index, element) {
if (element.backoffice_menu_url === null) {
element.data = Array();
check_all_done();
return;
}
if (element.service_id === 'wcs' && element.uniq === false) {
/* as wcs comes with many menu entries, if it's not the only instance
* in the environment, we simply skip it if it's not the active site.
*/
var that_hostname = $('<a>').attr('href', element.backoffice_menu_url)[0].hostname;
if (that_hostname != this_hostname) {
element.data = Array();
check_all_done();
return;
}
}
$.ajax({url: element.backoffice_menu_url,
xhrFields: { withCredentials: true },
async: true,