PageRenderTime 59ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/static/js/upload.js

https://github.com/jinbo51/DiscuzX
JavaScript | 1665 lines | 1401 code | 258 blank | 6 comment | 262 complexity | 7194b4d171afa375109266169e2389b6 MD5 | raw file
Possible License(s): BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. [Discuz!] (C)2001-2099 Comsenz Inc.
  3. This is NOT a freeware, use is subject to license terms
  4. $Id: swfupload.js 28981 2012-03-21 06:43:44Z zhengqingpeng $
  5. */
  6. var SWFUpload;
  7. var swfobject;
  8. if (SWFUpload == undefined) {
  9. SWFUpload = function (settings) {
  10. this.initSWFUpload(settings);
  11. };
  12. }
  13. SWFUpload.prototype.initSWFUpload = function (userSettings) {
  14. try {
  15. this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
  16. this.settings = {};
  17. this.eventQueue = [];
  18. this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
  19. this.movieElement = null;
  20. SWFUpload.instances[this.movieName] = this;
  21. this.initSettings(userSettings);
  22. this.loadSupport();
  23. if (this.swfuploadPreload()) {
  24. this.loadFlash();
  25. }
  26. this.displayDebugInfo();
  27. } catch (ex) {
  28. delete SWFUpload.instances[this.movieName];
  29. throw ex;
  30. }
  31. };
  32. SWFUpload.instances = {};
  33. SWFUpload.movieCount = 0;
  34. SWFUpload.version = "2.5.0 2010-01-15 Beta 2";
  35. SWFUpload.QUEUE_ERROR = {
  36. QUEUE_LIMIT_EXCEEDED : -100,
  37. FILE_EXCEEDS_SIZE_LIMIT : -110,
  38. ZERO_BYTE_FILE : -120,
  39. INVALID_FILETYPE : -130
  40. };
  41. SWFUpload.UPLOAD_ERROR = {
  42. HTTP_ERROR : -200,
  43. MISSING_UPLOAD_URL : -210,
  44. IO_ERROR : -220,
  45. SECURITY_ERROR : -230,
  46. UPLOAD_LIMIT_EXCEEDED : -240,
  47. UPLOAD_FAILED : -250,
  48. SPECIFIED_FILE_ID_NOT_FOUND : -260,
  49. FILE_VALIDATION_FAILED : -270,
  50. FILE_CANCELLED : -280,
  51. UPLOAD_STOPPED : -290,
  52. RESIZE : -300
  53. };
  54. SWFUpload.FILE_STATUS = {
  55. QUEUED : -1,
  56. IN_PROGRESS : -2,
  57. ERROR : -3,
  58. COMPLETE : -4,
  59. CANCELLED : -5
  60. };
  61. SWFUpload.UPLOAD_TYPE = {
  62. NORMAL : -1,
  63. RESIZED : -2
  64. };
  65. SWFUpload.BUTTON_ACTION = {
  66. SELECT_FILE : -100,
  67. SELECT_FILES : -110,
  68. START_UPLOAD : -120,
  69. JAVASCRIPT : -130, // DEPRECATED
  70. NONE : -130
  71. };
  72. SWFUpload.CURSOR = {
  73. ARROW : -1,
  74. HAND : -2
  75. };
  76. SWFUpload.WINDOW_MODE = {
  77. WINDOW : "window",
  78. TRANSPARENT : "transparent",
  79. OPAQUE : "opaque"
  80. };
  81. SWFUpload.RESIZE_ENCODING = {
  82. JPEG : -1,
  83. PNG : -2
  84. };
  85. SWFUpload.completeURL = function (url) {
  86. try {
  87. var path = "", indexSlash = -1;
  88. if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//) || url === "") {
  89. return url;
  90. }
  91. indexSlash = window.location.pathname.lastIndexOf("/");
  92. if (indexSlash <= 0) {
  93. path = "/";
  94. } else {
  95. path = window.location.pathname.substr(0, indexSlash) + "/";
  96. }
  97. return path + url;
  98. } catch (ex) {
  99. return url;
  100. }
  101. };
  102. SWFUpload.onload = function () {};
  103. SWFUpload.prototype.initSettings = function (userSettings) {
  104. this.ensureDefault = function (settingName, defaultValue) {
  105. var setting = userSettings[settingName];
  106. if (setting != undefined) {
  107. this.settings[settingName] = setting;
  108. } else {
  109. this.settings[settingName] = defaultValue;
  110. }
  111. };
  112. this.ensureDefault("upload_url", "");
  113. this.ensureDefault("preserve_relative_urls", false);
  114. this.ensureDefault("file_post_name", "Filedata");
  115. this.ensureDefault("post_params", {});
  116. this.ensureDefault("use_query_string", false);
  117. this.ensureDefault("requeue_on_error", false);
  118. this.ensureDefault("http_success", []);
  119. this.ensureDefault("assume_success_timeout", 0);
  120. this.ensureDefault("file_types", "*.*");
  121. this.ensureDefault("file_types_description", "All Files");
  122. this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
  123. this.ensureDefault("file_upload_limit", 0);
  124. this.ensureDefault("file_queue_limit", 0);
  125. this.ensureDefault("flash_url", IMGDIR+"/swfupload.swf");
  126. this.ensureDefault("flash9_url", IMGDIR+"/swfupload.swf");
  127. this.ensureDefault("prevent_swf_caching", true);
  128. this.ensureDefault("button_image_url", "");
  129. this.ensureDefault("button_width", 1);
  130. this.ensureDefault("button_height", 1);
  131. this.ensureDefault("button_text", "");
  132. this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
  133. this.ensureDefault("button_text_top_padding", 0);
  134. this.ensureDefault("button_text_left_padding", 0);
  135. this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
  136. this.ensureDefault("button_disabled", false);
  137. this.ensureDefault("button_placeholder_id", "");
  138. this.ensureDefault("button_placeholder", null);
  139. this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
  140. this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
  141. this.ensureDefault("debug", false);
  142. this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
  143. this.settings.return_upload_start_handler = this.returnUploadStart;
  144. this.ensureDefault("swfupload_preload_handler", null);
  145. this.ensureDefault("swfupload_load_failed_handler", null);
  146. this.ensureDefault("swfupload_loaded_handler", null);
  147. this.ensureDefault("file_dialog_start_handler", null);
  148. this.ensureDefault("file_queued_handler", null);
  149. this.ensureDefault("file_queue_error_handler", null);
  150. this.ensureDefault("file_dialog_complete_handler", null);
  151. this.ensureDefault("upload_resize_start_handler", null);
  152. this.ensureDefault("upload_start_handler", null);
  153. this.ensureDefault("upload_progress_handler", null);
  154. this.ensureDefault("upload_error_handler", null);
  155. this.ensureDefault("upload_success_handler", null);
  156. this.ensureDefault("upload_complete_handler", null);
  157. this.ensureDefault("mouse_click_handler", null);
  158. this.ensureDefault("mouse_out_handler", null);
  159. this.ensureDefault("mouse_over_handler", null);
  160. this.ensureDefault("debug_handler", this.debugMessage);
  161. this.ensureDefault("custom_settings", {});
  162. this.customSettings = this.settings.custom_settings;
  163. if (!!this.settings.prevent_swf_caching) {
  164. this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
  165. this.settings.flash9_url = this.settings.flash9_url + (this.settings.flash9_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
  166. }
  167. if (!this.settings.preserve_relative_urls) {
  168. this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
  169. this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
  170. }
  171. delete this.ensureDefault;
  172. };
  173. SWFUpload.prototype.loadSupport = function () {
  174. this.support = {
  175. loading : swfobject.hasFlashPlayerVersion("9.0.28"),
  176. imageResize : false
  177. };
  178. };
  179. SWFUpload.prototype.loadFlash = function () {
  180. var targetElement, tempParent, wrapperType, flashHTML, els;
  181. if (!this.support.loading) {
  182. this.queueEvent("swfupload_load_failed_handler", ["Flash Player doesn't support SWFUpload"]);
  183. return;
  184. }
  185. if (document.getElementById(this.movieName) !== null) {
  186. this.support.loading = false;
  187. this.queueEvent("swfupload_load_failed_handler", ["Element ID already in use"]);
  188. return;
  189. }
  190. targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
  191. if (targetElement == undefined) {
  192. this.support.loading = false;
  193. this.queueEvent("swfupload_load_failed_handler", ["button place holder not found"]);
  194. return;
  195. }
  196. wrapperType = (targetElement.currentStyle && targetElement.currentStyle["display"] || window.getComputedStyle && document.defaultView.getComputedStyle(targetElement, null).getPropertyValue("display")) !== "block" ? "span" : "div";
  197. tempParent = document.createElement(wrapperType);
  198. flashHTML = this.getFlashHTML();
  199. try {
  200. tempParent.innerHTML = flashHTML; // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
  201. } catch (ex) {
  202. this.support.loading = false;
  203. this.queueEvent("swfupload_load_failed_handler", ["Exception loading Flash HTML into placeholder"]);
  204. return;
  205. }
  206. els = tempParent.getElementsByTagName("object");
  207. if (!els || els.length > 1 || els.length === 0) {
  208. this.support.loading = false;
  209. this.queueEvent("swfupload_load_failed_handler", ["Unable to find movie after adding to DOM"]);
  210. return;
  211. } else if (els.length === 1) {
  212. this.movieElement = els[0];
  213. }
  214. targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
  215. if (window[this.movieName] == undefined) {
  216. window[this.movieName] = this.getMovieElement();
  217. }
  218. };
  219. SWFUpload.prototype.getFlashHTML = function (flashVersion) {
  220. if(BROWSER.ie && !BROWSER.opera) {
  221. return AC_FL_RunContent('id', this.movieName, 'width', this.settings.button_width, 'height', this.settings.button_height, 'src', this.settings.flash_url, 'quality', 'high', 'wmode', this.settings.button_window_mode, 'flashvars', this.getFlashVars(), 'AllowScriptAccess', 'always');
  222. } else {
  223. return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', (this.support.imageResize ? this.settings.flash_url : this.settings.flash9_url), '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
  224. '<param name="wmode" value="', this.settings.button_window_mode, '" />',
  225. '<param name="movie" value="', (this.support.imageResize ? this.settings.flash_url : this.settings.flash9_url), '" />',
  226. '<param name="quality" value="high" />',
  227. '<param name="allowScriptAccess" value="always" />',
  228. '<param name="flashvars" value="' + this.getFlashVars() + '" />',
  229. '</object>'].join("");
  230. }
  231. };
  232. SWFUpload.prototype.getFlashVars = function () {
  233. var httpSuccessString, paramString;
  234. paramString = this.buildParamString();
  235. httpSuccessString = this.settings.http_success.join(",");
  236. return ["movieName=", encodeURIComponent(this.movieName),
  237. "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
  238. "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
  239. "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
  240. "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
  241. "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
  242. "&amp;params=", encodeURIComponent(paramString),
  243. "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
  244. "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
  245. "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
  246. "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
  247. "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
  248. "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
  249. "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
  250. "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
  251. "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
  252. "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
  253. "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
  254. "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
  255. "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
  256. "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
  257. "&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
  258. "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
  259. "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
  260. ].join("");
  261. };
  262. SWFUpload.prototype.getMovieElement = function () {
  263. if (this.movieElement == undefined) {
  264. this.movieElement = document.getElementById(this.movieName);
  265. }
  266. if (this.movieElement === null) {
  267. throw "Could not find Flash element";
  268. }
  269. return this.movieElement;
  270. };
  271. SWFUpload.prototype.buildParamString = function () {
  272. var name, postParams, paramStringPairs = [];
  273. postParams = this.settings.post_params;
  274. if (typeof(postParams) === "object") {
  275. for (name in postParams) {
  276. if (postParams.hasOwnProperty(name)) {
  277. paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
  278. }
  279. }
  280. }
  281. return paramStringPairs.join("&amp;");
  282. };
  283. SWFUpload.prototype.destroy = function () {
  284. var movieElement;
  285. try {
  286. this.cancelUpload(null, false);
  287. movieElement = this.cleanUp();
  288. if (movieElement) {
  289. try {
  290. movieElement.parentNode.removeChild(movieElement);
  291. } catch (ex) {}
  292. }
  293. window[this.movieName] = null;
  294. SWFUpload.instances[this.movieName] = null;
  295. delete SWFUpload.instances[this.movieName];
  296. this.movieElement = null;
  297. this.settings = null;
  298. this.customSettings = null;
  299. this.eventQueue = null;
  300. this.movieName = null;
  301. return true;
  302. } catch (ex2) {
  303. return false;
  304. }
  305. };
  306. SWFUpload.prototype.displayDebugInfo = function () {
  307. this.debug(
  308. [
  309. "---SWFUpload Instance Info---\n",
  310. "Version: ", SWFUpload.version, "\n",
  311. "Movie Name: ", this.movieName, "\n",
  312. "Settings:\n",
  313. "\t", "upload_url: ", this.settings.upload_url, "\n",
  314. "\t", "flash_url: ", this.settings.flash_url, "\n",
  315. "\t", "flash9_url: ", this.settings.flash9_url, "\n",
  316. "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
  317. "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
  318. "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
  319. "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
  320. "\t", "file_post_name: ", this.settings.file_post_name, "\n",
  321. "\t", "post_params: ", this.settings.post_params.toString(), "\n",
  322. "\t", "file_types: ", this.settings.file_types, "\n",
  323. "\t", "file_types_description: ", this.settings.file_types_description, "\n",
  324. "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
  325. "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
  326. "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
  327. "\t", "debug: ", this.settings.debug.toString(), "\n",
  328. "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
  329. "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
  330. "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
  331. "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
  332. "\t", "button_width: ", this.settings.button_width.toString(), "\n",
  333. "\t", "button_height: ", this.settings.button_height.toString(), "\n",
  334. "\t", "button_text: ", this.settings.button_text.toString(), "\n",
  335. "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
  336. "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
  337. "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
  338. "\t", "button_action: ", this.settings.button_action.toString(), "\n",
  339. "\t", "button_cursor: ", this.settings.button_cursor.toString(), "\n",
  340. "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
  341. "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
  342. "Event Handlers:\n",
  343. "\t", "swfupload_preload_handler assigned: ", (typeof this.settings.swfupload_preload_handler === "function").toString(), "\n",
  344. "\t", "swfupload_load_failed_handler assigned: ", (typeof this.settings.swfupload_load_failed_handler === "function").toString(), "\n",
  345. "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
  346. "\t", "mouse_click_handler assigned: ", (typeof this.settings.mouse_click_handler === "function").toString(), "\n",
  347. "\t", "mouse_over_handler assigned: ", (typeof this.settings.mouse_over_handler === "function").toString(), "\n",
  348. "\t", "mouse_out_handler assigned: ", (typeof this.settings.mouse_out_handler === "function").toString(), "\n",
  349. "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
  350. "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
  351. "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
  352. "\t", "upload_resize_start_handler assigned: ", (typeof this.settings.upload_resize_start_handler === "function").toString(), "\n",
  353. "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
  354. "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
  355. "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
  356. "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
  357. "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
  358. "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n",
  359. "Support:\n",
  360. "\t", "Load: ", (this.support.loading ? "Yes" : "No"), "\n",
  361. "\t", "Image Resize: ", (this.support.imageResize ? "Yes" : "No"), "\n"
  362. ].join("")
  363. );
  364. };
  365. SWFUpload.prototype.addSetting = function (name, value, default_value) {
  366. if (value == undefined) {
  367. return (this.settings[name] = default_value);
  368. } else {
  369. return (this.settings[name] = value);
  370. }
  371. };
  372. SWFUpload.prototype.getSetting = function (name) {
  373. if (this.settings[name] != undefined) {
  374. return this.settings[name];
  375. }
  376. return "";
  377. };
  378. SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
  379. var movieElement, returnValue, returnString;
  380. argumentArray = argumentArray || [];
  381. movieElement = this.getMovieElement();
  382. try {
  383. if (movieElement != undefined) {
  384. returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
  385. returnValue = eval(returnString);
  386. } else {
  387. this.debug("Can't call flash because the movie wasn't found.");
  388. }
  389. } catch (ex) {
  390. this.debug("Exception calling flash function '" + functionName + "': " + ex.message);
  391. }
  392. if (returnValue != undefined && typeof returnValue.post === "object") {
  393. returnValue = this.unescapeFilePostParams(returnValue);
  394. }
  395. return returnValue;
  396. };
  397. SWFUpload.prototype.selectFile = function () {
  398. this.callFlash("SelectFile");
  399. };
  400. SWFUpload.prototype.selectFiles = function () {
  401. this.callFlash("SelectFiles");
  402. };
  403. SWFUpload.prototype.startUpload = function (fileID) {
  404. this.callFlash("StartUpload", [fileID]);
  405. };
  406. SWFUpload.prototype.startResizedUpload = function (fileID, width, height, encoding, quality, allowEnlarging) {
  407. this.callFlash("StartUpload", [fileID, { "width": width, "height" : height, "encoding" : encoding, "quality" : quality, "allowEnlarging" : allowEnlarging }]);
  408. };
  409. SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
  410. if (triggerErrorEvent !== false) {
  411. triggerErrorEvent = true;
  412. }
  413. this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
  414. };
  415. SWFUpload.prototype.stopUpload = function () {
  416. this.callFlash("StopUpload");
  417. };
  418. SWFUpload.prototype.requeueUpload = function (indexOrFileID) {
  419. return this.callFlash("RequeueUpload", [indexOrFileID]);
  420. };
  421. SWFUpload.prototype.getStats = function () {
  422. return this.callFlash("GetStats");
  423. };
  424. SWFUpload.prototype.setStats = function (statsObject) {
  425. this.callFlash("SetStats", [statsObject]);
  426. };
  427. SWFUpload.prototype.getFile = function (fileID) {
  428. if (typeof(fileID) === "number") {
  429. return this.callFlash("GetFileByIndex", [fileID]);
  430. } else {
  431. return this.callFlash("GetFile", [fileID]);
  432. }
  433. };
  434. SWFUpload.prototype.getQueueFile = function (fileID) {
  435. if (typeof(fileID) === "number") {
  436. return this.callFlash("GetFileByQueueIndex", [fileID]);
  437. } else {
  438. return this.callFlash("GetFile", [fileID]);
  439. }
  440. };
  441. SWFUpload.prototype.addFileParam = function (fileID, name, value) {
  442. return this.callFlash("AddFileParam", [fileID, name, value]);
  443. };
  444. SWFUpload.prototype.removeFileParam = function (fileID, name) {
  445. this.callFlash("RemoveFileParam", [fileID, name]);
  446. };
  447. SWFUpload.prototype.setUploadURL = function (url) {
  448. this.settings.upload_url = url.toString();
  449. this.callFlash("SetUploadURL", [url]);
  450. };
  451. SWFUpload.prototype.setPostParams = function (paramsObject) {
  452. this.settings.post_params = paramsObject;
  453. this.callFlash("SetPostParams", [paramsObject]);
  454. };
  455. SWFUpload.prototype.addPostParam = function (name, value) {
  456. this.settings.post_params[name] = value;
  457. this.callFlash("SetPostParams", [this.settings.post_params]);
  458. };
  459. SWFUpload.prototype.removePostParam = function (name) {
  460. delete this.settings.post_params[name];
  461. this.callFlash("SetPostParams", [this.settings.post_params]);
  462. };
  463. SWFUpload.prototype.setFileTypes = function (types, description) {
  464. this.settings.file_types = types;
  465. this.settings.file_types_description = description;
  466. this.callFlash("SetFileTypes", [types, description]);
  467. };
  468. SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
  469. this.settings.file_size_limit = fileSizeLimit;
  470. this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
  471. };
  472. SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
  473. this.settings.file_upload_limit = fileUploadLimit;
  474. this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
  475. };
  476. SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
  477. this.settings.file_queue_limit = fileQueueLimit;
  478. this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
  479. };
  480. SWFUpload.prototype.setFilePostName = function (filePostName) {
  481. this.settings.file_post_name = filePostName;
  482. this.callFlash("SetFilePostName", [filePostName]);
  483. };
  484. SWFUpload.prototype.setUseQueryString = function (useQueryString) {
  485. this.settings.use_query_string = useQueryString;
  486. this.callFlash("SetUseQueryString", [useQueryString]);
  487. };
  488. SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
  489. this.settings.requeue_on_error = requeueOnError;
  490. this.callFlash("SetRequeueOnError", [requeueOnError]);
  491. };
  492. SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
  493. if (typeof http_status_codes === "string") {
  494. http_status_codes = http_status_codes.replace(" ", "").split(",");
  495. }
  496. this.settings.http_success = http_status_codes;
  497. this.callFlash("SetHTTPSuccess", [http_status_codes]);
  498. };
  499. SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
  500. this.settings.assume_success_timeout = timeout_seconds;
  501. this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
  502. };
  503. SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
  504. this.settings.debug_enabled = debugEnabled;
  505. this.callFlash("SetDebugEnabled", [debugEnabled]);
  506. };
  507. SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
  508. if (buttonImageURL == undefined) {
  509. buttonImageURL = "";
  510. }
  511. this.settings.button_image_url = buttonImageURL;
  512. this.callFlash("SetButtonImageURL", [buttonImageURL]);
  513. };
  514. SWFUpload.prototype.setButtonDimensions = function (width, height) {
  515. this.settings.button_width = width;
  516. this.settings.button_height = height;
  517. var movie = this.getMovieElement();
  518. if (movie != undefined) {
  519. movie.style.width = width + "px";
  520. movie.style.height = height + "px";
  521. }
  522. this.callFlash("SetButtonDimensions", [width, height]);
  523. };
  524. SWFUpload.prototype.setButtonText = function (html) {
  525. this.settings.button_text = html;
  526. this.callFlash("SetButtonText", [html]);
  527. };
  528. SWFUpload.prototype.setButtonTextPadding = function (left, top) {
  529. this.settings.button_text_top_padding = top;
  530. this.settings.button_text_left_padding = left;
  531. this.callFlash("SetButtonTextPadding", [left, top]);
  532. };
  533. SWFUpload.prototype.setButtonTextStyle = function (css) {
  534. this.settings.button_text_style = css;
  535. this.callFlash("SetButtonTextStyle", [css]);
  536. };
  537. SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
  538. this.settings.button_disabled = isDisabled;
  539. this.callFlash("SetButtonDisabled", [isDisabled]);
  540. };
  541. SWFUpload.prototype.setButtonAction = function (buttonAction) {
  542. this.settings.button_action = buttonAction;
  543. this.callFlash("SetButtonAction", [buttonAction]);
  544. };
  545. SWFUpload.prototype.setButtonCursor = function (cursor) {
  546. this.settings.button_cursor = cursor;
  547. this.callFlash("SetButtonCursor", [cursor]);
  548. };
  549. SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
  550. var self = this;
  551. if (argumentArray == undefined) {
  552. argumentArray = [];
  553. } else if (!(argumentArray instanceof Array)) {
  554. argumentArray = [argumentArray];
  555. }
  556. if (typeof this.settings[handlerName] === "function") {
  557. this.eventQueue.push(function () {
  558. this.settings[handlerName].apply(this, argumentArray);
  559. });
  560. setTimeout(function () {
  561. self.executeNextEvent();
  562. }, 0);
  563. } else if (this.settings[handlerName] !== null) {
  564. throw "Event handler " + handlerName + " is unknown or is not a function";
  565. }
  566. };
  567. SWFUpload.prototype.executeNextEvent = function () {
  568. var f = this.eventQueue ? this.eventQueue.shift() : null;
  569. if (typeof(f) === "function") {
  570. f.apply(this);
  571. }
  572. };
  573. SWFUpload.prototype.unescapeFilePostParams = function (file) {
  574. var reg = /[$]([0-9a-f]{4})/i, unescapedPost = {}, uk, k, match;
  575. if (file != undefined) {
  576. for (k in file.post) {
  577. if (file.post.hasOwnProperty(k)) {
  578. uk = k;
  579. while ((match = reg.exec(uk)) !== null) {
  580. uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
  581. }
  582. unescapedPost[uk] = file.post[k];
  583. }
  584. }
  585. file.post = unescapedPost;
  586. }
  587. return file;
  588. };
  589. SWFUpload.prototype.swfuploadPreload = function () {
  590. var returnValue;
  591. if (typeof this.settings.swfupload_preload_handler === "function") {
  592. returnValue = this.settings.swfupload_preload_handler.call(this);
  593. } else if (this.settings.swfupload_preload_handler != undefined) {
  594. throw "upload_start_handler must be a function";
  595. }
  596. if (returnValue === undefined) {
  597. returnValue = true;
  598. }
  599. return !!returnValue;
  600. };
  601. SWFUpload.prototype.flashReady = function () {
  602. var movieElement = this.cleanUp();
  603. if (!movieElement) {
  604. this.debug("Flash called back ready but the flash movie can't be found.");
  605. return;
  606. }
  607. this.queueEvent("swfupload_loaded_handler");
  608. };
  609. SWFUpload.prototype.cleanUp = function () {
  610. var key, movieElement = this.getMovieElement();
  611. try {
  612. if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
  613. this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
  614. for (key in movieElement) {
  615. try {
  616. if (typeof(movieElement[key]) === "function") {
  617. movieElement[key] = null;
  618. }
  619. } catch (ex) {
  620. }
  621. }
  622. }
  623. } catch (ex1) {
  624. }
  625. window["__flash__removeCallback"] = function (instance, name) {
  626. try {
  627. if (instance) {
  628. instance[name] = null;
  629. }
  630. } catch (flashEx) {
  631. }
  632. };
  633. return movieElement;
  634. };
  635. SWFUpload.prototype.mouseClick = function () {
  636. this.queueEvent("mouse_click_handler");
  637. };
  638. SWFUpload.prototype.mouseOver = function () {
  639. this.queueEvent("mouse_over_handler");
  640. };
  641. SWFUpload.prototype.mouseOut = function () {
  642. this.queueEvent("mouse_out_handler");
  643. };
  644. SWFUpload.prototype.fileDialogStart = function () {
  645. this.queueEvent("file_dialog_start_handler");
  646. };
  647. SWFUpload.prototype.fileQueued = function (file) {
  648. file = this.unescapeFilePostParams(file);
  649. this.queueEvent("file_queued_handler", file);
  650. };
  651. SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
  652. file = this.unescapeFilePostParams(file);
  653. this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
  654. };
  655. SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
  656. this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
  657. };
  658. SWFUpload.prototype.uploadResizeStart = function (file, resizeSettings) {
  659. file = this.unescapeFilePostParams(file);
  660. this.queueEvent("upload_resize_start_handler", [file, resizeSettings.width, resizeSettings.height, resizeSettings.encoding, resizeSettings.quality]);
  661. };
  662. SWFUpload.prototype.uploadStart = function (file) {
  663. file = this.unescapeFilePostParams(file);
  664. this.queueEvent("return_upload_start_handler", file);
  665. };
  666. SWFUpload.prototype.returnUploadStart = function (file) {
  667. var returnValue;
  668. if (typeof this.settings.upload_start_handler === "function") {
  669. file = this.unescapeFilePostParams(file);
  670. returnValue = this.settings.upload_start_handler.call(this, file);
  671. } else if (this.settings.upload_start_handler != undefined) {
  672. throw "upload_start_handler must be a function";
  673. }
  674. if (returnValue === undefined) {
  675. returnValue = true;
  676. }
  677. returnValue = !!returnValue;
  678. this.callFlash("ReturnUploadStart", [returnValue]);
  679. };
  680. SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
  681. file = this.unescapeFilePostParams(file);
  682. this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
  683. };
  684. SWFUpload.prototype.uploadError = function (file, errorCode, message) {
  685. file = this.unescapeFilePostParams(file);
  686. this.queueEvent("upload_error_handler", [file, errorCode, message]);
  687. };
  688. SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
  689. file = this.unescapeFilePostParams(file);
  690. this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
  691. };
  692. SWFUpload.prototype.uploadComplete = function (file) {
  693. file = this.unescapeFilePostParams(file);
  694. this.queueEvent("upload_complete_handler", file);
  695. };
  696. SWFUpload.prototype.debug = function (message) {
  697. this.queueEvent("debug_handler", message);
  698. };
  699. SWFUpload.prototype.debugMessage = function (message) {
  700. var exceptionMessage, exceptionValues, key;
  701. if (this.settings.debug) {
  702. exceptionValues = [];
  703. if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
  704. for (key in message) {
  705. if (message.hasOwnProperty(key)) {
  706. exceptionValues.push(key + ": " + message[key]);
  707. }
  708. }
  709. exceptionMessage = exceptionValues.join("\n") || "";
  710. exceptionValues = exceptionMessage.split("\n");
  711. exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
  712. SWFUpload.Console.writeLine(exceptionMessage);
  713. } else {
  714. SWFUpload.Console.writeLine(message);
  715. }
  716. }
  717. };
  718. SWFUpload.Console = {};
  719. SWFUpload.Console.writeLine = function (message) {
  720. var console, documentForm;
  721. try {
  722. console = document.getElementById("SWFUpload_Console");
  723. if (!console) {
  724. documentForm = document.createElement("form");
  725. document.getElementsByTagName("body")[0].appendChild(documentForm);
  726. console = document.createElement("textarea");
  727. console.id = "SWFUpload_Console";
  728. console.style.fontFamily = "monospace";
  729. console.setAttribute("wrap", "off");
  730. console.wrap = "off";
  731. console.style.overflow = "auto";
  732. console.style.width = "700px";
  733. console.style.height = "350px";
  734. console.style.margin = "5px";
  735. documentForm.appendChild(console);
  736. }
  737. console.value += message + "\n";
  738. console.scrollTop = console.scrollHeight - console.clientHeight;
  739. } catch (ex) {
  740. alert("Exception: " + ex.name + " Message: " + ex.message);
  741. }
  742. };
  743. swfobject = function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
  744. swfobject.addDomLoadEvent(function () {
  745. if (typeof(SWFUpload.onload) === "function") {
  746. SWFUpload.onload.call(window);
  747. }
  748. });
  749. var SWFUpload;
  750. if (typeof(SWFUpload) === "function") {
  751. SWFUpload.queue = {};
  752. SWFUpload.prototype.initSettings = (function (oldInitSettings) {
  753. return function (userSettings) {
  754. if (typeof(oldInitSettings) === "function") {
  755. oldInitSettings.call(this, userSettings);
  756. }
  757. this.queueSettings = {};
  758. this.queueSettings.queue_cancelled_flag = false;
  759. this.queueSettings.queue_upload_count = 0;
  760. this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
  761. this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
  762. this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
  763. this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
  764. this.settings.queue_complete_handler = userSettings.queue_complete_handler || null;
  765. };
  766. })(SWFUpload.prototype.initSettings);
  767. SWFUpload.prototype.startUpload = function (fileID) {
  768. this.queueSettings.queue_cancelled_flag = false;
  769. this.callFlash("StartUpload", [fileID]);
  770. };
  771. SWFUpload.prototype.cancelQueue = function () {
  772. this.queueSettings.queue_cancelled_flag = true;
  773. this.stopUpload();
  774. var stats = this.getStats();
  775. while (stats.files_queued > 0) {
  776. this.cancelUpload();
  777. stats = this.getStats();
  778. }
  779. };
  780. SWFUpload.queue.uploadStartHandler = function (file) {
  781. var returnValue;
  782. if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
  783. returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
  784. }
  785. returnValue = (returnValue === false) ? false : true;
  786. this.queueSettings.queue_cancelled_flag = !returnValue;
  787. return returnValue;
  788. };
  789. SWFUpload.queue.uploadCompleteHandler = function (file) {
  790. var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
  791. var continueUpload;
  792. if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
  793. this.queueSettings.queue_upload_count++;
  794. }
  795. if (typeof(user_upload_complete_handler) === "function") {
  796. continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
  797. } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
  798. continueUpload = false;
  799. } else {
  800. continueUpload = true;
  801. }
  802. if (continueUpload) {
  803. var stats = this.getStats();
  804. if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
  805. this.startUpload();
  806. } else if (this.queueSettings.queue_cancelled_flag === false) {
  807. this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
  808. this.queueSettings.queue_upload_count = 0;
  809. } else {
  810. this.queueSettings.queue_cancelled_flag = false;
  811. this.queueSettings.queue_upload_count = 0;
  812. }
  813. }
  814. };
  815. }
  816. var sdCloseTime = 2;
  817. function preLoad() {
  818. if(!this.support.loading) {
  819. disableMultiUpload(this.customSettings);
  820. return false;
  821. }
  822. }
  823. function loadFailed() {
  824. disableMultiUpload(this.customSettings);
  825. }
  826. function disableMultiUpload(obj) {
  827. if(obj.uploadSource == 'forum' && obj.uploadFrom != 'fastpost') {
  828. try{
  829. obj.singleUpload.style.display = '';
  830. var dIdStr = obj.singleUpload.getAttribute("did");
  831. if(dIdStr != null) {
  832. if(typeof forum_post_inited == 'undefined') {
  833. appendscript(JSPATH + 'forum_post.js?' + VERHASH);
  834. }
  835. var idArr = dIdStr.split("|");
  836. $(idArr[0]).style.display = 'none';
  837. if(idArr[1] == 'local') {
  838. switchImagebutton('local');
  839. } else if(idArr[1] == 'upload') {
  840. switchAttachbutton('upload');
  841. }
  842. }
  843. } catch (e) {
  844. }
  845. }
  846. }
  847. function fileDialogStart() {
  848. if(this.customSettings.uploadSource == 'forum') {
  849. this.customSettings.alertType = 0;
  850. if(this.customSettings.uploadFrom == 'fastpost') {
  851. if(typeof forum_post_inited == 'undefined') {
  852. appendscript(JSPATH + 'forum_post.js?' + VERHASH);
  853. }
  854. }
  855. }
  856. }
  857. function fileQueued(file) {
  858. try {
  859. var createQueue = true;
  860. if(this.customSettings.uploadSource == 'forum' && this.customSettings.uploadType == 'poll') {
  861. var inputObj = $(this.customSettings.progressTarget+'_aid');
  862. if(inputObj && parseInt(inputObj.value)) {
  863. this.addPostParam('aid', inputObj.value);
  864. }
  865. } else if(this.customSettings.uploadSource == 'portal') {
  866. var inputObj = $('catid');
  867. if(inputObj && parseInt(inputObj.value)) {
  868. this.addPostParam('catid', inputObj.value);
  869. }
  870. }
  871. var progress = new FileProgress(file, this.customSettings.progressTarget);
  872. if(this.customSettings.uploadSource == 'forum') {
  873. if(this.customSettings.maxAttachNum != undefined) {
  874. if(this.customSettings.maxAttachNum > 0) {
  875. this.customSettings.maxAttachNum--;
  876. } else {
  877. this.customSettings.alertType = 6;
  878. createQueue = false;
  879. }
  880. }
  881. if(createQueue && this.customSettings.maxSizePerDay != undefined) {
  882. if(this.customSettings.maxSizePerDay - file.size > 0) {
  883. this.customSettings.maxSizePerDay = this.customSettings.maxSizePerDay - file.size
  884. } else {
  885. this.customSettings.alertType = 11;
  886. createQueue = false;
  887. }
  888. }
  889. if(createQueue && this.customSettings.filterType != undefined) {
  890. var fileSize = this.customSettings.filterType[file.type.substr(1).toLowerCase()];
  891. if(fileSize != undefined && fileSize && file.size > fileSize) {
  892. this.customSettings.alertType = 5;
  893. createQueue = false;
  894. }
  895. }
  896. }
  897. if(createQueue) {
  898. progress.setStatus("等待上传...");
  899. } else {
  900. this.cancelUpload(file.id);
  901. progress.setCancelled();
  902. }
  903. progress.toggleCancel(true, this);
  904. } catch (ex) {
  905. this.debug(ex);
  906. }
  907. }
  908. function fileQueueError(file, errorCode, message) {
  909. try {
  910. if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
  911. message = parseInt(message);
  912. showDialog("您选择的文件个数超过限制。\n"+(message === 0 ? "您已达到上传文件的上限了。" : "您还可以选择 " + message + " 个文件"), 'notice', null, null, 0, null, null, null, null, sdCloseTime);
  913. return;
  914. }
  915. var progress = new FileProgress(file, this.customSettings.progressTarget);
  916. progress.setError();
  917. progress.toggleCancel(false);
  918. switch (errorCode) {
  919. case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
  920. progress.setStatus("文件太大.");
  921. this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  922. break;
  923. case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
  924. progress.setStatus("不能上传零字节文件.");
  925. this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  926. break;
  927. case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
  928. progress.setStatus("禁止上传该类型的文件.");
  929. this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  930. break;
  931. case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
  932. alert("You have selected too many files. " + (message > 1 ? "You may only add " + message + " more files" : "You cannot add any more files."));
  933. break;
  934. default:
  935. if (file !== null) {
  936. progress.setStatus("Unhandled Error");
  937. }
  938. this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  939. break;
  940. }
  941. } catch (ex) {
  942. this.debug(ex);
  943. }
  944. }
  945. function fileDialogComplete(numFilesSelected, numFilesQueued) {
  946. try {
  947. if(this.customSettings.uploadSource == 'forum') {
  948. if(this.customSettings.uploadType == 'attach') {
  949. if(typeof switchAttachbutton == "function") {
  950. switchAttachbutton('attachlist');
  951. }
  952. try {
  953. if(this.getStats().files_queued) {
  954. $('attach_tblheader').style.display = '';
  955. $('attach_notice').style.display = '';
  956. }
  957. } catch (ex) {}
  958. } else if(this.customSettings.uploadType == 'image') {
  959. if(typeof switchImagebutton == "function") {
  960. switchImagebutton('imgattachlist');
  961. }
  962. try {
  963. $('imgattach_notice').style.display = '';
  964. } catch (ex) {}
  965. }
  966. var objId = this.customSettings.uploadType == 'attach' ? 'attachlist' : 'imgattachlist';
  967. var listObj = $(objId);
  968. va

Large files files are truncated, but you can click here to view the full file