Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Invoke the createTable function regardless of response #213

Merged
merged 2 commits into from Jul 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 10 additions & 13 deletions ores/wsgi/static/js/scorer.js
Expand Up @@ -27,13 +27,12 @@ function enableResult() {
$('#resultButton').removeAttr('disabled');
}
function createTable(data) {
var htm = '<div class="col-md-6 col-md-offset-3" style="margin-top: 3em; margin-bottom: 3em;">';
htm += '<table class="celled table sortable"><thead><tr><th>Wiki</th><th>Model</th><th>Revision ID</th>';
var htm = '<table class="celled table sortable"><thead><tr><th>Wiki</th><th>Model</th><th>Revision ID</th>';
htm += '<th>Value</th><th>Score</th></tr></thead>';
var revids = Object.keys(data);
if (data.error) {
return error(data.error.message);
if ( data.responseJSON && data.responseJSON.error) {
return error(data.responseJSON.error.message);
}
var revids = Object.keys(data);
for (i = 0; i < revids.length; i++) {
if (data[revids[i]].error) {
return error(data[revids[i]].error.message);
Expand All @@ -49,7 +48,7 @@ function createTable(data) {
}
}
}
htm += '</tbody></table></div>';
htm += '</tbody></table>';
return htm;
}
function loadModels(wiki) {
Expand Down Expand Up @@ -78,15 +77,13 @@ function getResults() {
models_url += $(this).val() + '|';
});
models_url = models_url.slice(0, -1);
var container = '<div id="tableContainer" class="col-md-6 col-md-offset-3" style="margin-top: 3em; margin-bottom: 3em;">';
var url = "/scores/" + $('#wikiDropDownInput').attr('value') + "/?models=" + models_url + "&revids=" + revs;
$.get(url, function (data) {
if ($('.table').length) {
$('.table').html(createTable(data));
} else {
$('#afterThis').after(createTable(data));
}
$.get({ url: url, datatype: 'jsonp' }).always(function(data) {
$('#tableContainer').remove();
$('#afterThis').after(container + createTable(data) + '</div>');
$('.sortable.table').tablesorter();
}, datatype='jsonp');
});
}

wikis();
Expand Down