📄 swfupload.js
字号:
debug_message += this.outputObject(this.settings);
debug_message += "----- SWFUPLOAD SETTINGS END ----\n";
debug_message += "\n";
this.debug(debug_message);
};
SWFUpload.prototype.outputObject = function (object, prefix) {
var output = "", key;
if (typeof(prefix) !== "string") {
prefix = "";
}
if (typeof(object) !== "object") {
return "";
}
for (key in object) {
if (object.hasOwnProperty(key)) {
if (typeof(object[key]) === "object") {
output += (prefix + key + ": { \n" + this.outputObject(object[key], "\t" + prefix) + prefix + "}" + "\n");
} else {
output += (prefix + key + ": " + object[key] + "\n");
}
}
}
return output;
};
/* *****************************
-- Flash control methods --
Your UI should use these
to operate SWFUpload
***************************** */
SWFUpload.prototype.selectFile = function () {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SelectFile) === "function") {
try {
movie_element.SelectFile();
}
catch (ex) {
this.debug("Could not call SelectFile: " + ex);
}
} else {
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.selectFiles = function () {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SelectFiles) === "function") {
try {
movie_element.SelectFiles();
}
catch (ex) {
this.debug("Could not call SelectFiles: " + ex);
}
} else {
this.debug("Could not find Flash element");
}
};
/* Start the upload. If a file_id is specified that file is uploaded. Otherwise the first
* file in the queue is uploaded. If no files are in the queue then nothing happens.
* This call uses setTimeout since Flash will be calling back in to JavaScript
*/
SWFUpload.prototype.startUpload = function (file_id) {
var self = this;
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.StartUpload) === "function") {
setTimeout(
function () {
try {
movie_element.StartUpload(file_id);
}
catch (ex) {
self.debug("Could not call StartUpload: " + ex);
}
}, 0
);
} else {
this.debug("Could not find Flash element");
}
};
/* Cancels a the file upload. You must specify a file_id */
SWFUpload.prototype.cancelUpload = function (file_id) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.CancelUpload) === "function") {
try {
movie_element.CancelUpload(file_id);
}
catch (ex) {
this.debug("Could not call CancelUpload: " + ex);
}
} else {
this.debug("Could not find Flash element");
}
};
// Stops the current upload. The file is re-queued. If nothing is currently uploading then nothing happens.
SWFUpload.prototype.stopUpload = function () {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.StopUpload) === "function") {
try {
movie_element.StopUpload();
}
catch (ex) {
this.debug("Could not call StopUpload: " + ex);
}
} else {
this.debug("Could not find Flash element");
}
};
/* ************************
* Settings methods
* These methods change the settings inside SWFUpload
* They shouldn't need to be called in a setTimeout since they
* should not call back from Flash to JavaScript (except perhaps in a Debug call)
* and some need to return data so setTimeout won't work.
*/
/* Gets the file statistics object. It looks like this (where n = number):
{
files_queued: n,
complete_uploads: n,
upload_errors: n,
uploads_cancelled: n,
queue_errors: n
}
*/
SWFUpload.prototype.getStats = function () {
var self = this;
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.GetStats) === "function") {
try {
return movie_element.GetStats();
}
catch (ex) {
self.debug("Could not call GetStats");
}
} else {
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.addFileParam = function (file_id, name, value) {
var self = this;
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.AddFileParam) === "function") {
try {
return movie_element.AddFileParam(file_id, name, value);
}
catch (ex) {
self.debug("Could not call AddFileParam");
}
} else {
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.removeFileParam = function (file_id, name) {
var self = this;
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.RemoveFileParam) === "function") {
try {
return movie_element.RemoveFileParam(file_id, name);
}
catch (ex) {
self.debug("Could not call AddFileParam");
}
} else {
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.setUploadURL = function (url) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetUploadURL) === "function") {
try {
this.addSetting("upload_url", url);
movie_element.SetUploadURL(this.getSetting("upload_url"));
}
catch (ex) {
this.debug("Could not call SetUploadURL");
}
} else {
this.debug("Could not find Flash element in setUploadURL");
}
};
SWFUpload.prototype.setPostParams = function (param_object) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetPostParams) === "function") {
try {
this.addSetting("post_params", param_object);
movie_element.SetPostParams(this.getSetting("post_params"));
}
catch (ex) {
this.debug("Could not call SetPostParams");
}
} else {
this.debug("Could not find Flash element in SetPostParams");
}
};
SWFUpload.prototype.setFileTypes = function (types, description) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetFileTypes) === "function") {
try {
this.addSetting("file_types", types);
this.addSetting("file_types_description", description);
movie_element.SetFileTypes(this.getSetting("file_types"), this.getSetting("file_types_description"));
}
catch (ex) {
this.debug("Could not call SetFileTypes");
}
} else {
this.debug("Could not find Flash element in SetFileTypes");
}
};
SWFUpload.prototype.setFileSizeLimit = function (file_size_limit) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetFileSizeLimit) === "function") {
try {
this.addSetting("file_size_limit", file_size_limit);
movie_element.SetFileSizeLimit(this.getSetting("file_size_limit"));
}
catch (ex) {
this.debug("Could not call SetFileSizeLimit");
}
} else {
this.debug("Could not find Flash element in SetFileSizeLimit");
}
};
SWFUpload.prototype.setFileUploadLimit = function (file_upload_limit) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetFileUploadLimit) === "function") {
try {
this.addSetting("file_upload_limit", file_upload_limit);
movie_element.SetFileUploadLimit(this.getSetting("file_upload_limit"));
}
catch (ex) {
this.debug("Could not call SetFileUploadLimit");
}
} else {
this.debug("Could not find Flash element in SetFileUploadLimit");
}
};
SWFUpload.prototype.setFileQueueLimit = function (file_queue_limit) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetFileQueueLimit) === "function") {
try {
this.addSetting("file_queue_limit", file_queue_limit);
movie_element.SetFileQueueLimit(this.getSetting("file_queue_limit"));
}
catch (ex) {
this.debug("Could not call SetFileQueueLimit");
}
} else {
this.debug("Could not find Flash element in SetFileQueueLimit");
}
};
SWFUpload.prototype.setFilePostName = function (file_post_name) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetFilePostName) === "function") {
try {
this.addSetting("file_post_name", file_post_name);
movie_element.SetFilePostName(this.getSetting("file_post_name"));
}
catch (ex) {
this.debug("Could not call SetFilePostName");
}
} else {
this.debug("Could not find Flash element in SetFilePostName");
}
};
SWFUpload.prototype.setDebugEnabled = function (debug_enabled) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetDebugEnabled) === "function") {
try {
this.addSetting("debug_enabled", debug_enabled);
this.debug_enabled = this.getSetting("debug_enabled");
movie_element.SetDebugEnabled(this.getSetting("debug_enabled"));
}
catch (ex) {
this.debug("Could not call SetDebugEnabled");
}
} else {
this.debug("Could not find Flash element in SetDebugEnabled");
}
};
/* *******************************
Internal Event Handlers, don't override these
These event handlers ensure that your custom event handlers
are called correctly
******************************* */
// This is the callback method that the Flash movie will call when it has been loaded and is ready to go.
// Calling this or showUI "manually" bypasses the Flash Detection built in to SWFUpload.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -