Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filter.update_queue_objects = function(updated_data)
- {
- if (updated_data instanceof Object)
- {
- // Make sure that the facets array actually exists in the new data
- if (updated_data.facets instanceof Object)
- {
- console.log('doing');
- console.log(updated_data.facets);
- console.log(filter.queue);
- // Iterate over each filter object in the queue
- for (var queue_index in filter.queue)
- {
- // If the filter object has a facet value
- if (filter.queue[queue_index] instanceof Object)
- {
- console.log('about to iterate activity values!');
- // Iterate over each activity value (inactive/active)
- for (var activity_value in updated_data.facets)
- {
- console.log('iterating activity values')
- // If the updated data object's facets object has an 'inactive' property
- if (updated_data.facets[activity_value] instanceof Object)
- {
- console.log('it is an object!');
- // Iterate over the updated data's inactive facets to find a facet that matches the facet for the current queued filter object
- for (var inactive_facet_index in updated_data.facets[activity_value])
- {
- // If the current inactive facet is an Object and the title property is equivalent to the facet value of the current queued filter object
- if ((updated_data.facets[activity_value][inactive_facet_index] instanceof Object) && (filter.queue[queue_index].facet === updated_data.facets[activity_value][inactive_facet_index].title))
- {
- var facet_buckets = updated_data.facets[activity_value][inactive_facet_index].buckets;
- // If the facet's buckets property is a valid array
- if (facet_buckets instanceof Array)
- {
- // Iterate over each of the buckets
- for (var facet_bucket_index in facet_buckets)
- {
- // If the current bucket is a valid object and its value property matches the bucket value of the current queued filter object
- if ((facet_buckets[facet_bucket_index] instanceof Object) && (facet_buckets[facet_bucket_index].value === filter.queue[queue_index].bucket))
- {
- // Assign the updated href value to the queued filter object value
- filter.queue[queue_index].href = facet_buckets[facet_bucket_index].href;
- return true;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement