Commit 7f301bed authored by Camil Staps's avatar Camil Staps 🐧

Add warnings to frontend (#226)

parent c04c629d
Pipeline #37545 passed with stages
in 32 minutes and 32 seconds
......@@ -716,6 +716,26 @@ function getResults(str, libs, include_builtins, include_core, include_apps, pag
return suggs;
};
var makeWarnings = function (warnings) {
var warns = document.createElement('div');
warns.id = 'warnings';
var label = document.createElement('b');
label.innerHTML = warnings.length > 1 ? 'Warnings:' : 'Warning: ';
warns.appendChild(label);
if (warnings.length == 1) {
warns.innerHTML += warnings[0].cloogleMarkup();
} else {
var list = document.createElement('ul');
for (i in warnings)
list.innerHTML += '<li>' + warnings[i].cloogleMarkup() + '</li>';
warns.appendChild(list);
}
return warns;
};
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
document.getElementById('loading').remove();
......@@ -774,6 +794,10 @@ function getResults(str, libs, include_builtins, include_core, include_apps, pag
par.insertBefore(makeSuggestions(responsedata['suggestions']), par.firstChild);
}
if ('warnings' in responsedata && responsedata['warnings'].length > 0) {
par.insertBefore(makeWarnings(responsedata['warnings']), par.firstChild);
}
if (unfold_more_information) {
var togglers = elem.getElementsByClassName('toggler');
for (var i=0; i<togglers.length; i++)
......
......@@ -208,8 +208,13 @@ a {
margin-top: 1em;
}
#suggestions {
padding: 1em;
#warnings, #suggestions {
padding: 0 1em 1em 1em;
}
#warnings ul {
margin: .2em;
padding-left: 1.5em;
}
#search-results p {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment