Use the REST API in the web interface for editing projects

This commit is contained in:
Eelco Dolstra
2013-10-03 17:23:41 +02:00
parent 8355dc57ee
commit ae13dd3e67
4 changed files with 84 additions and 55 deletions

View File

@ -88,3 +88,29 @@ var makeLazyTab = function(tabName, uri) {
}
});
}
var requestJSON = function(args) {
args.dataType = 'json';
args.error = function(data) {
json = {};
try {
if (data.responseText)
json = $.parseJSON(data.responseText);
} catch (err) {
}
if (json.error)
bootbox.alert(json.error);
else if (data.responseText)
bootbox.alert("Server error: " + data.responseText);
else
bootbox.alert("Unknown server error!");
};
return $.ajax(args);
}
var redirectJSON = function(args) {
args.success = function(data) {
window.location = data.redirect;
};
return requestJSON(args);
}