From dffcd9c82b7ff187ba29b5218e4408c3216a6756 Mon Sep 17 00:00:00 2001 From: Timo Hausmann Date: Wed, 10 Apr 2013 09:55:00 +0200 Subject: [PATCH] ability to only load ressources with specified tag(s) --- PxLoader.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/PxLoader.js b/PxLoader.js index d22a2bc..6e9694b 100644 --- a/PxLoader.js +++ b/PxLoader.js @@ -130,18 +130,27 @@ }; }; - this.start = function(orderedTags) { + this.start = function(orderedTags, specifiedTagsOnly) { timeStarted = Date.now(); // first order the resources - var compareResources = getResourceSort(orderedTags); + var compareResources = getResourceSort(orderedTags), + tags = new PxLoaderTags(orderedTags), + i = 0, + len = entries.length, + entry; + entries.sort(compareResources); // trigger requests for each resource - for (var i = 0, len = entries.length; i < len; i++) { - var entry = entries[i]; - entry.status = ResourceState.WAITING; - entry.resource.start(this); + for (; i < len; i++) { + + entry = entries[i]; + //when specifiedTagsOnly: only start resource if it has given tags + if( !specifiedTagsOnly || (specifiedTagsOnly && tags.intersects(entry.resource.tags)) ) { + entry.status = ResourceState.WAITING; + entry.resource.start(this); + } } // do an initial status check soon since items may be loaded from the cache