diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:56:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:56:53 +0000 |
commit | a9c818418b81b93680170e1a84d4e221e578ad2f (patch) | |
tree | 5b883aa428f1edb12f5d40f9768438ee16a7ed6b /debian/missing-sources/swfupload | |
parent | Adding upstream version 6.4.3+dfsg1. (diff) | |
download | wordpress-a9c818418b81b93680170e1a84d4e221e578ad2f.tar.xz wordpress-a9c818418b81b93680170e1a84d4e221e578ad2f.zip |
Adding debian version 6.4.3+dfsg1-1.debian/6.4.3+dfsg1-1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/missing-sources/swfupload')
17 files changed, 4942 insertions, 0 deletions
diff --git a/debian/missing-sources/swfupload/Core Changelog.txt b/debian/missing-sources/swfupload/Core Changelog.txt new file mode 100644 index 0000000..dfb40ae --- /dev/null +++ b/debian/missing-sources/swfupload/Core Changelog.txt @@ -0,0 +1,283 @@ + * SWFUpload Core, January 2009, www.swfupload.org, swfupload.googlecode.com
+
+ * --------- Version 2.2.0.1-----------
+ * - Removed requeueUpload due to bugs/poor testing
+ * = Fixed namespace conflict that broke stopUpload
+
+ * --------- Version 2.2.0-----------
+ * + Added button_placeholder setting that accepts a DOM element.
+ * + Added ability to requeue any file (including some improvement to internal queue state tracking)
+ * + UploadErrors caused by a missing upload_url now causes the file to be requeued automatically
+ * + Added preserve_relative_urls setting
+ * + SWFUpload now converts relative URLs to absolute URLs to avoid issues with Flash Player interpreting it differently on some clients
+ * + Added assume_success_timeout setting which allows uploadSuccess to be called after a timeout if, for some reason Flash ignores the server's response
+ * An additional parameter has been added to the uploadSuccess event to indicate whether a response was received or success was assumed.
+
+ * --------- Version 2.2.0 Beta 2 ~ 5-----------
+ * = Fixed a Queue Limit bug
+ * + Improved internal event handling code so uploadSuccess fires even when not content is returned from the server (*woot*, except for Macs)
+ * = Fixed issues in Destroy
+ * = Fixed issues with Queue Plugin
+ * + Added periodic checks of the ExternalInterface
+ * + Improved IE memory leak prevention code
+ * + Added Speed Plugin
+ * = Updated Queue Plugin for better multi-plugin compatibility
+
+ * --------- Version 2.2.0 Beta 1-----------
+ * + Added Flash Player 10 Support
+ * = Added setting for defining a button image
+ * = Added setting for defining button text
+ * = Added setting for defining button width, height and padding
+ * = Added setting for defining what element the Flash Movie should replace
+ * = Added setting for defining flash wmode
+ * = Added setting for defining the mouse cursor
+ * + Added prevent_swf_caching setting as a work-around for issues in Avant Browser (and other IE based browser)
+ * + Added setting for accepting HTTP Status codes other than 200 as successful
+ * + Added parameter to cancelUpload that allows the uploadError event for cancelled uploads to be supressed
+ * + Added pro-active memory leak fix for IE and fixed problems with the destroy function (credits to steffen for patches and testing)
+ * + Replaced callFlash with CallFunction (using the internal function that Flash uses). Based on code from MooTools.
+ * = Fixed bug in the Queue plugin that breaks startUpload when passing a file id.
+ * + Updated Queue plugin to stop the queue if false is returned from the uploadStart handler.
+ * = Fixed small issues in SWFObject plugin
+ * = Fixed issue with ExternalInterface string escaping
+ * - Dropped Graceful Degradation Plugin
+ * - Dropped v1.0.2 Plugin
+ * - Dropped Flash Player 8 support
+
+ * --------- Version 2.1.0 -----------
+ * = Fixed GET values so they are escaped properly
+ * + Added destroy function
+ * = Added exception handling around browse() calls
+ * = Minor code cleanup
+ * + Split Core and Demos
+
+ * --------- Version 2.1.0 Beta 2-----------
+ * = Fixed bug in XHTML fix where it wasn't split correctly by Flash
+ * = Fixed file params "undefined" in debug output
+ * + Added requeue_on_error settings so HTTP/IO/Security errors requeue the file instead of discarding it.
+ This will affect the queue plugin (if an error is occurring the file will be reuploaded and reuploaded).
+ * = Fixed HTTP/IO error behavior. We'll see how this goes Flash 9 is supposed to call HTTPError followed by an IO error but I suspect they come out of orde sometimes.
+ * = Fixed invalid characters in file param names. Worked around flash bug by escaping the names. Should be transparent to devs.
+ * = Fixed missing upload URL logic so it fires consistently
+ * = Fixed file params not being sent when useQueryString is true
+ * + Added SWFObject plugin and demo.
+ * + Added CookieBug demo to demonstrate what they bug really is all about.
+ * + Added VB.Net version of the Application Demo
+
+
+ * --------- Version 2.1.0 Beta 1-----------
+ * + Added allowScriptAccess="always" to the embed/object elements so the SWF can be served from different domains.
+ * = Fixed a type-o in the debug output that prevented the instance id (movieName) from displaying. - Thx Joel
+ * + Rewrote SWFUpload.js for better code reuse based on sample code from batiste.bieler (thanks!!!)
+ * + Added queueComplete event to the Queue Plugin
+ * + Added Simple Upload demo
+ * = JSLinted all the JavaScript code
+ * + Added use_query_string setting (and setUseQueryString function) that forces post_param and file_param values to be sent on the query_string instead of the post (for Flash 9 version)
+ * = Fixed file.type and date properties so a default value is provided (rather than null) when no value is provided by flash.
+ * = Fixed misc bugs in the demos
+ * = Fixed ExternalInterface calls being made available for Flash 9 versions <9.0.28 which aren't supported
+ * + Fixed use of & producing invalid XHTML in the <object> and <embed> tags.
+ * - Removed the use of the embed tag (using the <object> sample from the Flash Satay method)
+ * = Updated plugins to work with code rewrite changes.
+ * = Extracted FileProgress object in to its own file.
+ * + Added addPostParam and removePostParam functions
+
+ * --------- Version 2.0.2 -----------
+ * = Fixed a bug where post params could not be added to the current file (because it is removed from the queue when it becomes current)
+ * = Fixed a conversion error when converting kilobytes to bytes in the file size check
+ * = Fixed a problem in the documentation that said the file_size_limit was bytes when it is actually kilobytes
+ * + Added formatting to the documentation, a table of contents, and details for each setting .
+ * + Added units for file_size_limit setting. The setting understands B, KB, MB, GB. Default is KB.
+ * + Added a check for the ExternalInterface functions in flashReady so SWFUpload will not fire the loaded event if those are not available.
+
+ * --------- Version 2.0.1 -----------
+ * = Fixed a bug where zero-byte files would stop file the queuing process.
+ * = Finished updating Features Demo
+ * + Added GetFileByIndex(i) that gets a JavaScript File Object. The index never changes. Finished files continue to be available.
+ * The JavaScript GetFile function will accept a file_id or an index.
+ * + Added CheckFileSize constants to replace the magic numbers
+ * + Added some code in an attempt to fix "Script is running slowly" error messages
+ * = Better cleanup of FileReference objects
+
+ * --------- Version 2.0 -----------
+ * + Re-created SWFUpload in Actionscript v2 for Flash 8 compatibility. Flash 8 loses POST and Server Data features. The two versions are otherwise fully compatible.
+ * Flash 8 uses URL to pass post_params/file_params.
+ * = Changed uploadStart event so it's part of the setTimeout/eventQueue workaround. This allows Flash functions to be called from uploadStart.
+ * = Renamed uploadComplete to uploadSuccess and fileComplete to uploadComplete. All started uploads call uploadComplete (even if cancelled or stopped).
+ * = Changed startUpload validation failure behavior. Rather than cancelling the upload the file is now requeued. Devs can cancel
+ * or do whatever the need to in uploadError to handle the problem.
+ * = Fixed fileQueueLimit/fileUploadLimit logic so it works correctly.
+ * = Moved the upload request building to a later point so that the post params and file params can be updated in uploadStart.
+ * - Removed the last of the UI stuff (ui_container, degraded_container).
+ * + Started development on Plug-ins. Graceful Degradation, v1.0.2, Cookies, Queue Handling
+ * = Fixed missing file_status field in FileItem.
+ * + Added modificationDate to FileItem (file object)
+ * + Added setStats function that lets you change the file upload count, etc. This will give more power over the queue limits. Not well tested.
+ * = Renamed compeleted_uploads to successful_uploads in getStats object
+ * + Added in_progress to getStats object
+
+ * --------- Revision 7.0 beta 3 -----------
+ * + Added an "event queue". Events are added to an array and executeEvent is called on a setTimeout. This prevents out of order issues that occur
+ * in the Safari browser.
+ * + Added a check for the UPLOAD_COMPLETE_DATA event constant which only became available in Flash Player 9.0.28. This
+ * fixes the Flash Version detection (Flash Object Detection) which was accepting Flash Player 9 versions before 9.0.28.
+ * - Removed old code block that was missed when moving from a Flash Timer to the JavaScript timeout (caused certain cancel events to be called twice)
+ * = Change ShowUI to the swfUploadLoaded event which will hopefully make it more clear that this is an overrideable event
+ * = Changed flashReady to behave like the other events (uses setTimeout and the Event Queue).
+
+ * --------- Revision 7.0 beta 2 -----------
+ * = Changed ERROR_CODE_FILE_NOT_FOUND to ERROR_CODE_FILE_ID_NOT_FOUND
+ * + Grouped the error code constants in objects for queue errors and upload errors.
+ * + Added an UPLOAD_STOPPED error code.
+ * = Changed Event calling method (using Timer) in Flash. Timer is no longer called
+ * instead setTimeout is called in JavaScript. This includes a change to the
+ * JavaSCript design so the Event methods are not directly overridden but stored
+ * internally and called if defined (with a setTimeout). This is an effort
+ * be more compatible with the current Flash Player on Linux
+ * = Changed the parameter order for the fileQueueError and uploadError events so the fileObj is first, like other events.
+ * + Added an empty JavaScript object (customSettings) where users can store settings associated with the instance.
+ * + Worked around an escaping bug in the ExternalInterface library by escaping all backslashes in out-going strings.
+ * = Updated all the demos.
+
+ * --------- Revision 7.0 beta 1 -----------
+ * = Redesigned the Event Chain
+ * - Removed much of the queue concepts
+ * - Removed the fileValidation events. This can be done in the new uploadStart event
+ * - Removed beginUploadOnQueue feature. This can be done in the new dialogComplete event.
+ * - Removed use_server_data. This is now always on.
+ * + Added functions for retrieving queue stats (number of files uploaded, queued, errors, etc)
+ * + Added a file status property to the FileObject. This indicates, uploaded, error, waiting.
+ * + Added a single file browser (user cannot select multiple files)
+ * + Fixed bug (hopefully) caused if Flash call to JavaScript and in the callback JavaSCript calls to Flash
+ * This only place this does not apply is to uploadStart. If you call in to Flash from uploadStart use a setTimeout to do it.
+
+ * --------- Revision 6.2 -----------
+ * + Added API calls for changing all the changeable settings dynamically
+ * = Fixed a bug in FileComplete event handler (in the SWF) that caused an error in Debug Players
+ * and prevent the event from being called
+ * + Added a setting (use_server_data_event) to indicate whether FileComplete or ServerData should be called.
+ * The SWFUpload architecture requires that only one file upload success event can be called.
+ * = Updated all the Demos, especially the Features Demo and the Forms Demo
+
+
+ * --------- Revision 6 -----------
+ * - Removed the call to setUploadSettings in flashReady. This was a left over call that is unnecessary.
+ * + Finished the parsing of post params during the init stage. This ommision was hidden by the call to setUploadSettings.
+ * - Removed the flash_target_id setting. The Flash file should only ever be added to the body tag.
+ * + Fixed (hopefully for good) another SWF race condition. IE executes the SWF very very early. The this.movieElement value should never be referenced.
+ * The movie Element should always be retrieved using this.getMovieElement().
+
+ * --------- Revision 6 -----------
+ * + Ported to ActionScript 3. Revision 6 requires Flash Player 9.
+ * = Fixed bug caused when cancelling single files. Would break any function that searched for a file_id.
+ * - Removed the automatic cookie sending setting. Devs should just pass the value they want to send in the post_params
+ * - Removed the query params settings (global and file specific). All params should be sent in the post_params
+ * + Added post_params which adds post values to the file upload post.
+ * + Added validate_files setting flag which causes the fileValidation event to be called before each file is uploaded.
+ * + Added fileValidation event. Return false if validation fails and true if validation is successful.
+ * + Added server_data parameter to the fileComplete event which returns any text that the upload script returns.
+ * = Updated all demos to work with Revision 6
+ * + Added in-code file extension validation. Before a file is queued the extension is checked against the valid extensions.
+ * Files the have invalid extensions cause the error event to be raised.
+ * + Added 'file_post_name' setting that allows the post variable name containing the file data to be named something other than 'Filedata'
+ * = Fixed a race condition in loadFlash where a cached flash movie would execute before this.movieElement could be assigned and loading would fail.
+
+ * --------- Revision 5.2 -----------
+ * = A little more code cleaning and variable renaming
+ * + Changed from an array queue to a FIFO queue. This eliminates the "current_index" and
+ * should reduce some memory usage.
+ * + Added out of order file uploading. Call StartUpload(/file_id/).
+ * + Added custom query_string parameters in addition to the cookies
+ * + Added the ability to modify the URL, cookies, params and send to flash
+ * + Added per file query_string params
+ * + Added files queued limit. Sometimes you may want the user to only queue one file at a time (or something)
+ * + Fixed limits so a zero(0) value means unlimited.
+
+ * --------- Revision 5 -------------
+ * = More code cleaning. Ported SWF to FlashDevelop. (Since my Flash Studio trial expired)
+ * The port to FlashDevelop is a big deal. It significantly changes the code structure
+ * and could introduce bugs. Also there have been reported issues with the FlashDevelop
+ * version from swfupload.mammon.se: Doesn't start when reloading in IE. Doesn't start
+ * in Firefox if the SWF file is visible because of a page scroll.
+ * + I fixed the Firefox issue by removing the wmode attribute from the embed object.
+ * + I cannot reproduce the IE issue on my local machine (although I can reproduce it at swfupload.mammon.se)
+ * + Event Handlers are now attached to the SWFUpload javascript object. The SWF file
+ * now calls the handlers in the context of the SWFUpload object which means the "this"
+ * object inside the handler refers to the proper SWFUpload instance.
+ * + Tested and Fixed upload target cookie attachment
+ * = Cleaned up / renamed everything for clarity and consistancy
+ * + File queuing is now subject to the upload limit. If the user attempts to queue more files
+ * than allowed an error is returned and the files are not queued.
+ * + Fixed misc bugs and text encodings.
+ * + Added more debug info for the SWF file.
+ * + SWF file now obeys the debug setting.
+ * + Added SetUploadTargetURL function that allows you to "dynamically" change the upload target
+ * + Added error code for zero byte file uploads which always return an IO error. The files are now rejected
+ * instead of being uploaded.
+
+ * --------- Revision 4 -------------
+ * = Cleaned up code. Added comments. Reorganized. Added more try..catches. Removed old unused methods.
+ * - Removed the 'create_ui' setting. The UI is now completely up to the developer.
+ * + Added upload_backend_cookies setting. Can set a string, or array of cookie names. These values will be
+ * passed as part of the upload_backend url
+ *
+ * = Changed QueueComplete event to only fire if at least one file has been successfully uploaded.
+ * + Added "Stop Upload" feature.
+ * = Revised the FLA file to clean things up, better handle errors, etc.
+ * = Fixed a bug where cancelling the first upload would cause the remaining uploads to fire before calling
+ * "startUpload". This change is in the FLA.
+ *
+ * + Fixed a bug in the upload.swf that prevented further file processing after an error is returned.
+ * + Added uploadLimit variable. Only complete uploads are counted. Once the limit is reached the flash
+ * movie will not upload any more files. (The ability to select or queue many files is not affected
+ * by the upload limit)
+ * + Added cancelQueue and cancelUpload methods.
+ * + Added ID property to the FileObj in the upload.swf
+ * + Added Upload and Queue settings
+ * + Added methods for generating the flash HTML and inserting it into the DOM.
+ * - Removed SWFObject
+ * + Updated the upload.swf and added the "flashReady" event. This will only call back
+ * for Flash 8 and above. With this we don't need a flash version detect script.
+ * The script initializes the Flash then waits for the Callback to init the UI.
+ * + Added seperate ui_target, degraded_target, create_ui settings. This allows fine control
+ * over what parts of the GUI the script displays and hides
+ *
+ * + Changed from a Static Class to an Instance (changed code/class structure)
+ * + Added "flash_version" setting. When set to zero the version check is skipped
+ * + Added Debug Console. The Instance class can't do document.write.
+ * = De-obfuscated SWFObject a bit
+ * - Removed standalone mode.
+ * + Added "ui_target" setting. When non-blank the link is added.
+ * + Added "flash_target" setting. When blank the flash is appended to the <body> tag
+ * = This fixes ASP.Net not allowing the flash to be added to the Form
+ * + Added error checking to the callSWF method
+ *
+
+
+ * -------- -------- -------- -------- -------- -------- -------- --------
+ * SWFUpload 0.7: Flash upload dialog - http://profandesign.se/swfupload/
+ * SWFUpload is (c) 2006 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ * -------- -------- -------- -------- -------- -------- -------- --------
+
+ * SWFUpload 0.7: Flash upload dialog - http://profandesign.se/swfupload/
+ *
+ * VERSION HISTORY
+ * 0.5 - First release
+ *
+ * 0.6 - 2006-11-24
+ * - Got rid of flash overlay
+ * - SWF size reduced to 840b
+ * - CSS-only styling of button
+ * - Add upload to links etc.
+ *
+ * 0.7 - 2006-11-27
+ * - Added filesize param and check in SWF
+ *
+ * 0.7.1 - 2006-12-01
+ * - Added link_mode param for standalone links
+ * if set to "standalone", createElement("a") won't run.
+ * - Added link_text param if css isn't needed.
+ * - Renamed cssClass to css_class for consistency
+ *
+ */
diff --git a/debian/missing-sources/swfupload/Documentation/index.html b/debian/missing-sources/swfupload/Documentation/index.html new file mode 100644 index 0000000..419d47f --- /dev/null +++ b/debian/missing-sources/swfupload/Documentation/index.html @@ -0,0 +1,1181 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head>
+ <title>SWFUpload v2 Documentation</title>
+</head>
+
+<style type="text/css">
+ h1 /* Title */ {
+ }
+ h2 /* Chapter Header */ {
+ background-color: #DCE7F2;
+ border: solid 1px #CCD7E0;
+ padding: 10px;
+
+ margin-top: 50px;
+ margin-left: 5px;
+ }
+ h3 /* Section Header */ {
+ background-color: #EDFFEB;
+ padding: 10px;
+
+ margin-left: 15px;
+ }
+ h4 {
+ background-color: #FFFFD1;
+ padding: 7px;
+
+ margin-left: 20px;
+ }
+
+ h5 {
+ background-color: #F0F0F0;
+ padding: 4px;
+
+ font-weight: normal;
+
+ margin-left: 25px;
+ }
+
+ p {
+ margin-left: 35px;
+ }
+ span.function {
+ font-weight: bold;
+ }
+ span.parameter {
+ font-style: italic;
+ font-weight: normal;
+ }
+
+ hr {
+ margin-right: 25px;
+ }
+
+ ul, ol {
+ list-style-position: outside;
+ margin: 0;
+ padding: 0;
+ margin-left: 50px;
+ }
+ li {
+ padding-left: 15px;
+ }
+
+ code {
+ display: block;
+ border: solid 1px #EFEFEF;
+ background-color: #FAFAFA;
+ padding: 15px;
+ margin-left: 25px;
+
+ white-space: pre;
+
+ overflow-x: scroll;
+ overflow-y: visible;
+ }
+</style>
+
+<body>
+ <h1>SWFUpload v2.2.0.1 Documentation</h1>
+ <h2>TOC</h2>
+ <ol>
+ <li><a href="#swfupload">SWFUpload</a></li>
+ <li><a href="#v2">SWFUpload Version 2</a></li>
+ <li><a href="#overview">Overview</a></li>
+ <li><a href="#gettingstarted">Getting Started</a></li>
+ <li><a href="#javascriptobject">SWFUpload JavaScript Object</a>
+ <ol>
+ <li><a href="#constructor">Constructor</a></li>
+ <li><a href="#globals">Globals and Constants</a>
+ <ol>
+ <li><a href="#instances">instances</a></li>
+ <li><a href="#movieCount">movieCount</a></li>
+ <li><a href="#queue_error">QUEUE_ERROR</a></li>
+ <li><a href="#upload_error">UPLOAD_ERROR</a></li>
+ <li><a href="#file_status">FILE_STATUS</a></li>
+ <li><a href="#button_action">BUTTON_ACTION</a></li>
+ <li><a href="#button_cursor">CURSOR</a></li>
+ <li><a href="#button_window_mode">BUTTON_WINDOW_MODE</a></li>
+ </ol>
+ </li>
+ <li><a href="#properties">Properties</a>
+ <ol>
+ <li><a href="#customSettings">customSettings</a></li>
+ <li><a href="#movieName">movieName</a></li>
+ </ol>
+ </li>
+ <li><a href="#methods">Methods</a>
+ <ol>
+ <li><a href="#addSetting">addSetting</a> (deprecated)</li>
+ <li><a href="#getSetting">getSetting</a> (deprecated)</li>
+ <li><a href="#retrieveSetting">retrieveSetting</a> (removed in v2.1.0)</li>
+ <li><a href="#destroy">destroy</a> (added in v2.1.0)</li>
+ <li><a href="#displayDebugInfo">displayDebugInfo</a></li>
+ <li><a href="#selectFile">selectFile</a></li>
+ <li><a href="#selectFiles">selectFiles</a></li>
+ <li><a href="#startUpload">startUpload</a></li>
+ <li><a href="#cancelUpload">cancelUpload</a></li>
+ <li><a href="#stopUpload">stopUpload</a></li>
+ <li><a href="#getStats">getStats</a></li>
+ <li><a href="#setStats">setStats</a></li>
+ <li><a href="#getFile">getFile</a></li>
+ <li><a href="#addPostParam">addPostParam</a></li>
+ <li><a href="#removePostParam">removePostParam</a></li>
+ <li><a href="#addFileParam">addFileParam</a></li>
+ <li><a href="#removeFileParam">removeFileParam</a></li>
+ <li><a href="#setUploadURL">setUploadURL</a></li>
+ <li><a href="#setPostParams">setPostParams</a></li>
+ <li><a href="#setFileTypes">setFileTypes</a></li>
+ <li><a href="#setFileSizeLimit">setFileSizeLimit</a></li>
+ <li><a href="#setFileUploadLimit">setFileUploadLimit</a></li>
+ <li><a href="#setFileQueueLimit">setFileQueueLimit</a></li>
+ <li><a href="#setFilePostName">setFilePostName</a></li>
+ <li><a href="#setUseQueryString">setUseQueryString</a></li>
+ <li><a href="#setDebugEnabled">setDebugEnabled</a></li>
+ <li><a href="#setButtonImageURL">setButtonImageURL (added in v2.2.0)</a></li>
+ <li><a href="#setButtonDimensions">setButtonDimensions (added in v2.2.0)</a></li>
+ <li><a href="#setButtonText">setButtonText (added in v2.2.0)</a></li>
+ <li><a href="#setButtonTextStyle">setButtonTextStyle (added in v2.2.0)</a></li>
+ <li><a href="#setButtonTextPadding">setButtonTextPadding (added in v2.2.0)</a></li>
+ <li><a href="#setButtonDisabled">setButtonDisabled (added in v2.2.0)</a></li>
+ <li><a href="#setButtonAction">setButtonAction (added in v2.2.0)</a></li>
+ <li><a href="#setButtonCursor">setButtonCursor (added in v2.2.0)</a></li>
+ </ol>
+ </li>
+ <li><a href="#events">Events</a>
+ <ol>
+ <li><a href="#flashReady">flashReady</a></li>
+ <li><a href="#swfUploadLoaded">swfUploadLoaded</a></li>
+ <li><a href="#fileDialogStart">fileDialogStart</a></li>
+ <li><a href="#fileQueued">fileQueued</a></li>
+ <li><a href="#fileQueueError">fileQueueError</a></li>
+ <li><a href="#fileDialogComplete">fileDialogComplete</a></li>
+ <li><a href="#uploadStart">uploadStart</a></li>
+ <li><a href="#uploadProgress">uploadProgress</a></li>
+ <li><a href="#uploadError">uploadError</a></li>
+ <li><a href="#uploadSuccess">uploadSuccess</a></li>
+ <li><a href="#uploadComplete">uploadComplete</a></li>
+ <li><a href="#debug">debug</a></li>
+ </ol>
+ </li>
+ <li><a href="#utility">SWFUpload Utility Objects</a>
+ <ol>
+ <li><a href="#settingsobject">Settings Object</a></li>
+ <li><a href="#settingsdescription">Settings Description</a></li>
+ <li><a href="#fileobject">File Object</a></li>
+ <li><a href="#statsobject">Stats Object</a></li>
+ </ol>
+ </li>
+ </ol>
+ </li>
+ <li><a href="#plugins">SWFUpload Plug-ins</a></li>
+ <li><a href="#knownissues">Known Issues</a></li>
+ </ol>
+
+
+ <h2><a name="swfupload"></a>SWFUpload</h2>
+ <p>
+ <a href="http://www.swfupload.org">SWFUpload</a> is a client-side file upload tool originally developed by <a href="http://www.vinterwebb.se/">Vinterwebb.se</a>. It uses a combination of Flash and JavaScript to
+ provide file upload functionality beyond what the basic browser provides with the <input type="file" /> tag.
+ </p>
+ <p>The main features that SWFUpload provides are:</p>
+ <p>
+ <ul>
+ <li>The ability to select multiple files in the file browser dialog.</li>
+ <li>AJAX-style uploading without a page refresh.</li>
+ <li>Upload progress events.</li>
+ <li>Namespaced classes compatible with other JavaScript libraries (i.e., jQuery, Prototype, etc.).</li>
+ <li>Flash 9 and Flash 10 support. (Flash 8 support dropped in version 2.2.0)</li>
+ </ul>
+ </p>
+ <p>
+ SWFUpload is different from other Flash based upload tools because of the philosophy
+ behind its design. SWFUpload gives developers control by leaving the UI in the browser (as much as possible).
+ Developers can use XHTML, CSS, and JavaScript to tailor the upload UI to the needs and
+ style of their site. Upload status updates are made through a set of simple JavaScript events.
+ The developer uses these events to update the webpage as the file upload progresses.
+ </p>
+ <p>
+ Unfortunately Flash Player 10 has forced us have one button in a flash movie in order to trigger the file browser dialog window. SWFUpload
+ still empowers the devloper by provding the ability the button and overlay text from JavaScript.
+ </p>
+
+ <h2><a name="v2"></a>SWFUpload v2</h2>
+ <p>
+ SWFUpload v2 includes new advanced features, improved stability, Flash Player
+ bug work-arounds and a helpful set of Plug-ins. New features include:
+ </p>
+ <p>
+ <ul>
+ <li>Flash Player 10 security compatibility.</li>
+ <li>The ability to send additional POST values with the uploads.</li>
+ <li>Sending per file POST values.</li>
+ <li>Complete set of events.</li>
+ <li>All settings dynamically updateable.</li>
+ <li>Retrieve result data from the server.</li>
+ <li>Stop an upload without cancelling.</li>
+ <li>Upload files in any order.</li>
+ <li>Multi- & Single-file selection dialogs.</li>
+ <li>Queue size, files uploaded and file size limits.</li>
+ <li>Properly handling of zero-byte files.</li>
+ <li>Pre-upload validation event.</li>
+ <li>Work-arounds for bugs in Flash and Browser.</li>
+ </ul>
+ </p>
+
+ <h2><a name="overview"></a>Overview</h2>
+ <h3>HTML Upload</h3>
+ <p>
+ The standard HTML upload input box provides a box and a button to the user for selecting a file.
+ The file is submitted with the form. The entire file must be uploaded before the next
+ page is displayed. No pre-upload validation can be made on the file (e.g., file size limits or valid extensions).
+ Very little feedback is given to the user while the file uploads.
+ </p>
+ <p>
+ The usage pattern for standard HTML uploads is simple, straight forward, and supported by nearly all browser.
+ </p>
+ <h3>SWFUpload</h3>
+ <p>
+ SWFUpload uses a Flash movie to handle file selection and upload. A customizable button is displayed by the
+ Flash movie that activates Flashes advanced file selection dialog window.
+ The file selection dialog is configured to allow the user select to a single file or multiple files.
+ The file types can be restricted so users only select the appropriate files (e.g., *.jpg;*.gif).
+ </p>
+ <p>
+ Once selected each file is validated and queued. As the file is uploaded by Flash
+ several JavaScript events are fired which the developer handles in order to update the page's UI allowing you to provide
+ upload status and error messages in real-time.
+ </p>
+ <p>
+ The uploaded file is submitted separately from the rest of the page and form. Each file is uploaded
+ individually keeping the server-side upload handling script simple. Since Flash is providing the upload
+ service the page does not have to be submitted or reloaded. The usage pattern for SWFUpload is more
+ like that of an AJAX application than that of a standard HTML form. The page's form will be processed
+ separately from the file upload.
+ </p>
+ <h2><a name="gettingstarted"></a>Getting Started</h2>
+ <p>SWFUpload is not a drag & drop upload control. It requires knowledge of JavaScript and the DOM. Several demos are available that
+ show some of the things SWFUpload is capable of and how to accomplish common tasks.</p>
+
+ <p>SWFUpload consists of 4 pieces:</p>
+ <ol>
+ <li>Initialization and Settings (JavaScript)</li>
+ <li>JavaScript library: SWFUpload.js</li>
+ <li>Flash Control: swfupload.swf</li>
+ <li>The Event Handlers (JavaScript)</li>
+ </ol>
+
+ <p>Most problems implementing SWFUpload are caused by incorrect settings, poorly built event handlers, Flash/Browser Bugs, or server configuration.</p>
+
+ <h3>Initialization and Settings</h3>
+ <p>SWFUpload must be initialized on the page. This is commonly done in the window.onload event. The SWFUpload constructor takes a settings object.
+ The settings object can be passed directly to the constructor as an object literal.</p>
+ <p>A reference to the initialized SWFUpload object should be kept as it is needed to start uploads and to control other aspects of SWFUpload.</p>
+
+ <p><strong>Example:</strong> Initializing SWFUpload with an object literal</p>
+
+ <code>var swfu;
+
+window.onload = function () {
+ swfu = new SWFUpload({
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload.swf",
+ file_size_limit : "20 MB"
+ });
+};</code>
+
+ <p><strong>Example:</strong> Initializing SWFUpload with a settings object stored in a variable</p>
+
+ <code>var swfu;
+
+window.onload = function () {
+ var settings_object = {
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload.swf",
+ file_size_limit : "20 MB"
+ };
+
+ swfu = new SWFUpload(settings_object);
+};</code>
+
+ <h3>JavaScript library</h3>
+ <p>The JavaScript library file (swfupload.js) must be included on the page where the user will upload files.</p>
+ <p>Once a SWFUpload object has been created access to several functions become available which allow the developer to control SWFUpload.</p>
+
+ <p><strong>Example:</strong> Adding SWFUpload.js to a page</p>
+
+ <code>
+<script type="text/javascript" src="http://www.swfupload.org/swfupload.js"></script>
+ </code>
+
+ <p><strong>Example:</strong> Initializing SWFUpload with the required settings.</p>
+ <code>var swfu = new SWFUpload({
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload_f9.swf",
+ button_placeholder_id : "spanSWFUploadButton"
+});
+</code>
+
+ <h3>Flash Control</h3>
+ <p>The SWFUpload JavaScript library dynamically loads the Flash Control (swfupload.swf).</p>
+
+ <p>The location of the Flash Control file must be provided in the SWFUpload settings object during setup.</p>
+
+ <p>The Flash Control is a small Flash Movie that handles file browsing, validation and upload. It appears on the page as
+ a button and communicates with JavaScript to notify the browser of upload status and other events.</p>
+
+ <h3>The Event Handlers</h3>
+
+ <p>Developers must create a set of JavaScript functions that handle SWFUpload events. These functions are called as different important events occur.</p>
+
+ <p>By handling the SWFUpload events developers can provide feedback regarding the upload progress, error messages, and upload completion. Developers should not
+ overwrite functions stored in SWFUpload.prototype. Instead create your own set of functions and pass references to them in the settings object.</p>
+
+ <p><strong>Example:</strong> SWFUpload event handlers and initialization.</p>
+
+ <code>// The uploadStart event handler. This function variable is assigned to upload_start_handler in the settings object
+var myCustomUploadStartEventHandler = function (file) {
+ var continue_with_upload;
+
+ if (file.name === "the sky is blue") {
+ continue_with_upload = true;
+ } else {
+ continue_with_upload = false;
+ }
+
+ return continue_with_upload;
+};
+
+// The uploadSuccess event handler. This function variable is assigned to upload_success_handler in the settings object
+var myCustomUploadSuccessEventHandler = function (file, server_data, receivedResponse) {
+ alert("The file " + file.name + " has been delivered to the server. The server responded with " + server_data);
+};
+
+// Create the SWFUpload Object
+var swfu = new SWFUpload({
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload.swf",
+ file_size_limit : "200 MB",
+
+ upload_start_handler : myCustomUploadStartEventHandler,
+ upload_success_handler : myCustomUploadSuccessEventHandler
+});</code>
+
+
+ <h2><a name="javascriptobject"></a>SWFUpload JavaScript Object</h2>
+
+ <h3><a name="constructor"></a>Constructor</h3>
+
+ <p><span class="function">SWFUpload(<span class="parameter">settings object</span>)</span></p>
+ <p><b>Returns:</b> A SWFUpload instance</p>
+ <code>var swfupload_instance = new SWFUpload(settings_object);</code>
+
+ <h3><a name="globals"></a>Globals and Constants</h3>
+ <p>
+ Several globals and constants are associated with the SWFUpload object. These are useful for
+ advanced SWFUpload applications and for handling errors. These are considered read-only.
+ </p>
+ <h4><a name="instances"></a>SWFUpload.instances</h4>
+ <p>SWFUpload.instances is an object containing a reference to each SWFUpload instance loaded on a page. The Flash Player
+ relies on this object in order to call the correct event handlers. SWFUpload.instances indexes by the movieName property.</p>
+
+ <h4><a name="movieCount"></a>SWFUpload.movieCount</h4>
+ <p>SWFUpload.movieCount is a global that tracks the number on SWFUpload instances that have been created and helps to ensure each movie is
+ given a unique movieName.</p>
+
+ <h4><a name="queue_error"></a>SWFUpload.QUEUE_ERROR</h4>
+ <p>SWFUpload.QUEUE_ERROR is a simple object that contains Queue Error code constants. It is generally used to determine which error code was sent
+ in the fileQueueError event.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>QUEUE_LIMIT_EXCEEDED - indicates that the user has attempted to queue more files that is allowed by the settings. Once files have been updated and removed from the queue the user is again allowed to queue additional files.</li>
+ <li>FILE_EXCEEDS_SIZE_LIMIT - indicates the selected file is larger than is allwed by the file_size_limit.</li>
+ <li>ZERO_BYTE_FILE - indicates that the selected file is empty. The Flash Player cannot handle empty files and the file is rejected. Windows Shortcut files may also trigger this error.</li>
+ <li>INVALID_FILETYPE - The selected file's extension does not match a valid extension from the file_types setting. User's can circumvent the file_types restriction by manually entering a file name.</li>
+ </ul>
+
+ <h4><a name="upload_error"></a>SWFUpload.UPLOAD_ERROR</h4>
+ <p>SWFUpload.UPLOAD_ERROR is a simple object that contains Upload Error code constants. It is generally used to determine which error code was sent
+ in the uploadError event.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>HTTP_ERROR - The file upload was attempted but the server did not return a 200 status code.</li>
+ <li>MISSING_UPLOAD_URL - The upload_url setting was not set.</li>
+ <li>IO_ERROR - Some kind of error occurred while reading or transmitting the file. This most commonly occurs when the server unexpectedly terminates the connection.</li>
+ <li>SECURITY_ERROR - The upload violates a security restriction. This error is rare.</li>
+ <li>UPLOAD_LIMIT_EXCEEDED - The user has attempted to upload more files than is allowed by the file_upload_limit setting.</li>
+ <li>UPLOAD_FAILED - The attempt to initiate the upload caused an error. This error is rare.</li>
+ <li>SPECIFIED_FILE_ID_NOT_FOUND - A file ID was passed to startUpload but that file ID could not be found.</li>
+ <li>FILE_VALIDATION_FAILED - False was returned from the uploadStart event</li>
+ <li>FILE_CANCELLED - cancelUpload was called</li>
+ <li>UPLOAD_STOPPED - stopUpload was called.</li>
+ </ul>
+
+ <h4><a name="file_status"></a>SWFUpload.FILE_STATUS</h4>
+ <p>SWFUpload.FILE_STATUS is a simple object that contains File Status code constants. It can be used to check the file status property on the File object.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>QUEUED - indicates the this file is waiting in the queue.</li>
+ <li>IN_PROGRESS - indicates that this file is currently being uploaded.</li>
+ <li>ERROR - indicates that this file caused a queue or upload error.</li>
+ <li>COMPLETE - indicates that this file was successfully transmitted to the server.</li>
+ <li>CANCELLED - indicates that this file was cancelled by a call to cancelUpload.</li>
+ </ul>
+
+
+ <h4><a name="button_action"></a>SWFUpload.BUTTON_ACTION</h4>
+ <p>SWFUpload.BUTTON_ACTION is a simple object that contains button action code constants. It is used with the button_action setting to set the behavior of the Flash based file dialog button.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>SELECT_FILE - when the Flash button is clicked the file dialog will only allow a single file to be selected.</li>
+ <li>SELECT_FILES - when the Flash button is clicked the file dialog allows multiple files to be selected.</li>
+ <li>START_UPLOAD - while the Flash button is clicked the first queued file will be uploaded.</li>
+ </ul>
+
+ <h4><a name="button_cursor"></a>SWFUpload.CURSOR</h4>
+ <p>SWFUpload.CURSOR is a simple object that contains button cursor code constants. It is used with the button_cursor setting to set the mouse cursor when hovering over the Flash button.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>ARROW - the cursor will display as an arrow pointer</li>
+ <li>HAND - the cursor will display has a finger/hand pointer</li>
+ </ul>
+
+ <h4><a name="button_window_mode"></a>SWFUpload.WINDOW_MODE</h4>
+ <p>SWFUpload.WINDOW_MODE is a simple object that contains button movie wmode parameter constants. It is used to tell the browser how to display the Flash Movie.</p>
+ <p>The some WINDOW_MODE/WMODE settings can cause problems in some browsers. See the <a href="#knownissues">Known Issues</a>.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>WINDOW is the default mode. The movie is drawn over the top of all other elements on the page.</li>
+ <li>OPAQUE causes the movie to be rendered in the page allowing other elements to cover up the button.</li>
+ <li>TRANSPARENT the button background is rendered transparent allowing html elements under the button to show through.</li>
+ </ul>
+
+ <h3><a name="properties"></a>Properties</h3>
+ <p>
+ The following list of properties is intended for your use as described below. Using other properties or
+ writing to read-only properties can cause SWFUpload to malfunction.
+ </p>
+ <h4><a name="customSettings"></a>customSettings (read/write)</h4>
+ <p>
+ The customSettings property is an empty JavaScript object that can be used to store data associated with
+ an instance of SWFUpload. The customSettings object contents can be initialized using the custom_settings setting.
+ </p>
+
+ <p><strong>Example:</strong></p>
+ <code>// Initialize SWFUpload with some custom settings
+var swfu = new SWFUpload({
+ custom_settings : {
+ custom_setting_1 : "custom_setting_value_1",
+ custom_setting_2 : "custom_setting_value_2",
+ custom_setting_n : "custom_setting_value_n",
+ }
+});
+
+swfu.customSettings.custom_setting_1 = "custom_setting_value_1"; // Change an existing custom setting
+swfu.customSettings.myNewCustomSetting = "new custom setting value"; // Add a new custom setting
+
+// Overwrite the customSettings with a completely new object
+swfu.customSettings = {
+ custom_setting_A : "custom_setting_value_A",
+ custom_setting_B : "custom_setting_value_B"
+};
+ </code>
+
+ <p>The values stored in the customSettings object can then be easily accessed in the event handlers: </p>
+
+ <code>
+function uploadSuccess(file, serverData, receivedResponse) {
+ if (this.customSettings.custom_setting_A === true) {
+ alert("Checked the custom setting!");
+ }
+}
+ </code>
+
+ <h4><a name="movieName"></a>movieName</h4>
+ <p>Contains the unique movie name of the SWFUpload instance. This value is passed to Flash and is used to facilitate Flash-to-JavaScript communication.
+ This value is used to index the instance in the SWFUpload.instances array. You should not change the movieName value.</p>
+
+ <h3><a name="methods"></a>Methods</h3>
+ <p>The following methods are used to operate SWFUpload. Some are bound to DOM element click event handlers and others are used inside
+ SWFUpload event handlers.</p>
+
+ <h4><a name="addSetting"></a>object addSetting(<span class="parameter">setting_name</span>, <span class="parameter">value</span>, <span class="parameter">default_value</span>)</h4>
+ <p><strong>Deprecated</strong> The addSetting function sets a setting value. If the value is undefined then the default_value is used. The function is used by SWFUpload
+ during initialization. Using addSetting to update a setting will not change the setting in the Flash Control.</p>
+ <p>addSetting returns the value that was stored in the setting.</p>
+
+ <h4><a name="getSetting"></a>object getSetting(<span class="parameter">setting_name</span>)</h4>
+ <p><strong>Deprecated</strong> The getSetting function retrieves the value of a setting. If the setting is not found an empty string is returned.</p>
+
+ <h4><a name="retrieveSetting"></a>object retrieveSetting(<span class="parameter">setting_value</span>, <span class="parameter">default_value</span>)</h4>
+ <p><strong>Removed in v2.1.0</strong> The retrieveSetting function is similar to the addSetting function except it does not modify the internal settings object. retrieveSetting
+ returns the setting_value unless it is undefined in which case it returns the default_value</p>
+ <p>This is a utility function.</p>
+
+ <h4><a name="destroy"></a>bool destroy()</h4>
+ <p><strong>Added in v2.1.0</strong></p>
+ <p>Removes the SWF DOM elements and then destroys SWFUpload internal references. Used for removing a SWFUpload instance from a page. It also attempts to prevent memory leaks in IE.</p>
+ <p>Returns true if the elements were removed successfully. Returns false if any error occurs leaving the SWFUpload instance in an inconsistent state.</p>
+
+ <h4><a name="displayDebugInfo"></a>void displayDebugInfo()</h4>
+ <p>The displayDebugInfo outputs SWFUpload settings using the debug event. This function is automatically called after initialization if the debug setting is 'true'</p>
+
+ <h4><a name="selectFile"></a>void selectFile()</h4>
+ <p><strong>Deprecated. Not compatible with Flash Player 10.</strong></p>
+ <p>selectFile causes the Flash Control to display a File Selection Dialog window. A single file may be selected from the Dialog window.</p>
+ <p>Calling selectFile begins the File Event Chain.</p>
+
+ <h4><a name="selectFiles"></a>void selectFiles()</h4>
+ <p><strong>Deprecated. Not compatible with Flash Player 10.</strong></p>
+ <p>selectFiles causes the Flash Control to display a File Selection Dialog window. A multiple files may be selected from the Dialog window.</p>
+ <p>Calling selectFiles begins the File Event Chain.</p>
+
+ <h4><a name="startUpload"></a>void startUpload(<span class="parameter">file_id</span>)</h4>
+ <p>startUpload causes the file specified by the file_id parameter to start the upload process. If the file_id parameter is omitted or undefined then the first file in the queue is uploaded.</p>
+
+ <p>Calling startUpload begins the Upload Event Chain.</p>
+
+ <h4><a name="cancelUpload"></a>void cancelUpload(<span class="parameter">file_id</span>, <span class="parameter">trigger_error_event</span>)</h4>
+
+ <p>cancelUpload cancels the file specified by the file_id parameter. The file is then removed from the queue.</p>
+ <p>If the file_id parameter is omitted or undefined then the first file in the queue is cancelled.</p>
+ <p>The trigger_error_event is optional. If set to false the uploadError event is suppressed.</p>
+
+ <h4><a name="stopUpload"></a>void stopUpload()</h4>
+
+ <p>stopUpload stops and re-queues the file currently being uploaded.</p>
+ <p>After the uploading file is stopped the uploadError event is fired. If no file is being uploaded then nothing happens and no event is fired.</p>
+
+ <h4><a name="getStats"></a>object getStats()</h4>
+ <p>Retrieves the stats object.</p>
+
+ <h4><a name="setStats"></a>void setStats(<span class="parameter">stats_object</span>)</h4>
+ <p>The Stats Object may be modified. This is useful if you wish to change the number of successful uploads or upload errors after an upload
+ has completed.</p>
+
+ <h4><a name="getFile"></a>object getFile(<span class="parameter">file_id</span>|<span class="parameter">index</span>)</h4>
+ <p>getFile is used to retrieve a File Object from the queue. The file retrieved by passing in a file id (the id property from a file object) or a file index (the index property from a file object).</p>
+ <p>When getting a file by file_id only files in the queue are available. If the file is not found null is returned.</p>
+ <p>When getting a file by index all queued (or files that generated a queue error) are available. If the index is out of range then null is returned</p>
+
+ <h4><a name="addPostParam"></a>void addPostParam(<span class="parameter">name</span>, <span class="parameter">value</span>)</h4>
+ <p>The addPostParam function adds a name/value pair that will be sent in the POST for all files uploaded.</p>
+ <p>The name/value pair will also appear in the post_params setting.</p>
+
+ <h4><a name="removePostParam"></a>void removePostParam(<span class="parameter">name</span>)</h4>
+ <p>The removePostParam function removes a name/value pair from the values sent with the POST for file uploads.</p>
+ <p>The name/value pair is also be removed from the post_params setting.</p>
+
+ <h4><a name="addFileParam"></a>bool addFileParam(<span class="parameter">file_id</span>, <span class="parameter">name</span>, <span class="parameter">value</span>)</h4>
+ <p>The addFileParam function adds a name/value pair that will be sent in the POST with the file specified by the file_id parameter.</p>
+ <p>The name/value pair will only be sent with the file it is added to. To send name/value pairs with all uploads use the post_param setting.</p>
+
+ <h4><a name="removeFileParam"></a>bool removeFileParam(<span class="parameter">file_id</span>, <span class="parameter">name</span>)</h4>
+ <p>The removeFileParam function removes a name/value pair from a file upload that was added using addFileParam.</p>
+ <p>If the name/value pair was not found then 'false' is returned.</p>
+
+ <h4><a name="setUploadURL"></a>void setUploadURL(<span class="parameter">url</span>)</h4>
+ <p>Dynamically modifies the upload_url setting.</p>
+
+ <h4><a name="setPostParams"></a>void setPostParams(<span class="parameter">param_object</span>)</h4>
+ <p>Dynamically modifies the post_params setting. Any previous values are over-written. The param_object should be a simple JavaScript object. All names and values must be strings.</p>
+
+ <h4><a name="setFileTypes"></a>void setFileTypes(<span class="parameter">types</span>, <span class="parameter">description</span>)</h4>
+ <p>Dynamically updates the file_types and file_types_description settings. Both parameters are required.</p>
+
+ <h4><a name="setFileSizeLimit"></a>void setFileSizeLimit(<span class="parameter">file_size_limit</span>)</h4>
+ <p>Dynamically modifies the file_size_limit setting. This applies to all future files that are queued. The file_size_limit parameter will accept a unit. Valid units are B, KB, MB, and GB. The default unit is KB.</p>
+ <p>Examples: 2147483648 B, 2097152, 2097152KB, 2048 MB, 2 GB</p>
+
+ <h4><a name="setFileUploadLimit"></a>void setFileUploadLimit(<span class="parameter">file_upload_limit</span>)</h4>
+ <p>Dynamically modifies the file_upload_limit setting. The special value zero (0) indicates "no limit".</p>
+
+ <h4><a name="setFileQueueLimit"></a>void setFileQueueLimit(<span class="parameter">file_queue_limit</span>)</h4>
+ <p>Dynamically modifies the file_queue_limit setting. The special value zero (0) indicates "no limit".</p>
+
+ <h4><a name="setFilePostName"></a>void setFilePostName(<span class="parameter">file_post_name</span>)</h4>
+ <p>Dynamically modifies the file_post_name setting. The Linux Flash Player ignores this setting.</p>
+
+ <h4><a name="setUseQueryString"></a>void setUseQueryString(<span class="parameter">use_query_string</span>)</h4>
+ <p>Dynamically modifies the use_query_string setting. When true this forces SWFUpload to send post parameters on the query string rather than in the post. The use_query_string parameter should be a boolean true or false.</p>
+
+ <h4><a name="setDebugEnabled"></a>void setDebugEnabled(<span class="parameter">debug_enabled</span>)</h4>
+ <p>Dynamically enables or disables debug output. The debug_enabled parameter should be a boolean true or false.</p>
+
+ <h4><a name="setButtonImageURL"></a>void setButtonImageURL(<span class="parameter">url</span>)</h4>
+ <p>Dynamically change the image used in the Flash Button. The image url must be relative to the swfupload.swf file, an absolute path (e.g., starting with a /), or
+ a fully qualified url (e.g., http://www.swfupload.org/buttonImage.png). Any image format supported by Flash can be loaded. The most notable formats are jpg, gif, and png.</p>
+
+ <p>The button image is expected to be a button sprite (or a single image file with several images stacked together). The image will be used to represent
+ all the button states by moving the image up or down to only display the needed portion. These states include: normal, hover, click, disabled. See the sample button images.</p>
+
+ <h4><a name="setButtonDimensions"></a>void setButtonDimensions(<span class="parameter">width</span>, <span class="parameter">height</span>)</h4>
+ <p>Dynamically change the Flash button's width and height. The values should be numeric and should not include any units. The height value should
+ be 1/4th of the total button image height so the button state sprite images can be displayed correctly</p>
+
+ <h4><a name="setButtonText"></a>void setButtonText(<span class="parameter">text</span>)</h4>
+ <p>Sets the text that should be displayed over the Flash button. Text that is too large and overflows the button size will be clipped.</p>
+ <p>The text can be styled using HTML supported by the Flash Player (<a target="_blank" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html#htmlText">Adobe Documentation</a>)</p>
+
+ <h4><a name="setButtonTextStyle"></a>void setButtonTextStyle(<span class="parameter">css_style_text</span>)</h4>
+ <p>Sets the CSS styles used to style the Flash Button Text. CSS should be formatted according to the Flash Player documentation (<a target="_blank" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/StyleSheet.html">Adobe Documentation</a>)</p>
+ <p>Style classes defined here can then be referenced by HTML in the button_text setting.</p>
+
+ <h4><a name="setButtonTextPadding"></a>void setButtonTextPadding(<span class="parameter">left</span>, <span class="parameter">top</span>)</h4>
+ <p>Sets the top and left padding of the Flash button text. The values may be negative.</p>
+
+ <h4><a name="setButtonDisabled"></a>void setButtonDisabled(<span class="parameter">isDisabled</span>)</h4>
+ <p>When 'true' changes the Flash Button state to disabled and ignores any clicks.</p>
+
+ <h4><a name="setButtonAction"></a>void setButtonAction(<span class="parameter">buttonAction</span>)</h4>
+ <p>Sets the action taken when the Flash button is clicked. Valid action values are taken from the BUTTON_ACTION constants.</p>
+
+ <h4><a name="setButtonCursor"></a>void setButtonCursor(<span class="parameter">buttonCursor</span>)</h4>
+ <p>Sets the mouse cursor shown when hovering over the Flash button. Valid cursor values are taken from the CURSOR constants.</p>
+
+
+
+ <h3><a name="events"></a>Events</h3>
+ <p>SWFUpload fires various events during its operation. These events can be handled by the developer to update the UI, change behavior, or report errors.</p>
+ <p>All SWFUpload events are called in the context of a SWFUpload instance. This means that the 'this' object refers to the SWFUpload instance that
+ fired the event.</p>
+
+ <p>SWFUpload events should be set only by assigning the event handler function in the settings object during object initialization. You should not override the
+ internal functions belonging to the SWFUpload.prototype object.</p>
+
+ <p>During a file upload events are usually called in this order (the Upload Event Chain):</p>
+ <ul>
+ <li>uploadStart</li>
+ <li>uploadProgress (called over and over again as the file uploads)</li>
+ <li>uploadError (called if some kind of error occurs, the file is canceled or stopped)</li>
+ <li>uploadSuccess (the upload finished successfully, data returned from the server is available)</li>
+ <li>uploadComplete (the upload is complete and SWFUpload is ready to start the next file)</li>
+ </ul>
+
+ <h4><a name="flashReady"></a><span class="function">flashReady()</span></h4>
+ <p>flashReady is an internal event that should not be overwritten. It is called by the Flash Control to notify SWFUpload that the Flash
+ movie has loaded and is ready to accept commands.</p>
+
+ <h4><a name="swfUploadLoaded"></a><span class="function">swfUploadLoaded()</span></h4>
+ <p>The swfUploadLoaded event is fired by flashReady. It is settable. swfUploadLoaded is called to let you know that it is safe to call SWFUpload methods.</p>
+
+ <h4><a name="fileDialogStart"></a><span class="function">fileDialogStart(<span class="parameter"></span>)</span></h4>
+ <p>fileDialogStart is fired after selectFile for selectFiles is called. This event is fired immediately before the File Selection Dialog
+ window is displayed. However, the event may not execute until after the Dialog window is closed.</p>
+
+ <h4><a name="fileQueued"></a><span class="function">fileQueued(<span class="parameter">file object</span>)</span></h4>
+ <p>The fileQueued event is fired for each file that is queued after the File Selection Dialog window is closed.</p>
+
+ <h4><a name="fileQueueError"></a><span class="function">fileQueueError(<span class="parameter">file object</span>, <span class="parameter">error code</span>, <span class="parameter">message</span>)</span></h4>
+ <p>The fileQueueError event is fired for each file that was not queued after the File Selection Dialog window is closed. A file may not be queued
+ for several reasons such as, the file exceeds the file size, the file is empty or a file or queue limit has been exceeded.</p>
+ <p>The reason for the queue error is specified by the error code parameter. The error code corresponds to a SWFUpload.QUEUE_ERROR constant.</p>
+
+ <h4><a name="fileDialogComplete"></a><span class="function">fileDialogComplete(<span class="parameter">number of files selected</span>, <span class="parameter">number of files queued</span>, <span class="parameter">total number of files in the queued</span>)</span></h4>
+ <p>The fileDialogComplete event fires after the File Selection Dialog window has been closed and all the selected files have been processed. The 'number of files queued' argument indicates the number of files that were queued from the dialog selection (as opposed to the number of files in the queue).</p>
+ <p>If you want file uploading to begin automatically this is a good place to call 'this.startUpload()'</p>
+
+ <h4><a name="uploadStart"></a><span class="function">uploadStart(<span class="parameter">file object</span>)</span></h4>
+ <p>uploadStart is called immediately before the file is uploaded. This event provides an opportunity to perform any last minute validation, add post
+ params or do any other work before the file is uploaded.</p>
+
+ <p>The upload can be cancelled by returning 'false' from uploadStart. If you return 'true' or do not return any value then the upload proceeds. Returning
+ 'false' will cause an uploadError event to fired.</p>
+
+ <h4><a name="uploadProgress"></a><span class="function">uploadProgress(<span class="parameter">file object</span>, <span class="parameter">bytes complete</span>, <span class="parameter">total bytes</span>)</span></h4>
+ <p>The uploadProgress event is fired periodically by the Flash Control. This event is useful for providing UI updates on the page.</p>
+ <p><strong>Note:</strong> The Linux Flash Player fires a single uploadProgress event after the entire file has been uploaded. This is a bug in
+ the Linux Flash Player that we cannot work around.</p>
+
+ <h4><a name="uploadError"></a><span class="function">uploadError(<span class="parameter">file object</span>, <span class="parameter">error code</span>, <span class="parameter">message</span>)</span></h4>
+ <p>The uploadError event is fired any time an upload is interrupted or does not complete successfully. The error code parameter indicates the type of error
+ that occurred. The error code parameter specifies a constant in SWFUpload.UPLOAD_ERROR.</p>
+ <p>Stopping, Cancelling or returning 'false' from uploadStart will cause uploadError to fire. Upload error will not fire for files that are cancelled
+ but still waiting in the queue.</p>
+
+ <h4><a name="uploadSuccess"></a><span class="function">uploadSuccess(<span class="parameter">file object</span>, <span class="parameter">server data</span>, <span class="parameter">received response</span>)</span></h4>
+ <p>uploadSuccess is fired when the entire upload has been transmitted and the server returns a HTTP 200 status code. Any data outputted by the server is available
+ in the server data parameter.</p>
+
+ <p>
+ Due to some bugs in the Flash Player the server response may not be acknowledged and no uploadSuccess event is fired by Flash. In this case the
+ assume_success_timeout setting is checked to see if enough time has passed to fire uploadSuccess anyway. In this case the received response parameter will be false.
+ </p>
+
+ <p>
+ The http_success setting allows uploadSuccess to be fired for HTTP status codes other than 200. In this case no server data is available from the Flash Player.
+ </p>
+
+ <p>At this point the upload is not yet complete. Another upload cannot be started from uploadSuccess.</p>
+
+ <h4><a name="uploadComplete"></a><span class="function">uploadComplete(<span class="parameter">file object</span>)</span></h4>
+ <p>uploadComplete is always fired at the end of an upload cycle (after uploadError or uploadSuccess). At this point the upload is complete and
+ another upload can be started.</p>
+ <p>If you want the next upload to start automatically this is a good place to call this.uploadStart(). Use caution when calling uploadStart inside
+ the uploadComplete event if you also have code that cancels all the uploads in a queue.</p>
+
+ <h4><a name="debug"></a><span class="function">debug(<span class="parameter">message</span>)</span></h4>
+ <p>The debug event is called by the SWFUpload library and the Flash Control when the debug setting is set to 'true'. If the debug
+ event is not overridden then SWFUpload writes debug messages to the SWFUpload console (a text box dynamically added to the end of the page body).</p>
+
+ <h3><a name="utility"></a>SWFUpload Utility Objects</h3>
+ <h4><a name="settingsobject"></a>Settings object</h4>
+ <p>The settings object is a JavaScript object that provides the settings for the SWFUpload instance. <strong>Each setting should only appear once.</strong> Many settings
+ are optional and provide suitable default values if omitted. See the setting details for required and optional settings.</p>
+ <p><strong>Example:</strong></p>
+ <code>{
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload.swf",
+
+ file_post_name : "Filedata",
+ post_params : {
+ "post_param_name_1" : "post_param_value_1",
+ "post_param_name_2" : "post_param_value_2",
+ "post_param_name_n" : "post_param_value_n"
+ },
+ use_query_string : false,
+ requeue_on_error : false,
+ http_success : [201, 202],
+ assume_success_timeout : 0,
+ file_types : "*.jpg;*.gif",
+ file_types_description: "Web Image Files",
+ file_size_limit : "1024",
+ file_upload_limit : 10,
+ file_queue_limit : 2,
+
+ debug : false,
+
+ prevent_swf_caching : false,
+ preserve_relative_urls : false,
+
+ button_placeholder_id : "element_id",
+ button_image_url : "http://www.swfupload.org/button_sprite.png",
+ button_width : 61,
+ button_height : 22,
+ button_text : "<b>Click</b> <span class="redText">here</span>",
+ button_text_style : ".redText { color: #FF0000; }",
+ button_text_left_padding : 3,
+ button_text_top_padding : 2,
+ button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES,
+ button_disabled : false,
+ button_cursor : SWFUpload.CURSOR.HAND,
+ button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT,
+
+ swfupload_loaded_handler : swfupload_loaded_function,
+ file_dialog_start_handler : file_dialog_start_function,
+ file_queued_handler : file_queued_function,
+ file_queue_error_handler : file_queue_error_function,
+ file_dialog_complete_handler : file_dialog_complete_function,
+ upload_start_handler : upload_start_function,
+ upload_progress_handler : upload_progress_function,
+ upload_error_handler : upload_error_function,
+ upload_success_handler : upload_success_function,
+ upload_complete_handler : upload_complete_function,
+ debug_handler : debug_function,
+
+ custom_settings : {
+ custom_setting_1 : "custom_setting_value_1",
+ custom_setting_2 : "custom_setting_value_2",
+ custom_setting_n : "custom_setting_value_n",
+ }
+}</code>
+ <h4><a name="settingsdescription"></a>Settings Description</h4>
+
+ <h5>upload_url</h5>
+ <p>The upload_url setting accepts a full, absolute, or relative target URL for the uploaded file. Relative URLs should be relative to document. The upload_url should be in the same domain as the Flash Control for best compatibility.</p>
+ <p>If the preserve_relative_urls setting is false SWFUpload will convert the relative URL to an absolute URL to avoid the URL being interpreted differently by the Flash Player on different platforms. If you disable SWFUploads conversion of the URL relative URLs should be relative to the swfupload.swf file.</p>
+
+ <h5>file_post_name</h5>
+ <p>The file_post_name allows you to set the value name used to post the file. This is not related to the file name.
+ The default value is 'Filedata'. For maximum compatibility it is recommended that the default value is used.</p>
+
+ <h5>post_params</h5>
+ <p>
+ The post_params setting defines the name/value pairs that will be posted with each uploaded file. This setting accepts a simple JavaScript object.
+ Multiple post name/value pairs should be defined as demonstrated in the sample settings object. Values must be either strings or numbers (as interpreted by the JavaScript typeof function).
+ </p>
+ <p>Note: Flash Player 8 does not support sending additional post parameters. SWFUpload will automatically send the post_params as part of the query string.</p>
+
+ <h5>use_query_string</h5>
+ <p>
+ The use_query_string setting may be true or false. This value indicates whether SWFUpload should send the post_params and file params on the query string or the post. This setting was introduced in SWFUpload v2.1.0.
+ </p>
+
+ <h5>preserve_relative_urls</h5>
+ <p>A boolean value that indicates whether SWFUpload should attempt to convert relative URLs used by the Flash Player to absolute URLs. If set to true SWFUpload will not modify any URLs. The default value is false.</p>
+
+ <h5>requeue_on_error</h5>
+ <p>
+ The requeue_on_error setting may be true or false. When this setting is true any files that has an
+ uploadError (excluding fileQueue errors and the FILE_CANCELLED uploadError) is returned to the front of
+ the queue rather than being discarded. The file can be uploaded again if needed. To remove the file from the
+ queue the cancelUpload method must be called.
+ </p>
+ <p>
+ All the events associated with a failed upload are still called and so the requeuing the failed upload can conflict
+ with the Queue Plugin (or custom code that uploads the entire queue). Code that automatically uploads the next file
+ in the queue will upload the failed file over and over again if care is not taken to allow the failing upload to be
+ cancelled.
+ </p>
+ <p>
+ This setting was introduced in SWFUpload v2.1.0.
+ </p>
+
+ <h5>http_success</h5>
+ <p>
+ An array that defines the HTTP Status Codes that will trigger success. 200 is always a success. Also, only the 200 status code provides the serverData.
+ </p>
+ <p>
+ When returning and accepting an HTTP Status Code other than 200 it is not necessary for the server to return content.
+ </p>
+
+ <h5>assume_success_timeout</h5>
+ <p>
+ The number of seconds SWFUpload should wait for Flash to detect the server's response after the file has finished uploading. This setting allows you to
+ work around the Flash Player bugs where long running server side scripts causes Flash to ignore the server response or the Mac Flash Player bug that ignores
+ server responses with no content.
+ </p>
+ <p>
+ Testing has shown that Flash will ignore server responses that take longer than 30 seconds after the last uploadProgress event.
+ </p>
+ <p>
+ A timeout of zero (0) seconds disables this feature and is the default value. SWFUpload will wait indefinitely for the Flash Player to trigger the uploadSuccess event.
+ </p>
+
+ <h5>file_types</h5>
+ <p>
+ The file_types setting accepts a semi-colon separated list of file extensions that are allowed to be selected by the user. Use '*.*' to allow all file types.
+ </p>
+
+ <h5>file_types_description</h5>
+ <p>
+ A text description that is displayed to the user in the File Browser dialog.
+ </p>
+
+ <h5>file_size_limit</h5>
+ <p>
+ The file_size_limit setting defines the maximum allowed size of a file to be uploaded. This setting accepts a value and unit.
+ Valid units are B, KB, MB and GB. If the unit is omitted default is KB. A value of 0 (zero) is interpreted as unlimited.
+ </p>
+ <p>
+ Note: This setting only applies to the user's browser. It does not affect any settings or limits on the web server.
+ </p>
+
+ <h5>file_upload_limit</h5>
+ <p>
+ Defines the number of files allowed to be uploaded by SWFUpload. This setting also sets the upper bound of the file_queue_limit
+ setting. Once the user has uploaded or queued the maximum number of files she will no longer be able to queue additional files. The
+ value of 0 (zero) is interpreted as unlimited. Only successful uploads (uploads the trigger the uploadSuccess event) are counted
+ toward the upload limit. The setStats function can be used to modify the number of successful uploads.
+ </p>
+ <p>Note: This value is not tracked across pages and is reset when a page is refreshed. File quotas should be managed by the web server.</p>
+
+ <h5>file_queue_limit</h5>
+ <p>
+ Defines the number of unprocessed files allowed to be simultaneously queued. Once a file is uploaded, errored, or cancelled a new
+ files can be queued in its place until the queue limit has been reached. If the upload limit (or remaining uploads allowed) is less
+ than the queue limit then the lower number is used.
+ </p>
+
+ <h5>flash_url</h5>
+ <p>
+ The full, absolute, or relative URL to the Flash Control swf file. This setting cannot be changed once the SWFUpload has been
+ instantiated. Relative URLs are relative to the page URL.
+ </p>
+
+ <h5>flash_width</h5>
+ <p>
+ <strong>(Removed in v2.1.0)</strong> Defines the width of the HTML element that contains the flash. Some browsers do not function correctly if this setting is less than 1 px.
+ This setting is optional and has a default value of 1px.
+ </p>
+
+ <h5>flash_height</h5>
+ <p>
+ <strong>(Removed in v2.1.0)</strong> Defines the height of the HTML element that contains the flash. Some browsers do not function correctly if this setting is less than 1 px.
+ This setting is optional and has a default value of 1px.
+ </p>
+
+ <h5>flash_color</h5>
+ <p>
+ <strong>Removed in v2.2.0</strong> This setting sets the background color of the HTML element that contains the flash. The default value is '#FFFFFF'.
+ </p>
+ <p>
+ Note: This setting may not be effective in "skinning" 1px flash element in all browsers.
+ </p>
+
+ <h5>prevent_swf_caching</h5>
+ <p>
+ <strong>Added in v2.2.0</strong> This boolean setting indicates whether a random value should be added to the Flash URL in an attempt to
+ prevent the browser from caching the SWF movie. This works around a bug in some IE-engine based browsers.
+ </p>
+ <p>Note: The algorithm for adding the random number to the URL is dumb and cannot handle URLs that already have some parameters.</p>
+
+ <h5>debug</h5>
+ <p>A boolean value that defines whether the debug event handler should be fired.</p>
+
+ <h5>button_placeholder_id</h5>
+ <p><strong>(Added in v2.2.0)</strong> This required setting sets the ID of DOM element that will be <em>replaced</em> by the Flash Button. This setting overrides the button_placeholder setting. The Flash button can be styled using the CSS class 'swfupload'.</p>
+
+ <h5>button_placeholder</h5>
+ <p><strong>(Added in v2.2.0)</strong> This required setting sets the DOM element that will be <em>replaced</em> by the Flash Button. This setting is only applied if the button_placeholder_id is not set. The Flash button can be styled using the CSS class 'swfupload'.</p>
+
+ <h5>button_image_url</h5>
+ <p><strong>(Added in v2.2.0)</strong> Fully qualified, absolute or relative URL to the image file to be used as the Flash button. Any Flash supported image file format can be used (another SWF file or gif, jpg, or png).</p>
+ <p>This URL is affected by the preserve_relative_urls setting and should follow the same rules as the upload_url setting.</p>
+
+ <p>The button image is treated as a sprite. There are 4 button states that must be represented by the button image. Each button state image
+ should be stacked above the other in this order: normal, hover, down/click, disabled.</p>
+
+ <h5>button_width</h5>
+ <p><strong>(Added in v2.2.0)</strong> A number defining the width of the Flash button.</p>
+
+ <h5>button_height</h5>
+ <p><strong>(Added in v2.2.0)</strong> A number defining the height of the Flash button. This value should be 1/4th of the height or
+ the button image.</p>
+
+ <h5>button_text</h5>
+ <p><strong>(Added in v2.2.0)</strong> Plain or HTML text that is displayed over the Flash button. HTML text can be further styled using CSS
+ classes and the button_text_style setting. See <a target="_blank" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html#htmlText">Adobe's Flash documentation</a> for details.</p>
+
+ <h5>button_text_style</h5>
+ <p><strong>(Added in v2.2.0)</strong> CSS style string that defines how the button_text is displayed.
+ See <a target="_blank" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/StyleSheet.html">Adobe's Flash documentation</a> for details.</p>
+
+ <h5>button_text_top_padding</h5>
+ <p><strong>(Added in v2.2.0)</strong> Used to vertically position the Flash button text. Negative values may be used.</p>
+
+ <h5>button_text_left_padding</h5>
+ <p><strong>(Added in v2.2.0)</strong> Used to horizontally position the Flash button text. Negative values may be used.</p>
+
+ <h5>button_action</h5>
+ <p><strong>(Added in v2.2.0)</strong> Defines the action taken when the Flash button is clicked. Valid action values can be found in the swfupload.js file under the BUTTON_ACTION object.</p>
+
+ <h5>button_disabled</h5>
+ <p><strong>(Added in v2.2.0)</strong> A boolean value that sets whether the Flash button is in the disabled state. When in the disabled state the button will not execute any actions.</p>
+
+ <h5>button_cursor</h5>
+ <p><strong>(Added in v2.2.0)</strong> Used to define what type of mouse cursor is displayed when hovering over the Flash button.</p>
+
+ <h5>button_window_mode</h5>
+ <p><strong>(Added in v2.2.0)</strong> Sets the WMODE property of the Flash Movie. Valid values are available in the SWFUpload.WINDOW_MODE constants.</p>
+
+ <h5>custom_settings</h5>
+ <p>
+ The custom_settings setting allows developers to safely attach additional information to a SWFUpload instance without
+ worrying about affecting internal SWFUpload values or changes in new SWFUpload versions. This setting accepts a JavaScript
+ object.
+ </p>
+ <p>
+ Once instantiated the custom settings are accessed in the 'customSettings' property of the SWFUpload instance.
+ </p>
+ <code>var swfu = new SWFUpload({
+ custom_settings : {
+ "My Setting" : "This is my setting",
+ myothersetting : "This is my other setting",
+ integer_setting : 100,
+ a_dom_setting : document.getElementById("some_element_id")
+ }
+});
+
+var my_setting = swfu.customSettings["My Setting"]);
+swfu.customSettings["My Setting"] = "This is my new setting";
+swfu.customSetting.myothersetting = "another new value";
+swfu.customSetting.integer_setting += 25;
+swfu.customSetting["a_dom_setting"].style.visibility = "hidden";</code>
+
+ <h5>Event Handlers</h5>
+ <p>
+ The remaining settings define the event handlers called by SWFUpload during its operation. JavaScript functions should
+ be defined to handle these events as needed.
+ </p>
+
+
+
+ <h4><a name="fileobject"></a>File Object</h4>
+ <p>The file object is passed to several event handlers. It contains information about the file. Some operating systems do not fill in all the values (this
+ is especially true for the createdate and modificationdate values).</p>
+ <code>{
+ id : string, // SWFUpload file id, used for starting or cancelling and upload
+ index : number, // The index of this file for use in getFile(i)
+ name : string, // The file name. The path is not included.
+ size : number, // The file size in bytes
+ type : string, // The file type as reported by the client operating system
+ creationdate : Date, // The date the file was created
+ modificationdate : Date, // The date the file was last modified
+ filestatus : number, // The file's current status. Use SWFUpload.FILE_STATUS to interpret the value.
+
+}</code>
+
+ <h4><a name="statsobject"></a>Stats Object</h4>
+ <p>The Stats object provides information about the upload queue.</p>
+ <p>That stats object contains the following properties:</p>
+ <code>{
+ in_progress : number // 1 or 0 indicating if a file upload is currently in progress
+ files_queued : number // The number of files currently in the queue
+ successful_uploads : number // The number of files that have uploaded successfully (caused uploadSuccess to be fired)
+ upload_errors : number // The number of files that have had errors (excluding cancelled files)
+ upload_cancelled : number // The number of files that have been cancelled
+ queue_errors : number // The number of files that caused fileQueueError to be fired
+}</code>
+ <p>All these values can be updated using setStats() except the <em>in_progress</em> and <em>files_queued</em> values.</p>
+
+ <h2><a name="plugins"></a>SWFUpload Plug-ins</h2>
+
+ <p>With SWFUpload v2.0 several plugins have been introduced. They are provided to help with common tasks associated with implementing SWFUpload.</p>
+ <p>Currently most of the documentation for using the plugins is contained in the plugin JavaScript file.</p>
+
+ <h3>SWFObject</h3>
+ <p>
+ The SWFObject plugin uses the <a href="http://code.google.com/p/swfobject/">SWFObject library</a> to handle the embedding
+ of the SWFUpload Flash Component into the page.
+ </p>
+ <p>
+ This plugin also provides support for Document Ready loading and Flash Version Detection. Usage details are documented
+ in the plugin file itself. You should not use the SWFObject's Document Ready loading mixed with another libraries DOMReady. Use
+ one or the other but not both.
+ </p>
+
+ <p><strong>Flash Player 10: </strong> Because Flash Player 10 requires the SWFUpload swf to act is a button the movie must be visible in order
+ for it to load. If the button_placeholder_id is set to an element that is hidden (visibility set to hidden or display set to none) SWFUpload will
+ fail to load.</p>
+
+ <h3>Cookies</h3>
+ <p>In response to the Flash Cookie Bug the Cookies Plugin automatically retrieves your browser's cookies and sends them
+ with the upload. The are sent as POST or GET variables to the upload url.</p>
+
+ <p>Note that this plugin sends the cookies name/values in the POST or GET. On the server side they will not be accessible as cookies. Some frameworks that
+ automatically check cookies for session or authentication values still will not be able to find the values.</p>
+
+ <h3>Queue Handling</h3>
+ <p>This plugin provides Queue Handling features such as entire queue uploading, entire queue cancelling and automatic starting of uploads after being queued.</p>
+
+
+ <h3>Speed</h3>
+ <p>This Plugin extends the 'file' object with several properties that describe the current upload. This includes current speed, average speed, elapsed time, remaining time and more.</p>
+
+
+ <h2><a name="knownissues"></a>Known Issues</h2>
+ <p>The Flash Player and many Browsers have bugs that have a direct impact on the performance of SWFUpload. While we have worked
+ hard to get around many issues but there are some things that we cannot fix.</p>
+
+ <h3>Cancelling in Linux</h3>
+ <p>Older Flash 9 Players for Linux cause the browser to crash if an upload is cancelled. Newer Flash 9 Players behave better.</p>
+
+ <h3>Upload Progress in Linux</h3>
+ <p>The Flash Player in Linux sends a single uploadProgress event after the file has finished uploading.</p>
+ <p>In some distributions the entire browser locks up while the upload is in progress.</p>
+
+ <h3>Upload Progress in OS X</h3>
+ <p>There have been some reports that uploadProgress events are not fired in MAC Flash Players. The specifics haven't been pinned down but be aware of the possible issue.</p>
+
+ <h3>MIME Type</h3>
+ <p>The Flash Player uploads all files with a mime type of <em>application/octet-stream</em> regardless of the file's actual mime type.</p>
+
+ <h3>Maximum number of selected files</h3>
+ <p>The Flash Player does not impose a maximum number of selected files. However, it builds a selected files string which does have a maximum length.
+ The string is built using the file's name and the separator [quote][space][quote]. The total number of files selected is determined by the sum
+ of the lengths of the file names and a prefixed and postfixed [quote] character (2 characters) and the number of files selected minus one times 3 (for the separator string)</p>
+
+ <p>This limitation may vary from system to system. If a use selects too many files they will be receive a Flash Player generated warning message and will
+ be left at the File Selection Dialog.</p>
+
+ <h3>Proxies</h3>
+ <p>The Flash Player may not properly use proxies. It does not handle authenticating proxies well (if at all) and will some-times crash.</p>
+ <p>Some anti-virus software uses a proxy to scan uploads and cause SWFUpload to believe the entire file has been uploaded. SWFUpload will fire uploadProgress events very quickly
+ until it reaches 100% and will then seem to pause until the proxy completes uploading the file to the server.</p>
+
+ <h3>Apache mod_security</h3>
+ <p>Apache's mod_security validates POST to the server. Flash Player has implemented an edge case (there is argument as to whether it is invalid or note)
+ POST for file uploads and so servers implementing
+ mod_security will reject the upload. mod_security can be disabled using your .htaccess file</p>
+
+ <h3>SSL</h3>
+ <p>There have been some reports that the Flash Player cannot upload through SSL.
+ The issue has not been pinned down but uploading over SSL may be unreliable. There especially seems to be an issue with
+ using self-signed certificates.</p>
+ <p>Also, SSL tickets from untrusted Certificate Authorities (CA) do not work as Flash does not provide a method for accepting the certificate. It has been noted that, like the cookie bug,
+ that Flash Player on Windows obtains its trusted CA list from Internet Explorer regardless of the browser in use.</p>
+
+ <h3>Authentication</h3>
+ <p>HTTP Authentication is not well supported by the Flash Player. Later versions of Flash Player behave better. Old version of Flash Player would crash the browser.</p>
+
+ <h3>Prematurely terminated connections</h3>
+ <p>Prematurely ending the response (such as a Response.end() in ASP.Net) can sometimes cause successful uploads to be reported as failed.</p>
+
+ <h3>Filedata in Linux</h3>
+ <p>Changing the Filedata value (file_post_name setting) is ignored in Linux Flash Players.</p>
+
+ <h3>Cookie issue</h3>
+ <p>On Windows the Non-IE Flash Player plugin (FireFox, Opera, Safari, etc) will send the IE cookies regardless of the browser used. This breaks authentication and sessions for many server-side scripting technologies.</p>
+ <p>Developers should manually pass Session and Authentication cookie information and manually restore Sessions on the Server Side if they wish to use Sessions</p>
+ <p>The SWFUpload package contains work-around sample code for PHP and ASP.Net</p>
+
+ <h3>ExternalInterface bugs</h3>
+ <p>Flash Player does not properly escape data when communication with the browser/JavaScript. SWFUpload goes to great lengths to work-around this issue. If this
+ bug is fixed in future Flash Players/Browsers then SWFUpload will send extra escaped data.</p>
+
+ <h3>Server Data length bugs</h3>
+ <p>Very long server data is corrupted on Mac and Linux Flash Players. Server data will be truncated, garbled, and/or repeated. We recommend
+ keeping data returned from the server short and concise.</p>
+
+ <h3>Avant Browser</h3>
+ <p>For some users the Avant Browser does not work with SWFUpload after the Flash Control has been cached. This has been reproduced by the
+ SWFUpload developers but the Avant Browser developers did not experience any problems.</p>
+ <p>When the page is reloaded SWFUpload loads and fires the swfupload_loaded event. However, none of the ExternalInterface callback functions are defined
+ on the movie element. SWFUpload v2.0.2 has added checks which prevent swfupload_loaded from firing if the callback functions are not detected.</p>
+
+ <p><strong>SWFUpload v2.2.0 added the prevent_swf_caching setting that attempts to work around this issue.</strong></p>
+
+ <h3>File Dialog & Page Changing</h3>
+ <p>Leaving or reloading the current page while the File Browser Dialog window is open will cause the browser to crash (all browsers, all OSs). Most commonly this is caused by failing to
+ cancel a click event on an <a> tag where the onclick event calls the selectFile or selectFiles function.</p>
+
+ <h3>Long Running Upload Scripts</h3>
+ <p>After Flash has uploaded the file to the webserver the upload script is executed. This script handles the file whether that means saving it, creating a thumbnail, scanning for viruses, etc.
+ If the upload script does not return any data within 30 seconds Flash will disconnect and return an IO Error. You can prevent this by returning characters or data while
+ the script runs (if possible). For PHP, the script continues to run and complete successfully even though Flash has terminated the connection. Any data returned
+ by the script after Flash has disconnected is lost.</p>
+
+ <h3>WMODE / BUTTON_WINDOW_MODE</h3>
+
+ <p>In some browsers the selected WMODE (which is set using the BUTTON_WINDOW_MODE) can prevent the Flash Control from loading
+ if the control is not on screen. The control will finally load once the user scrolls the page so the control becomes visible.</p>
+
+ <p>This behavior can adversely affect the SWFObject plugin. No SWFUpload events will be fire and the button image will not be
+ loaded until the control becomes visible.</p>
+
+ <h3>Memory Leaks</h3>
+ <p>Some browsers (especially IE) cannot recover memory used by the Flash Player when JavaScript communication via the ExternalInterface classes is used (like in SWFUpload).
+ Creating many SWFUpload instances and/or reloading the page several times will cause the browser to consume more and more memory until it crashes or otherwise harms the
+ system.</p>
+
+ <p>In v2.2.0 SWFUpload we gave implemented some preventative measures. Some of these measures are pro-active but it is still recommended that you
+ call the destroy method when the page unloads. If you are using hundreds of SWFUpload instances on a page you should use caution and test
+ carefully for memory leaks.</p>
+
+ <h3>Other Mac Issues</h3>
+ <ul>
+ <li>
+ Users have reported that uploading to subdomains does not work with the Mac Flash Player.
+ </li>
+ <li>
+ Users have reported that pages that redirect (HTTP Status 302) are not handled by the Mac Flash Player. Windows
+ clients seem to handle this issue.
+ </li>
+ <li>
+ The flash documentation states that on OS early than OS X 10.3 the bytes loaded is always reported as -1. SWFUpload converts
+ this to 0 but the total bytes will never be sent and 100% won't be reached. The UI should be updated to display 100% complete in
+ uploadSuccess or uploadComplete events to maintain a consistent UI.
+ </li>
+ <li>
+ Some users have reported issues if there is a space character in the upload_url for the Mac Flash Player. Avoid spaces or try replacing them with + or %20.
+ </li>
+ <li>
+ Users have reported that the Flash Player for Mac adds the PORT to the HTTP_HOST server variable (e.g., http://www.example.com:80). If you are
+ checking this variable in your server-side script be aware of the possible issue.
+ </li>
+ </ul>
+
+</body>
+</html>
\ No newline at end of file diff --git a/debian/missing-sources/swfupload/Flash/ExternalCall.as b/debian/missing-sources/swfupload/Flash/ExternalCall.as new file mode 100644 index 0000000..091f5ec --- /dev/null +++ b/debian/missing-sources/swfupload/Flash/ExternalCall.as @@ -0,0 +1,121 @@ +package {
+ import flash.external.ExternalInterface;
+
+ internal class ExternalCall
+ {
+
+ /*public function ExternalCall()
+ {
+
+ }
+ */
+
+ public static function Simple(callback:String):void {
+ ExternalInterface.call(callback);
+ }
+ public static function FileQueued(callback:String, file_object:Object):void {
+ ExternalInterface.call(callback, EscapeMessage(file_object));
+ }
+ public static function FileQueueError(callback:String, error_code:Number, file_object:Object, message:String):void {
+
+ ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(error_code), EscapeMessage(message));
+
+ }
+ public static function FileDialogComplete(callback:String, num_files_selected:Number, num_files_queued:Number, total_num_files_queued:Number):void {
+
+ ExternalInterface.call(callback, EscapeMessage(num_files_selected), EscapeMessage(num_files_queued), EscapeMessage(total_num_files_queued));
+
+ }
+
+ public static function UploadStart(callback:String, file_object:Object):void {
+ ExternalInterface.call(callback, EscapeMessage(file_object));
+ }
+
+ public static function UploadProgress(callback:String, file_object:Object, bytes_loaded:uint, bytes_total:uint):void {
+
+ ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(bytes_loaded), EscapeMessage(bytes_total));
+
+ }
+ public static function UploadSuccess(callback:String, file_object:Object, server_data:String, responseReceived:Boolean):void {
+
+ ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(server_data), EscapeMessage(responseReceived));
+
+ }
+ public static function UploadError(callback:String, error_code:Number, file_object:Object, message:String):void {
+
+ ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(error_code), EscapeMessage(message));
+
+ }
+ public static function UploadComplete(callback:String, file_object:Object):void {
+
+ ExternalInterface.call(callback, EscapeMessage(file_object));
+
+ }
+ public static function Debug(callback:String, message:String):void {
+
+ ExternalInterface.call(callback, EscapeMessage(message));
+ }
+
+ public static function Bool(callback:String):Boolean {
+ return ExternalInterface.call(callback);
+ }
+
+
+ /* Escapes all the backslashes which are not translated correctly in the Flash -> JavaScript Interface
+ *
+ * These functions had to be developed because the ExternalInterface has a bug that simply places the
+ * value a string in quotes (except for a " which is escaped) in a JavaScript string literal which
+ * is executed by the browser. These often results in improperly escaped string literals if your
+ * input string has any backslash characters. For example the string:
+ * "c:\Program Files\uploadtools\"
+ * is placed in a string literal (with quotes escaped) and becomes:
+ * var __flash__temp = "\"c:\Program Files\uploadtools\\"";
+ * This statement will cause errors when executed by the JavaScript interpreter:
+ * 1) The first \" is succesfully transformed to a "
+ * 2) \P is translated to P and the \ is lost
+ * 3) \u is interpreted as a unicode character and causes an error in IE
+ * 4) \\ is translated to \
+ * 5) leaving an unescaped " which causes an error
+ *
+ * I fixed this by escaping \ characters in all outgoing strings. The above escaped string becomes:
+ * var __flash__temp = "\"c:\\Program Files\\uploadtools\\\"";
+ * which contains the correct string literal.
+ *
+ * Note: The "var __flash__temp = " portion of the example is part of the ExternalInterface not part of
+ * my escaping routine.
+ */
+ private static function EscapeMessage(message:*):* {
+ if (message is String) {
+ message = EscapeString(message);
+ }
+ else if (message is Array) {
+ message = EscapeArray(message);
+ }
+ else if (message is Object) {
+ message = EscapeObject(message);
+ }
+
+ return message;
+ }
+
+ private static function EscapeString(message:String):String {
+ var replacePattern:RegExp = /\\/g; //new RegExp("/\\/", "g");
+ return message.replace(replacePattern, "\\\\");
+ }
+ private static function EscapeArray(message_array:Array):Array {
+ var length:uint = message_array.length;
+ var i:uint = 0;
+ for (i; i < length; i++) {
+ message_array[i] = EscapeMessage(message_array[i]);
+ }
+ return message_array;
+ }
+ private static function EscapeObject(message_obj:Object):Object {
+ for (var name:String in message_obj) {
+ message_obj[name] = EscapeMessage(message_obj[name]);
+ }
+ return message_obj;
+ }
+
+ }
+}
\ No newline at end of file diff --git a/debian/missing-sources/swfupload/Flash/FileItem.as b/debian/missing-sources/swfupload/Flash/FileItem.as new file mode 100644 index 0000000..9eb3952 --- /dev/null +++ b/debian/missing-sources/swfupload/Flash/FileItem.as @@ -0,0 +1,112 @@ +package {
+ import flash.net.FileReference;
+
+ internal class FileItem
+ {
+ private static var file_id_sequence:Number = 0; // tracks the file id sequence
+
+ private var postObject:Object;
+ public var file_reference:FileReference;
+ public var id:String;
+ public var index:Number = -1;
+ public var file_status:int = 0;
+ private var js_object:Object;
+
+ public static var FILE_STATUS_QUEUED:int = -1;
+ public static var FILE_STATUS_IN_PROGRESS:int = -2;
+ public static var FILE_STATUS_ERROR:int = -3;
+ public static var FILE_STATUS_SUCCESS:int = -4;
+ public static var FILE_STATUS_CANCELLED:int = -5;
+ public static var FILE_STATUS_NEW:int = -6; // This file status should never be sent to JavaScript
+
+ public function FileItem(file_reference:FileReference, control_id:String, index:Number)
+ {
+ this.postObject = {};
+ this.file_reference = file_reference;
+ this.id = control_id + "_" + (FileItem.file_id_sequence++);
+ this.file_status = FileItem.FILE_STATUS_NEW;
+ this.index = index;
+
+ this.js_object = {
+ id: this.id,
+ index: this.index,
+ post: this.GetPostObject()
+ };
+
+ // Cleanly attempt to retrieve the FileReference info
+ // this can fail and so is wrapped in try..catch
+ try {
+ this.js_object.name = this.file_reference.name;
+ this.js_object.size = this.file_reference.size;
+ this.js_object.type = this.file_reference.type || "";
+ this.js_object.creationdate = this.file_reference.creationDate || new Date(0);
+ this.js_object.modificationdate = this.file_reference.modificationDate || new Date(0);
+ } catch (ex:Error) {
+ this.file_status = FileItem.FILE_STATUS_ERROR;
+ }
+
+ this.js_object.filestatus = this.file_status;
+ }
+
+ public function AddParam(name:String, value:String):void {
+ this.postObject[name] = value;
+ }
+
+ public function RemoveParam(name:String):void {
+ delete this.postObject[name];
+ }
+
+ public function GetPostObject(escape:Boolean = false):Object {
+ if (escape) {
+ var escapedPostObject:Object = { };
+ for (var k:String in this.postObject) {
+ if (this.postObject.hasOwnProperty(k)) {
+ var escapedName:String = FileItem.EscapeParamName(k);
+ escapedPostObject[escapedName] = this.postObject[k];
+ }
+ }
+ return escapedPostObject;
+ } else {
+ return this.postObject;
+ }
+ }
+
+ // Create the simply file object that is passed to the browser
+ public function ToJavaScriptObject():Object {
+ this.js_object.filestatus = this.file_status;
+ this.js_object.post = this.GetPostObject(true);
+
+ return this.js_object;
+ }
+
+ public function toString():String {
+ return "FileItem - ID: " + this.id;
+ }
+
+ /*
+ // The purpose of this function is to escape the property names so when Flash
+ // passes them back to javascript they can be interpretted correctly.
+ // ***They have to be unescaped again by JavaScript.**
+ //
+ // This works around a bug where Flash sends objects this way:
+ // object.parametername = "value";
+ // instead of
+ // object["parametername"] = "value";
+ // This can be a problem if the parameter name has characters that are not
+ // allowed in JavaScript identifiers:
+ // object.parameter.name! = "value";
+ // does not work but,
+ // object["parameter.name!"] = "value";
+ // would have worked.
+ */
+ public static function EscapeParamName(name:String):String {
+ name = name.replace(/[^a-z0-9_]/gi, FileItem.EscapeCharacter);
+ name = name.replace(/^[0-9]/, FileItem.EscapeCharacter);
+ return name;
+ }
+ public static function EscapeCharacter():String {
+ return "$" + ("0000" + arguments[0].charCodeAt(0).toString(16)).substr(-4, 4);
+ }
+
+ }
+}
\ No newline at end of file diff --git a/debian/missing-sources/swfupload/Flash/SWFUpload v2.as3proj b/debian/missing-sources/swfupload/Flash/SWFUpload v2.as3proj new file mode 100644 index 0000000..302944a --- /dev/null +++ b/debian/missing-sources/swfupload/Flash/SWFUpload v2.as3proj @@ -0,0 +1,79 @@ +ďťż<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <!-- Output SWF options -->
+ <output>
+ <movie disabled="False" />
+ <movie input="" />
+ <movie path="swfupload.swf" />
+ <movie fps="15" />
+ <movie width="300" />
+ <movie height="300" />
+ <movie version="9" />
+ <movie background="#FFFFFF" />
+ </output>
+ <!-- Other classes to be compiled into your SWF -->
+ <classpaths>
+ <class path="." />
+ </classpaths>
+ <!-- Build options -->
+ <build>
+ <option accessible="False" />
+ <option allowSourcePathOverlap="False" />
+ <option benchmark="False" />
+ <option es="False" />
+ <option loadConfig="" />
+ <option optimize="True" />
+ <option showActionScriptWarnings="True" />
+ <option showBindingWarnings="True" />
+ <option showDeprecationWarnings="True" />
+ <option showUnusedTypeSelectorWarnings="True" />
+ <option strict="True" />
+ <option useNetwork="True" />
+ <option useResourceBundleMetadata="True" />
+ <option warnings="True" />
+ <option verboseStackTraces="False" />
+ <option additional="" />
+ <option customSDK="" />
+ </build>
+ <!-- SWC Include Libraries -->
+ <includeLibraries>
+ <!-- example: <element path="..." /> -->
+ </includeLibraries>
+ <!-- SWC Libraries -->
+ <libraryPaths>
+ <!-- example: <element path="..." /> -->
+ </libraryPaths>
+ <!-- External Libraries -->
+ <externalLibraryPaths>
+ <!-- example: <element path="..." /> -->
+ </externalLibraryPaths>
+ <!-- Runtime Shared Libraries -->
+ <rslPaths>
+ <!-- example: <element path="..." /> -->
+ </rslPaths>
+ <!-- Intrinsic Libraries -->
+ <intrinsics>
+ <!-- example: <element path="..." /> -->
+ </intrinsics>
+ <!-- Assets to embed into the output SWF -->
+ <library>
+ <!-- example: <asset path="..." id="..." update="..." glyphs="..." mode="..." place="..." sharepoint="..." /> -->
+ </library>
+ <!-- Class files to compile (other referenced classes will automatically be included) -->
+ <compileTargets>
+ <compile path="SWFUpload.as" />
+ </compileTargets>
+ <!-- Paths to exclude from the Project Explorer tree -->
+ <hiddenPaths>
+ <!-- example: <hidden path="..." /> -->
+ </hiddenPaths>
+ <!-- Executed before build -->
+ <preBuildCommand />
+ <!-- Executed after build -->
+ <postBuildCommand alwaysRun="True">deploy.bat</postBuildCommand>
+ <!-- Other project options -->
+ <options>
+ <option showHiddenPaths="False" />
+ <option testMovie="NewWindow" />
+ </options>
+</project>
\ No newline at end of file diff --git a/debian/missing-sources/swfupload/Flash/SWFUpload.as b/debian/missing-sources/swfupload/Flash/SWFUpload.as new file mode 100644 index 0000000..3b0e11d --- /dev/null +++ b/debian/missing-sources/swfupload/Flash/SWFUpload.as @@ -0,0 +1,1519 @@ +package {
+ import flash.display.BlendMode;
+ import flash.display.DisplayObjectContainer;
+ import flash.display.Loader;
+ import flash.display.Stage;
+ import flash.display.Sprite;
+ import flash.display.StageAlign;
+ import flash.display.StageScaleMode;
+ import flash.net.FileReferenceList;
+ import flash.net.FileReference;
+ import flash.net.FileFilter;
+ import flash.net.URLRequest;
+ import flash.net.URLRequestMethod;
+ import flash.net.URLVariables;
+ import flash.events.*;
+ import flash.external.ExternalInterface;
+ import flash.system.Security;
+ import flash.text.AntiAliasType;
+ import flash.text.GridFitType;
+ import flash.text.StaticText;
+ import flash.text.StyleSheet;
+ import flash.text.TextDisplayMode;
+ import flash.text.TextField;
+ import flash.text.TextFieldType;
+ import flash.text.TextFieldAutoSize;
+ import flash.text.TextFormat;
+ import flash.ui.Mouse;
+ import flash.utils.Timer;
+
+ import FileItem;
+ import ExternalCall;
+
+ public class SWFUpload extends Sprite {
+ // Cause SWFUpload to start as soon as the movie starts
+ public static function main():void
+ {
+ var SWFUpload:SWFUpload = new SWFUpload();
+ }
+
+ private const build_number:String = "SWFUPLOAD 2.2.0";
+
+ // State tracking variables
+ private var fileBrowserMany:FileReferenceList = new FileReferenceList();
+ private var fileBrowserOne:FileReference = null; // This isn't set because it can't be reused like the FileReferenceList. It gets setup in the SelectFile method
+
+ private var file_queue:Array = new Array(); // holds a list of all items that are to be uploaded.
+ private var current_file_item:FileItem = null; // the item that is currently being uploaded.
+
+ private var file_index:Array = new Array();
+
+ private var successful_uploads:Number = 0; // Tracks the uploads that have been completed
+ private var queue_errors:Number = 0; // Tracks files rejected during queueing
+ private var upload_errors:Number = 0; // Tracks files that fail upload
+ private var upload_cancelled:Number = 0; // Tracks number of cancelled files
+ private var queued_uploads:Number = 0; // Tracks the FileItems that are waiting to be uploaded.
+
+ private var valid_file_extensions:Array = new Array();// Holds the parsed valid extensions.
+
+ private var serverDataTimer:Timer = null;
+ private var assumeSuccessTimer:Timer = null;
+
+ private var restoreExtIntTimer:Timer;
+ private var hasCalledFlashReady:Boolean = false;
+
+ // Callbacks
+ private var flashReady_Callback:String;
+ private var fileDialogStart_Callback:String;
+ private var fileQueued_Callback:String;
+ private var fileQueueError_Callback:String;
+ private var fileDialogComplete_Callback:String;
+
+ private var uploadStart_Callback:String;
+ private var uploadProgress_Callback:String;
+ private var uploadError_Callback:String;
+ private var uploadSuccess_Callback:String;
+
+ private var uploadComplete_Callback:String;
+
+ private var debug_Callback:String;
+ private var testExternalInterface_Callback:String;
+ private var cleanUp_Callback:String;
+
+ // Values passed in from the HTML
+ private var movieName:String;
+ private var uploadURL:String;
+ private var filePostName:String;
+ private var uploadPostObject:Object;
+ private var fileTypes:String;
+ private var fileTypesDescription:String;
+ private var fileSizeLimit:Number;
+ private var fileUploadLimit:Number = 0;
+ private var fileQueueLimit:Number = 0;
+ private var useQueryString:Boolean = false;
+ private var requeueOnError:Boolean = false;
+ private var httpSuccess:Array = [];
+ private var assumeSuccessTimeout:Number = 0;
+ private var debugEnabled:Boolean;
+
+ private var buttonLoader:Loader;
+ private var buttonTextField:TextField;
+ private var buttonCursorSprite:Sprite;
+ private var buttonImageURL:String;
+ private var buttonWidth:Number;
+ private var buttonHeight:Number;
+ private var buttonText:String;
+ private var buttonTextStyle:String;
+ private var buttonTextTopPadding:Number;
+ private var buttonTextLeftPadding:Number;
+ private var buttonAction:Number;
+ private var buttonCursor:Number;
+ private var buttonStateOver:Boolean;
+ private var buttonStateMouseDown:Boolean;
+ private var buttonStateDisabled:Boolean;
+
+ // Error code "constants"
+ // Size check constants
+ private var SIZE_TOO_BIG:Number = 1;
+ private var SIZE_ZERO_BYTE:Number = -1;
+ private var SIZE_OK:Number = 0;
+
+ // Queue errors
+ private var ERROR_CODE_QUEUE_LIMIT_EXCEEDED:Number = -100;
+ private var ERROR_CODE_FILE_EXCEEDS_SIZE_LIMIT:Number = -110;
+ private var ERROR_CODE_ZERO_BYTE_FILE:Number = -120;
+ private var ERROR_CODE_INVALID_FILETYPE:Number = -130;
+
+ // Upload Errors
+ private var ERROR_CODE_HTTP_ERROR:Number = -200;
+ private var ERROR_CODE_MISSING_UPLOAD_URL:Number = -210;
+ private var ERROR_CODE_IO_ERROR:Number = -220;
+ private var ERROR_CODE_SECURITY_ERROR:Number = -230;
+ private var ERROR_CODE_UPLOAD_LIMIT_EXCEEDED:Number = -240;
+ private var ERROR_CODE_UPLOAD_FAILED:Number = -250;
+ private var ERROR_CODE_SPECIFIED_FILE_ID_NOT_FOUND:Number = -260;
+ private var ERROR_CODE_FILE_VALIDATION_FAILED:Number = -270;
+ private var ERROR_CODE_FILE_CANCELLED:Number = -280;
+ private var ERROR_CODE_UPLOAD_STOPPED:Number = -290;
+
+
+ // Button Actions
+ private var BUTTON_ACTION_SELECT_FILE:Number = -100;
+ private var BUTTON_ACTION_SELECT_FILES:Number = -110;
+ private var BUTTON_ACTION_START_UPLOAD:Number = -120;
+
+ private var BUTTON_CURSOR_ARROW:Number = -1;
+ private var BUTTON_CURSOR_HAND:Number = -2;
+
+ public function SWFUpload() {
+ // Do the feature detection. Make sure this version of Flash supports the features we need. If not
+ // abort initialization.
+ if (!flash.net.FileReferenceList || !flash.net.FileReference || !flash.net.URLRequest || !flash.external.ExternalInterface || !flash.external.ExternalInterface.available || !DataEvent.UPLOAD_COMPLETE_DATA) {
+ return;
+ }
+
+ Security.allowDomain("*"); // Allow uploading to any domain
+
+ // Keep Flash Player busy so it doesn't show the "flash script is running slowly" error
+ var counter:Number = 0;
+ root.addEventListener(Event.ENTER_FRAME, function ():void { if (++counter > 100) counter = 0; });
+
+ // Setup file FileReferenceList events
+ this.fileBrowserMany.addEventListener(Event.SELECT, this.Select_Many_Handler);
+ this.fileBrowserMany.addEventListener(Event.CANCEL, this.DialogCancelled_Handler);
+
+
+ this.stage.align = StageAlign.TOP_LEFT;
+ this.stage.scaleMode = StageScaleMode.NO_SCALE;
+
+ // Setup the button and text label
+ this.buttonLoader = new Loader();
+ var doNothing:Function = function ():void { };
+ this.buttonLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, doNothing );
+ this.buttonLoader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, doNothing );
+ this.stage.addChild(this.buttonLoader);
+
+ var self:SWFUpload = this;
+
+ this.stage.addEventListener(MouseEvent.CLICK, function (event:MouseEvent):void {
+ self.UpdateButtonState();
+ self.ButtonClickHandler(event);
+ });
+ this.stage.addEventListener(MouseEvent.MOUSE_DOWN, function (event:MouseEvent):void {
+ self.buttonStateMouseDown = true;
+ self.UpdateButtonState();
+ });
+ this.stage.addEventListener(MouseEvent.MOUSE_UP, function (event:MouseEvent):void {
+ self.buttonStateMouseDown = false;
+ self.UpdateButtonState();
+ });
+ this.stage.addEventListener(MouseEvent.MOUSE_OVER, function (event:MouseEvent):void {
+ self.buttonStateMouseDown = event.buttonDown;
+ self.buttonStateOver = true;
+ self.UpdateButtonState();
+ });
+ this.stage.addEventListener(MouseEvent.MOUSE_OUT, function (event:MouseEvent):void {
+ self.buttonStateMouseDown = false;
+ self.buttonStateOver = false;
+ self.UpdateButtonState();
+ });
+ // Handle the mouse leaving the flash movie altogether
+ this.stage.addEventListener(Event.MOUSE_LEAVE, function (event:Event):void {
+ self.buttonStateMouseDown = false;
+ self.buttonStateOver = false;
+ self.UpdateButtonState();
+ });
+
+ this.buttonTextField = new TextField();
+ this.buttonTextField.type = TextFieldType.DYNAMIC;
+ this.buttonTextField.antiAliasType = AntiAliasType.ADVANCED;
+ this.buttonTextField.autoSize = TextFieldAutoSize.NONE;
+ this.buttonTextField.cacheAsBitmap = true;
+ this.buttonTextField.multiline = true;
+ this.buttonTextField.wordWrap = false;
+ this.buttonTextField.tabEnabled = false;
+ this.buttonTextField.background = false;
+ this.buttonTextField.border = false;
+ this.buttonTextField.selectable = false;
+ this.buttonTextField.condenseWhite = true;
+
+ this.stage.addChild(this.buttonTextField);
+
+
+ this.buttonCursorSprite = new Sprite();
+ this.buttonCursorSprite.graphics.beginFill(0xFFFFFF, 0);
+ this.buttonCursorSprite.graphics.drawRect(0, 0, 1, 1);
+ this.buttonCursorSprite.graphics.endFill();
+ this.buttonCursorSprite.buttonMode = true;
+ this.buttonCursorSprite.x = 0;
+ this.buttonCursorSprite.y = 0;
+ this.buttonCursorSprite.addEventListener(MouseEvent.CLICK, doNothing);
+ this.stage.addChild(this.buttonCursorSprite);
+
+ // Get the movie name
+ this.movieName = root.loaderInfo.parameters.movieName;
+
+ // **Configure the callbacks**
+ // The JavaScript tracks all the instances of SWFUpload on a page. We can access the instance
+ // associated with this SWF file using the movieName. Each callback is accessible by making
+ // a call directly to it on our instance. There is no error handling for undefined callback functions.
+ // A developer would have to deliberately remove the default functions,set the variable to null, or remove
+ // it from the init function.
+ this.flashReady_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].flashReady";
+ this.fileDialogStart_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].fileDialogStart";
+ this.fileQueued_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].fileQueued";
+ this.fileQueueError_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].fileQueueError";
+ this.fileDialogComplete_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].fileDialogComplete";
+
+ this.uploadStart_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].uploadStart";
+ this.uploadProgress_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].uploadProgress";
+ this.uploadError_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].uploadError";
+ this.uploadSuccess_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].uploadSuccess";
+
+ this.uploadComplete_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].uploadComplete";
+
+ this.debug_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].debug";
+
+ this.testExternalInterface_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].testExternalInterface";
+ this.cleanUp_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].cleanUp";
+
+ // Get the Flash Vars
+ this.uploadURL = root.loaderInfo.parameters.uploadURL;
+ this.filePostName = root.loaderInfo.parameters.filePostName;
+ this.fileTypes = root.loaderInfo.parameters.fileTypes;
+ this.fileTypesDescription = root.loaderInfo.parameters.fileTypesDescription + " (" + this.fileTypes + ")";
+ this.loadPostParams(root.loaderInfo.parameters.params);
+
+
+ if (!this.filePostName) {
+ this.filePostName = "Filedata";
+ }
+ if (!this.fileTypes) {
+ this.fileTypes = "*.*";
+ }
+ if (!this.fileTypesDescription) {
+ this.fileTypesDescription = "All Files";
+ }
+
+ this.LoadFileExensions(this.fileTypes);
+
+ try {
+ this.debugEnabled = root.loaderInfo.parameters.debugEnabled == "true" ? true : false;
+ } catch (ex:Object) {
+ this.debugEnabled = false;
+ }
+
+ try {
+ this.SetFileSizeLimit(String(root.loaderInfo.parameters.fileSizeLimit));
+ } catch (ex:Object) {
+ this.fileSizeLimit = 0;
+ }
+
+
+ try {
+ this.fileUploadLimit = Number(root.loaderInfo.parameters.fileUploadLimit);
+ if (this.fileUploadLimit < 0) this.fileUploadLimit = 0;
+ } catch (ex:Object) {
+ this.fileUploadLimit = 0;
+ }
+
+ try {
+ this.fileQueueLimit = Number(root.loaderInfo.parameters.fileQueueLimit);
+ if (this.fileQueueLimit < 0) this.fileQueueLimit = 0;
+ } catch (ex:Object) {
+ this.fileQueueLimit = 0;
+ }
+
+ // Set the queue limit to match the upload limit when the queue limit is bigger than the upload limit
+ if (this.fileQueueLimit > this.fileUploadLimit && this.fileUploadLimit != 0) this.fileQueueLimit = this.fileUploadLimit;
+ // The the queue limit is unlimited and the upload limit is not then set the queue limit to the upload limit
+ if (this.fileQueueLimit == 0 && this.fileUploadLimit != 0) this.fileQueueLimit = this.fileUploadLimit;
+
+ try {
+ this.useQueryString = root.loaderInfo.parameters.useQueryString == "true" ? true : false;
+ } catch (ex:Object) {
+ this.useQueryString = false;
+ }
+
+ try {
+ this.requeueOnError = root.loaderInfo.parameters.requeueOnError == "true" ? true : false;
+ } catch (ex:Object) {
+ this.requeueOnError = false;
+ }
+
+ try {
+ this.SetHTTPSuccess(String(root.loaderInfo.parameters.httpSuccess));
+ } catch (ex:Object) {
+ this.SetHTTPSuccess([]);
+ }
+
+ try {
+ this.SetAssumeSuccessTimeout(Number(root.loaderInfo.parameters.assumeSuccessTimeout));
+ } catch (ex:Object) {
+ this.SetAssumeSuccessTimeout(0);
+ }
+
+
+ try {
+ this.SetButtonDimensions(Number(root.loaderInfo.parameters.buttonWidth), Number(root.loaderInfo.parameters.buttonHeight));
+ } catch (ex:Object) {
+ this.SetButtonDimensions(0, 0);
+ }
+
+ try {
+ this.SetButtonImageURL(String(root.loaderInfo.parameters.buttonImageURL));
+ } catch (ex:Object) {
+ this.SetButtonImageURL("");
+ }
+
+ try {
+ this.SetButtonText(String(root.loaderInfo.parameters.buttonText));
+ } catch (ex:Object) {
+ this.SetButtonText("");
+ }
+
+ try {
+ this.SetButtonTextPadding(Number(root.loaderInfo.parameters.buttonTextLeftPadding), Number(root.loaderInfo.parameters.buttonTextTopPadding));
+ } catch (ex:Object) {
+ this.SetButtonTextPadding(0, 0);
+ }
+
+ try {
+ this.SetButtonTextStyle(String(root.loaderInfo.parameters.buttonTextStyle));
+ } catch (ex:Object) {
+ this.SetButtonTextStyle("");
+ }
+
+ try {
+ this.SetButtonAction(Number(root.loaderInfo.parameters.buttonAction));
+ } catch (ex:Object) {
+ this.SetButtonAction(this.BUTTON_ACTION_SELECT_FILES);
+ }
+
+ try {
+ this.SetButtonDisabled(root.loaderInfo.parameters.buttonDisabled == "true" ? true : false);
+ } catch (ex:Object) {
+ this.SetButtonDisabled(Boolean(false));
+ }
+
+ try {
+ this.SetButtonCursor(Number(root.loaderInfo.parameters.buttonCursor));
+ } catch (ex:Object) {
+ this.SetButtonCursor(this.BUTTON_CURSOR_ARROW);
+ }
+
+ this.SetupExternalInterface();
+
+ this.Debug("SWFUpload Init Complete");
+ this.PrintDebugInfo();
+
+ if (ExternalCall.Bool(this.testExternalInterface_Callback)) {
+ ExternalCall.Simple(this.flashReady_Callback);
+ this.hasCalledFlashReady = true;
+ }
+
+ // Start periodically checking the external interface
+ var oSelf:SWFUpload = this;
+ this.restoreExtIntTimer = new Timer(1000, 0);
+ this.restoreExtIntTimer.addEventListener(TimerEvent.TIMER, function ():void { oSelf.CheckExternalInterface();} );
+ this.restoreExtIntTimer.start();
+ }
+
+ // Used to periodically check that the External Interface functions are still working
+ private function CheckExternalInterface():void {
+ if (!ExternalCall.Bool(this.testExternalInterface_Callback)) {
+ this.SetupExternalInterface();
+ this.Debug("ExternalInterface reinitialized");
+ if (!this.hasCalledFlashReady) {
+ ExternalCall.Simple(this.flashReady_Callback);
+ this.hasCalledFlashReady = true;
+ }
+ }
+ }
+
+ // Called by JS to see if it can access the external interface
+ private function TestExternalInterface():Boolean {
+ return true;
+ }
+
+ private function SetupExternalInterface():void {
+ try {
+ ExternalInterface.addCallback("SelectFile", this.SelectFile);
+ ExternalInterface.addCallback("SelectFiles", this.SelectFiles);
+ ExternalInterface.addCallback("StartUpload", this.StartUpload);
+ ExternalInterface.addCallback("ReturnUploadStart", this.ReturnUploadStart);
+ ExternalInterface.addCallback("StopUpload", this.StopUpload);
+ ExternalInterface.addCallback("CancelUpload", this.CancelUpload);
+ ExternalInterface.addCallback("RequeueUpload", this.RequeueUpload);
+
+ ExternalInterface.addCallback("GetStats", this.GetStats);
+ ExternalInterface.addCallback("SetStats", this.SetStats);
+ ExternalInterface.addCallback("GetFile", this.GetFile);
+ ExternalInterface.addCallback("GetFileByIndex", this.GetFileByIndex);
+
+ ExternalInterface.addCallback("AddFileParam", this.AddFileParam);
+ ExternalInterface.addCallback("RemoveFileParam", this.RemoveFileParam);
+
+ ExternalInterface.addCallback("SetUploadURL", this.SetUploadURL);
+ ExternalInterface.addCallback("SetPostParams", this.SetPostParams);
+ ExternalInterface.addCallback("SetFileTypes", this.SetFileTypes);
+ ExternalInterface.addCallback("SetFileSizeLimit", this.SetFileSizeLimit);
+ ExternalInterface.addCallback("SetFileUploadLimit", this.SetFileUploadLimit);
+ ExternalInterface.addCallback("SetFileQueueLimit", this.SetFileQueueLimit);
+ ExternalInterface.addCallback("SetFilePostName", this.SetFilePostName);
+ ExternalInterface.addCallback("SetUseQueryString", this.SetUseQueryString);
+ ExternalInterface.addCallback("SetRequeueOnError", this.SetRequeueOnError);
+ ExternalInterface.addCallback("SetHTTPSuccess", this.SetHTTPSuccess);
+ ExternalInterface.addCallback("SetAssumeSuccessTimeout", this.SetAssumeSuccessTimeout);
+ ExternalInterface.addCallback("SetDebugEnabled", this.SetDebugEnabled);
+
+ ExternalInterface.addCallback("SetButtonImageURL", this.SetButtonImageURL);
+ ExternalInterface.addCallback("SetButtonDimensions", this.SetButtonDimensions);
+ ExternalInterface.addCallback("SetButtonText", this.SetButtonText);
+ ExternalInterface.addCallback("SetButtonTextPadding", this.SetButtonTextPadding);
+ ExternalInterface.addCallback("SetButtonTextStyle", this.SetButtonTextStyle);
+ ExternalInterface.addCallback("SetButtonAction", this.SetButtonAction);
+ ExternalInterface.addCallback("SetButtonDisabled", this.SetButtonDisabled);
+ ExternalInterface.addCallback("SetButtonCursor", this.SetButtonCursor);
+
+ ExternalInterface.addCallback("TestExternalInterface", this.TestExternalInterface);
+
+ } catch (ex:Error) {
+ this.Debug("Callbacks where not set: " + ex.message);
+ return;
+ }
+
+ ExternalCall.Simple(this.cleanUp_Callback);
+ }
+
+ /* *****************************************
+ * FileReference Event Handlers
+ * *************************************** */
+ private function DialogCancelled_Handler(event:Event):void {
+ this.Debug("Event: fileDialogComplete: File Dialog window cancelled.");
+ ExternalCall.FileDialogComplete(this.fileDialogComplete_Callback, 0, 0, this.queued_uploads);
+ }
+
+ private function Open_Handler(event:Event):void {
+ this.Debug("Event: uploadProgress (OPEN): File ID: " + this.current_file_item.id);
+ ExternalCall.UploadProgress(this.uploadProgress_Callback, this.current_file_item.ToJavaScriptObject(), 0, this.current_file_item.file_reference.size);
+ }
+
+ private function FileProgress_Handler(event:ProgressEvent):void {
+ // On early than Mac OS X 10.3 bytesLoaded is always -1, convert this to zero. Do bytesTotal for good measure.
+ // http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html#event:progress
+ var bytesLoaded:Number = event.bytesLoaded < 0 ? 0 : event.bytesLoaded;
+ var bytesTotal:Number = event.bytesTotal < 0 ? 0 : event.bytesTotal;
+
+ // Because Flash never fires a complete event if the server doesn't respond after 30 seconds or on Macs if there
+ // is no content in the response we'll set a timer and assume that the upload is successful after the defined amount of
+ // time. If the timeout is zero then we won't use the timer.
+ if (bytesLoaded === bytesTotal && bytesTotal > 0 && this.assumeSuccessTimeout > 0) {
+ if (this.assumeSuccessTimer !== null) {
+ this.assumeSuccessTimer.stop();
+ this.assumeSuccessTimer = null;
+ }
+
+ this.assumeSuccessTimer = new Timer(this.assumeSuccessTimeout * 1000, 1);
+ this.assumeSuccessTimer.addEventListener(TimerEvent.TIMER_COMPLETE, AssumeSuccessTimer_Handler);
+ this.assumeSuccessTimer.start();
+ }
+
+ this.Debug("Event: uploadProgress: File ID: " + this.current_file_item.id + ". Bytes: " + bytesLoaded + ". Total: " + bytesTotal);
+ ExternalCall.UploadProgress(this.uploadProgress_Callback, this.current_file_item.ToJavaScriptObject(), bytesLoaded, bytesTotal);
+ }
+
+ private function AssumeSuccessTimer_Handler(event:TimerEvent):void {
+ this.Debug("Event: AssumeSuccess: " + this.assumeSuccessTimeout + " passed without server response");
+ this.UploadSuccess(this.current_file_item, "", false);
+ }
+
+ private function Complete_Handler(event:Event):void {
+ /* Because we can't do COMPLETE or DATA events (we have to do both) we can't
+ * just call uploadSuccess from the complete handler, we have to wait for
+ * the Data event which may never come. However, testing shows it always comes
+ * within a couple milliseconds if it is going to come so the solution is:
+ *
+ * Set a timer in the COMPLETE event (which always fires) and if DATA is fired
+ * it will stop the timer and call uploadComplete
+ *
+ * If the timer expires then DATA won't be fired and we call uploadComplete
+ * */
+
+ // Set the timer
+ if (serverDataTimer != null) {
+ this.serverDataTimer.stop();
+ this.serverDataTimer = null;
+ }
+
+ this.serverDataTimer = new Timer(100, 1);
+ //var self:SWFUpload = this;
+ this.serverDataTimer.addEventListener(TimerEvent.TIMER, this.ServerDataTimer_Handler);
+ this.serverDataTimer.start();
+ }
+ private function ServerDataTimer_Handler(event:TimerEvent):void {
+ this.UploadSuccess(this.current_file_item, "");
+ }
+
+ private function ServerData_Handler(event:DataEvent):void {
+ this.UploadSuccess(this.current_file_item, event.data);
+ }
+
+ private function UploadSuccess(file:FileItem, serverData:String, responseReceived:Boolean = true):void {
+ if (this.serverDataTimer !== null) {
+ this.serverDataTimer.stop();
+ this.serverDataTimer = null;
+ }
+ if (this.assumeSuccessTimer !== null) {
+ this.assumeSuccessTimer.stop();
+ this.assumeSuccessTimer = null;
+ }
+
+ this.successful_uploads++;
+ file.file_status = FileItem.FILE_STATUS_SUCCESS;
+
+ this.Debug("Event: uploadSuccess: File ID: " + file.id + " Response Received: " + responseReceived.toString() + " Data: " + serverData);
+ ExternalCall.UploadSuccess(this.uploadSuccess_Callback, file.ToJavaScriptObject(), serverData, responseReceived);
+
+ this.UploadComplete(false);
+
+ }
+
+ private function HTTPError_Handler(event:HTTPStatusEvent):void {
+ var isSuccessStatus:Boolean = false;
+ for (var i:Number = 0; i < this.httpSuccess.length; i++) {
+ if (this.httpSuccess[i] === event.status) {
+ isSuccessStatus = true;
+ break;
+ }
+ }
+
+
+ if (isSuccessStatus) {
+ this.Debug("Event: httpError: Translating status code " + event.status + " to uploadSuccess");
+
+ var serverDataEvent:DataEvent = new DataEvent(DataEvent.UPLOAD_COMPLETE_DATA, event.bubbles, event.cancelable, "");
+ this.ServerData_Handler(serverDataEvent);
+ } else {
+ this.upload_errors++;
+ this.current_file_item.file_status = FileItem.FILE_STATUS_ERROR;
+
+ this.Debug("Event: uploadError: HTTP ERROR : File ID: " + this.current_file_item.id + ". HTTP Status: " + event.status + ".");
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_HTTP_ERROR, this.current_file_item.ToJavaScriptObject(), event.status.toString());
+ this.UploadComplete(true); // An IO Error is also called so we don't want to complete the upload yet.
+ }
+ }
+
+ // Note: Flash Player does not support Uploads that require authentication. Attempting this will trigger an
+ // IO Error or it will prompt for a username and password and may crash the browser (FireFox/Opera)
+ private function IOError_Handler(event:IOErrorEvent):void {
+ // Only trigger an IO Error event if we haven't already done an HTTP error
+ if (this.current_file_item.file_status != FileItem.FILE_STATUS_ERROR) {
+ this.upload_errors++;
+ this.current_file_item.file_status = FileItem.FILE_STATUS_ERROR;
+
+ this.Debug("Event: uploadError : IO Error : File ID: " + this.current_file_item.id + ". IO Error: " + event.text);
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_IO_ERROR, this.current_file_item.ToJavaScriptObject(), event.text);
+ }
+
+ this.UploadComplete(true);
+ }
+
+ private function SecurityError_Handler(event:SecurityErrorEvent):void {
+ this.upload_errors++;
+ this.current_file_item.file_status = FileItem.FILE_STATUS_ERROR;
+
+ this.Debug("Event: uploadError : Security Error : File Number: " + this.current_file_item.id + ". Error text: " + event.text);
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_SECURITY_ERROR, this.current_file_item.ToJavaScriptObject(), event.text);
+
+ this.UploadComplete(true);
+ }
+
+ private function Select_Many_Handler(event:Event):void {
+ this.Select_Handler(this.fileBrowserMany.fileList);
+ }
+ private function Select_One_Handler(event:Event):void {
+ var fileArray:Array = new Array(1);
+ fileArray[0] = this.fileBrowserOne;
+ this.Select_Handler(fileArray);
+ }
+
+ private function Select_Handler(file_reference_list:Array):void {
+ this.Debug("Select Handler: Received the files selected from the dialog. Processing the file list...");
+
+ var num_files_queued:Number = 0;
+
+ // Determine how many queue slots are remaining (check the unlimited (0) settings, successful uploads and queued uploads)
+ var queue_slots_remaining:Number = 0;
+ if (this.fileUploadLimit == 0) {
+ queue_slots_remaining = this.fileQueueLimit == 0 ? file_reference_list.length : (this.fileQueueLimit - this.queued_uploads); // If unlimited queue make the allowed size match however many files were selected.
+ } else {
+ var remaining_uploads:Number = this.fileUploadLimit - this.successful_uploads - this.queued_uploads;
+ if (remaining_uploads < 0) remaining_uploads = 0;
+ if (this.fileQueueLimit == 0 || this.fileQueueLimit >= remaining_uploads) {
+ queue_slots_remaining = remaining_uploads;
+ } else if (this.fileQueueLimit < remaining_uploads) {
+ queue_slots_remaining = this.fileQueueLimit - this.queued_uploads;
+ }
+ }
+
+ if (queue_slots_remaining < 0) queue_slots_remaining = 0;
+
+ // Check if the number of files selected is greater than the number allowed to queue up.
+ if (queue_slots_remaining < file_reference_list.length) {
+ this.Debug("Event: fileQueueError : Selected Files (" + file_reference_list.length + ") exceeds remaining Queue size (" + queue_slots_remaining + ").");
+ ExternalCall.FileQueueError(this.fileQueueError_Callback, this.ERROR_CODE_QUEUE_LIMIT_EXCEEDED, null, queue_slots_remaining.toString());
+ } else {
+ // Process each selected file
+ for (var i:Number = 0; i < file_reference_list.length; i++) {
+ var file_item:FileItem = new FileItem(file_reference_list[i], this.movieName, this.file_index.length);
+ this.file_index[file_item.index] = file_item;
+
+ // Verify that the file is accessible. Zero byte files and possibly other conditions can cause a file to be inaccessible.
+ var jsFileObj:Object = file_item.ToJavaScriptObject();
+ var is_valid_file_reference:Boolean = (jsFileObj.filestatus !== FileItem.FILE_STATUS_ERROR);
+
+ if (is_valid_file_reference) {
+ // Check the size, if it's within the limit add it to the upload list.
+ var size_result:Number = this.CheckFileSize(file_item);
+ var is_valid_filetype:Boolean = this.CheckFileType(file_item);
+ if(size_result == this.SIZE_OK && is_valid_filetype) {
+ file_item.file_status = FileItem.FILE_STATUS_QUEUED;
+ this.file_queue.push(file_item);
+ this.queued_uploads++;
+ num_files_queued++;
+ this.Debug("Event: fileQueued : File ID: " + file_item.id);
+ ExternalCall.FileQueued(this.fileQueued_Callback, file_item.ToJavaScriptObject());
+ }
+ else if (!is_valid_filetype) {
+ file_item.file_reference = null; // Cleanup the object
+ this.queue_errors++;
+ this.Debug("Event: fileQueueError : File not of a valid type.");
+ ExternalCall.FileQueueError(this.fileQueueError_Callback, this.ERROR_CODE_INVALID_FILETYPE, file_item.ToJavaScriptObject(), "File is not an allowed file type.");
+ }
+ else if (size_result == this.SIZE_TOO_BIG) {
+ file_item.file_reference = null; // Cleanup the object
+ this.queue_errors++;
+ this.Debug("Event: fileQueueError : File exceeds size limit.");
+ ExternalCall.FileQueueError(this.fileQueueError_Callback, this.ERROR_CODE_FILE_EXCEEDS_SIZE_LIMIT, file_item.ToJavaScriptObject(), "File size exceeds allowed limit.");
+ }
+ else if (size_result == this.SIZE_ZERO_BYTE) {
+ file_item.file_reference = null; // Cleanup the object
+ this.queue_errors++;
+ this.Debug("Event: fileQueueError : File is zero bytes.");
+ ExternalCall.FileQueueError(this.fileQueueError_Callback, this.ERROR_CODE_ZERO_BYTE_FILE, file_item.ToJavaScriptObject(), "File is zero bytes and cannot be uploaded.");
+ }
+ } else {
+ file_item.file_reference = null; // Cleanup the object
+ this.queue_errors++;
+ this.Debug("Event: fileQueueError : File is zero bytes or FileReference is invalid.");
+ ExternalCall.FileQueueError(this.fileQueueError_Callback, this.ERROR_CODE_ZERO_BYTE_FILE, file_item.ToJavaScriptObject(), "File is zero bytes or cannot be accessed and cannot be uploaded.");
+ }
+ }
+ }
+
+ this.Debug("Event: fileDialogComplete : Finished processing selected files. Files selected: " + file_reference_list.length + ". Files Queued: " + num_files_queued);
+ ExternalCall.FileDialogComplete(this.fileDialogComplete_Callback, file_reference_list.length, num_files_queued, this.queued_uploads);
+ }
+
+
+ /* ****************************************************************
+ Externally exposed functions
+ ****************************************************************** */
+ // Opens a file browser dialog that allows one file to be selected.
+ private function SelectFile():void {
+ this.fileBrowserOne = new FileReference();
+ this.fileBrowserOne.addEventListener(Event.SELECT, this.Select_One_Handler);
+ this.fileBrowserOne.addEventListener(Event.CANCEL, this.DialogCancelled_Handler);
+
+ // Default file type settings
+ var allowed_file_types:String = "*.*";
+ var allowed_file_types_description:String = "All Files";
+
+ // Get the instance settings
+ if (this.fileTypes.length > 0) allowed_file_types = this.fileTypes;
+ if (this.fileTypesDescription.length > 0) allowed_file_types_description = this.fileTypesDescription;
+
+ this.Debug("Event: fileDialogStart : Browsing files. Single Select. Allowed file types: " + allowed_file_types);
+ ExternalCall.Simple(this.fileDialogStart_Callback);
+
+ try {
+ this.fileBrowserOne.browse([new FileFilter(allowed_file_types_description, allowed_file_types)]);
+ } catch (ex:Error) {
+ this.Debug("Exception: " + ex.toString());
+ }
+ }
+
+ // Opens a file browser dialog that allows multiple files to be selected.
+ private function SelectFiles():void {
+ var allowed_file_types:String = "*.*";
+ var allowed_file_types_description:String = "All Files";
+
+ if (this.fileTypes.length > 0) allowed_file_types = this.fileTypes;
+ if (this.fileTypesDescription.length > 0) allowed_file_types_description = this.fileTypesDescription;
+
+ this.Debug("Event: fileDialogStart : Browsing files. Multi Select. Allowed file types: " + allowed_file_types);
+ ExternalCall.Simple(this.fileDialogStart_Callback);
+
+ try {
+ this.fileBrowserMany.browse([new FileFilter(allowed_file_types_description, allowed_file_types)]);
+ } catch (ex:Error) {
+ this.Debug("Exception: " + ex.toString());
+ }
+ }
+
+
+ // Cancel the current upload and stops. Doesn't advance the upload pointer. The current file is requeued at the beginning.
+ private function StopUpload():void {
+ if (this.current_file_item != null) {
+ // Cancel the upload and re-queue the FileItem
+ this.current_file_item.file_reference.cancel();
+
+ // Remove the event handlers
+ this.removeFileReferenceEventListeners(this.current_file_item);
+
+ this.current_file_item.file_status = FileItem.FILE_STATUS_QUEUED;
+ this.file_queue.unshift(this.current_file_item);
+ var js_object:Object = this.current_file_item.ToJavaScriptObject();
+ this.current_file_item = null;
+
+ this.Debug("Event: uploadError: upload stopped. File ID: " + js_object.ID);
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_UPLOAD_STOPPED, js_object, "Upload Stopped");
+ this.Debug("Event: uploadComplete. File ID: " + js_object.ID);
+ ExternalCall.UploadComplete(this.uploadComplete_Callback, js_object);
+
+ this.Debug("StopUpload(): upload stopped.");
+ } else {
+ this.Debug("StopUpload(): No file is currently uploading. Nothing to do.");
+ }
+ }
+
+ /* Cancels the upload specified by file_id
+ * If the file is currently uploading it is cancelled and the uploadComplete
+ * event gets called.
+ * If the file is not currently uploading then only the uploadCancelled event is fired.
+ * */
+ private function CancelUpload(file_id:String, triggerErrorEvent:Boolean = true):void {
+ var file_item:FileItem = null;
+
+ // Check the current file item
+ if (this.current_file_item != null && (this.current_file_item.id == file_id || !file_id)) {
+ this.current_file_item.file_reference.cancel();
+ this.current_file_item.file_status = FileItem.FILE_STATUS_CANCELLED;
+ this.upload_cancelled++;
+
+ if (triggerErrorEvent) {
+ this.Debug("Event: uploadError: File ID: " + this.current_file_item.id + ". Cancelled current upload");
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_CANCELLED, this.current_file_item.ToJavaScriptObject(), "File Upload Cancelled.");
+ } else {
+ this.Debug("Event: cancelUpload: File ID: " + this.current_file_item.id + ". Cancelled current upload. Suppressed uploadError event.");
+ }
+ this.UploadComplete(false);
+ } else if (file_id) {
+ // Find the file in the queue
+ var file_index:Number = this.FindIndexInFileQueue(file_id);
+ if (file_index >= 0) {
+ // Remove the file from the queue
+ file_item = FileItem(this.file_queue[file_index]);
+ file_item.file_status = FileItem.FILE_STATUS_CANCELLED;
+ this.file_queue[file_index] = null;
+ this.queued_uploads--;
+ this.upload_cancelled++;
+
+ // Cancel the file (just for good measure) and make the callback
+ file_item.file_reference.cancel();
+ this.removeFileReferenceEventListeners(file_item);
+ file_item.file_reference = null;
+
+ if (triggerErrorEvent) {
+ this.Debug("Event: uploadError : " + file_item.id + ". Cancelled queued upload");
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_CANCELLED, file_item.ToJavaScriptObject(), "File Cancelled");
+ } else {
+ this.Debug("Event: cancelUpload: File ID: " + file_item.id + ". Cancelled current upload. Suppressed uploadError event.");
+ }
+
+ // Get rid of the file object
+ file_item = null;
+ }
+ } else {
+ // Get the first file and cancel it
+ while (this.file_queue.length > 0 && file_item == null) {
+ // Check that File Reference is valid (if not make sure it's deleted and get the next one on the next loop)
+ file_item = FileItem(this.file_queue.shift()); // Cast back to a FileItem
+ if (typeof(file_item) == "undefined") {
+ file_item = null;
+ continue;
+ }
+ }
+
+ if (file_item != null) {
+ file_item.file_status = FileItem.FILE_STATUS_CANCELLED;
+ this.queued_uploads--;
+ this.upload_cancelled++;
+
+
+ // Cancel the file (just for good measure) and make the callback
+ file_item.file_reference.cancel();
+ this.removeFileReferenceEventListeners(file_item);
+ file_item.file_reference = null;
+
+ if (triggerErrorEvent) {
+ this.Debug("Event: uploadError : " + file_item.id + ". Cancelled queued upload");
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_CANCELLED, file_item.ToJavaScriptObject(), "File Cancelled");
+ } else {
+ this.Debug("Event: cancelUpload: File ID: " + file_item.id + ". Cancelled current upload. Suppressed uploadError event.");
+ }
+
+ // Get rid of the file object
+ file_item = null;
+ }
+
+ }
+
+ }
+
+ /* Requeues the indicated file. Returns true if successful or if the file is
+ * already in the queue. Otherwise returns false.
+ * */
+ private function RequeueUpload(fileIdentifier:*):Boolean {
+ var file:FileItem = null;
+ if (typeof(fileIdentifier) === "number") {
+ var fileIndex:Number = Number(fileIdentifier);
+ if (fileIndex >= 0 && fileIndex < this.file_index.length) {
+ file = this.file_index[fileIndex];
+ }
+ } else if (typeof(fileIdentifier) === "string") {
+ file = FindFileInFileIndex(String(fileIdentifier));
+ } else {
+ return false;
+ }
+
+ if (file !== null) {
+ if (file.file_status === FileItem.FILE_STATUS_IN_PROGRESS || file.file_status === FileItem.FILE_STATUS_NEW) {
+ return false;
+ } else if (file.file_status !== FileItem.FILE_STATUS_QUEUED) {
+ file.file_status = FileItem.FILE_STATUS_QUEUED;
+ this.file_queue.unshift(file);
+ this.queued_uploads++;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ private function GetStats():Object {
+ return {
+ in_progress : this.current_file_item == null ? 0 : 1,
+ files_queued : this.queued_uploads,
+ successful_uploads : this.successful_uploads,
+ upload_errors : this.upload_errors,
+ upload_cancelled : this.upload_cancelled,
+ queue_errors : this.queue_errors
+ };
+ }
+ private function SetStats(stats:Object):void {
+ this.successful_uploads = typeof(stats["successful_uploads"]) === "number" ? stats["successful_uploads"] : this.successful_uploads;
+ this.upload_errors = typeof(stats["upload_errors"]) === "number" ? stats["upload_errors"] : this.upload_errors;
+ this.upload_cancelled = typeof(stats["upload_cancelled"]) === "number" ? stats["upload_cancelled"] : this.upload_cancelled;
+ this.queue_errors = typeof(stats["queue_errors"]) === "number" ? stats["queue_errors"] : this.queue_errors;
+ }
+
+ private function GetFile(file_id:String):Object {
+ var file_index:Number = this.FindIndexInFileQueue(file_id);
+ if (file_index >= 0) {
+ var file:FileItem = this.file_queue[file_index];
+ } else {
+ if (this.current_file_item != null) {
+ file = this.current_file_item;
+ } else {
+ for (var i:Number = 0; i < this.file_queue.length; i++) {
+ file = this.file_queue[i];
+ if (file != null) break;
+ }
+ }
+ }
+
+ if (file == null) {
+ return null;
+ } else {
+ return file.ToJavaScriptObject();
+ }
+
+ }
+
+ private function GetFileByIndex(index:Number):Object {
+ if (index < 0 || index > this.file_index.length - 1) {
+ return null;
+ } else {
+ return this.file_index[index].ToJavaScriptObject();
+ }
+ }
+
+ private function AddFileParam(file_id:String, name:String, value:String):Boolean {
+ var item:FileItem = this.FindFileInFileIndex(file_id);
+ if (item != null) {
+ item.AddParam(name, value);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ private function RemoveFileParam(file_id:String, name:String):Boolean {
+ var item:FileItem = this.FindFileInFileIndex(file_id);
+ if (item != null) {
+ item.RemoveParam(name);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ private function SetUploadURL(url:String):void {
+ if (typeof(url) !== "undefined" && url !== "") {
+ this.uploadURL = url;
+ }
+ }
+
+ private function SetPostParams(post_object:Object):void {
+ if (typeof(post_object) !== "undefined" && post_object !== null) {
+ this.uploadPostObject = post_object;
+ }
+ }
+
+ private function SetFileTypes(types:String, description:String):void {
+ this.fileTypes = types;
+ this.fileTypesDescription = description;
+
+ this.LoadFileExensions(this.fileTypes);
+ }
+
+ // Sets the file size limit. Accepts size values with units: 100 b, 1KB, 23Mb, 4 Gb
+ // Parsing is not robust. "100 200 MB KB B GB" parses as "100 MB"
+ private function SetFileSizeLimit(size:String):void {
+ var value:Number = 0;
+ var unit:String = "kb";
+
+ // Trim the string
+ var trimPattern:RegExp = /^\s*|\s*$/;
+
+ size = size.toLowerCase();
+ size = size.replace(trimPattern, "");
+
+
+ // Get the value part
+ var values:Array = size.match(/^\d+/);
+ if (values !== null && values.length > 0) {
+ value = parseInt(values[0]);
+ }
+ if (isNaN(value) || value < 0) value = 0;
+
+ // Get the units part
+ var units:Array = size.match(/(b|kb|mb|gb)/);
+ if (units != null && units.length > 0) {
+ unit = units[0];
+ }
+
+ // Set the multiplier for converting the unit to bytes
+ var multiplier:Number = 1024;
+ if (unit === "b")
+ multiplier = 1;
+ else if (unit === "mb")
+ multiplier = 1048576;
+ else if (unit === "gb")
+ multiplier = 1073741824;
+
+ this.fileSizeLimit = value * multiplier;
+ }
+
+ private function SetFileUploadLimit(file_upload_limit:Number):void {
+ if (file_upload_limit < 0) file_upload_limit = 0;
+ this.fileUploadLimit = file_upload_limit;
+ }
+
+ private function SetFileQueueLimit(file_queue_limit:Number):void {
+ if (file_queue_limit < 0) file_queue_limit = 0;
+ this.fileQueueLimit = file_queue_limit;
+ }
+
+ private function SetFilePostName(file_post_name:String):void {
+ if (file_post_name != "") {
+ this.filePostName = file_post_name;
+ }
+ }
+
+ private function SetUseQueryString(use_query_string:Boolean):void {
+ this.useQueryString = use_query_string;
+ }
+
+ private function SetRequeueOnError(requeue_on_error:Boolean):void {
+ this.requeueOnError = requeue_on_error;
+ }
+
+ private function SetHTTPSuccess(http_status_codes:*):void {
+ this.httpSuccess = [];
+
+ if (typeof http_status_codes === "string") {
+ var status_code_strings:Array = http_status_codes.replace(" ", "").split(",");
+ for each (var http_status_string:String in status_code_strings)
+ {
+ try {
+ this.httpSuccess.push(Number(http_status_string));
+ } catch (ex:Object) {
+ // Ignore errors
+ this.Debug("Could not add HTTP Success code: " + http_status_string);
+ }
+ }
+ }
+ else if (typeof http_status_codes === "object" && typeof http_status_codes.length === "number") {
+ for each (var http_status:* in http_status_codes)
+ {
+ try {
+ this.Debug("adding: " + http_status);
+ this.httpSuccess.push(Number(http_status));
+ } catch (ex:Object) {
+ this.Debug("Could not add HTTP Success code: " + http_status);
+ }
+ }
+ }
+ }
+
+ private function SetAssumeSuccessTimeout(timeout_seconds:Number):void {
+ this.assumeSuccessTimeout = timeout_seconds < 0 ? 0 : timeout_seconds;
+ }
+
+ private function SetDebugEnabled(debug_enabled:Boolean):void {
+ this.debugEnabled = debug_enabled;
+ }
+
+ /* *************************************************************
+ Button Handling Functions
+ *************************************************************** */
+ private function SetButtonImageURL(button_image_url:String):void {
+ this.buttonImageURL = button_image_url;
+
+ try {
+ if (this.buttonImageURL !== null && this.buttonImageURL !== "") {
+ this.buttonLoader.load(new URLRequest(this.buttonImageURL));
+ }
+ } catch (ex:Object) {
+ }
+ }
+
+ private function ButtonClickHandler(e:MouseEvent):void {
+ if (!this.buttonStateDisabled) {
+ if (this.buttonAction === this.BUTTON_ACTION_SELECT_FILE) {
+ this.SelectFile();
+ }
+ else if (this.buttonAction === this.BUTTON_ACTION_START_UPLOAD) {
+ this.StartUpload();
+ }
+ else {
+ this.SelectFiles();
+ }
+ }
+ }
+
+ private function UpdateButtonState():void {
+ var xOffset:Number = 0;
+ var yOffset:Number = 0;
+
+ this.buttonLoader.x = xOffset;
+ this.buttonLoader.y = yOffset;
+
+ if (this.buttonStateDisabled) {
+ this.buttonLoader.y = this.buttonHeight * -3 + yOffset;
+ }
+ else if (this.buttonStateMouseDown) {
+ this.buttonLoader.y = this.buttonHeight * -2 + yOffset;
+ }
+ else if (this.buttonStateOver) {
+ this.buttonLoader.y = this.buttonHeight * -1 + yOffset;
+ }
+ else {
+ this.buttonLoader.y = -yOffset;
+ }
+ };
+
+ private function SetButtonDimensions(width:Number = -1, height:Number = -1):void {
+ if (width >= 0) {
+ this.buttonWidth = width;
+ }
+ if (height >= 0) {
+ this.buttonHeight = height;
+ }
+
+ this.buttonTextField.width = this.buttonWidth;
+ this.buttonTextField.height = this.buttonHeight;
+ this.buttonCursorSprite.width = this.buttonWidth;
+ this.buttonCursorSprite.height = this.buttonHeight;
+
+ this.UpdateButtonState();
+ }
+
+ private function SetButtonText(button_text:String):void {
+ this.buttonText = button_text;
+
+ this.SetButtonTextStyle(this.buttonTextStyle);
+ }
+
+ private function SetButtonTextStyle(button_text_style:String):void {
+ this.buttonTextStyle = button_text_style;
+
+ var style:StyleSheet = new StyleSheet();
+ style.parseCSS(this.buttonTextStyle);
+ this.buttonTextField.styleSheet = style;
+ this.buttonTextField.htmlText = this.buttonText;
+ }
+
+ private function SetButtonTextPadding(left:Number, top:Number):void {
+ this.buttonTextField.x = this.buttonTextLeftPadding = left;
+ this.buttonTextField.y = this.buttonTextTopPadding = top;
+ }
+
+ private function SetButtonDisabled(disabled:Boolean):void {
+ this.buttonStateDisabled = disabled;
+ this.UpdateButtonState();
+ }
+
+ private function SetButtonAction(button_action:Number):void {
+ this.buttonAction = button_action;
+ }
+
+ private function SetButtonCursor(button_cursor:Number):void {
+ this.buttonCursor = button_cursor;
+
+ this.buttonCursorSprite.useHandCursor = (button_cursor === this.BUTTON_CURSOR_HAND);
+ }
+
+ /* *************************************************************
+ File processing and handling functions
+ *************************************************************** */
+ private function StartUpload(file_id:String = ""):void {
+ // Only upload a file uploads are being processed.
+ if (this.current_file_item != null) {
+ this.Debug("StartUpload(): Upload already in progress. Not starting another upload.");
+ return;
+ }
+
+ this.Debug("StartUpload: " + (file_id ? "File ID: " + file_id : "First file in queue"));
+
+ // Check the upload limit
+ if (this.successful_uploads >= this.fileUploadLimit && this.fileUploadLimit != 0) {
+ this.Debug("Event: uploadError : Upload limit reached. No more files can be uploaded.");
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_UPLOAD_LIMIT_EXCEEDED, null, "The upload limit has been reached.");
+ this.current_file_item = null;
+ return;
+ }
+
+ // Get the next file to upload
+ if (!file_id) {
+ while (this.file_queue.length > 0 && this.current_file_item == null) {
+ this.current_file_item = FileItem(this.file_queue.shift());
+ if (typeof(this.current_file_item) == "undefined") {
+ this.current_file_item = null;
+ }
+ }
+ } else {
+ var file_index:Number = this.FindIndexInFileQueue(file_id);
+ if (file_index >= 0) {
+ // Set the file as the current upload and remove it from the queue
+ this.current_file_item = FileItem(this.file_queue[file_index]);
+ this.file_queue[file_index] = null;
+ } else {
+ this.Debug("Event: uploadError : File ID not found in queue: " + file_id);
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_SPECIFIED_FILE_ID_NOT_FOUND, null, "File ID not found in the queue.");
+ }
+ }
+
+
+ if (this.current_file_item != null) {
+ // Trigger the uploadStart event which will call ReturnUploadStart to begin the actual upload
+ this.Debug("Event: uploadStart : File ID: " + this.current_file_item.id);
+
+ this.current_file_item.file_status = FileItem.FILE_STATUS_IN_PROGRESS;
+ ExternalCall.UploadStart(this.uploadStart_Callback, this.current_file_item.ToJavaScriptObject());
+ }
+ // Otherwise we've would have looped through all the FileItems. This means the queue is empty)
+ else {
+ this.Debug("StartUpload(): No files found in the queue.");
+ }
+ }
+
+ // This starts the upload when the user returns TRUE from the uploadStart event. Rather than just have the value returned from
+ // the function we do a return function call so we can use the setTimeout work-around for Flash/JS circular calls.
+ private function ReturnUploadStart(start_upload:Boolean):void {
+ if (this.current_file_item == null) {
+ this.Debug("ReturnUploadStart called but no file was prepped for uploading. The file may have been cancelled or stopped.");
+ return;
+ }
+
+ var js_object:Object;
+
+ if (start_upload) {
+ try {
+ // Set the event handlers
+ this.current_file_item.file_reference.addEventListener(Event.OPEN, this.Open_Handler);
+ this.current_file_item.file_reference.addEventListener(ProgressEvent.PROGRESS, this.FileProgress_Handler);
+ this.current_file_item.file_reference.addEventListener(IOErrorEvent.IO_ERROR, this.IOError_Handler);
+ this.current_file_item.file_reference.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.SecurityError_Handler);
+ this.current_file_item.file_reference.addEventListener(HTTPStatusEvent.HTTP_STATUS, this.HTTPError_Handler);
+ this.current_file_item.file_reference.addEventListener(Event.COMPLETE, this.Complete_Handler);
+ this.current_file_item.file_reference.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, this.ServerData_Handler);
+
+ // Get the request (post values, etc)
+ var request:URLRequest = this.BuildRequest();
+
+ if (this.uploadURL.length == 0) {
+ this.Debug("Event: uploadError : IO Error : File ID: " + this.current_file_item.id + ". Upload URL string is empty.");
+
+ // Remove the event handlers
+ this.removeFileReferenceEventListeners(this.current_file_item);
+
+ this.current_file_item.file_status = FileItem.FILE_STATUS_QUEUED;
+ this.file_queue.unshift(this.current_file_item);
+ js_object = this.current_file_item.ToJavaScriptObject();
+ this.current_file_item = null;
+
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_MISSING_UPLOAD_URL, js_object, "Upload URL string is empty.");
+ } else {
+ this.Debug("ReturnUploadStart(): File accepted by startUpload event and readied for upload. Starting upload to " + request.url + " for File ID: " + this.current_file_item.id);
+ this.current_file_item.file_status = FileItem.FILE_STATUS_IN_PROGRESS;
+ this.current_file_item.file_reference.upload(request, this.filePostName, false);
+ }
+ } catch (ex:Error) {
+ this.Debug("ReturnUploadStart: Exception occurred: " + message);
+
+ this.upload_errors++;
+ this.current_file_item.file_status = FileItem.FILE_STATUS_ERROR;
+
+ var message:String = ex.errorID + "\n" + ex.name + "\n" + ex.message + "\n" + ex.getStackTrace();
+ this.Debug("Event: uploadError(): Upload Failed. Exception occurred: " + message);
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_UPLOAD_FAILED, this.current_file_item.ToJavaScriptObject(), message);
+
+ this.UploadComplete(true);
+ }
+ } else {
+ // Remove the event handlers
+ this.removeFileReferenceEventListeners(this.current_file_item);
+
+ // Re-queue the FileItem
+ this.current_file_item.file_status = FileItem.FILE_STATUS_QUEUED;
+ js_object = this.current_file_item.ToJavaScriptObject();
+ this.file_queue.unshift(this.current_file_item);
+ this.current_file_item = null;
+
+ this.Debug("Event: uploadError : Call to uploadStart returned false. Not uploading the file.");
+ ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_VALIDATION_FAILED, js_object, "Call to uploadStart return false. Not uploading file.");
+ this.Debug("Event: uploadComplete : Call to uploadStart returned false. Not uploading the file.");
+ ExternalCall.UploadComplete(this.uploadComplete_Callback, js_object);
+ }
+ }
+
+ // Completes the file upload by deleting it's reference, advancing the pointer.
+ // Once this event fires a new upload can be started.
+ private function UploadComplete(eligible_for_requeue:Boolean):void {
+ var jsFileObj:Object = this.current_file_item.ToJavaScriptObject();
+
+ this.removeFileReferenceEventListeners(this.current_file_item);
+
+ if (!eligible_for_requeue || this.requeueOnError == false) {
+ this.current_file_item.file_reference = null;
+ this.queued_uploads--;
+ } else if (this.requeueOnError == true) {
+ this.current_file_item.file_status = FileItem.FILE_STATUS_QUEUED;
+ this.file_queue.unshift(this.current_file_item);
+ }
+
+ this.current_file_item = null;
+
+ this.Debug("Event: uploadComplete : Upload cycle complete.");
+ ExternalCall.UploadComplete(this.uploadComplete_Callback, jsFileObj);
+ }
+
+
+ /* *************************************************************
+ Utility Functions
+ *************************************************************** */
+
+
+ // Check the size of the file against the allowed file size. If it is less the return TRUE. If it is too large return FALSE
+ private function CheckFileSize(file_item:FileItem):Number {
+ if (file_item.file_reference.size == 0) {
+ return this.SIZE_ZERO_BYTE;
+ } else if (this.fileSizeLimit != 0 && file_item.file_reference.size > this.fileSizeLimit) {
+ return this.SIZE_TOO_BIG;
+ } else {
+ return this.SIZE_OK;
+ }
+ }
+
+ private function CheckFileType(file_item:FileItem):Boolean {
+ // If no extensions are defined then a *.* was passed and the check is unnecessary
+ if (this.valid_file_extensions.length == 0) {
+ return true;
+ }
+
+ var fileRef:FileReference = file_item.file_reference;
+ var last_dot_index:Number = fileRef.name.lastIndexOf(".");
+ var extension:String = "";
+ if (last_dot_index >= 0) {
+ extension = fileRef.name.substr(last_dot_index + 1).toLowerCase();
+ }
+
+ var is_valid_filetype:Boolean = false;
+ for (var i:Number=0; i < this.valid_file_extensions.length; i++) {
+ if (String(this.valid_file_extensions[i]) == extension) {
+ is_valid_filetype = true;
+ break;
+ }
+ }
+
+ return is_valid_filetype;
+ }
+
+ private function BuildRequest():URLRequest {
+ // Create the request object
+ var request:URLRequest = new URLRequest();
+ request.method = URLRequestMethod.POST;
+
+ var file_post:Object = this.current_file_item.GetPostObject();
+
+ if (this.useQueryString) {
+ var pairs:Array = new Array();
+ for (key in this.uploadPostObject) {
+ this.Debug("Global URL Item: " + key + "=" + this.uploadPostObject[key]);
+ if (this.uploadPostObject.hasOwnProperty(key)) {
+ pairs.push(escape(key) + "=" + escape(this.uploadPostObject[key]));
+ }
+ }
+
+ for (key in file_post) {
+ this.Debug("File Post Item: " + key + "=" + file_post[key]);
+ if (file_post.hasOwnProperty(key)) {
+ pairs.push(escape(key) + "=" + escape(file_post[key]));
+ }
+ }
+
+ request.url = this.uploadURL + (this.uploadURL.indexOf("?") > -1 ? "&" : "?") + pairs.join("&");
+
+ } else {
+ var key:String;
+ var post:URLVariables = new URLVariables();
+ for (key in this.uploadPostObject) {
+ this.Debug("Global Post Item: " + key + "=" + this.uploadPostObject[key]);
+ if (this.uploadPostObject.hasOwnProperty(key)) {
+ post[key] = this.uploadPostObject[key];
+ }
+ }
+
+ for (key in file_post) {
+ this.Debug("File Post Item: " + key + "=" + file_post[key]);
+ if (file_post.hasOwnProperty(key)) {
+ post[key] = file_post[key];
+ }
+ }
+
+ request.url = this.uploadURL;
+ request.data = post;
+ }
+
+ return request;
+ }
+
+ private function Debug(msg:String):void {
+ try {
+ if (this.debugEnabled) {
+ var lines:Array = msg.split("\n");
+ for (var i:Number=0; i < lines.length; i++) {
+ lines[i] = "SWF DEBUG: " + lines[i];
+ }
+ ExternalCall.Debug(this.debug_Callback, lines.join("\n"));
+ }
+ } catch (ex:Error) {
+ // pretend nothing happened
+ trace(ex);
+ }
+ }
+
+ private function PrintDebugInfo():void {
+ var debug_info:String = "\n----- SWF DEBUG OUTPUT ----\n";
+ debug_info += "Build Number: " + this.build_number + "\n";
+ debug_info += "movieName: " + this.movieName + "\n";
+ debug_info += "Upload URL: " + this.uploadURL + "\n";
+ debug_info += "File Types String: " + this.fileTypes + "\n";
+ debug_info += "Parsed File Types: " + this.valid_file_extensions.toString() + "\n";
+ debug_info += "HTTP Success: " + this.httpSuccess.join(", ") + "\n";
+ debug_info += "File Types Description: " + this.fileTypesDescription + "\n";
+ debug_info += "File Size Limit: " + this.fileSizeLimit + " bytes\n";
+ debug_info += "File Upload Limit: " + this.fileUploadLimit + "\n";
+ debug_info += "File Queue Limit: " + this.fileQueueLimit + "\n";
+ debug_info += "Post Params:\n";
+ for (var key:String in this.uploadPostObject) {
+ if (this.uploadPostObject.hasOwnProperty(key)) {
+ debug_info += " " + key + "=" + this.uploadPostObject[key] + "\n";
+ }
+ }
+ debug_info += "----- END SWF DEBUG OUTPUT ----\n";
+
+ this.Debug(debug_info);
+ }
+
+ private function FindIndexInFileQueue(file_id:String):Number {
+ for (var i:Number = 0; i < this.file_queue.length; i++) {
+ var item:FileItem = this.file_queue[i];
+ if (item != null && item.id == file_id) return i;
+ }
+
+ return -1;
+ }
+
+ private function FindFileInFileIndex(file_id:String):FileItem {
+ for (var i:Number = 0; i < this.file_index.length; i++) {
+ var item:FileItem = this.file_index[i];
+ if (item != null && item.id == file_id) return item;
+ }
+
+ return null;
+ }
+
+
+ // Parse the file extensions in to an array so we can validate them agains
+ // the files selected later.
+ private function LoadFileExensions(filetypes:String):void {
+ var extensions:Array = filetypes.split(";");
+ this.valid_file_extensions = new Array();
+
+ for (var i:Number=0; i < extensions.length; i++) {
+ var extension:String = String(extensions[i]);
+ var dot_index:Number = extension.lastIndexOf(".");
+
+ if (dot_index >= 0) {
+ extension = extension.substr(dot_index + 1).toLowerCase();
+ } else {
+ extension = extension.toLowerCase();
+ }
+
+ // If one of the extensions is * then we allow all files
+ if (extension == "*") {
+ this.valid_file_extensions = new Array();
+ break;
+ }
+
+ this.valid_file_extensions.push(extension);
+ }
+ }
+
+ private function loadPostParams(param_string:String):void {
+ var post_object:Object = {};
+
+ if (param_string != null) {
+ var name_value_pairs:Array = param_string.split("&");
+
+ for (var i:Number = 0; i < name_value_pairs.length; i++) {
+ var name_value:String = String(name_value_pairs[i]);
+ var index_of_equals:Number = name_value.indexOf("=");
+ if (index_of_equals > 0) {
+ post_object[decodeURIComponent(name_value.substring(0, index_of_equals))] = decodeURIComponent(name_value.substr(index_of_equals + 1));
+ }
+ }
+ }
+ this.uploadPostObject = post_object;
+ }
+
+ private function removeFileReferenceEventListeners(file_item:FileItem):void {
+ if (file_item != null && file_item.file_reference != null) {
+ file_item.file_reference.removeEventListener(Event.OPEN, this.Open_Handler);
+ file_item.file_reference.removeEventListener(ProgressEvent.PROGRESS, this.FileProgress_Handler);
+ file_item.file_reference.removeEventListener(IOErrorEvent.IO_ERROR, this.IOError_Handler);
+ file_item.file_reference.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, this.SecurityError_Handler);
+ file_item.file_reference.removeEventListener(HTTPStatusEvent.HTTP_STATUS, this.HTTPError_Handler);
+ file_item.file_reference.removeEventListener(DataEvent.UPLOAD_COMPLETE_DATA, this.ServerData_Handler);
+ }
+ }
+
+ }
+}
diff --git a/debian/missing-sources/swfupload/Flash/deploy.bat b/debian/missing-sources/swfupload/Flash/deploy.bat new file mode 100644 index 0000000..a6a95f8 --- /dev/null +++ b/debian/missing-sources/swfupload/Flash/deploy.bat @@ -0,0 +1,3 @@ +@echo off
+copy ..\swfupload.js ..\..\samples\demos\swfupload
+copy swfupload.swf ..\..\samples\demos\swfupload
diff --git a/debian/missing-sources/swfupload/Flash/obj/SWFUpload-v2Config.old b/debian/missing-sources/swfupload/Flash/obj/SWFUpload-v2Config.old new file mode 100644 index 0000000..0f4039a --- /dev/null +++ b/debian/missing-sources/swfupload/Flash/obj/SWFUpload-v2Config.old @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!--Flex compiler config for project SWFUpload-v2 generated by FDBuild-->
+<!--============-->
+<!--This file was generated by a tool.-->
+<!--Any modifications you make may be lost.-->
+<flex-config>
+ <compiler>
+ <source-path append="true">
+ <path-element>C:\inetpub\wwwroot\other\swfupload\core\Flash</path-element>
+ <path-element>C:\Program Files (x86)\FlashDevelop\Library\AS3\classes</path-element>
+ </source-path>
+ </compiler>
+ <file-specs>
+ <path-element>C:\inetpub\wwwroot\other\swfupload\core\Flash\SWFUpload.as</path-element>
+ </file-specs>
+ <default-background-color>#FFFFFF</default-background-color>
+ <default-frame-rate>15</default-frame-rate>
+ <default-size>
+ <width>300</width>
+ <height>300</height>
+ </default-size>
+</flex-config>
\ No newline at end of file diff --git a/debian/missing-sources/swfupload/Flash/obj/SWFUpload-v2Config.xml b/debian/missing-sources/swfupload/Flash/obj/SWFUpload-v2Config.xml new file mode 100644 index 0000000..0f4039a --- /dev/null +++ b/debian/missing-sources/swfupload/Flash/obj/SWFUpload-v2Config.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!--Flex compiler config for project SWFUpload-v2 generated by FDBuild-->
+<!--============-->
+<!--This file was generated by a tool.-->
+<!--Any modifications you make may be lost.-->
+<flex-config>
+ <compiler>
+ <source-path append="true">
+ <path-element>C:\inetpub\wwwroot\other\swfupload\core\Flash</path-element>
+ <path-element>C:\Program Files (x86)\FlashDevelop\Library\AS3\classes</path-element>
+ </source-path>
+ </compiler>
+ <file-specs>
+ <path-element>C:\inetpub\wwwroot\other\swfupload\core\Flash\SWFUpload.as</path-element>
+ </file-specs>
+ <default-background-color>#FFFFFF</default-background-color>
+ <default-frame-rate>15</default-frame-rate>
+ <default-size>
+ <width>300</width>
+ <height>300</height>
+ </default-size>
+</flex-config>
\ No newline at end of file diff --git a/debian/missing-sources/swfupload/Flash/swfupload.swf b/debian/missing-sources/swfupload/Flash/swfupload.swf Binary files differnew file mode 100644 index 0000000..e3f7670 --- /dev/null +++ b/debian/missing-sources/swfupload/Flash/swfupload.swf diff --git a/debian/missing-sources/swfupload/plugins/SWFObject License.txt b/debian/missing-sources/swfupload/plugins/SWFObject License.txt new file mode 100644 index 0000000..c393619 --- /dev/null +++ b/debian/missing-sources/swfupload/plugins/SWFObject License.txt @@ -0,0 +1,4 @@ +/* SWFObject v2.0 rc4 <http://code.google.com/p/swfobject/>
+ Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
+ This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
+*/
diff --git a/debian/missing-sources/swfupload/plugins/swfupload.cookies.js b/debian/missing-sources/swfupload/plugins/swfupload.cookies.js new file mode 100644 index 0000000..b8fa5f5 --- /dev/null +++ b/debian/missing-sources/swfupload/plugins/swfupload.cookies.js @@ -0,0 +1,53 @@ +/*
+ Cookie Plug-in
+
+ This plug in automatically gets all the cookies for this site and adds them to the post_params.
+ Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params.
+ The cookies will override any other post params with the same name.
+*/
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+ SWFUpload.prototype.initSettings = function (oldInitSettings) {
+ return function () {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this);
+ }
+
+ this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point
+ };
+ }(SWFUpload.prototype.initSettings);
+
+ // refreshes the post_params and updates SWFUpload. The sendToFlash parameters is optional and defaults to True
+ SWFUpload.prototype.refreshCookies = function (sendToFlash) {
+ if (sendToFlash === undefined) {
+ sendToFlash = true;
+ }
+ sendToFlash = !!sendToFlash;
+
+ // Get the post_params object
+ var postParams = this.settings.post_params;
+
+ // Get the cookies
+ var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
+ for (i = 0; i < caLength; i++) {
+ c = cookieArray[i];
+
+ // Left Trim spaces
+ while (c.charAt(0) === " ") {
+ c = c.substring(1, c.length);
+ }
+ eqIndex = c.indexOf("=");
+ if (eqIndex > 0) {
+ name = c.substring(0, eqIndex);
+ value = c.substring(eqIndex + 1);
+ postParams[name] = value;
+ }
+ }
+
+ if (sendToFlash) {
+ this.setPostParams(postParams);
+ }
+ };
+
+}
diff --git a/debian/missing-sources/swfupload/plugins/swfupload.queue.js b/debian/missing-sources/swfupload/plugins/swfupload.queue.js new file mode 100644 index 0000000..00aef32 --- /dev/null +++ b/debian/missing-sources/swfupload/plugins/swfupload.queue.js @@ -0,0 +1,98 @@ +/*
+ Queue Plug-in
+
+ Features:
+ *Adds a cancelQueue() method for cancelling the entire queue.
+ *All queued files are uploaded when startUpload() is called.
+ *If false is returned from uploadComplete then the queue upload is stopped.
+ If false is not returned (strict comparison) then the queue upload is continued.
+ *Adds a QueueComplete event that is fired when all the queued files have finished uploading.
+ Set the event handler with the queue_complete_handler setting.
+
+ */
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+ SWFUpload.queue = {};
+
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+ return function () {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this);
+ }
+
+ this.queueSettings = {};
+
+ this.queueSettings.queue_cancelled_flag = false;
+ this.queueSettings.queue_upload_count = 0;
+
+ this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
+ this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
+ this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
+ this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
+
+ this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
+ };
+ })(SWFUpload.prototype.initSettings);
+
+ SWFUpload.prototype.startUpload = function (fileID) {
+ this.queueSettings.queue_cancelled_flag = false;
+ this.callFlash("StartUpload", [fileID]);
+ };
+
+ SWFUpload.prototype.cancelQueue = function () {
+ this.queueSettings.queue_cancelled_flag = true;
+ this.stopUpload();
+
+ var stats = this.getStats();
+ while (stats.files_queued > 0) {
+ this.cancelUpload();
+ stats = this.getStats();
+ }
+ };
+
+ SWFUpload.queue.uploadStartHandler = function (file) {
+ var returnValue;
+ if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
+ returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
+ }
+
+ // To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
+ returnValue = (returnValue === false) ? false : true;
+
+ this.queueSettings.queue_cancelled_flag = !returnValue;
+
+ return returnValue;
+ };
+
+ SWFUpload.queue.uploadCompleteHandler = function (file) {
+ var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
+ var continueUpload;
+
+ if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
+ this.queueSettings.queue_upload_count++;
+ }
+
+ if (typeof(user_upload_complete_handler) === "function") {
+ continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
+ } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
+ // If the file was stopped and re-queued don't restart the upload
+ continueUpload = false;
+ } else {
+ continueUpload = true;
+ }
+
+ if (continueUpload) {
+ var stats = this.getStats();
+ if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
+ this.startUpload();
+ } else if (this.queueSettings.queue_cancelled_flag === false) {
+ this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
+ this.queueSettings.queue_upload_count = 0;
+ } else {
+ this.queueSettings.queue_cancelled_flag = false;
+ this.queueSettings.queue_upload_count = 0;
+ }
+ }
+ };
+}
\ No newline at end of file diff --git a/debian/missing-sources/swfupload/plugins/swfupload.speed.js b/debian/missing-sources/swfupload/plugins/swfupload.speed.js new file mode 100644 index 0000000..6b7bf94 --- /dev/null +++ b/debian/missing-sources/swfupload/plugins/swfupload.speed.js @@ -0,0 +1,342 @@ +/*
+ Speed Plug-in
+
+ Features:
+ *Adds several properties to the 'file' object indicated upload speed, time left, upload time, etc.
+ - currentSpeed -- String indicating the upload speed, bytes per second
+ - averageSpeed -- Overall average upload speed, bytes per second
+ - movingAverageSpeed -- Speed over averaged over the last several measurements, bytes per second
+ - timeRemaining -- Estimated remaining upload time in seconds
+ - timeElapsed -- Number of seconds passed for this upload
+ - percentUploaded -- Percentage of the file uploaded (0 to 100)
+ - sizeUploaded -- Formatted size uploaded so far, bytes
+
+ *Adds setting 'moving_average_history_size' for defining the window size used to calculate the moving average speed.
+
+ *Adds several Formatting functions for formatting that values provided on the file object.
+ - SWFUpload.speed.formatBPS(bps) -- outputs string formatted in the best units (Gbps, Mbps, Kbps, bps)
+ - SWFUpload.speed.formatTime(seconds) -- outputs string formatted in the best units (x Hr y M z S)
+ - SWFUpload.speed.formatSize(bytes) -- outputs string formatted in the best units (w GB x MB y KB z B )
+ - SWFUpload.speed.formatPercent(percent) -- outputs string formatted with a percent sign (x.xx %)
+ - SWFUpload.speed.formatUnits(baseNumber, divisionArray, unitLabelArray, fractionalBoolean)
+ - Formats a number using the division array to determine how to apply the labels in the Label Array
+ - factionalBoolean indicates whether the number should be returned as a single fractional number with a unit (speed)
+ or as several numbers labeled with units (time)
+ */
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+ SWFUpload.speed = {};
+
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+ return function () {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this);
+ }
+
+ this.ensureDefault = function (settingName, defaultValue) {
+ this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+ };
+
+ // List used to keep the speed stats for the files we are tracking
+ this.fileSpeedStats = {};
+ this.speedSettings = {};
+
+ this.ensureDefault("moving_average_history_size", "10");
+
+ this.speedSettings.user_file_queued_handler = this.settings.file_queued_handler;
+ this.speedSettings.user_file_queue_error_handler = this.settings.file_queue_error_handler;
+ this.speedSettings.user_upload_start_handler = this.settings.upload_start_handler;
+ this.speedSettings.user_upload_error_handler = this.settings.upload_error_handler;
+ this.speedSettings.user_upload_progress_handler = this.settings.upload_progress_handler;
+ this.speedSettings.user_upload_success_handler = this.settings.upload_success_handler;
+ this.speedSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
+
+ this.settings.file_queued_handler = SWFUpload.speed.fileQueuedHandler;
+ this.settings.file_queue_error_handler = SWFUpload.speed.fileQueueErrorHandler;
+ this.settings.upload_start_handler = SWFUpload.speed.uploadStartHandler;
+ this.settings.upload_error_handler = SWFUpload.speed.uploadErrorHandler;
+ this.settings.upload_progress_handler = SWFUpload.speed.uploadProgressHandler;
+ this.settings.upload_success_handler = SWFUpload.speed.uploadSuccessHandler;
+ this.settings.upload_complete_handler = SWFUpload.speed.uploadCompleteHandler;
+
+ delete this.ensureDefault;
+ };
+ })(SWFUpload.prototype.initSettings);
+
+
+ SWFUpload.speed.fileQueuedHandler = function (file) {
+ if (typeof this.speedSettings.user_file_queued_handler === "function") {
+ file = SWFUpload.speed.extendFile(file);
+
+ return this.speedSettings.user_file_queued_handler.call(this, file);
+ }
+ };
+
+ SWFUpload.speed.fileQueueErrorHandler = function (file, errorCode, message) {
+ if (typeof this.speedSettings.user_file_queue_error_handler === "function") {
+ file = SWFUpload.speed.extendFile(file);
+
+ return this.speedSettings.user_file_queue_error_handler.call(this, file, errorCode, message);
+ }
+ };
+
+ SWFUpload.speed.uploadStartHandler = function (file) {
+ if (typeof this.speedSettings.user_upload_start_handler === "function") {
+ file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+ return this.speedSettings.user_upload_start_handler.call(this, file);
+ }
+ };
+
+ SWFUpload.speed.uploadErrorHandler = function (file, errorCode, message) {
+ file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+ SWFUpload.speed.removeTracking(file, this.fileSpeedStats);
+
+ if (typeof this.speedSettings.user_upload_error_handler === "function") {
+ return this.speedSettings.user_upload_error_handler.call(this, file, errorCode, message);
+ }
+ };
+ SWFUpload.speed.uploadProgressHandler = function (file, bytesComplete, bytesTotal) {
+ this.updateTracking(file, bytesComplete);
+ file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+
+ if (typeof this.speedSettings.user_upload_progress_handler === "function") {
+ return this.speedSettings.user_upload_progress_handler.call(this, file, bytesComplete, bytesTotal);
+ }
+ };
+
+ SWFUpload.speed.uploadSuccessHandler = function (file, serverData) {
+ if (typeof this.speedSettings.user_upload_success_handler === "function") {
+ file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+ return this.speedSettings.user_upload_success_handler.call(this, file, serverData);
+ }
+ };
+ SWFUpload.speed.uploadCompleteHandler = function (file) {
+ file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+ SWFUpload.speed.removeTracking(file, this.fileSpeedStats);
+
+ if (typeof this.speedSettings.user_upload_complete_handler === "function") {
+ return this.speedSettings.user_upload_complete_handler.call(this, file);
+ }
+ };
+
+ // Private: extends the file object with the speed plugin values
+ SWFUpload.speed.extendFile = function (file, trackingList) {
+ var tracking;
+
+ if (trackingList) {
+ tracking = trackingList[file.id];
+ }
+
+ if (tracking) {
+ file.currentSpeed = tracking.currentSpeed;
+ file.averageSpeed = tracking.averageSpeed;
+ file.movingAverageSpeed = tracking.movingAverageSpeed;
+ file.timeRemaining = tracking.timeRemaining;
+ file.timeElapsed = tracking.timeElapsed;
+ file.percentUploaded = tracking.percentUploaded;
+ file.sizeUploaded = tracking.bytesUploaded;
+
+ } else {
+ file.currentSpeed = 0;
+ file.averageSpeed = 0;
+ file.movingAverageSpeed = 0;
+ file.timeRemaining = 0;
+ file.timeElapsed = 0;
+ file.percentUploaded = 0;
+ file.sizeUploaded = 0;
+ }
+
+ return file;
+ };
+
+ // Private: Updates the speed tracking object, or creates it if necessary
+ SWFUpload.prototype.updateTracking = function (file, bytesUploaded) {
+ var tracking = this.fileSpeedStats[file.id];
+ if (!tracking) {
+ this.fileSpeedStats[file.id] = tracking = {};
+ }
+
+ // Sanity check inputs
+ bytesUploaded = bytesUploaded || tracking.bytesUploaded || 0;
+ if (bytesUploaded < 0) {
+ bytesUploaded = 0;
+ }
+ if (bytesUploaded > file.size) {
+ bytesUploaded = file.size;
+ }
+
+ var tickTime = (new Date()).getTime();
+ if (!tracking.startTime) {
+ tracking.startTime = (new Date()).getTime();
+ tracking.lastTime = tracking.startTime;
+ tracking.currentSpeed = 0;
+ tracking.averageSpeed = 0;
+ tracking.movingAverageSpeed = 0;
+ tracking.movingAverageHistory = [];
+ tracking.timeRemaining = 0;
+ tracking.timeElapsed = 0;
+ tracking.percentUploaded = bytesUploaded / file.size;
+ tracking.bytesUploaded = bytesUploaded;
+ } else if (tracking.startTime > tickTime) {
+ this.debug("When backwards in time");
+ } else {
+ // Get time and deltas
+ var now = (new Date()).getTime();
+ var lastTime = tracking.lastTime;
+ var deltaTime = now - lastTime;
+ var deltaBytes = bytesUploaded - tracking.bytesUploaded;
+
+ if (deltaBytes === 0 || deltaTime === 0) {
+ return tracking;
+ }
+
+ // Update tracking object
+ tracking.lastTime = now;
+ tracking.bytesUploaded = bytesUploaded;
+
+ // Calculate speeds
+ tracking.currentSpeed = (deltaBytes * 8 ) / (deltaTime / 1000);
+ tracking.averageSpeed = (tracking.bytesUploaded * 8) / ((now - tracking.startTime) / 1000);
+
+ // Calculate moving average
+ tracking.movingAverageHistory.push(tracking.currentSpeed);
+ if (tracking.movingAverageHistory.length > this.settings.moving_average_history_size) {
+ tracking.movingAverageHistory.shift();
+ }
+
+ tracking.movingAverageSpeed = SWFUpload.speed.calculateMovingAverage(tracking.movingAverageHistory);
+
+ // Update times
+ tracking.timeRemaining = (file.size - tracking.bytesUploaded) * 8 / tracking.movingAverageSpeed;
+ tracking.timeElapsed = (now - tracking.startTime) / 1000;
+
+ // Update percent
+ tracking.percentUploaded = (tracking.bytesUploaded / file.size * 100);
+ }
+
+ return tracking;
+ };
+ SWFUpload.speed.removeTracking = function (file, trackingList) {
+ try {
+ trackingList[file.id] = null;
+ delete trackingList[file.id];
+ } catch (ex) {
+ }
+ };
+
+ SWFUpload.speed.formatUnits = function (baseNumber, unitDivisors, unitLabels, singleFractional) {
+ var i, unit, unitDivisor, unitLabel;
+
+ if (baseNumber === 0) {
+ return "0 " + unitLabels[unitLabels.length - 1];
+ }
+
+ if (singleFractional) {
+ unit = baseNumber;
+ unitLabel = unitLabels.length >= unitDivisors.length ? unitLabels[unitDivisors.length - 1] : "";
+ for (i = 0; i < unitDivisors.length; i++) {
+ if (baseNumber >= unitDivisors[i]) {
+ unit = (baseNumber / unitDivisors[i]).toFixed(2);
+ unitLabel = unitLabels.length >= i ? " " + unitLabels[i] : "";
+ break;
+ }
+ }
+
+ return unit + unitLabel;
+ } else {
+ var formattedStrings = [];
+ var remainder = baseNumber;
+
+ for (i = 0; i < unitDivisors.length; i++) {
+ unitDivisor = unitDivisors[i];
+ unitLabel = unitLabels.length > i ? " " + unitLabels[i] : "";
+
+ unit = remainder / unitDivisor;
+ if (i < unitDivisors.length -1) {
+ unit = Math.floor(unit);
+ } else {
+ unit = unit.toFixed(2);
+ }
+ if (unit > 0) {
+ remainder = remainder % unitDivisor;
+
+ formattedStrings.push(unit + unitLabel);
+ }
+ }
+
+ return formattedStrings.join(" ");
+ }
+ };
+
+ SWFUpload.speed.formatBPS = function (baseNumber) {
+ var bpsUnits = [1073741824, 1048576, 1024, 1], bpsUnitLabels = ["Gbps", "Mbps", "Kbps", "bps"];
+ return SWFUpload.speed.formatUnits(baseNumber, bpsUnits, bpsUnitLabels, true);
+
+ };
+ SWFUpload.speed.formatTime = function (baseNumber) {
+ var timeUnits = [86400, 3600, 60, 1], timeUnitLabels = ["d", "h", "m", "s"];
+ return SWFUpload.speed.formatUnits(baseNumber, timeUnits, timeUnitLabels, false);
+
+ };
+ SWFUpload.speed.formatBytes = function (baseNumber) {
+ var sizeUnits = [1073741824, 1048576, 1024, 1], sizeUnitLabels = ["GB", "MB", "KB", "bytes"];
+ return SWFUpload.speed.formatUnits(baseNumber, sizeUnits, sizeUnitLabels, true);
+
+ };
+ SWFUpload.speed.formatPercent = function (baseNumber) {
+ return baseNumber.toFixed(2) + " %";
+ };
+
+ SWFUpload.speed.calculateMovingAverage = function (history) {
+ var vals = [], size, sum = 0.0, mean = 0.0, varianceTemp = 0.0, variance = 0.0, standardDev = 0.0;
+ var i;
+ var mSum = 0, mCount = 0;
+
+ size = history.length;
+
+ // Check for sufficient data
+ if (size >= 8) {
+ // Clone the array and Calculate sum of the values
+ for (i = 0; i < size; i++) {
+ vals[i] = history[i];
+ sum += vals[i];
+ }
+
+ mean = sum / size;
+
+ // Calculate variance for the set
+ for (i = 0; i < size; i++) {
+ varianceTemp += Math.pow((vals[i] - mean), 2);
+ }
+
+ variance = varianceTemp / size;
+ standardDev = Math.sqrt(variance);
+
+ //Standardize the Data
+ for (i = 0; i < size; i++) {
+ vals[i] = (vals[i] - mean) / standardDev;
+ }
+
+ // Calculate the average excluding outliers
+ var deviationRange = 2.0;
+ for (i = 0; i < size; i++) {
+
+ if (vals[i] <= deviationRange && vals[i] >= -deviationRange) {
+ mCount++;
+ mSum += history[i];
+ }
+ }
+
+ } else {
+ // Calculate the average (not enough data points to remove outliers)
+ mCount = size;
+ for (i = 0; i < size; i++) {
+ mSum += history[i];
+ }
+ }
+
+ return mSum / mCount;
+ };
+
+}
\ No newline at end of file diff --git a/debian/missing-sources/swfupload/plugins/swfupload.swfobject.js b/debian/missing-sources/swfupload/plugins/swfupload.swfobject.js new file mode 100644 index 0000000..a75adbf --- /dev/null +++ b/debian/missing-sources/swfupload/plugins/swfupload.swfobject.js @@ -0,0 +1,111 @@ +/*
+ SWFUpload.SWFObject Plugin
+
+ Summary:
+ This plugin uses SWFObject to embed SWFUpload dynamically in the page. SWFObject provides accurate Flash Player detection and DOM Ready loading.
+ This plugin replaces the Graceful Degradation plugin.
+
+ Features:
+ * swfupload_load_failed_hander event
+ * swfupload_pre_load_handler event
+ * minimum_flash_version setting (default: "9.0.28")
+ * SWFUpload.onload event for early loading
+
+ Usage:
+ Provide handlers and settings as needed. When using the SWFUpload.SWFObject plugin you should initialize SWFUploading
+ in SWFUpload.onload rather than in window.onload. When initialized this way SWFUpload can load earlier preventing the UI flicker
+ that was seen using the Graceful Degradation plugin.
+
+ <script type="text/javascript">
+ var swfu;
+ SWFUpload.onload = function () {
+ swfu = new SWFUpload({
+ minimum_flash_version: "9.0.28",
+ swfupload_pre_load_handler: swfuploadPreLoad,
+ swfupload_load_failed_handler: swfuploadLoadFailed
+ });
+ };
+ </script>
+
+ Notes:
+ You must provide set minimum_flash_version setting to "8" if you are using SWFUpload for Flash Player 8.
+ The swfuploadLoadFailed event is only fired if the minimum version of Flash Player is not met. Other issues such as missing SWF files, browser bugs
+ or corrupt Flash Player installations will not trigger this event.
+ The swfuploadPreLoad event is fired as soon as the minimum version of Flash Player is found. It does not wait for SWFUpload to load and can
+ be used to prepare the SWFUploadUI and hide alternate content.
+ swfobject's onDomReady event is cross-browser safe but will default to the window.onload event when DOMReady is not supported by the browser.
+ Early DOM Loading is supported in major modern browsers but cannot be guaranteed for every browser ever made.
+*/
+
+
+/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
+ Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
+ This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
+*/
+var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
+
+
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+ SWFUpload.onload = function () {};
+
+ swfobject.addDomLoadEvent(function () {
+ if (typeof(SWFUpload.onload) === "function") {
+ SWFUpload.onload.call(window);
+ }
+ });
+
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+ return function () {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this);
+ }
+
+ this.ensureDefault = function (settingName, defaultValue) {
+ this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+ };
+
+ this.ensureDefault("minimum_flash_version", "9.0.28");
+ this.ensureDefault("swfupload_pre_load_handler", null);
+ this.ensureDefault("swfupload_load_failed_handler", null);
+
+ delete this.ensureDefault;
+
+ };
+ })(SWFUpload.prototype.initSettings);
+
+
+ SWFUpload.prototype.loadFlash = function (oldLoadFlash) {
+ return function () {
+ var hasFlash = swfobject.hasFlashPlayerVersion(this.settings.minimum_flash_version);
+
+ if (hasFlash) {
+ this.queueEvent("swfupload_pre_load_handler");
+ if (typeof(oldLoadFlash) === "function") {
+ oldLoadFlash.call(this);
+ }
+ } else {
+ this.queueEvent("swfupload_load_failed_handler");
+ }
+ };
+
+ }(SWFUpload.prototype.loadFlash);
+
+ SWFUpload.prototype.displayDebugInfo = function (oldDisplayDebugInfo) {
+ return function () {
+ if (typeof(oldDisplayDebugInfo) === "function") {
+ oldDisplayDebugInfo.call(this);
+ }
+
+ this.debug(
+ [
+ "SWFUpload.SWFObject Plugin settings:", "\n",
+ "\t", "minimum_flash_version: ", this.settings.minimum_flash_version, "\n",
+ "\t", "swfupload_pre_load_handler assigned: ", (typeof(this.settings.swfupload_pre_load_handler) === "function").toString(), "\n",
+ "\t", "swfupload_load_failed_handler assigned: ", (typeof(this.settings.swfupload_load_failed_handler) === "function").toString(), "\n",
+ ].join("")
+ );
+ };
+ }(SWFUpload.prototype.displayDebugInfo);
+}
diff --git a/debian/missing-sources/swfupload/swfupload license.txt b/debian/missing-sources/swfupload/swfupload license.txt new file mode 100644 index 0000000..3704d20 --- /dev/null +++ b/debian/missing-sources/swfupload/swfupload license.txt @@ -0,0 +1,12 @@ +/** + * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com + * + * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/ + * + * SWFUpload is (c) 2006-2007 Lars Huring, Olov NilzĂŠn and Mammon Media and is released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + */ diff --git a/debian/missing-sources/swfupload/swfupload.js b/debian/missing-sources/swfupload/swfupload.js new file mode 100644 index 0000000..969e200 --- /dev/null +++ b/debian/missing-sources/swfupload/swfupload.js @@ -0,0 +1,980 @@ +/**
+ * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
+ *
+ * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
+ *
+ * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ */
+
+
+/* ******************* */
+/* Constructor & Init */
+/* ******************* */
+var SWFUpload;
+
+if (SWFUpload == undefined) {
+ SWFUpload = function (settings) {
+ this.initSWFUpload(settings);
+ };
+}
+
+SWFUpload.prototype.initSWFUpload = function (settings) {
+ try {
+ this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
+ this.settings = settings;
+ this.eventQueue = [];
+ this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
+ this.movieElement = null;
+
+
+ // Setup global control tracking
+ SWFUpload.instances[this.movieName] = this;
+
+ // Load the settings. Load the Flash movie.
+ this.initSettings();
+ this.loadFlash();
+ this.displayDebugInfo();
+ } catch (ex) {
+ delete SWFUpload.instances[this.movieName];
+ throw ex;
+ }
+};
+
+/* *************** */
+/* Static Members */
+/* *************** */
+SWFUpload.instances = {};
+SWFUpload.movieCount = 0;
+SWFUpload.version = "2.2.0 2009-03-25";
+SWFUpload.QUEUE_ERROR = {
+ QUEUE_LIMIT_EXCEEDED : -100,
+ FILE_EXCEEDS_SIZE_LIMIT : -110,
+ ZERO_BYTE_FILE : -120,
+ INVALID_FILETYPE : -130
+};
+SWFUpload.UPLOAD_ERROR = {
+ HTTP_ERROR : -200,
+ MISSING_UPLOAD_URL : -210,
+ IO_ERROR : -220,
+ SECURITY_ERROR : -230,
+ UPLOAD_LIMIT_EXCEEDED : -240,
+ UPLOAD_FAILED : -250,
+ SPECIFIED_FILE_ID_NOT_FOUND : -260,
+ FILE_VALIDATION_FAILED : -270,
+ FILE_CANCELLED : -280,
+ UPLOAD_STOPPED : -290
+};
+SWFUpload.FILE_STATUS = {
+ QUEUED : -1,
+ IN_PROGRESS : -2,
+ ERROR : -3,
+ COMPLETE : -4,
+ CANCELLED : -5
+};
+SWFUpload.BUTTON_ACTION = {
+ SELECT_FILE : -100,
+ SELECT_FILES : -110,
+ START_UPLOAD : -120
+};
+SWFUpload.CURSOR = {
+ ARROW : -1,
+ HAND : -2
+};
+SWFUpload.WINDOW_MODE = {
+ WINDOW : "window",
+ TRANSPARENT : "transparent",
+ OPAQUE : "opaque"
+};
+
+// Private: takes a URL, determines if it is relative and converts to an absolute URL
+// using the current site. Only processes the URL if it can, otherwise returns the URL untouched
+SWFUpload.completeURL = function(url) {
+ if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
+ return url;
+ }
+
+ var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
+
+ var indexSlash = window.location.pathname.lastIndexOf("/");
+ if (indexSlash <= 0) {
+ path = "/";
+ } else {
+ path = window.location.pathname.substr(0, indexSlash) + "/";
+ }
+
+ return /*currentURL +*/ path + url;
+
+};
+
+
+/* ******************** */
+/* Instance Members */
+/* ******************** */
+
+// Private: initSettings ensures that all the
+// settings are set, getting a default value if one was not assigned.
+SWFUpload.prototype.initSettings = function () {
+ this.ensureDefault = function (settingName, defaultValue) {
+ this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+ };
+
+ // Upload backend settings
+ this.ensureDefault("upload_url", "");
+ this.ensureDefault("preserve_relative_urls", false);
+ this.ensureDefault("file_post_name", "Filedata");
+ this.ensureDefault("post_params", {});
+ this.ensureDefault("use_query_string", false);
+ this.ensureDefault("requeue_on_error", false);
+ this.ensureDefault("http_success", []);
+ this.ensureDefault("assume_success_timeout", 0);
+
+ // File Settings
+ this.ensureDefault("file_types", "*.*");
+ this.ensureDefault("file_types_description", "All Files");
+ this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
+ this.ensureDefault("file_upload_limit", 0);
+ this.ensureDefault("file_queue_limit", 0);
+
+ // Flash Settings
+ this.ensureDefault("flash_url", "swfupload.swf");
+ this.ensureDefault("prevent_swf_caching", true);
+
+ // Button Settings
+ this.ensureDefault("button_image_url", "");
+ this.ensureDefault("button_width", 1);
+ this.ensureDefault("button_height", 1);
+ this.ensureDefault("button_text", "");
+ this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
+ this.ensureDefault("button_text_top_padding", 0);
+ this.ensureDefault("button_text_left_padding", 0);
+ this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
+ this.ensureDefault("button_disabled", false);
+ this.ensureDefault("button_placeholder_id", "");
+ this.ensureDefault("button_placeholder", null);
+ this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
+ this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
+
+ // Debug Settings
+ this.ensureDefault("debug", false);
+ this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
+
+ // Event Handlers
+ this.settings.return_upload_start_handler = this.returnUploadStart;
+ this.ensureDefault("swfupload_loaded_handler", null);
+ this.ensureDefault("file_dialog_start_handler", null);
+ this.ensureDefault("file_queued_handler", null);
+ this.ensureDefault("file_queue_error_handler", null);
+ this.ensureDefault("file_dialog_complete_handler", null);
+
+ this.ensureDefault("upload_start_handler", null);
+ this.ensureDefault("upload_progress_handler", null);
+ this.ensureDefault("upload_error_handler", null);
+ this.ensureDefault("upload_success_handler", null);
+ this.ensureDefault("upload_complete_handler", null);
+
+ this.ensureDefault("debug_handler", this.debugMessage);
+
+ this.ensureDefault("custom_settings", {});
+
+ // Other settings
+ this.customSettings = this.settings.custom_settings;
+
+ // Update the flash url if needed
+ if (!!this.settings.prevent_swf_caching) {
+ this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
+ }
+
+ if (!this.settings.preserve_relative_urls) {
+ //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it
+ this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
+ this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
+ }
+
+ delete this.ensureDefault;
+};
+
+// Private: loadFlash replaces the button_placeholder element with the flash movie.
+SWFUpload.prototype.loadFlash = function () {
+ var targetElement, tempParent;
+
+ // Make sure an element with the ID we are going to use doesn't already exist
+ if (document.getElementById(this.movieName) !== null) {
+ throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
+ }
+
+ // Get the element where we will be placing the flash movie
+ targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
+
+ if (targetElement == undefined) {
+ throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
+ }
+
+ // Append the container and load the flash
+ tempParent = document.createElement("div");
+ tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
+ targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
+
+ // Fix IE Flash/Form bug
+ if (window[this.movieName] == undefined) {
+ window[this.movieName] = this.getMovieElement();
+ }
+
+};
+
+// Private: getFlashHTML generates the object tag needed to embed the flash in to the document
+SWFUpload.prototype.getFlashHTML = function () {
+ // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
+ return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
+ '<param name="wmode" value="', this.settings.button_window_mode, '" />',
+ '<param name="movie" value="', this.settings.flash_url, '" />',
+ '<param name="quality" value="high" />',
+ '<param name="menu" value="false" />',
+ '<param name="allowScriptAccess" value="always" />',
+ '<param name="flashvars" value="' + this.getFlashVars() + '" />',
+ '</object>'].join("");
+};
+
+// Private: getFlashVars builds the parameter string that will be passed
+// to flash in the flashvars param.
+SWFUpload.prototype.getFlashVars = function () {
+ // Build a string from the post param object
+ var paramString = this.buildParamString();
+ var httpSuccessString = this.settings.http_success.join(",");
+
+ // Build the parameter string
+ return ["movieName=", encodeURIComponent(this.movieName),
+ "&uploadURL=", encodeURIComponent(this.settings.upload_url),
+ "&useQueryString=", encodeURIComponent(this.settings.use_query_string),
+ "&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
+ "&httpSuccess=", encodeURIComponent(httpSuccessString),
+ "&assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
+ "&params=", encodeURIComponent(paramString),
+ "&filePostName=", encodeURIComponent(this.settings.file_post_name),
+ "&fileTypes=", encodeURIComponent(this.settings.file_types),
+ "&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
+ "&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
+ "&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
+ "&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
+ "&debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
+ "&buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
+ "&buttonWidth=", encodeURIComponent(this.settings.button_width),
+ "&buttonHeight=", encodeURIComponent(this.settings.button_height),
+ "&buttonText=", encodeURIComponent(this.settings.button_text),
+ "&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
+ "&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
+ "&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
+ "&buttonAction=", encodeURIComponent(this.settings.button_action),
+ "&buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
+ "&buttonCursor=", encodeURIComponent(this.settings.button_cursor)
+ ].join("");
+};
+
+// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
+// The element is cached after the first lookup
+SWFUpload.prototype.getMovieElement = function () {
+ if (this.movieElement == undefined) {
+ this.movieElement = document.getElementById(this.movieName);
+ }
+
+ if (this.movieElement === null) {
+ throw "Could not find Flash element";
+ }
+
+ return this.movieElement;
+};
+
+// Private: buildParamString takes the name/value pairs in the post_params setting object
+// and joins them up in to a string formatted "name=value&name=value"
+SWFUpload.prototype.buildParamString = function () {
+ var postParams = this.settings.post_params;
+ var paramStringPairs = [];
+
+ if (typeof(postParams) === "object") {
+ for (var name in postParams) {
+ if (postParams.hasOwnProperty(name)) {
+ paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
+ }
+ }
+ }
+
+ return paramStringPairs.join("&");
+};
+
+// Public: Used to remove a SWFUpload instance from the page. This method strives to remove
+// all references to the SWF, and other objects so memory is properly freed.
+// Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
+// Credits: Major improvements provided by steffen
+SWFUpload.prototype.destroy = function () {
+ try {
+ // Make sure Flash is done before we try to remove it
+ this.cancelUpload(null, false);
+
+
+ // Remove the SWFUpload DOM nodes
+ var movieElement = null;
+ movieElement = this.getMovieElement();
+
+ if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
+ // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
+ for (var i in movieElement) {
+ try {
+ if (typeof(movieElement[i]) === "function") {
+ movieElement[i] = null;
+ }
+ } catch (ex1) {}
+ }
+
+ // Remove the Movie Element from the page
+ try {
+ movieElement.parentNode.removeChild(movieElement);
+ } catch (ex) {}
+ }
+
+ // Remove IE form fix reference
+ window[this.movieName] = null;
+
+ // Destroy other references
+ SWFUpload.instances[this.movieName] = null;
+ delete SWFUpload.instances[this.movieName];
+
+ this.movieElement = null;
+ this.settings = null;
+ this.customSettings = null;
+ this.eventQueue = null;
+ this.movieName = null;
+
+
+ return true;
+ } catch (ex2) {
+ return false;
+ }
+};
+
+
+// Public: displayDebugInfo prints out settings and configuration
+// information about this SWFUpload instance.
+// This function (and any references to it) can be deleted when placing
+// SWFUpload in production.
+SWFUpload.prototype.displayDebugInfo = function () {
+ this.debug(
+ [
+ "---SWFUpload Instance Info---\n",
+ "Version: ", SWFUpload.version, "\n",
+ "Movie Name: ", this.movieName, "\n",
+ "Settings:\n",
+ "\t", "upload_url: ", this.settings.upload_url, "\n",
+ "\t", "flash_url: ", this.settings.flash_url, "\n",
+ "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
+ "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
+ "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
+ "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
+ "\t", "file_post_name: ", this.settings.file_post_name, "\n",
+ "\t", "post_params: ", this.settings.post_params.toString(), "\n",
+ "\t", "file_types: ", this.settings.file_types, "\n",
+ "\t", "file_types_description: ", this.settings.file_types_description, "\n",
+ "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
+ "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
+ "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
+ "\t", "debug: ", this.settings.debug.toString(), "\n",
+
+ "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
+
+ "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
+ "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
+ "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
+ "\t", "button_width: ", this.settings.button_width.toString(), "\n",
+ "\t", "button_height: ", this.settings.button_height.toString(), "\n",
+ "\t", "button_text: ", this.settings.button_text.toString(), "\n",
+ "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
+ "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
+ "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
+ "\t", "button_action: ", this.settings.button_action.toString(), "\n",
+ "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
+
+ "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
+ "Event Handlers:\n",
+ "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
+ "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
+ "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
+ "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
+ "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
+ "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
+ "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
+ "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
+ "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
+ "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
+ ].join("")
+ );
+};
+
+/* Note: addSetting and getSetting are no longer used by SWFUpload but are included
+ the maintain v2 API compatibility
+*/
+// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
+SWFUpload.prototype.addSetting = function (name, value, default_value) {
+ if (value == undefined) {
+ return (this.settings[name] = default_value);
+ } else {
+ return (this.settings[name] = value);
+ }
+};
+
+// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
+SWFUpload.prototype.getSetting = function (name) {
+ if (this.settings[name] != undefined) {
+ return this.settings[name];
+ }
+
+ return "";
+};
+
+
+
+// Private: callFlash handles function calls made to the Flash element.
+// Calls are made with a setTimeout for some functions to work around
+// bugs in the ExternalInterface library.
+SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
+ argumentArray = argumentArray || [];
+
+ var movieElement = this.getMovieElement();
+ var returnValue, returnString;
+
+ // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
+ try {
+ returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
+ returnValue = eval(returnString);
+ } catch (ex) {
+ throw "Call to " + functionName + " failed";
+ }
+
+ // Unescape file post param values
+ if (returnValue != undefined && typeof returnValue.post === "object") {
+ returnValue = this.unescapeFilePostParams(returnValue);
+ }
+
+ return returnValue;
+};
+
+/* *****************************
+ -- Flash control methods --
+ Your UI should use these
+ to operate SWFUpload
+ ***************************** */
+
+// WARNING: this function does not work in Flash Player 10
+// Public: selectFile causes a File Selection Dialog window to appear. This
+// dialog only allows 1 file to be selected.
+SWFUpload.prototype.selectFile = function () {
+ this.callFlash("SelectFile");
+};
+
+// WARNING: this function does not work in Flash Player 10
+// Public: selectFiles causes a File Selection Dialog window to appear/ This
+// dialog allows the user to select any number of files
+// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
+// If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
+// for this bug.
+SWFUpload.prototype.selectFiles = function () {
+ this.callFlash("SelectFiles");
+};
+
+
+// Public: startUpload starts uploading the first file in the queue unless
+// the optional parameter 'fileID' specifies the ID
+SWFUpload.prototype.startUpload = function (fileID) {
+ this.callFlash("StartUpload", [fileID]);
+};
+
+// Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
+// If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
+// If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
+SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
+ if (triggerErrorEvent !== false) {
+ triggerErrorEvent = true;
+ }
+ this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
+};
+
+// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
+// If nothing is currently uploading then nothing happens.
+SWFUpload.prototype.stopUpload = function () {
+ this.callFlash("StopUpload");
+};
+
+/* ************************
+ * Settings methods
+ * These methods change the SWFUpload settings.
+ * SWFUpload settings should not be changed directly on the settings object
+ * since many of the settings need to be passed to Flash in order to take
+ * effect.
+ * *********************** */
+
+// Public: getStats gets the file statistics object.
+SWFUpload.prototype.getStats = function () {
+ return this.callFlash("GetStats");
+};
+
+// Public: setStats changes the SWFUpload statistics. You shouldn't need to
+// change the statistics but you can. Changing the statistics does not
+// affect SWFUpload accept for the successful_uploads count which is used
+// by the upload_limit setting to determine how many files the user may upload.
+SWFUpload.prototype.setStats = function (statsObject) {
+ this.callFlash("SetStats", [statsObject]);
+};
+
+// Public: getFile retrieves a File object by ID or Index. If the file is
+// not found then 'null' is returned.
+SWFUpload.prototype.getFile = function (fileID) {
+ if (typeof(fileID) === "number") {
+ return this.callFlash("GetFileByIndex", [fileID]);
+ } else {
+ return this.callFlash("GetFile", [fileID]);
+ }
+};
+
+// Public: addFileParam sets a name/value pair that will be posted with the
+// file specified by the Files ID. If the name already exists then the
+// exiting value will be overwritten.
+SWFUpload.prototype.addFileParam = function (fileID, name, value) {
+ return this.callFlash("AddFileParam", [fileID, name, value]);
+};
+
+// Public: removeFileParam removes a previously set (by addFileParam) name/value
+// pair from the specified file.
+SWFUpload.prototype.removeFileParam = function (fileID, name) {
+ this.callFlash("RemoveFileParam", [fileID, name]);
+};
+
+// Public: setUploadUrl changes the upload_url setting.
+SWFUpload.prototype.setUploadURL = function (url) {
+ this.settings.upload_url = url.toString();
+ this.callFlash("SetUploadURL", [url]);
+};
+
+// Public: setPostParams changes the post_params setting
+SWFUpload.prototype.setPostParams = function (paramsObject) {
+ this.settings.post_params = paramsObject;
+ this.callFlash("SetPostParams", [paramsObject]);
+};
+
+// Public: addPostParam adds post name/value pair. Each name can have only one value.
+SWFUpload.prototype.addPostParam = function (name, value) {
+ this.settings.post_params[name] = value;
+ this.callFlash("SetPostParams", [this.settings.post_params]);
+};
+
+// Public: removePostParam deletes post name/value pair.
+SWFUpload.prototype.removePostParam = function (name) {
+ delete this.settings.post_params[name];
+ this.callFlash("SetPostParams", [this.settings.post_params]);
+};
+
+// Public: setFileTypes changes the file_types setting and the file_types_description setting
+SWFUpload.prototype.setFileTypes = function (types, description) {
+ this.settings.file_types = types;
+ this.settings.file_types_description = description;
+ this.callFlash("SetFileTypes", [types, description]);
+};
+
+// Public: setFileSizeLimit changes the file_size_limit setting
+SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
+ this.settings.file_size_limit = fileSizeLimit;
+ this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
+};
+
+// Public: setFileUploadLimit changes the file_upload_limit setting
+SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
+ this.settings.file_upload_limit = fileUploadLimit;
+ this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
+};
+
+// Public: setFileQueueLimit changes the file_queue_limit setting
+SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
+ this.settings.file_queue_limit = fileQueueLimit;
+ this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
+};
+
+// Public: setFilePostName changes the file_post_name setting
+SWFUpload.prototype.setFilePostName = function (filePostName) {
+ this.settings.file_post_name = filePostName;
+ this.callFlash("SetFilePostName", [filePostName]);
+};
+
+// Public: setUseQueryString changes the use_query_string setting
+SWFUpload.prototype.setUseQueryString = function (useQueryString) {
+ this.settings.use_query_string = useQueryString;
+ this.callFlash("SetUseQueryString", [useQueryString]);
+};
+
+// Public: setRequeueOnError changes the requeue_on_error setting
+SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
+ this.settings.requeue_on_error = requeueOnError;
+ this.callFlash("SetRequeueOnError", [requeueOnError]);
+};
+
+// Public: setHTTPSuccess changes the http_success setting
+SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
+ if (typeof http_status_codes === "string") {
+ http_status_codes = http_status_codes.replace(" ", "").split(",");
+ }
+
+ this.settings.http_success = http_status_codes;
+ this.callFlash("SetHTTPSuccess", [http_status_codes]);
+};
+
+// Public: setHTTPSuccess changes the http_success setting
+SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
+ this.settings.assume_success_timeout = timeout_seconds;
+ this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
+};
+
+// Public: setDebugEnabled changes the debug_enabled setting
+SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
+ this.settings.debug_enabled = debugEnabled;
+ this.callFlash("SetDebugEnabled", [debugEnabled]);
+};
+
+// Public: setButtonImageURL loads a button image sprite
+SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
+ if (buttonImageURL == undefined) {
+ buttonImageURL = "";
+ }
+
+ this.settings.button_image_url = buttonImageURL;
+ this.callFlash("SetButtonImageURL", [buttonImageURL]);
+};
+
+// Public: setButtonDimensions resizes the Flash Movie and button
+SWFUpload.prototype.setButtonDimensions = function (width, height) {
+ this.settings.button_width = width;
+ this.settings.button_height = height;
+
+ var movie = this.getMovieElement();
+ if (movie != undefined) {
+ movie.style.width = width + "px";
+ movie.style.height = height + "px";
+ }
+
+ this.callFlash("SetButtonDimensions", [width, height]);
+};
+// Public: setButtonText Changes the text overlaid on the button
+SWFUpload.prototype.setButtonText = function (html) {
+ this.settings.button_text = html;
+ this.callFlash("SetButtonText", [html]);
+};
+// Public: setButtonTextPadding changes the top and left padding of the text overlay
+SWFUpload.prototype.setButtonTextPadding = function (left, top) {
+ this.settings.button_text_top_padding = top;
+ this.settings.button_text_left_padding = left;
+ this.callFlash("SetButtonTextPadding", [left, top]);
+};
+
+// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
+SWFUpload.prototype.setButtonTextStyle = function (css) {
+ this.settings.button_text_style = css;
+ this.callFlash("SetButtonTextStyle", [css]);
+};
+// Public: setButtonDisabled disables/enables the button
+SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
+ this.settings.button_disabled = isDisabled;
+ this.callFlash("SetButtonDisabled", [isDisabled]);
+};
+// Public: setButtonAction sets the action that occurs when the button is clicked
+SWFUpload.prototype.setButtonAction = function (buttonAction) {
+ this.settings.button_action = buttonAction;
+ this.callFlash("SetButtonAction", [buttonAction]);
+};
+
+// Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
+SWFUpload.prototype.setButtonCursor = function (cursor) {
+ this.settings.button_cursor = cursor;
+ this.callFlash("SetButtonCursor", [cursor]);
+};
+
+/* *******************************
+ Flash Event Interfaces
+ These functions are used by Flash to trigger the various
+ events.
+
+ All these functions a Private.
+
+ Because the ExternalInterface library is buggy the event calls
+ are added to a queue and the queue then executed by a setTimeout.
+ This ensures that events are executed in a determinate order and that
+ the ExternalInterface bugs are avoided.
+******************************* */
+
+SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
+
+ if (argumentArray == undefined) {
+ argumentArray = [];
+ } else if (!(argumentArray instanceof Array)) {
+ argumentArray = [argumentArray];
+ }
+
+ var self = this;
+ if (typeof this.settings[handlerName] === "function") {
+ // Queue the event
+ this.eventQueue.push(function () {
+ this.settings[handlerName].apply(this, argumentArray);
+ });
+
+ // Execute the next queued event
+ setTimeout(function () {
+ self.executeNextEvent();
+ }, 0);
+
+ } else if (this.settings[handlerName] !== null) {
+ throw "Event handler " + handlerName + " is unknown or is not a function";
+ }
+};
+
+// Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
+// we must queue them in order to garentee that they are executed in order.
+SWFUpload.prototype.executeNextEvent = function () {
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
+
+ var f = this.eventQueue ? this.eventQueue.shift() : null;
+ if (typeof(f) === "function") {
+ f.apply(this);
+ }
+};
+
+// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
+// properties that contain characters that are not valid for JavaScript identifiers. To work around this
+// the Flash Component escapes the parameter names and we must unescape again before passing them along.
+SWFUpload.prototype.unescapeFilePostParams = function (file) {
+ var reg = /[$]([0-9a-f]{4})/i;
+ var unescapedPost = {};
+ var uk;
+
+ if (file != undefined) {
+ for (var k in file.post) {
+ if (file.post.hasOwnProperty(k)) {
+ uk = k;
+ var match;
+ while ((match = reg.exec(uk)) !== null) {
+ uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
+ }
+ unescapedPost[uk] = file.post[k];
+ }
+ }
+
+ file.post = unescapedPost;
+ }
+
+ return file;
+};
+
+// Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working)
+SWFUpload.prototype.testExternalInterface = function () {
+ try {
+ return this.callFlash("TestExternalInterface");
+ } catch (ex) {
+ return false;
+ }
+};
+
+// Private: This event is called by Flash when it has finished loading. Don't modify this.
+// Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
+SWFUpload.prototype.flashReady = function () {
+ // Check that the movie element is loaded correctly with its ExternalInterface methods defined
+ var movieElement = this.getMovieElement();
+
+ if (!movieElement) {
+ this.debug("Flash called back ready but the flash movie can't be found.");
+ return;
+ }
+
+ this.cleanUp(movieElement);
+
+ this.queueEvent("swfupload_loaded_handler");
+};
+
+// Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
+// This function is called by Flash each time the ExternalInterface functions are created.
+SWFUpload.prototype.cleanUp = function (movieElement) {
+ // Pro-actively unhook all the Flash functions
+ try {
+ if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
+ this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
+ for (var key in movieElement) {
+ try {
+ if (typeof(movieElement[key]) === "function") {
+ movieElement[key] = null;
+ }
+ } catch (ex) {
+ }
+ }
+ }
+ } catch (ex1) {
+
+ }
+
+ // Fix Flashes own cleanup code so if the SWFMovie was removed from the page
+ // it doesn't display errors.
+ window["__flash__removeCallback"] = function (instance, name) {
+ try {
+ if (instance) {
+ instance[name] = null;
+ }
+ } catch (flashEx) {
+
+ }
+ };
+
+};
+
+
+/* This is a chance to do something before the browse window opens */
+SWFUpload.prototype.fileDialogStart = function () {
+ this.queueEvent("file_dialog_start_handler");
+};
+
+
+/* Called when a file is successfully added to the queue. */
+SWFUpload.prototype.fileQueued = function (file) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("file_queued_handler", file);
+};
+
+
+/* Handle errors that occur when an attempt to queue a file fails. */
+SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
+};
+
+/* Called after the file dialog has closed and the selected files have been queued.
+ You could call startUpload here if you want the queued files to begin uploading immediately. */
+SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
+ this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
+};
+
+SWFUpload.prototype.uploadStart = function (file) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("return_upload_start_handler", file);
+};
+
+SWFUpload.prototype.returnUploadStart = function (file) {
+ var returnValue;
+ if (typeof this.settings.upload_start_handler === "function") {
+ file = this.unescapeFilePostParams(file);
+ returnValue = this.settings.upload_start_handler.call(this, file);
+ } else if (this.settings.upload_start_handler != undefined) {
+ throw "upload_start_handler must be a function";
+ }
+
+ // Convert undefined to true so if nothing is returned from the upload_start_handler it is
+ // interpretted as 'true'.
+ if (returnValue === undefined) {
+ returnValue = true;
+ }
+
+ returnValue = !!returnValue;
+
+ this.callFlash("ReturnUploadStart", [returnValue]);
+};
+
+
+
+SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
+};
+
+SWFUpload.prototype.uploadError = function (file, errorCode, message) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("upload_error_handler", [file, errorCode, message]);
+};
+
+SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
+};
+
+SWFUpload.prototype.uploadComplete = function (file) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("upload_complete_handler", file);
+};
+
+/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
+ internal debug console. You can override this event and have messages written where you want. */
+SWFUpload.prototype.debug = function (message) {
+ this.queueEvent("debug_handler", message);
+};
+
+
+/* **********************************
+ Debug Console
+ The debug console is a self contained, in page location
+ for debug message to be sent. The Debug Console adds
+ itself to the body if necessary.
+
+ The console is automatically scrolled as messages appear.
+
+ If you are using your own debug handler or when you deploy to production and
+ have debug disabled you can remove these functions to reduce the file size
+ and complexity.
+********************************** */
+
+// Private: debugMessage is the default debug_handler. If you want to print debug messages
+// call the debug() function. When overriding the function your own function should
+// check to see if the debug setting is true before outputting debug information.
+SWFUpload.prototype.debugMessage = function (message) {
+ if (this.settings.debug) {
+ var exceptionMessage, exceptionValues = [];
+
+ // Check for an exception object and print it nicely
+ if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
+ for (var key in message) {
+ if (message.hasOwnProperty(key)) {
+ exceptionValues.push(key + ": " + message[key]);
+ }
+ }
+ exceptionMessage = exceptionValues.join("\n") || "";
+ exceptionValues = exceptionMessage.split("\n");
+ exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
+ SWFUpload.Console.writeLine(exceptionMessage);
+ } else {
+ SWFUpload.Console.writeLine(message);
+ }
+ }
+};
+
+SWFUpload.Console = {};
+SWFUpload.Console.writeLine = function (message) {
+ var console, documentForm;
+
+ try {
+ console = document.getElementById("SWFUpload_Console");
+
+ if (!console) {
+ documentForm = document.createElement("form");
+ document.getElementsByTagName("body")[0].appendChild(documentForm);
+
+ console = document.createElement("textarea");
+ console.id = "SWFUpload_Console";
+ console.style.fontFamily = "monospace";
+ console.setAttribute("wrap", "off");
+ console.wrap = "off";
+ console.style.overflow = "auto";
+ console.style.width = "700px";
+ console.style.height = "350px";
+ console.style.margin = "5px";
+ documentForm.appendChild(console);
+ }
+
+ console.value += message + "\n";
+
+ console.scrollTop = console.scrollHeight - console.clientHeight;
+ } catch (ex) {
+ alert("Exception: " + ex.name + " Message: " + ex.message);
+ }
+};
|