@cryptotaxi247 / netdata-1 / commits / 1b9e70dfd

sorted list of mirrored machines

Costa Tsaousis (ktsaou) committed Mar 12, 2017 at 14:50 UTC 1b9e70dfd788fa42ec69ee254f05c8965fa3612f
1 file changed +13 -3
web/index.html
+13 -3
@@ -601,6 +601,8 @@
601 var len, i, url, hostname, icon;
602
603 if(options.hosts.length > 1) {
604 + // there are mirrored hosts here
605 +
606 el += '<li><a href="#" onClick="return false;" style="color: #666;" target="_blank">databases available on this host</a></li>';
607 a1 += '<li><a href="#" onClick="return false;"><i class="fa fa-info-circle" aria-hidden="true" style="color: #666;"></i></a></li>';
608
@@ -611,11 +613,19 @@
613 if(base.endsWith("/"))
614 base = base.substring(0, base.length - 1);
615
616 + var master = options.hosts[0].hostname;
617 + var sorted = options.hosts.sort(function(a, b) {
618 + if(a.hostname === master) return -1;
619 + if(a.hostname === b.hostname) return 0;
620 + else if(a.hostname > b.hostname) return 1;
621 + return -1;
622 + });
623 +
624 i = 0;
615 - len = options.hosts.length;
625 + len = sorted.length;
626 while(len--) {
617 - hostname = options.hosts[i].hostname;
618 - if(i == 0) {
627 + hostname = sorted[i].hostname;
628 + if(hostname == master) {
629 url = base + "/";
630 icon = "home";
631 }