Skip to content

Commit

Permalink
Add ordering of submissions to view page
Browse files Browse the repository at this point in the history
  • Loading branch information
Nullreff committed Mar 31, 2015
1 parent 02d46e9 commit 5a06fa8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions public/js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
}
lastKeys = keys;

var items = [];
var requests = $.map(keys.split('\n'), function(key) {
var parts = keys.split('\n');
var items = new Array(parts.length);
var requests = $.map(parts, function(key, i) {
return $.get(baseUrl + key).done(function(data) {
var json = JSON.parse(data);
var feedback = $('<div/>').text(json.feedback).addClass('feedback');
Expand All @@ -22,7 +23,7 @@
var item = $('<div/>').append(feedback)
.append(artwork)
.attr('id', key);
items.push(item);
items[i] = item;
}).fail(function() {
console.log('Failed to fetch data for key ' + key);
});
Expand All @@ -31,7 +32,9 @@
$.when.apply($, requests).done(function () {
$('#items').empty();
$.each(items, function(i, item) {
$('#items').append(item);
if (item) {
$('#items').append(item);
}
});
$('#submissions').text(items.length);
});
Expand Down

0 comments on commit 5a06fa8

Please sign in to comment.