app/views/home/validate_ontology_file.html.haml
:javascript
var process_id = "#{@process_id}";
var timer = null;
var parserHuman = {
"org.semanticweb.owlapi.oboformat.OBOFormatOWLAPIParser": "OBO",
"org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser": "RDF/XML",
"org.semanticweb.owlapi.owlxml.parser.OWLXMLParser": "OWL or OWL/XML",
"org.semanticweb.owlapi.functional.parser.OWLFunctionalSyntaxOWLParser": "OWL Functional",
"org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxOntologyParser": "Manchester OWL",
"org.bioontology.UnknownParseError": "Unknown"
};
var getErrors = function() {
jQuery.ajax({
url: determineHTTPS(jQuery(document).data().bp.config.rest_url) + "/validate_ontology_file/" + process_id,
data: {
apikey: jQuery(document).data().bp.config.apikey,
userapikey: jQuery(document).data().bp.config.userapikey,
format: "jsonp"
},
dataType: "jsonp",
timeout: 30000,
success: function(data){
if (typeof data === 'string') {
// still processing
jQuery("#processing_text").append(".");
} else {
// done processing, show errors or all clear
jQuery("#processing").hide();
if (Object.keys(data).length === 0) {
// no errors
jQuery("#success_container").show();
} else {
var $errors = jQuery("#errors");
var multiple = Object.keys(data).length > 1;
var $error_p = jQuery("<p>");
if ($errors.html().length > 0) { return; }
$error_p.append("We detected a problem with the file.");
if (multiple) {
$error_p.append(" Select your format below to see the error.");
}
$errors.append($error_p).append("<br/>");
jQuery.each(data, function(parser, error) {
if (multiple) {
$errors.append("<h4><a href='' onclick='event.preventDefault(); jQuery(\"#" + parser.replace(/\./g, '') + "\").show();'>" + parserHuman[parser] + "</a></h4>");
$errors.append("<p style='display: none;' id='" + parser.replace(/\./g, '') + "'>" + error.join("<br/>") + "</p>");
} else {
$errors.append("<h4>" + parserHuman[parser] + "</h4>");
$errors.append("<p>" + error.join("<br/>") + "</p>");
}
});
jQuery("#errors_container").show();
}
clearTimeout(timer);
}
},
error: function(data, errorStr, error) {
clearTimeout(timer);
if (jQuery("#errors").html().length > 0) { return; }
jQuery("#processing").hide();
jQuery("#errors").append("Problem validating file, please try again");
jQuery("#errors_container").show();
}
});
timer = setTimeout(getErrors, 750);
};
jQuery(document).ready(function() {
getErrors();
});
%div#processing_container{style: "padding: 3em;"}
%div#processing
%h1#processing_text Processing...
%div#success_container{style: "display: none;"}
%h1 Valid Ontology
%p No errors were found
%div#errors_container{style: "display: none;"}
%h1 Errors
%div#errors