diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-08-31 00:03:46 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-08-31 00:03:46 -0700 |
commit | db769b76ab7b7ed54579225fca836defc7afbd11 (patch) | |
tree | dafe40aa8ffc758b6eee0ea56ca3a5b94fa8da1f /modules/gallery/views/form_uploadify.html.php | |
parent | 5568ab24decd31e185fa1b19d29838ec3b30e570 (diff) |
Expire completed uploads and introduce a text message that says how
many photos have been uploaded successfully. This is to pave the way
for retry code later on.
Diffstat (limited to 'modules/gallery/views/form_uploadify.html.php')
-rw-r--r-- | modules/gallery/views/form_uploadify.html.php | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index 2ed7912f..36f5f284 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -3,7 +3,24 @@ <script type="text/javascript" src="<?= url::file("lib/uploadify/jquery.uploadify.min.js") ?>"></script> <script type="text/javascript"> <? $flash_minimum_version = "9.0.24" ?> + var success_count = 0; + var error_count = 0; + var updating = 0; $("#g-add-photos-canvas").ready(function () { + var update_status = function() { + if (updating) { + // poor man's mutex + setTimeout(function() { update_status(); }, 500); + } + updating = 1; + $.get("<?= url::site("uploader/status/_S/_E") ?>" + .replace("_S", success_count).replace("_E", error_count), + function(data) { + $("#g-add-photos-status-message").html(data); + updating = 0; + }); + }; + if (swfobject.hasFlashPlayerVersion("<?= $flash_minimum_version ?>")) { $("#g-uploadify").uploadify({ width: 150, @@ -40,13 +57,12 @@ onComplete: function(event, queueID, fileObj, response, data) { var re = /^error: (.*)$/i; var msg = re.exec(response); - if (msg) { - $("#g-add-photos-status ul").append( - "<li class=\"g-error\">" + fileObj.name + " - " + msg[1] + "</li>"); - } else { - $("#g-add-photos-status ul").append( - "<li class=\"g-success\">" + fileObj.name + " - " + <?= t("Completed")->for_js() ?> + "</li>"); - } + $("#g-add-photos-status ul").append( + "<li id=\"q" + queueID + "\" class=\"g-success\">" + fileObj.name + " - " + + <?= t("Completed")->for_js() ?> + "</li>"); + setTimeout(function() { $("#q" + queueID).slideUp("slow") }, 5000); + success_count++; + update_status(); return true; }, onError: function(event, queueID, fileObj, errorObj) { @@ -73,6 +89,8 @@ $("#g-add-photos-status ul").append( "<li class=\"g-error\">" + fileObj.name + msg + "</li>"); $("#g-uploadify" + queueID).remove(); + error_count++; + update_status(); }, onSelect: function(event) { if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) { |