3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">/*
\r
12 *Adds a cancelQueue() method for cancelling the entire queue.
\r
13 *All queued files are uploaded when startUpload() is called.
\r
14 *If false is returned from uploadComplete then the queue upload is stopped.
\r
15 If false is not returned (strict comparison) then the queue upload is continued.
\r
16 *Adds a QueueComplete event that is fired when all the queued files have finished uploading.
\r
17 Set the event handler with the queue_complete_handler setting.
\r
22 if (typeof(SWFUpload) === "function") {
\r
23 SWFUpload.queue = {};
\r
25 SWFUpload.prototype.initSettings = (function (oldInitSettings) {
\r
26 return function () {
\r
27 if (typeof(oldInitSettings) === "function") {
\r
28 oldInitSettings.call(this);
\r
31 this.queueSettings = {};
\r
33 this.queueSettings.queue_cancelled_flag = false;
\r
34 this.queueSettings.queue_upload_count = 0;
\r
36 this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
\r
37 this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
\r
38 this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
\r
39 this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
\r
41 this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
\r
43 })(SWFUpload.prototype.initSettings);
\r
45 SWFUpload.prototype.startUpload = function (fileID) {
\r
46 this.queueSettings.queue_cancelled_flag = false;
\r
47 this.callFlash("StartUpload", [fileID]);
\r
50 SWFUpload.prototype.cancelQueue = function () {
\r
51 this.queueSettings.queue_cancelled_flag = true;
\r
54 var stats = this.getStats();
\r
55 while (stats.files_queued > 0) {
\r
56 this.cancelUpload();
\r
57 stats = this.getStats();
\r
61 SWFUpload.queue.uploadStartHandler = function (file) {
\r
63 if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
\r
64 returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
\r
67 // To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
\r
68 returnValue = (returnValue === false) ? false : true;
\r
70 this.queueSettings.queue_cancelled_flag = !returnValue;
\r
75 SWFUpload.queue.uploadCompleteHandler = function (file) {
\r
76 var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
\r
79 if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
\r
80 this.queueSettings.queue_upload_count++;
\r
83 if (typeof(user_upload_complete_handler) === "function") {
\r
84 continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
\r
85 } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
\r
86 // If the file was stopped and re-queued don't restart the upload
\r
87 continueUpload = false;
\r
89 continueUpload = true;
\r
92 if (continueUpload) {
\r
93 var stats = this.getStats();
\r
94 if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
\r
96 } else if (this.queueSettings.queue_cancelled_flag === false) {
\r
97 this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
\r
98 this.queueSettings.queue_upload_count = 0;
\r
100 this.queueSettings.queue_cancelled_flag = false;
\r
101 this.queueSettings.queue_upload_count = 0;
\r