Commit 57909890 authored by ale's avatar ale

* convert some old prototype.js syntax to JQuery

* better error handling
* fixed bugs #18 and #13
parent 4a7ae1c5
......@@ -45,8 +45,8 @@ pingHandler = function(stat, cur, tot) {
debug('Upload complete!');
showProgress(tot, tot);
// Fill out final form, and submit it!
$('newFileFormToken').value = token;
$('newFileForm').submit();
$('#newFileFormToken').attr("value", token);
$('#newFileForm').submit();
return false;
}
showProgress(cur, tot);
......@@ -54,17 +54,20 @@ pingHandler = function(stat, cur, tot) {
};
// Periodical polling of the uploadserver
uploadPoller = function(timer) {
getUploadPoller = function(token) {
var pingUrl = uploadserverUrl + '/ping/' + token;
$.ajax({
type: "GET",
url: pingUrl,
dataType: "json",
success: function(values) {
if (!pingHandler(values[0], values[1], values[2])) {
timer.stop();
}
}});
var uploadPoller = function(timer) {
$.ajax({
type: "GET",
url: pingUrl,
dataType: "json",
success: function(values) {
if (!pingHandler(values[0], values[1], values[2])) {
timer.stop();
}
}});
};
return uploadPoller;
};
// Obtain an upload token, and initiate the upload process
......@@ -78,13 +81,16 @@ getToken = function() {
success: function(token) {
debug('received token: ' + token);
// Now, submit the form
$('#uploadForm').action += '/' + token;
debug('submitting form to ' + $('#uploadForm').action);
action = $('#uploadForm').attr('action');
action += '/' + token;
$('#uploadForm').attr('action', action);
debug('submitting form to ' + action);
$('#uploadForm').submit();
$.timer(5000, uploadPoller);
$.timer(5000, getUploadPoller(token));
},
error: function(){
debug('error getting upload token!');
error('Could not communicate with the upload server (no upload token)');
uploadFailed();
}
});
};
......
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