From bc2bffce7e6c93000cd094a84558fb16ce43e472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Wed, 28 Sep 2011 10:17:13 +0000 Subject: [PATCH] Fix that prevents an item to be listed twice... git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2938 44740490-163a-0410-bde0-09ae8108e29a --- .../www/discojuice/discojuice.control.js | 19 +++++++++++++++++++ .../www/discojuice/discojuice.ui.js | 14 ++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/modules/discojuice/www/discojuice/discojuice.control.js b/modules/discojuice/www/discojuice/discojuice.control.js index ec647355d..dd3873846 100644 --- a/modules/discojuice/www/discojuice/discojuice.control.js +++ b/modules/discojuice/www/discojuice/discojuice.control.js @@ -44,6 +44,24 @@ DiscoJuice.Control = { if (this.wncr[i] && typeof this.wncr[i] === 'function') this.wncr[i](); }, + + // "mergeData": function (data) { + // var i, item, relID; + // for (i = 0; i < data.length; i++) { + // item = data[i]; + // relID = item.entityID; + // if (item.subID) { + // relID += '#' + item.subID; + // } + // item['relID'] = relID; + // + // if (!this.alreadyLoaded[relID]) { + // this.data.push(item); + // this.alreadyLoaded[relID] = true; + // } + // } + // }, + /* * Fetching JSON Metadata using AJAX. * Callback postLoad is called when data is returned. @@ -99,6 +117,7 @@ DiscoJuice.Control = { data: parameters, success: function(data) { that.data = $.merge(that.data, data); + //that.mergeData(data); that.parent.Utils.log('Successfully loaded metadata (' + data.length + ') (' + j + ' of ' + metadataurls.length + ')'); notifyCompleted(); } diff --git a/modules/discojuice/www/discojuice/discojuice.ui.js b/modules/discojuice/www/discojuice/discojuice.ui.js index 5d9818159..20beb28f2 100644 --- a/modules/discojuice/www/discojuice/discojuice.ui.js +++ b/modules/discojuice/www/discojuice/discojuice.ui.js @@ -16,6 +16,7 @@ DiscoJuice.UI = { // Reference to the "popup": null, + "alreadyLoaded": {}, // Entities / items "resulthtml": 'Loading data…', @@ -39,6 +40,7 @@ DiscoJuice.UI = { "clearItems": function() { this.resulthtml = ''; + this.alreadyLoaded = {}; }, "addItem": function(item, countrydef, search, distance, quickentry, enabled) { @@ -52,6 +54,13 @@ DiscoJuice.UI = { var debugweight = this.parent.Utils.options.get('debug.weight', false); + var relID = item.entityID; + if (item.subID) { + relID += '#' + item.subID; + } + + if (this.alreadyLoaded[relID]) return; + this.alreadyLoaded[relID] = true; // Add icon element first if (item.icon && this.parent.Utils.options.get('showIcon', true)) { @@ -134,10 +143,7 @@ DiscoJuice.UI = { } - var relID = item.entityID; - if (item.subID) { - relID += '#' + item.subID; - } + -- GitLab