📄 swfupload.js
字号:
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 movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.GetStats) === "function") {
try {
return movie_element.GetStats();
}
catch (ex) {
this.debug("Could not call GetStats");
}
} else {
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.setStats = function (stats_object) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetStats) === "function") {
try {
movie_element.SetStats(stats_object);
}
catch (ex) {
this.debug("Could not call SetStats");
}
} else {
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.setCredentials = function(name, password) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.SetCredentials) === "function") {
try {
return movie_element.SetCredentials(name, password);
}
catch (ex) {
this.debug("Could not call SetCredentials");
}
} else {
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.getFile = function (file_id) {
var movie_element = this.getMovieElement();
if (typeof(file_id) === "number") {
if (movie_element !== null && typeof(movie_element.GetFileByIndex) === "function") {
try {
return movie_element.GetFileByIndex(file_id);
}
catch (ex) {
this.debug("Could not call GetFileByIndex");
}
} else {
this.debug("Could not find Flash element");
}
} else {
if (movie_element !== null && typeof(movie_element.GetFile) === "function") {
try {
return movie_element.GetFile(file_id);
}
catch (ex) {
this.debug("Could not call GetFile");
}
} else {
this.debug("Could not find Flash element");
}
}
};
SWFUpload.prototype.addFileParam = function (file_id, name, value) {
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) {
this.debug("Could not call AddFileParam");
}
} else {
this.debug("Could not find Flash element");
}
};
SWFUpload.prototype.removeFileParam = function (file_id, name) {
var movie_element = this.getMovieElement();
if (movie_element !== null && typeof(movie_element.RemoveFileParam) === "function") {
try {
return movie_element.RemoveFileParam(file_id, name);
}
catch (ex) {
this.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);
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 Callers
Don't override these! These event callers ensure that your custom event handlers
are called safely and in order.
******************************* */
/* 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" will bypass the Flash Detection built in to SWFUpload.
Use a ui_function setting if you want to control the UI loading after the flash has loaded.
*/
SWFUpload.prototype.flashReady = function () {
// Check that the movie element is loaded correctly with its ExternalInterface methods defined
var movie_element = this.getMovieElement();
if (movie_element === null || typeof(movie_element.StartUpload) !== "function") {
this.debug("ExternalInterface methods failed to initialize.");
return;
}
var self = this;
if (typeof(self.flashReady_handler) === "function") {
this.eventQueue[this.eventQueue.length] = function() { self.flashReady_handler(); };
setTimeout(function () { self.executeNextEvent();}, 0);
} else {
this.debug("flashReady_handler event not defined");
}
};
/*
Event Queue. Rather can call events directly from Flash they events are
are placed in a queue and then executed. This ensures that each event is
executed in the order it was called which is not guarenteed when calling
setTimeout. Out of order events was especially problematic in Safari.
*/
SWFUpload.prototype.executeNextEvent = function () {
var f = this.eventQueue.shift();
if (typeof(f) === "function") {
f();
}
}
/* This is a chance to do something before the browse window opens */
SWFUpload.prototype.fileDialogStart = function () {
var self = this;
if (typeof(self.fileDialogStart_handler) === "function") {
this.eventQueue[this.eventQueue.length] = function() { self.fileDialogStart_handler(); };
setTimeout(function () { self.executeNextEvent();}, 0);
} else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -