ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

Functions | Variables
swfupload.js File Reference

Go to the source code of this file.

## Functions
| if (SWFUpload==undefined)
| if (indexSlash<=0)

## Variables
var | SWFUpload
SWFUpload prototype | initSWFUpload
SWFUpload | instances = {}
SWFUpload | movieCount = 0
SWFUpload | version = "2.2.0 2009-03-25"
SWFUpload | QUEUE_ERROR
SWFUpload | UPLOAD_ERROR
SWFUpload | FILE_STATUS
SWFUpload | BUTTON_ACTION
SWFUpload | CURSOR
SWFUpload | WINDOW_MODE
SWFUpload | completeURL = "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "")
var | indexSlash = window.location.pathname.lastIndexOf("/")
SWFUpload prototype | initSettings
SWFUpload prototype | loadFlash
SWFUpload prototype | getFlashHTML
SWFUpload prototype | getFlashVars
SWFUpload prototype | getMovieElement
SWFUpload prototype | buildParamString
SWFUpload prototype | destroy
SWFUpload prototype | displayDebugInfo
SWFUpload prototype | addSetting
SWFUpload prototype | getSetting
SWFUpload prototype | callFlash
SWFUpload prototype | selectFile
SWFUpload prototype | selectFiles
SWFUpload prototype | startUpload
SWFUpload prototype | cancelUpload
SWFUpload prototype | stopUpload
SWFUpload prototype | getStats
SWFUpload prototype | setStats
SWFUpload prototype | getFile
SWFUpload prototype | addFileParam
SWFUpload prototype | removeFileParam
SWFUpload prototype | setUploadURL
SWFUpload prototype | setPostParams
SWFUpload prototype | addPostParam
SWFUpload prototype | removePostParam
SWFUpload prototype | setFileTypes
SWFUpload prototype | setFileSizeLimit
SWFUpload prototype | setFileUploadLimit
SWFUpload prototype | setFileQueueLimit
SWFUpload prototype | setFilePostName
SWFUpload prototype | setUseQueryString
SWFUpload prototype | setRequeueOnError
SWFUpload prototype | setHTTPSuccess
SWFUpload prototype | setAssumeSuccessTimeout
SWFUpload prototype | setDebugEnabled
SWFUpload prototype | setButtonImageURL
SWFUpload prototype | setButtonDimensions
SWFUpload prototype | setButtonText
SWFUpload prototype | setButtonTextPadding
SWFUpload prototype | setButtonTextStyle
SWFUpload prototype | setButtonDisabled
SWFUpload prototype | setButtonAction
SWFUpload prototype | setButtonCursor
SWFUpload prototype | queueEvent
SWFUpload prototype | executeNextEvent
SWFUpload prototype | unescapeFilePostParams
SWFUpload prototype | testExternalInterface
SWFUpload prototype | flashReady
SWFUpload prototype | cleanUp
SWFUpload prototype | fileDialogStart
SWFUpload prototype | fileQueued
SWFUpload prototype | fileQueueError
SWFUpload prototype | fileDialogComplete
SWFUpload prototype | uploadStart
SWFUpload prototype | returnUploadStart
SWFUpload prototype | uploadProgress
SWFUpload prototype | uploadError
SWFUpload prototype | uploadSuccess
SWFUpload prototype | uploadComplete
SWFUpload prototype | debug
SWFUpload prototype | debugMessage
SWFUpload | Console = {}
SWFUpload Console | writeLine

## Function Documentation

if | ( |  | SWFUpload = `= undefined` | ) |

Definition at line 20 of file swfupload.js.

{
SWFUpload = function (settings) {
this.initSWFUpload(settings);
};
}

if | ( | indexSlash<= | 0 | ) |

Definition at line 104 of file swfupload.js.

{
path = "/";
} else {

## Variable Documentation

SWFUpload prototype addFileParam

Initial value:
function (fileID, name, value) {
return this.callFlash("AddFileParam", [fileID, name, value]);
}

Definition at line 543 of file swfupload.js.

SWFUpload prototype addPostParam

Initial value:
function (name, value) {
this.settings.post_params[name] = value;
this.callFlash("SetPostParams", [this.settings.post_params]);
}

Definition at line 566 of file swfupload.js.

SWFUpload prototype addSetting

Initial value:
function (name, value, default_value) {
if (value == undefined) {
return (this.settings[name] = default_value);
} else {
return (this.settings[name] = value);
}
}

Definition at line 419 of file swfupload.js.

SWFUpload prototype buildParamString

Initial value:
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("&amp;");
}

Definition at line 293 of file swfupload.js.

SWFUpload BUTTON_ACTION

Initial value:
{
SELECT_FILE : -100,
SELECT_FILES : -110,
START_UPLOAD : -120
}

Definition at line 79 of file swfupload.js.

SWFUpload prototype callFlash

Initial value:
function (functionName, argumentArray) {
argumentArray = argumentArray || [];
var movieElement = this.getMovieElement();
var returnValue, returnString;
try {
returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
returnValue = eval(returnString);
} catch (ex) {
throw "Call to " + functionName + " failed";
}
if (returnValue != undefined && typeof returnValue.post === "object") {
returnValue = this.unescapeFilePostParams(returnValue);
}
return returnValue;
}

Definition at line 441 of file swfupload.js.

SWFUpload prototype cancelUpload

Initial value:
function (fileID, triggerErrorEvent) {
if (triggerErrorEvent !== false) {
triggerErrorEvent = true;
}
this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
}

Definition at line 496 of file swfupload.js.

SWFUpload prototype cleanUp

Definition at line 802 of file swfupload.js.

SWFUpload completeURL = "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "")

Definition at line 96 of file swfupload.js.

SWFUpload Console = {}

Definition at line 951 of file swfupload.js.

SWFUpload CURSOR

Initial value:
{
ARROW : -1,
HAND : -2
}

Definition at line 84 of file swfupload.js.

SWFUpload prototype debug

Initial value:
function (message) {
this.queueEvent("debug_handler", message);
}

Definition at line 909 of file swfupload.js.

SWFUpload prototype debugMessage

Initial value:
function (message) {
if (this.settings.debug) {
var exceptionMessage, exceptionValues = [];
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);
}
}
}

Definition at line 930 of file swfupload.js.

SWFUpload prototype destroy

Definition at line 312 of file swfupload.js.

SWFUpload prototype displayDebugInfo

Definition at line 363 of file swfupload.js.

SWFUpload prototype executeNextEvent

Initial value:
function () {
var f = this.eventQueue ? this.eventQueue.shift() : null;
if (typeof(f) === "function") {
f.apply(this);
}
}

Definition at line 740 of file swfupload.js.

SWFUpload FILE_STATUS

Initial value:
{
QUEUED : -1,
IN_PROGRESS : -2,
ERROR : -3,
COMPLETE : -4,
CANCELLED : -5
}

Definition at line 72 of file swfupload.js.

SWFUpload prototype fileDialogComplete

Initial value:
function (numFilesSelected, numFilesQueued, numFilesInQueue) {
this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
}

Definition at line 856 of file swfupload.js.

SWFUpload prototype fileDialogStart

Initial value:
function () {
this.queueEvent("file_dialog_start_handler");
}

Definition at line 836 of file swfupload.js.

SWFUpload prototype fileQueued

Initial value:
function (file) {
file = this.unescapeFilePostParams(file);
this.queueEvent("file_queued_handler", file);
}

Definition at line 842 of file swfupload.js.

SWFUpload prototype fileQueueError

Initial value:
function (file, errorCode, message) {
file = this.unescapeFilePostParams(file);
this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
}

Definition at line 849 of file swfupload.js.

SWFUpload prototype flashReady

Initial value:
function () {
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");
}

Definition at line 786 of file swfupload.js.

SWFUpload prototype getFile

Initial value:
function (fileID) {
if (typeof(fileID) === "number") {
return this.callFlash("GetFileByIndex", [fileID]);
} else {
return this.callFlash("GetFile", [fileID]);
}
}

Definition at line 532 of file swfupload.js.

SWFUpload prototype getFlashHTML

Initial value:
function () {
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("");
}

Definition at line 230 of file swfupload.js.

SWFUpload prototype getFlashVars

Definition at line 244 of file swfupload.js.

SWFUpload prototype getMovieElement

Initial value:
function () {
if (this.movieElement == undefined) {
this.movieElement = document.getElementById(this.movieName);
}
if (this.movieElement === null) {
throw "Could not find Flash element";
}
return this.movieElement;
}

Definition at line 279 of file swfupload.js.

SWFUpload prototype getSetting

Initial value:
function (name) {
if (this.settings[name] != undefined) {
return this.settings[name];
}
return "";
}

Definition at line 428 of file swfupload.js.

SWFUpload prototype getStats

Initial value:
function () {
return this.callFlash("GetStats");
}

Definition at line 518 of file swfupload.js.

var indexSlash = window.location.pathname.lastIndexOf("/")

Definition at line 103 of file swfupload.js.

SWFUpload prototype initSettings

Definition at line 121 of file swfupload.js.

SWFUpload prototype initSWFUpload

Initial value:
function (settings) {
try {
this.customSettings = {};
this.settings = settings;
this.eventQueue = [];
this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
this.movieElement = null;
SWFUpload.instances[this.movieName] = this;
this.initSettings();
this.loadFlash();
this.displayDebugInfo();
} catch (ex) {
delete SWFUpload.instances[this.movieName];
throw ex;
}
}

Definition at line 26 of file swfupload.js.

SWFUpload instances = {}

Definition at line 51 of file swfupload.js.

SWFUpload prototype loadFlash

Initial value:
function () {
var targetElement, tempParent;
if (document.getElementById(this.movieName) !== null) {
throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
}
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;
}
tempParent = document.createElement("div");
tempParent.innerHTML = this.getFlashHTML();
targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
if (window[this.movieName] == undefined) {
window[this.movieName] = this.getMovieElement();
}
}

Definition at line 202 of file swfupload.js.

SWFUpload movieCount = 0

Definition at line 52 of file swfupload.js.

SWFUpload QUEUE_ERROR

Initial value:
{
QUEUE_LIMIT_EXCEEDED : -100,
FILE_EXCEEDS_SIZE_LIMIT : -110,
ZERO_BYTE_FILE : -120,
INVALID_FILETYPE : -130
}

Definition at line 54 of file swfupload.js.

SWFUpload prototype queueEvent

Initial value:
function (handlerName, argumentArray) {
if (argumentArray == undefined) {
argumentArray = [];
} else if (!(argumentArray instanceof Array)) {
argumentArray = [argumentArray];
}
var self = this;
if (typeof this.settings[handlerName] === "function") {
this.eventQueue.push(function () {
this.settings[handlerName].apply(this, argumentArray);
});
setTimeout(function () {
self.executeNextEvent();
}, 0);
} else if (this.settings[handlerName] !== null) {
throw "Event handler " + handlerName + " is unknown or is not a function";
}
}

Definition at line 712 of file swfupload.js.

SWFUpload prototype removeFileParam

Initial value:
function (fileID, name) {
this.callFlash("RemoveFileParam", [fileID, name]);
}

Definition at line 549 of file swfupload.js.

SWFUpload prototype removePostParam

Initial value:
function (name) {
delete this.settings.post_params[name];
this.callFlash("SetPostParams", [this.settings.post_params]);
}

Definition at line 572 of file swfupload.js.

SWFUpload prototype returnUploadStart

Initial value:
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";
}
if (returnValue === undefined) {
returnValue = true;
}
returnValue = !!returnValue;
this.callFlash("ReturnUploadStart", [returnValue]);
}

Definition at line 865 of file swfupload.js.

SWFUpload prototype selectFile

Initial value:
function () {
this.callFlash("SelectFile");
}

Definition at line 472 of file swfupload.js.

SWFUpload prototype selectFiles

Initial value:
function () {
this.callFlash("SelectFiles");
}

Definition at line 482 of file swfupload.js.

SWFUpload prototype setAssumeSuccessTimeout

Initial value:
function (timeout_seconds) {
this.settings.assume_success_timeout = timeout_seconds;
this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
}

Definition at line 631 of file swfupload.js.

SWFUpload prototype setButtonAction

Initial value:
function (buttonAction) {
this.settings.button_action = buttonAction;
this.callFlash("SetButtonAction", [buttonAction]);
}

Definition at line 688 of file swfupload.js.

SWFUpload prototype setButtonCursor

Initial value:
function (cursor) {
this.settings.button_cursor = cursor;
this.callFlash("SetButtonCursor", [cursor]);
}

Definition at line 694 of file swfupload.js.

SWFUpload prototype setButtonDimensions

Initial value:
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]);
}

Definition at line 653 of file swfupload.js.

SWFUpload prototype setButtonDisabled

Initial value:
function (isDisabled) {
this.settings.button_disabled = isDisabled;
this.callFlash("SetButtonDisabled", [isDisabled]);
}

Definition at line 683 of file swfupload.js.

SWFUpload prototype setButtonImageURL

Initial value:
function (buttonImageURL) {
if (buttonImageURL == undefined) {
buttonImageURL = "";
}
this.settings.button_image_url = buttonImageURL;
this.callFlash("SetButtonImageURL", [buttonImageURL]);
}

Definition at line 643 of file swfupload.js.

SWFUpload prototype setButtonText

Initial value:
function (html) {
this.settings.button_text = html;
this.callFlash("SetButtonText", [html]);
}

Definition at line 666 of file swfupload.js.

SWFUpload prototype setButtonTextPadding

Initial value:
function (left, top) {
this.settings.button_text_top_padding = top;
this.settings.button_text_left_padding = left;
this.callFlash("SetButtonTextPadding", [left, top]);
}

Definition at line 671 of file swfupload.js.

SWFUpload prototype setButtonTextStyle

Initial value:
function (css) {
this.settings.button_text_style = css;
this.callFlash("SetButtonTextStyle", [css]);
}

Definition at line 678 of file swfupload.js.

SWFUpload prototype setDebugEnabled

Initial value:
function (debugEnabled) {
this.settings.debug_enabled = debugEnabled;
this.callFlash("SetDebugEnabled", [debugEnabled]);
}

Definition at line 637 of file swfupload.js.

SWFUpload prototype setFilePostName

Initial value:
function (filePostName) {
this.settings.file_post_name = filePostName;
this.callFlash("SetFilePostName", [filePostName]);
}

Definition at line 603 of file swfupload.js.

SWFUpload prototype setFileQueueLimit

Initial value:
function (fileQueueLimit) {
this.settings.file_queue_limit = fileQueueLimit;
this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
}

Definition at line 597 of file swfupload.js.

SWFUpload prototype setFileSizeLimit

Initial value:
function (fileSizeLimit) {
this.settings.file_size_limit = fileSizeLimit;
this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
}

Definition at line 585 of file swfupload.js.

SWFUpload prototype setFileTypes

Initial value:
function (types, description) {
this.settings.file_types = types;
this.settings.file_types_description = description;
this.callFlash("SetFileTypes", [types, description]);
}

Definition at line 578 of file swfupload.js.

SWFUpload prototype setFileUploadLimit

Initial value:
function (fileUploadLimit) {
this.settings.file_upload_limit = fileUploadLimit;
this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
}

Definition at line 591 of file swfupload.js.

SWFUpload prototype setHTTPSuccess

Initial value:
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]);
}

Definition at line 621 of file swfupload.js.

SWFUpload prototype setPostParams

Initial value:
function (paramsObject) {
this.settings.post_params = paramsObject;
this.callFlash("SetPostParams", [paramsObject]);
}

Definition at line 560 of file swfupload.js.

SWFUpload prototype setRequeueOnError

Initial value:
function (requeueOnError) {
this.settings.requeue_on_error = requeueOnError;
this.callFlash("SetRequeueOnError", [requeueOnError]);
}

Definition at line 615 of file swfupload.js.

SWFUpload prototype setStats

Initial value:
function (statsObject) {
this.callFlash("SetStats", [statsObject]);
}

Definition at line 526 of file swfupload.js.

SWFUpload prototype setUploadURL

Initial value:
function (url) {
this.settings.upload_url = url.toString();
this.callFlash("SetUploadURL", [url]);
}

Definition at line 554 of file swfupload.js.

SWFUpload prototype setUseQueryString

Initial value:
function (useQueryString) {
this.settings.use_query_string = useQueryString;
this.callFlash("SetUseQueryString", [useQueryString]);
}

Definition at line 609 of file swfupload.js.

SWFUpload prototype startUpload

Initial value:
function (fileID) {
this.callFlash("StartUpload", [fileID]);
}

Definition at line 489 of file swfupload.js.

SWFUpload prototype stopUpload

Initial value:
function () {
this.callFlash("StopUpload");
}

Definition at line 505 of file swfupload.js.

var SWFUpload

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

Definition at line 18 of file swfupload.js.

SWFUpload prototype testExternalInterface

Initial value:
function () {
try {
return this.callFlash("TestExternalInterface");
} catch (ex) {
return false;
}
}

Definition at line 776 of file swfupload.js.

SWFUpload prototype unescapeFilePostParams

Initial value:
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;
}

Definition at line 752 of file swfupload.js.

SWFUpload UPLOAD_ERROR

Initial value:
{
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
}

Definition at line 60 of file swfupload.js.

SWFUpload prototype uploadComplete

Initial value:
function (file) {
file = this.unescapeFilePostParams(file);
this.queueEvent("upload_complete_handler", file);
}

Definition at line 902 of file swfupload.js.

SWFUpload prototype uploadError

Initial value:
function (file, errorCode, message) {
file = this.unescapeFilePostParams(file);
this.queueEvent("upload_error_handler", [file, errorCode, message]);
}

Definition at line 892 of file swfupload.js.

SWFUpload prototype uploadProgress

Initial value:
function (file, bytesComplete, bytesTotal) {
file = this.unescapeFilePostParams(file);
this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
}

Definition at line 887 of file swfupload.js.

SWFUpload prototype uploadStart

Initial value:
function (file) {
file = this.unescapeFilePostParams(file);
this.queueEvent("return_upload_start_handler", file);
}

Definition at line 860 of file swfupload.js.

SWFUpload prototype uploadSuccess

Initial value:
function (file, serverData, responseReceived) {
file = this.unescapeFilePostParams(file);
this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
}

Definition at line 897 of file swfupload.js.

SWFUpload version = "2.2.0 2009-03-25"

Definition at line 53 of file swfupload.js.

SWFUpload WINDOW_MODE

Initial value:
{
WINDOW : "window",
TRANSPARENT : "transparent",
OPAQUE : "opaque"
}

Definition at line 88 of file swfupload.js.

SWFUpload Console writeLine

Initial value:
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);
}
}

Definition at line 952 of file swfupload.js.