| 96 | | this.addSetting("upload_url", init_settings.upload_url, ""); |
| 97 | | this.addSetting("file_post_name", init_settings.file_post_name, "Filedata"); |
| 98 | | this.addSetting("post_params", init_settings.post_params, {}); |
| 99 | | |
| | 93 | this.ensureDefault("upload_url", ""); |
| | 94 | this.ensureDefault("file_post_name", "Filedata"); |
| | 95 | this.ensureDefault("post_params", {}); |
| | 96 | this.ensureDefault("use_query_string", false); |
| | 97 | this.ensureDefault("requeue_on_error", false); |
| | 98 | |
| 101 | | this.addSetting("file_types", init_settings.file_types, "*.*"); |
| 102 | | this.addSetting("file_types_description", init_settings.file_types_description, "All Files"); |
| 103 | | this.addSetting("file_size_limit", init_settings.file_size_limit, "1024"); |
| 104 | | this.addSetting("file_upload_limit", init_settings.file_upload_limit, "0"); |
| 105 | | this.addSetting("file_queue_limit", init_settings.file_queue_limit, "0"); |
| | 100 | this.ensureDefault("file_types", "*.*"); |
| | 101 | this.ensureDefault("file_types_description", "All Files"); |
| | 102 | this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited" |
| | 103 | this.ensureDefault("file_upload_limit", 0); |
| | 104 | this.ensureDefault("file_queue_limit", 0); |
| 108 | | this.addSetting("flash_url", init_settings.flash_url, "swfupload.swf"); |
| 109 | | this.addSetting("flash_width", init_settings.flash_width, "1px"); |
| 110 | | this.addSetting("flash_height", init_settings.flash_height, "1px"); |
| 111 | | this.addSetting("flash_color", init_settings.flash_color, "#FFFFFF"); |
| 112 | | |
| | 107 | this.ensureDefault("flash_url", "swfupload.swf"); |
| | 108 | this.ensureDefault("prevent_swf_caching", true); |
| | 109 | |
| | 110 | // Button Settings |
| | 111 | this.ensureDefault("button_image_url", ""); |
| | 112 | this.ensureDefault("button_width", 1); |
| | 113 | this.ensureDefault("button_height", 1); |
| | 114 | this.ensureDefault("button_text", ""); |
| | 115 | this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;"); |
| | 116 | this.ensureDefault("button_text_top_padding", 0); |
| | 117 | this.ensureDefault("button_text_left_padding", 0); |
| | 118 | this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES); |
| | 119 | this.ensureDefault("button_disabled", false); |
| | 120 | this.ensureDefault("button_placeholder_id", null); |
| | 121 | |
| 117 | | this.flashReady_handler = SWFUpload.flashReady; // This is a non-overrideable event handler |
| 118 | | this.swfUploadLoaded_handler = this.retrieveSetting(init_settings.swfupload_loaded_handler, SWFUpload.swfUploadLoaded); |
| | 127 | this.settings.return_upload_start_handler = this.returnUploadStart; |
| | 128 | this.ensureDefault("swfupload_loaded_handler", null); |
| | 129 | this.ensureDefault("file_dialog_start_handler", null); |
| | 130 | this.ensureDefault("file_queued_handler", null); |
| | 131 | this.ensureDefault("file_queue_error_handler", null); |
| | 132 | this.ensureDefault("file_dialog_complete_handler", null); |
| 120 | | this.fileDialogStart_handler = this.retrieveSetting(init_settings.file_dialog_start_handler, SWFUpload.fileDialogStart); |
| 121 | | this.fileQueued_handler = this.retrieveSetting(init_settings.file_queued_handler, SWFUpload.fileQueued); |
| 122 | | this.fileQueueError_handler = this.retrieveSetting(init_settings.file_queue_error_handler, SWFUpload.fileQueueError); |
| 123 | | this.fileDialogComplete_handler = this.retrieveSetting(init_settings.file_dialog_complete_handler, SWFUpload.fileDialogComplete); |
| | 134 | this.ensureDefault("upload_start_handler", null); |
| | 135 | this.ensureDefault("upload_progress_handler", null); |
| | 136 | this.ensureDefault("upload_error_handler", null); |
| | 137 | this.ensureDefault("upload_success_handler", null); |
| | 138 | this.ensureDefault("upload_complete_handler", null); |
| 190 | | html += '<param name="bgcolor" value="' + this.getSetting("flash_color") + '" />'; |
| 191 | | html += '<param name="quality" value="high" />'; |
| 192 | | html += '<param name="menu" value="false" />'; |
| 193 | | |
| 194 | | html += '<param name="flashvars" value="' + this.getFlashVars() + '" />'; |
| 195 | | html += '</object>'; |
| 196 | | } |
| 197 | | |
| 198 | | return html; |
| | 213 | // Private: getFlashHTML generates the object tag needed to embed the flash in to the document |
| | 214 | SWFUpload.prototype.getFlashHTML = function () { |
| | 215 | var transparent = this.settings.button_image_url === "" ? true : false; |
| | 216 | |
| | 217 | // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay |
| | 218 | 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">', |
| | 219 | '<param name="wmode" value="', transparent ? "transparent" : "window", '" />', |
| | 220 | '<param name="movie" value="', this.settings.flash_url, '" />', |
| | 221 | '<param name="quality" value="high" />', |
| | 222 | '<param name="menu" value="false" />', |
| | 223 | '<param name="allowScriptAccess" value="always" />', |
| | 224 | '<param name="flashvars" value="' + this.getFlashVars() + '" />', |
| | 225 | '</object>'].join(""); |
| 208 | | var html = ""; |
| 209 | | html += "movieName=" + encodeURIComponent(this.movieName); |
| 210 | | html += "&uploadURL=" + encodeURIComponent(this.getSetting("upload_url")); |
| 211 | | html += "¶ms=" + encodeURIComponent(param_string); |
| 212 | | html += "&filePostName=" + encodeURIComponent(this.getSetting("file_post_name")); |
| 213 | | html += "&fileTypes=" + encodeURIComponent(this.getSetting("file_types")); |
| 214 | | html += "&fileTypesDescription=" + encodeURIComponent(this.getSetting("file_types_description")); |
| 215 | | html += "&fileSizeLimit=" + encodeURIComponent(this.getSetting("file_size_limit")); |
| 216 | | html += "&fileUploadLimit=" + encodeURIComponent(this.getSetting("file_upload_limit")); |
| 217 | | html += "&fileQueueLimit=" + encodeURIComponent(this.getSetting("file_queue_limit")); |
| 218 | | html += "&debugEnabled=" + encodeURIComponent(this.getSetting("debug_enabled")); |
| 219 | | |
| 220 | | return html; |
| | 235 | return ["movieName=", encodeURIComponent(this.movieName), |
| | 236 | "&uploadURL=", encodeURIComponent(this.settings.upload_url), |
| | 237 | "&useQueryString=", encodeURIComponent(this.settings.use_query_string), |
| | 238 | "&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), |
| | 239 | "&params=", encodeURIComponent(paramString), |
| | 240 | "&filePostName=", encodeURIComponent(this.settings.file_post_name), |
| | 241 | "&fileTypes=", encodeURIComponent(this.settings.file_types), |
| | 242 | "&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), |
| | 243 | "&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), |
| | 244 | "&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), |
| | 245 | "&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), |
| | 246 | "&debugEnabled=", encodeURIComponent(this.settings.debug_enabled), |
| | 247 | "&buttonImageURL=", encodeURIComponent(this.settings.button_image_url), |
| | 248 | "&buttonWidth=", encodeURIComponent(this.settings.button_width), |
| | 249 | "&buttonHeight=", encodeURIComponent(this.settings.button_height), |
| | 250 | "&buttonText=", encodeURIComponent(this.settings.button_text), |
| | 251 | "&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), |
| | 252 | "&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), |
| | 253 | "&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), |
| | 254 | "&buttonAction=", encodeURIComponent(this.settings.button_action), |
| | 255 | "&buttonDisabled=", encodeURIComponent(this.settings.button_disabled) |
| | 256 | ].join(""); |
| 258 | | // Saves a setting. If the value given is undefined or null then the default_value is used. |
| 259 | | SWFUpload.prototype.addSetting = function (name, value, default_value) { |
| 260 | | if (typeof(value) === "undefined" || value === null) { |
| 261 | | this.settings[name] = default_value; |
| 262 | | } else { |
| 263 | | this.settings[name] = value; |
| 264 | | } |
| | 290 | // Public: Used to remove a SWFUpload instance from the page. This method strives to remove |
| | 291 | // all references to the SWF, and other objects so memory is properly freed. |
| | 292 | // Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state. |
| | 293 | SWFUpload.prototype.destroy = function () { |
| | 294 | try { |
| | 295 | // Make sure Flash is done before we try to remove it |
| | 296 | this.stopUpload(); |
| | 297 | |
| | 298 | // Remove the SWFUpload DOM nodes |
| | 299 | var movieElement = null; |
| | 300 | try { |
| | 301 | movieElement = this.getMovieElement(); |
| | 302 | } catch (ex) { |
| | 303 | } |
| | 304 | |
| | 305 | if (movieElement != undefined && movieElement.parentNode != undefined && typeof movieElement.parentNode.removeChild === "function") { |
| | 306 | var container = movieElement.parentNode; |
| | 307 | if (container != undefined) { |
| | 308 | container.removeChild(movieElement); |
| | 309 | if (container.parentNode != undefined && typeof container.parentNode.removeChild === "function") { |
| | 310 | container.parentNode.removeChild(container); |
| | 311 | } |
| | 312 | } |
| | 313 | } |
| | 314 | |
| | 315 | // Destroy references |
| | 316 | SWFUpload.instances[this.movieName] = null; |
| | 317 | delete SWFUpload.instances[this.movieName]; |
| 278 | | // Gets a setting, if the setting is undefined then return the default value |
| 279 | | // This does not affect or use the interal setting object. |
| 280 | | SWFUpload.prototype.retrieveSetting = function (value, default_value) { |
| 281 | | if (typeof(value) === "undefined" || value === null) { |
| 282 | | return default_value; |
| 283 | | } else { |
| 284 | | return value; |
| 285 | | } |
| 286 | | }; |
| 287 | | |
| 288 | | |
| 289 | | // It loops through all the settings and displays |
| 290 | | // them in the debug Console. |
| | 333 | // Public: displayDebugInfo prints out settings and configuration |
| | 334 | // information about this SWFUpload instance. |
| | 335 | // This function (and any references to it) can be deleted when placing |
| | 336 | // SWFUpload in production. |
| 292 | | var key, debug_message = ""; |
| | 338 | this.debug( |
| | 339 | [ |
| | 340 | "---SWFUpload Instance Info---\n", |
| | 341 | "Version: ", SWFUpload.version, "\n", |
| | 342 | "Movie Name: ", this.movieName, "\n", |
| | 343 | "Settings:\n", |
| | 344 | "\t", "upload_url: ", this.settings.upload_url, "\n", |
| | 345 | "\t", "flash_url: ", this.settings.flash_url, "\n", |
| | 346 | "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n", |
| | 347 | "\t", "file_post_name: ", this.settings.file_post_name, "\n", |
| | 348 | "\t", "post_params: ", this.settings.post_params.toString(), "\n", |
| | 349 | "\t", "file_types: ", this.settings.file_types, "\n", |
| | 350 | "\t", "file_types_description: ", this.settings.file_types_description, "\n", |
| | 351 | "\t", "file_size_limit: ", this.settings.file_size_limit, "\n", |
| | 352 | "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n", |
| | 353 | "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n", |
| | 354 | "\t", "debug: ", this.settings.debug.toString(), "\n", |
| 296 | | debug_message += this.outputObject(this.settings); |
| | 358 | "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n", |
| | 359 | "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n", |
| | 360 | "\t", "button_width: ", this.settings.button_width.toString(), "\n", |
| | 361 | "\t", "button_height: ", this.settings.button_height.toString(), "\n", |
| | 362 | "\t", "button_text: ", this.settings.button_text.toString(), "\n", |
| | 363 | "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n", |
| | 364 | "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n", |
| | 365 | "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", |
| | 366 | "\t", "button_action: ", this.settings.button_action.toString(), "\n", |
| | 367 | "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n", |
| 298 | | debug_message += "----- SWFUPLOAD SETTINGS END ----\n"; |
| 299 | | debug_message += "\n"; |
| | 369 | "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n", |
| | 370 | "Event Handlers:\n", |
| | 371 | "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", |
| | 372 | "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", |
| | 373 | "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", |
| | 374 | "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", |
| | 375 | "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", |
| | 376 | "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", |
| | 377 | "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", |
| | 378 | "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", |
| | 379 | "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", |
| | 380 | "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n" |
| | 381 | ].join("") |
| | 382 | ); |
| | 383 | }; |
| 313 | | for (key in object) { |
| 314 | | if (object.hasOwnProperty(key)) { |
| 315 | | if (typeof(object[key]) === "object") { |
| 316 | | output += (prefix + key + ": { \n" + this.outputObject(object[key], "\t" + prefix) + prefix + "}" + "\n"); |
| 317 | | } else { |
| 318 | | output += (prefix + key + ": " + object[key] + "\n"); |
| 319 | | } |
| | 403 | return ""; |
| | 404 | }; |
| | 405 | |
| | 406 | |
| | 407 | |
| | 408 | // Private: callFlash handles function calls made to the Flash element. |
| | 409 | // Calls are made with a setTimeout for some functions to work around |
| | 410 | // bugs in the ExternalInterface library. |
| | 411 | SWFUpload.prototype.callFlash = function (functionName, argumentArray) { |
| | 412 | argumentArray = argumentArray || []; |
| | 413 | |
| | 414 | var movieElement = this.getMovieElement(); |
| | 415 | var returnValue; |
| | 416 | |
| | 417 | if (typeof movieElement[functionName] === "function") { |
| | 418 | // We have to go through all this if/else stuff because the Flash functions don't have apply() and only accept the exact number of arguments. |
| | 419 | if (argumentArray.length === 0) { |
| | 420 | returnValue = movieElement[functionName](); |
| | 421 | } else if (argumentArray.length === 1) { |
| | 422 | returnValue = movieElement[functionName](argumentArray[0]); |
| | 423 | } else if (argumentArray.length === 2) { |
| | 424 | returnValue = movieElement[functionName](argumentArray[0], argumentArray[1]); |
| | 425 | } else if (argumentArray.length === 3) { |
| | 426 | returnValue = movieElement[functionName](argumentArray[0], argumentArray[1], argumentArray[2]); |
| | 427 | } else { |
| | 428 | throw "Too many arguments"; |
| 363 | | /* Start the upload. If a file_id is specified that file is uploaded. Otherwise the first |
| 364 | | * file in the queue is uploaded. If no files are in the queue then nothing happens. |
| 365 | | * This call uses setTimeout since Flash will be calling back in to JavaScript |
| 366 | | */ |
| 367 | | SWFUpload.prototype.startUpload = function (file_id) { |
| 368 | | var self = this; |
| 369 | | var movie_element = this.getMovieElement(); |
| 370 | | if (movie_element !== null && typeof(movie_element.StartUpload) === "function") { |
| 371 | | setTimeout( |
| 372 | | function () { |
| 373 | | try { |
| 374 | | movie_element.StartUpload(file_id); |
| 375 | | } |
| 376 | | catch (ex) { |
| 377 | | self.debug("Could not call StartUpload: " + ex); |
| 378 | | } |
| 379 | | }, 0 |
| 380 | | ); |
| 381 | | } else { |
| 382 | | this.debug("Could not find Flash element"); |
| 383 | | } |
| 384 | | |
| | 465 | // Public: startUpload starts uploading the first file in the queue unless |
| | 466 | // the optional parameter 'fileID' specifies the ID |
| | 467 | SWFUpload.prototype.startUpload = function (fileID) { |
| | 468 | this.callFlash("StartUpload", [fileID]); |
| 449 | | SWFUpload.prototype.setStats = function (stats_object) { |
| 450 | | var movie_element = this.getMovieElement(); |
| 451 | | if (movie_element !== null && typeof(movie_element.SetStats) === "function") { |
| 452 | | try { |
| 453 | | movie_element.SetStats(stats_object); |
| 454 | | } |
| 455 | | catch (ex) { |
| 456 | | this.debug("Could not call SetStats"); |
| 457 | | } |
| 458 | | } else { |
| 459 | | this.debug("Could not find Flash element"); |
| 460 | | } |
| | 496 | |
| | 497 | // Public: setStats changes the SWFUpload statistics. You shouldn't need to |
| | 498 | // change the statistics but you can. Changing the statistics does not |
| | 499 | // affect SWFUpload accept for the successful_uploads count which is used |
| | 500 | // by the upload_limit setting to determine how many files the user may upload. |
| | 501 | SWFUpload.prototype.setStats = function (statsObject) { |
| | 502 | this.callFlash("SetStats", [statsObject]); |
| 463 | | SWFUpload.prototype.setCredentials = function(name, password) { |
| 464 | | var movie_element = this.getMovieElement(); |
| 465 | | if (movie_element !== null && typeof(movie_element.SetCredentials) === "function") { |
| 466 | | try { |
| 467 | | return movie_element.SetCredentials(name, password); |
| 468 | | } |
| 469 | | catch (ex) { |
| 470 | | this.debug("Could not call SetCredentials"); |
| 471 | | } |
| | 505 | // Public: getFile retrieves a File object by ID or Index. If the file is |
| | 506 | // not found then 'null' is returned. |
| | 507 | SWFUpload.prototype.getFile = function (fileID) { |
| | 508 | if (typeof(fileID) === "number") { |
| | 509 | return this.callFlash("GetFileByIndex", [fileID]); |
| 477 | | SWFUpload.prototype.getFile = function (file_id) { |
| 478 | | var movie_element = this.getMovieElement(); |
| 479 | | if (typeof(file_id) === "number") { |
| 480 | | if (movie_element !== null && typeof(movie_element.GetFileByIndex) === "function") { |
| 481 | | try { |
| 482 | | return movie_element.GetFileByIndex(file_id); |
| 483 | | } |
| 484 | | catch (ex) { |
| 485 | | this.debug("Could not call GetFileByIndex"); |
| 486 | | } |
| 487 | | } else { |
| 488 | | this.debug("Could not find Flash element"); |
| 489 | | } |
| 490 | | } else { |
| 491 | | if (movie_element !== null && typeof(movie_element.GetFile) === "function") { |
| 492 | | try { |
| 493 | | return movie_element.GetFile(file_id); |
| 494 | | } |
| 495 | | catch (ex) { |
| 496 | | this.debug("Could not call GetFile"); |
| 497 | | } |
| 498 | | } else { |
| 499 | | this.debug("Could not find Flash element"); |
| 500 | | } |
| 501 | | } |
| | 515 | // Public: addFileParam sets a name/value pair that will be posted with the |
| | 516 | // file specified by the Files ID. If the name already exists then the |
| | 517 | // exiting value will be overwritten. |
| | 518 | SWFUpload.prototype.addFileParam = function (fileID, name, value) { |
| | 519 | return this.callFlash("AddFileParam", [fileID, name, value]); |
| 504 | | SWFUpload.prototype.addFileParam = function (file_id, name, value) { |
| 505 | | var movie_element = this.getMovieElement(); |
| 506 | | if (movie_element !== null && typeof(movie_element.AddFileParam) === "function") { |
| 507 | | try { |
| 508 | | return movie_element.AddFileParam(file_id, name, value); |
| 509 | | } |
| 510 | | catch (ex) { |
| 511 | | this.debug("Could not call AddFileParam"); |
| 512 | | } |
| 513 | | } else { |
| 514 | | this.debug("Could not find Flash element"); |
| 515 | | } |
| | 522 | // Public: removeFileParam removes a previously set (by addFileParam) name/value |
| | 523 | // pair from the specified file. |
| | 524 | SWFUpload.prototype.removeFileParam = function (fileID, name) { |
| | 525 | this.callFlash("RemoveFileParam", [fileID, name]); |
| 518 | | SWFUpload.prototype.removeFileParam = function (file_id, name) { |
| 519 | | var movie_element = this.getMovieElement(); |
| 520 | | if (movie_element !== null && typeof(movie_element.RemoveFileParam) === "function") { |
| 521 | | try { |
| 522 | | return movie_element.RemoveFileParam(file_id, name); |
| 523 | | } |
| 524 | | catch (ex) { |
| 525 | | this.debug("Could not call AddFileParam"); |
| 526 | | } |
| 527 | | } else { |
| 528 | | this.debug("Could not find Flash element"); |
| 529 | | } |
| | 528 | // Public: setUploadUrl changes the upload_url setting. |
| | 529 | SWFUpload.prototype.setUploadURL = function (url) { |
| | 530 | this.settings.upload_url = url.toString(); |
| | 531 | this.callFlash("SetUploadURL", [url]); |
| | 532 | }; |
| 533 | | SWFUpload.prototype.setUploadURL = function (url) { |
| 534 | | var movie_element = this.getMovieElement(); |
| 535 | | if (movie_element !== null && typeof(movie_element.SetUploadURL) === "function") { |
| 536 | | try { |
| 537 | | this.addSetting("upload_url", url); |
| 538 | | movie_element.SetUploadURL(this.getSetting("upload_url")); |
| 539 | | } |
| 540 | | catch (ex) { |
| 541 | | this.debug("Could not call SetUploadURL"); |
| 542 | | } |
| 543 | | } else { |
| 544 | | this.debug("Could not find Flash element in setUploadURL"); |
| 545 | | } |
| | 540 | // Public: addPostParam adds post name/value pair. Each name can have only one value. |
| | 541 | SWFUpload.prototype.addPostParam = function (name, value) { |
| | 542 | this.settings.post_params[name] = value; |
| | 543 | this.callFlash("SetPostParams", [this.settings.post_params]); |
| 548 | | SWFUpload.prototype.setPostParams = function (param_object) { |
| 549 | | var movie_element = this.getMovieElement(); |
| 550 | | if (movie_element !== null && typeof(movie_element.SetPostParams) === "function") { |
| 551 | | try { |
| 552 | | this.addSetting("post_params", param_object); |
| 553 | | movie_element.SetPostParams(this.getSetting("post_params")); |
| 554 | | } |
| 555 | | catch (ex) { |
| 556 | | this.debug("Could not call SetPostParams"); |
| 557 | | } |
| 558 | | } else { |
| 559 | | this.debug("Could not find Flash element in SetPostParams"); |
| 560 | | } |
| | 546 | // Public: removePostParam deletes post name/value pair. |
| | 547 | SWFUpload.prototype.removePostParam = function (name) { |
| | 548 | delete this.settings.post_params[name]; |
| | 549 | this.callFlash("SetPostParams", [this.settings.post_params]); |
| 564 | | var movie_element = this.getMovieElement(); |
| 565 | | if (movie_element !== null && typeof(movie_element.SetFileTypes) === "function") { |
| 566 | | try { |
| 567 | | this.addSetting("file_types", types); |
| 568 | | this.addSetting("file_types_description", description); |
| 569 | | movie_element.SetFileTypes(this.getSetting("file_types"), this.getSetting("file_types_description")); |
| 570 | | } |
| 571 | | catch (ex) { |
| 572 | | this.debug("Could not call SetFileTypes"); |
| 573 | | } |
| 574 | | } else { |
| 575 | | this.debug("Could not find Flash element in SetFileTypes"); |
| 576 | | } |
| | 554 | this.settings.file_types = types; |
| | 555 | this.settings.file_types_description = description; |
| | 556 | this.callFlash("SetFileTypes", [types, description]); |
| 579 | | SWFUpload.prototype.setFileSizeLimit = function (file_size_limit) { |
| 580 | | var movie_element = this.getMovieElement(); |
| 581 | | if (movie_element !== null && typeof(movie_element.SetFileSizeLimit) === "function") { |
| 582 | | try { |
| 583 | | this.addSetting("file_size_limit", file_size_limit); |
| 584 | | movie_element.SetFileSizeLimit(this.getSetting("file_size_limit")); |
| 585 | | } |
| 586 | | catch (ex) { |
| 587 | | this.debug("Could not call SetFileSizeLimit"); |
| 588 | | } |
| 589 | | } else { |
| 590 | | this.debug("Could not find Flash element in SetFileSizeLimit"); |
| 591 | | } |
| | 559 | // Public: setFileSizeLimit changes the file_size_limit setting |
| | 560 | SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) { |
| | 561 | this.settings.file_size_limit = fileSizeLimit; |
| | 562 | this.callFlash("SetFileSizeLimit", [fileSizeLimit]); |
| 594 | | SWFUpload.prototype.setFileUploadLimit = function (file_upload_limit) { |
| 595 | | var movie_element = this.getMovieElement(); |
| 596 | | if (movie_element !== null && typeof(movie_element.SetFileUploadLimit) === "function") { |
| 597 | | try { |
| 598 | | this.addSetting("file_upload_limit", file_upload_limit); |
| 599 | | movie_element.SetFileUploadLimit(this.getSetting("file_upload_limit")); |
| 600 | | } |
| 601 | | catch (ex) { |
| 602 | | this.debug("Could not call SetFileUploadLimit"); |
| 603 | | } |
| 604 | | } else { |
| 605 | | this.debug("Could not find Flash element in SetFileUploadLimit"); |
| 606 | | } |
| | 565 | // Public: setFileUploadLimit changes the file_upload_limit setting |
| | 566 | SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) { |
| | 567 | this.settings.file_upload_limit = fileUploadLimit; |
| | 568 | this.callFlash("SetFileUploadLimit", [fileUploadLimit]); |
| 609 | | SWFUpload.prototype.setFileQueueLimit = function (file_queue_limit) { |
| 610 | | var movie_element = this.getMovieElement(); |
| 611 | | if (movie_element !== null && typeof(movie_element.SetFileQueueLimit) === "function") { |
| 612 | | try { |
| 613 | | this.addSetting("file_queue_limit", file_queue_limit); |
| 614 | | movie_element.SetFileQueueLimit(this.getSetting("file_queue_limit")); |
| 615 | | } |
| 616 | | catch (ex) { |
| 617 | | this.debug("Could not call SetFileQueueLimit"); |
| 618 | | } |
| 619 | | } else { |
| 620 | | this.debug("Could not find Flash element in SetFileQueueLimit"); |
| 621 | | } |
| | 571 | // Public: setFileQueueLimit changes the file_queue_limit setting |
| | 572 | SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) { |
| | 573 | this.settings.file_queue_limit = fileQueueLimit; |
| | 574 | this.callFlash("SetFileQueueLimit", [fileQueueLimit]); |
| 624 | | SWFUpload.prototype.setFilePostName = function (file_post_name) { |
| 625 | | var movie_element = this.getMovieElement(); |
| 626 | | if (movie_element !== null && typeof(movie_element.SetFilePostName) === "function") { |
| 627 | | try { |
| 628 | | this.addSetting("file_post_name", file_post_name); |
| 629 | | movie_element.SetFilePostName(this.getSetting("file_post_name")); |
| 630 | | } |
| 631 | | catch (ex) { |
| 632 | | this.debug("Could not call SetFilePostName"); |
| 633 | | } |
| 634 | | } else { |
| 635 | | this.debug("Could not find Flash element in SetFilePostName"); |
| 636 | | } |
| | 577 | // Public: setFilePostName changes the file_post_name setting |
| | 578 | SWFUpload.prototype.setFilePostName = function (filePostName) { |
| | 579 | this.settings.file_post_name = filePostName; |
| | 580 | this.callFlash("SetFilePostName", [filePostName]); |
| 639 | | SWFUpload.prototype.setDebugEnabled = function (debug_enabled) { |
| 640 | | var movie_element = this.getMovieElement(); |
| 641 | | if (movie_element !== null && typeof(movie_element.SetDebugEnabled) === "function") { |
| 642 | | try { |
| 643 | | this.addSetting("debug_enabled", debug_enabled); |
| 644 | | movie_element.SetDebugEnabled(this.getSetting("debug_enabled")); |
| 645 | | } |
| 646 | | catch (ex) { |
| 647 | | this.debug("Could not call SetDebugEnabled"); |
| 648 | | } |
| 649 | | } else { |
| 650 | | this.debug("Could not find Flash element in SetDebugEnabled"); |
| 651 | | } |
| | 583 | // Public: setUseQueryString changes the use_query_string setting |
| | 584 | SWFUpload.prototype.setUseQueryString = function (useQueryString) { |
| | 585 | this.settings.use_query_string = useQueryString; |
| | 586 | this.callFlash("SetUseQueryString", [useQueryString]); |
| 654 | | /* ******************************* |
| 655 | | Internal Event Callers |
| 656 | | Don't override these! These event callers ensure that your custom event handlers |
| 657 | | are called safely and in order. |
| 658 | | ******************************* */ |
| 659 | | |
| 660 | | /* This is the callback method that the Flash movie will call when it has been loaded and is ready to go. |
| 661 | | Calling this or showUI() "manually" will bypass the Flash Detection built in to SWFUpload. |
| 662 | | Use a ui_function setting if you want to control the UI loading after the flash has loaded. |
| 663 | | */ |
| 664 | | SWFUpload.prototype.flashReady = function () { |
| 665 | | // Check that the movie element is loaded correctly with its ExternalInterface methods defined |
| 666 | | var movie_element = this.getMovieElement(); |
| 667 | | if (movie_element === null || typeof(movie_element.StartUpload) !== "function") { |
| 668 | | this.debug("ExternalInterface methods failed to initialize."); |
| 669 | | return; |
| 670 | | } |
| 671 | | |
| 672 | | var self = this; |
| 673 | | if (typeof(self.flashReady_handler) === "function") { |
| 674 | | this.eventQueue[this.eventQueue.length] = function() { self.flashReady_handler(); }; |
| 675 | | setTimeout(function () { self.executeNextEvent();}, 0); |
| 676 | | } else { |
| 677 | | this.debug("flashReady_handler event not defined"); |
| 678 | | } |
| | 589 | // Public: setRequeueOnError changes the requeue_on_error setting |
| | 590 | SWFUpload.prototype.setRequeueOnError = function (requeueOnError) { |
| | 591 | this.settings.requeue_on_error = requeueOnError; |
| | 592 | this.callFlash("SetRequeueOnError", [requeueOnError]); |
| 681 | | /* |
| 682 | | Event Queue. Rather can call events directly from Flash they events are |
| 683 | | are placed in a queue and then executed. This ensures that each event is |
| 684 | | executed in the order it was called which is not guarenteed when calling |
| 685 | | setTimeout. Out of order events was especially problematic in Safari. |
| 686 | | */ |
| 687 | | SWFUpload.prototype.executeNextEvent = function () { |
| 688 | | var f = this.eventQueue.shift(); |
| 689 | | if (typeof(f) === "function") { |
| 690 | | f(); |
| 691 | | } |
| 692 | | } |
| 693 | | |
| 694 | | /* This is a chance to do something before the browse window opens */ |
| 695 | | SWFUpload.prototype.fileDialogStart = function () { |
| 696 | | var self = this; |
| 697 | | if (typeof(self.fileDialogStart_handler) === "function") { |
| 698 | | this.eventQueue[this.eventQueue.length] = function() { self.fileDialogStart_handler(); }; |
| 699 | | setTimeout(function () { self.executeNextEvent();}, 0); |
| 700 | | } else { |
| 701 | | this.debug("fileDialogStart event not defined"); |
| 702 | | } |
| | 595 | // Public: setDebugEnabled changes the debug_enabled setting |
| | 596 | SWFUpload.prototype.setDebugEnabled = function (debugEnabled) { |
| | 597 | this.settings.debug_enabled = debugEnabled; |
| | 598 | this.callFlash("SetDebugEnabled", [debugEnabled]); |
| 717 | | |
| 718 | | /* Handle errors that occur when an attempt to queue a file fails. */ |
| 719 | | SWFUpload.prototype.fileQueueError = function (file, error_code, message) { |
| 720 | | var self = this; |
| 721 | | if (typeof(self.fileQueueError_handler) === "function") { |
| 722 | | this.eventQueue[this.eventQueue.length] = function() { self.fileQueueError_handler(file, error_code, message); }; |
| 723 | | setTimeout(function () { self.executeNextEvent();}, 0); |
| 724 | | } else { |
| 725 | | this.debug("fileQueueError event not defined"); |
| | 611 | // Public: setButtonDimensions resizes the Flash Movie and button |
| | 612 | SWFUpload.prototype.setButtonDimensions = function (width, height) { |
| | 613 | this.settings.button_width = width; |
| | 614 | this.settings.button_height = height; |
| | 615 | |
| | 616 | var movie = this.getMovieElement(); |
| | 617 | if (movie != undefined) { |
| | 618 | movie.style.width = width + "px"; |
| | 619 | movie.style.height = height + "px"; |
| | 624 | // Public: setButtonText Changes the text overlaid on the button |
| | 625 | SWFUpload.prototype.setButtonText = function (html) { |
| | 626 | this.settings.button_text = html; |
| | 627 | this.callFlash("SetButtonText", [html]); |
| | 628 | }; |
| | 629 | // Public: setButtonTextPadding changes the top and left padding of the text overlay |
| | 630 | SWFUpload.prototype.setButtonTextPadding = function (left, top) { |
| | 631 | this.settings.button_text_top_padding = top; |
| | 632 | this.settings.button_text_left_padding = left; |
| | 633 | this.callFlash("SetButtonTextPadding", [left, top]); |
| | 634 | }; |
| 729 | | /* Called after the file dialog has closed and the selected files have been queued. |
| 730 | | You could call startUpload here if you want the queued files to begin uploading immediately. */ |
| 731 | | SWFUpload.prototype.fileDialogComplete = function (num_files_selected) { |
| 732 | | var self = this; |
| 733 | | if (typeof(self.fileDialogComplete_handler) === "function") { |
| 734 | | this.eventQueue[this.eventQueue.length] = function() { self.fileDialogComplete_handler(num_files_selected); }; |
| 735 | | setTimeout(function () { self.executeNextEvent();}, 0); |
| 736 | | } else { |
| 737 | | this.debug("fileDialogComplete event not defined"); |
| 738 | | } |
| | 636 | // Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button |
| | 637 | SWFUpload.prototype.setButtonTextStyle = function (css) { |
| | 638 | this.settings.button_text_style = css; |
| | 639 | this.callFlash("SetButtonTextStyle", [css]); |
| 744 | | This is a good place to do any file validation you need. |
| 745 | | */ |
| 746 | | SWFUpload.prototype.uploadStart = function (file) { |
| | 657 | All these functions a Private. |
| | 658 | |
| | 659 | Because the ExternalInterface library is buggy the event calls |
| | 660 | are added to a queue and the queue then executed by a setTimeout. |
| | 661 | This ensures that events are executed in a determinate order and that |
| | 662 | the ExternalInterface bugs are avoided. |
| | 663 | ******************************* */ |
| | 664 | |
| | 665 | SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) { |
| | 666 | // Warning: Don't call this.debug inside here or you'll create an infinite loop |
| | 667 | |
| | 668 | if (argumentArray == undefined) { |
| | 669 | argumentArray = []; |
| | 670 | } else if (!(argumentArray instanceof Array)) { |
| | 671 | argumentArray = [argumentArray]; |
| | 672 | } |
| | 673 | |
| 748 | | if (typeof(self.fileDialogComplete_handler) === "function") { |
| 749 | | this.eventQueue[this.eventQueue.length] = function() { self.returnUploadStart(self.uploadStart_handler(file)); }; |
| 750 | | setTimeout(function () { self.executeNextEvent();}, 0); |
| 751 | | } else { |
| 752 | | this.debug("uploadStart event not defined"); |
| | 675 | if (typeof this.settings[handlerName] === "function") { |
| | 676 | // Queue the event |
| | 677 | this.eventQueue.push(function () { |
| | 678 | this.settings[handlerName].apply(this, argumentArray); |
| | 679 | }); |
| | 680 | |
| | 681 | // Execute the next queued event |
| | 682 | setTimeout(function () { |
| | 683 | self.executeNextEvent(); |
| | 684 | }, 0); |
| | 685 | |
| | 686 | } else if (this.settings[handlerName] !== null) { |
| | 687 | throw "Event handler " + handlerName + " is unknown or is not a function"; |
| 756 | | /* Note: Internal use only. This function returns the result of uploadStart to |
| 757 | | flash. Since returning values in the normal way can result in Flash/JS circular |
| 758 | | call issues we split up the call in a Timeout. This is transparent from the API |
| 759 | | point of view. |
| 760 | | */ |
| 761 | | SWFUpload.prototype.returnUploadStart = function (return_value) { |
| 762 | | var movie_element = this.getMovieElement(); |
| 763 | | if (movie_element !== null && typeof(movie_element.ReturnUploadStart) === "function") { |
| 764 | | try { |
| 765 | | movie_element.ReturnUploadStart(return_value); |
| 766 | | } |
| 767 | | catch (ex) { |
| 768 | | this.debug("Could not call ReturnUploadStart"); |
| 769 | | } |
| 770 | | } else { |
| 771 | | this.debug("Could not find Flash element in returnUploadStart"); |
| | 691 | // Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout |
| | 692 | // we must queue them in order to garentee that they are executed in order. |
| | 693 | SWFUpload.prototype.executeNextEvent = function () { |
| | 694 | // Warning: Don't call this.debug inside here or you'll create an infinite loop |
| | 695 | |
| | 696 | var f = this.eventQueue ? this.eventQueue.shift() : null; |
| | 697 | if (typeof(f) === "function") { |
| | 698 | f.apply(this); |
| 788 | | /* Called when an error occurs during an upload. Use error_code and the SWFUpload.UPLOAD_ERROR constants to determine |
| 789 | | which error occurred. The uploadComplete event is called after an error code indicating that the next file is |
| 790 | | ready for upload. For files cancelled out of order the uploadComplete event will not be called. */ |
| 791 | | SWFUpload.prototype.uploadError = function (file, error_code, message) { |
| 792 | | var self = this; |
| 793 | | if (typeof(this.uploadError_handler) === "function") { |
| 794 | | this.eventQueue[this.eventQueue.length] = function() { self.uploadError_handler(file, error_code, message); }; |
| 795 | | setTimeout(function () { self.executeNextEvent();}, 0); |
| 796 | | } else { |
| 797 | | this.debug("uploadError event not defined"); |
| 798 | | } |
| | 725 | return file; |
| 801 | | /* This gets called when a file finishes uploading and the server-side upload script has completed and returned a 200 |
| 802 | | status code. Any text returned by the server is available in server_data. |
| 803 | | **NOTE: The upload script MUST return some text or the uploadSuccess and uploadComplete events will not fire and the |
| 804 | | upload will become 'stuck'. */ |
| 805 | | SWFUpload.prototype.uploadSuccess = function (file, server_data) { |
| 806 | | var self = this; |
| 807 | | if (typeof(self.uploadSuccess_handler) === "function") { |
| 808 | | this.eventQueue[this.eventQueue.length] = function() { self.uploadSuccess_handler(file, server_data); }; |
| 809 | | setTimeout(function () { self.executeNextEvent();}, 0); |
| 810 | | } else { |
| 811 | | this.debug("uploadSuccess event not defined"); |
| | 728 | SWFUpload.prototype.flashReady = function () { |
| | 729 | // Check that the movie element is loaded correctly with its ExternalInterface methods defined |
| | 730 | var movieElement = this.getMovieElement(); |
| | 731 | if (typeof movieElement.StartUpload !== "function") { |
| | 732 | throw "ExternalInterface methods failed to initialize."; |
| 825 | | }; |
| 826 | | |
| 827 | | /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the |
| 828 | | internal debug console. You can override this event and have messages written where you want. */ |
| 829 | | SWFUpload.prototype.debug = function (message) { |
| 830 | | var self = this; |
| 831 | | if (typeof(self.debug_handler) === "function") { |
| 832 | | this.eventQueue[this.eventQueue.length] = function() { self.debug_handler(message); }; |
| 833 | | setTimeout(function () { self.executeNextEvent();}, 0); |
| 834 | | } else { |
| 835 | | this.eventQueue[this.eventQueue.length] = function() { self.debugMessage(message); }; |
| 836 | | setTimeout(function () { self.executeNextEvent();}, 0); |
| 837 | | } |
| 838 | | }; |
| 839 | | |
| 840 | | |
| 841 | | /* ********************************** |
| 842 | | Default Event Handlers. |
| 843 | | These event handlers are used by default if an overriding handler is |
| 844 | | not defined in the SWFUpload settings object. |
| 846 | | JS Note: even though these are defined on the SWFUpload object (rather than the prototype) they |
| 847 | | are attached (read: copied) to a SWFUpload instance and 'this' is given the proper context. |
| 848 | | ********************************** */ |
| 849 | | |
| 850 | | /* This is a special event handler that has no override in the settings. Flash calls this when it has |
| 851 | | been loaded by the browser and is ready for interaction. You should not override it. If you need |
| 852 | | to do something with SWFUpload has loaded then use the swfupload_loaded_handler setting. |
| 853 | | */ |
| 854 | | SWFUpload.flashReady = function () { |
| 855 | | try { |
| 856 | | this.debug("Flash called back and is ready."); |
| 857 | | |
| 858 | | if (typeof(this.swfUploadLoaded_handler) === "function") { |
| 859 | | this.swfUploadLoaded_handler(); |
| 860 | | } |
| 861 | | } catch (ex) { |
| 862 | | this.debug(ex); |
| 863 | | } |
| | 740 | this.queueEvent("swfupload_loaded_handler"); |
| 882 | | SWFUpload.fileQueueError = function (file, error_code, message) { |
| 883 | | try { |
| 884 | | switch (error_code) { |
| 885 | | case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: |
| 886 | | this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); |
| 887 | | break; |
| 888 | | case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: |
| 889 | | this.debug("Error Code: Zero Byte File, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); |
| 890 | | break; |
| 891 | | case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED: |
| 892 | | this.debug("Error Code: Upload limit reached, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); |
| 893 | | break; |
| 894 | | case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: |
| 895 | | this.debug("Error Code: File extension is not allowed, Message: " + message); |
| 896 | | break; |
| 897 | | default: |
| 898 | | this.debug("Error Code: Unhandled error occured. Errorcode: " + error_code); |
| 899 | | } |
| 900 | | } catch (ex) { |
| 901 | | this.debug(ex); |
| 902 | | } |
| | 758 | SWFUpload.prototype.fileQueueError = function (file, errorCode, message) { |
| | 759 | file = this.unescapeFilePostParams(file); |
| | 760 | this.queueEvent("file_queue_error_handler", [file, errorCode, message]); |
| 910 | | /* Gets called when a file upload is about to be started. Return true to continue the upload. Return false to stop the upload. |
| 911 | | If you return false then the uploadError callback is called and then uploadComplete (like normal). |
| | 769 | SWFUpload.prototype.uploadStart = function (file) { |
| | 770 | file = this.unescapeFilePostParams(file); |
| | 771 | this.queueEvent("return_upload_start_handler", file); |
| | 772 | }; |
| | 773 | |
| | 774 | SWFUpload.prototype.returnUploadStart = function (file) { |
| | 775 | var returnValue; |
| | 776 | if (typeof this.settings.upload_start_handler === "function") { |
| | 777 | file = this.unescapeFilePostParams(file); |
| | 778 | returnValue = this.settings.upload_start_handler.call(this, file); |
| | 779 | } else if (this.settings.upload_start_handler != undefined) { |
| | 780 | throw "upload_start_handler must be a function"; |
| | 781 | } |
| | 782 | |
| | 783 | // Convert undefined to true so if nothing is returned from the upload_start_handler it is |
| | 784 | // interpretted as 'true'. |
| | 785 | if (returnValue === undefined) { |
| | 786 | returnValue = true; |
| | 787 | } |
| 928 | | /* This gets called when a file finishes uploading and the upload script has completed and returned a 200 status code. Any text returned by the |
| 929 | | server is available in server_data. The upload script must return some text or uploadSuccess will not fire (neither will uploadComplete). */ |
| 930 | | SWFUpload.uploadSuccess = function (file, server_data) { |
| 931 | | this.debug("Upload Success: " + file.id + ", Server: " + server_data); |
| | 801 | SWFUpload.prototype.uploadError = function (file, errorCode, message) { |
| | 802 | file = this.unescapeFilePostParams(file); |
| | 803 | this.queueEvent("upload_error_handler", [file, errorCode, message]); |
| 949 | | /* Called when an upload occurs during upload. For HTTP errors 'message' will contain the HTTP STATUS CODE */ |
| 950 | | SWFUpload.uploadError = function (file, errcode, msg) { |
| 951 | | try { |
| 952 | | switch (errcode) { |
| 953 | | case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND: |
| 954 | | this.debug("Error Code: File ID specified for upload was not found, Message: " + msg); |
| 955 | | break; |
| 956 | | case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: |
| 957 | | this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + msg); |
| 958 | | break; |
| 959 | | case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL: |
| 960 | | this.debug("Error Code: No backend file, File name: " + file.name + ", Message: " + msg); |
| 961 | | break; |
| 962 | | case SWFUpload.UPLOAD_ERROR.IO_ERROR: |
| 963 | | this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + msg); |
| 964 | | break; |
| 965 | | case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: |
| 966 | | this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + msg); |
| 967 | | break; |
| 968 | | case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: |
| 969 | | this.debug("Error Code: Upload limit reached, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); |
| 970 | | break; |
| 971 | | case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: |
| 972 | | this.debug("Error Code: Upload Initialization exception, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); |
| 973 | | break; |
| 974 | | case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: |
| 975 | | this.debug("Error Code: uploadStart callback returned false, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); |
| 976 | | break; |
| 977 | | case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: |
| 978 | | this.debug("Error Code: The file upload was cancelled, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); |
| 979 | | break; |
| 980 | | case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: |
| 981 | | this.debug("Error Code: The file upload was stopped, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); |
| 982 | | break; |
| 983 | | default: |
| 984 | | this.debug("Error Code: Unhandled error occured. Errorcode: " + errcode); |
| 985 | | } |
| 986 | | } catch (ex) { |
| 987 | | this.debug(ex); |
| 988 | | } |
| | 816 | /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the |
| | 817 | internal debug console. You can override this event and have messages written where you want. */ |
| | 818 | SWFUpload.prototype.debug = function (message) { |
| | 819 | this.queueEvent("debug_handler", message); |
| 1007 | | if (typeof(message) === "object" && typeof(message.name) === "string" && typeof(message.message) === "string") { |
| 1008 | | exception_message = ""; |
| 1009 | | exception_values = []; |
| 1010 | | for (var key in message) { |
| 1011 | | exception_values.push(key + ": " + message[key]); |
| | 843 | // Check for an exception object and print it nicely |
| | 844 | if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") { |
| | 845 | for (var key in message) { |
| | 846 | if (message.hasOwnProperty(key)) { |
| | 847 | exceptionValues.push(key + ": " + message[key]); |
| | 848 | } |
| | 849 | } |
| | 850 | exceptionMessage = exceptionValues.join("\n") || ""; |
| | 851 | exceptionValues = exceptionMessage.split("\n"); |
| | 852 | exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: "); |
| | 853 | SWFUpload.Console.writeLine(exceptionMessage); |
| | 854 | } else { |
| | 855 | SWFUpload.Console.writeLine(message); |