jquery.uploadify.js 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245
  1. /*
  2. SWFObject v2.2 <http://code.google.com/p/swfobject/>
  3. is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
  4. */
  5. ;
  6. var swfobject = function () {
  7. var D = "undefined",
  8. r = "object",
  9. S = "Shockwave Flash",
  10. W = "ShockwaveFlash.ShockwaveFlash",
  11. q = "application/x-shockwave-flash",
  12. R = "SWFObjectExprInst",
  13. x = "onreadystatechange",
  14. O = window,
  15. j = document,
  16. t = navigator,
  17. T = false,
  18. U = [h],
  19. o = [],
  20. N = [],
  21. I = [],
  22. l,
  23. Q,
  24. E,
  25. B,
  26. J = false,
  27. a = false,
  28. n,
  29. G,
  30. m = true,
  31. M = function () {
  32. var aa = typeof j.getElementById != D && typeof j.getElementsByTagName != D && typeof j.createElement != D,
  33. ah = t.userAgent.toLowerCase(),
  34. Y = t.platform.toLowerCase(),
  35. ae = Y ? /win/.test(Y) : /win/.test(ah),
  36. ac = Y ? /mac/.test(Y) : /mac/.test(ah),
  37. af = /webkit/.test(ah) ? parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false,
  38. X = ! +"\v1",
  39. ag = [0, 0, 0],
  40. ab = null;
  41. if (typeof t.plugins != D && typeof t.plugins[S] == r) {
  42. ab = t.plugins[S].description;
  43. if (ab && !(typeof t.mimeTypes != D && t.mimeTypes[q] && !t.mimeTypes[q].enabledPlugin)) {
  44. T = true;
  45. X = false;
  46. ab = ab.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
  47. ag[0] = parseInt(ab.replace(/^(.*)\..*$/, "$1"), 10);
  48. ag[1] = parseInt(ab.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
  49. ag[2] = /[a-zA-Z]/.test(ab) ? parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
  50. }
  51. } else {
  52. if (typeof O.ActiveXObject != D) {
  53. try {
  54. var ad = new ActiveXObject(W);
  55. if (ad) {
  56. ab = ad.GetVariable("$version");
  57. if (ab) {
  58. X = true;
  59. ab = ab.split(" ")[1].split(",");
  60. ag = [parseInt(ab[0], 10), parseInt(ab[1], 10), parseInt(ab[2], 10)];
  61. }
  62. }
  63. } catch (Z) { }
  64. }
  65. }
  66. return {
  67. w3: aa,
  68. pv: ag,
  69. wk: af,
  70. ie: X,
  71. win: ae,
  72. mac: ac
  73. };
  74. }
  75. (),
  76. k = function () {
  77. if (!M.w3) {
  78. return;
  79. }
  80. if ((typeof j.readyState != D && j.readyState == "complete") || (typeof j.readyState == D && (j.getElementsByTagName("body")[0] || j.body))) {
  81. f();
  82. }
  83. if (!J) {
  84. if (typeof j.addEventListener != D) {
  85. j.addEventListener("DOMContentLoaded", f, false);
  86. }
  87. if (M.ie && M.win) {
  88. j.attachEvent(x, function () {
  89. if (j.readyState == "complete") {
  90. j.detachEvent(x, arguments.callee);
  91. f();
  92. }
  93. });
  94. if (O == top) {
  95. (function () {
  96. if (J) {
  97. return;
  98. }
  99. try {
  100. j.documentElement.doScroll("left");
  101. } catch (X) {
  102. setTimeout(arguments.callee, 0);
  103. return;
  104. }
  105. f();
  106. })();
  107. }
  108. }
  109. if (M.wk) {
  110. (function () {
  111. if (J) {
  112. return;
  113. }
  114. if (!/loaded|complete/.test(j.readyState)) {
  115. setTimeout(arguments.callee, 0);
  116. return;
  117. }
  118. f();
  119. })();
  120. }
  121. s(f);
  122. }
  123. }
  124. ();
  125. function f() {
  126. if (J) {
  127. return;
  128. }
  129. try {
  130. var Z = j.getElementsByTagName("body")[0].appendChild(C("span"));
  131. Z.parentNode.removeChild(Z);
  132. } catch (aa) {
  133. return;
  134. }
  135. J = true;
  136. var X = U.length;
  137. for (var Y = 0; Y < X; Y++) {
  138. U[Y]();
  139. }
  140. }
  141. function K(X) {
  142. if (J) {
  143. X();
  144. } else {
  145. U[U.length] = X;
  146. }
  147. }
  148. function s(Y) {
  149. if (typeof O.addEventListener != D) {
  150. O.addEventListener("load", Y, false);
  151. } else {
  152. if (typeof j.addEventListener != D) {
  153. j.addEventListener("load", Y, false);
  154. } else {
  155. if (typeof O.attachEvent != D) {
  156. i(O, "onload", Y);
  157. } else {
  158. if (typeof O.onload == "function") {
  159. var X = O.onload;
  160. O.onload = function () {
  161. X();
  162. Y();
  163. };
  164. } else {
  165. O.onload = Y;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. function h() {
  172. if (T) {
  173. V();
  174. } else {
  175. H();
  176. }
  177. }
  178. function V() {
  179. var X = j.getElementsByTagName("body")[0];
  180. var aa = C(r);
  181. aa.setAttribute("type", q);
  182. var Z = X.appendChild(aa);
  183. if (Z) {
  184. var Y = 0;
  185. (function () {
  186. if (typeof Z.GetVariable != D) {
  187. var ab = Z.GetVariable("$version");
  188. if (ab) {
  189. ab = ab.split(" ")[1].split(",");
  190. M.pv = [parseInt(ab[0], 10), parseInt(ab[1], 10), parseInt(ab[2], 10)];
  191. }
  192. } else {
  193. if (Y < 10) {
  194. Y++;
  195. setTimeout(arguments.callee, 10);
  196. return;
  197. }
  198. }
  199. X.removeChild(aa);
  200. Z = null;
  201. H();
  202. })();
  203. } else {
  204. H();
  205. }
  206. }
  207. function H() {
  208. var ag = o.length;
  209. if (ag > 0) {
  210. for (var af = 0; af < ag; af++) {
  211. var Y = o[af].id;
  212. var ab = o[af].callbackFn;
  213. var aa = {
  214. success: false,
  215. id: Y
  216. };
  217. if (M.pv[0] > 0) {
  218. var ae = c(Y);
  219. if (ae) {
  220. if (F(o[af].swfVersion) && !(M.wk && M.wk < 312)) {
  221. w(Y, true);
  222. if (ab) {
  223. aa.success = true;
  224. aa.ref = z(Y);
  225. ab(aa);
  226. }
  227. } else {
  228. if (o[af].expressInstall && A()) {
  229. var ai = {};
  230. ai.data = o[af].expressInstall;
  231. ai.width = ae.getAttribute("width") || "0";
  232. ai.height = ae.getAttribute("height") || "0";
  233. if (ae.getAttribute("class")) {
  234. ai.styleclass = ae.getAttribute("class");
  235. }
  236. if (ae.getAttribute("align")) {
  237. ai.align = ae.getAttribute("align");
  238. }
  239. var ah = {};
  240. var X = ae.getElementsByTagName("param");
  241. var ac = X.length;
  242. for (var ad = 0; ad < ac; ad++) {
  243. if (X[ad].getAttribute("name").toLowerCase() != "movie") {
  244. ah[X[ad].getAttribute("name")] = X[ad].getAttribute("value");
  245. }
  246. }
  247. P(ai, ah, Y, ab);
  248. } else {
  249. p(ae);
  250. if (ab) {
  251. ab(aa);
  252. }
  253. }
  254. }
  255. }
  256. } else {
  257. w(Y, true);
  258. if (ab) {
  259. var Z = z(Y);
  260. if (Z && typeof Z.SetVariable != D) {
  261. aa.success = true;
  262. aa.ref = Z;
  263. }
  264. ab(aa);
  265. }
  266. }
  267. }
  268. }
  269. }
  270. function z(aa) {
  271. var X = null;
  272. var Y = c(aa);
  273. if (Y && Y.nodeName == "OBJECT") {
  274. if (typeof Y.SetVariable != D) {
  275. X = Y;
  276. } else {
  277. var Z = Y.getElementsByTagName(r)[0];
  278. if (Z) {
  279. X = Z;
  280. }
  281. }
  282. }
  283. return X;
  284. }
  285. function A() {
  286. return !a && F("6.0.65") && (M.win || M.mac) && !(M.wk && M.wk < 312);
  287. }
  288. function P(aa, ab, X, Z) {
  289. a = true;
  290. E = Z || null;
  291. B = {
  292. success: false,
  293. id: X
  294. };
  295. var ae = c(X);
  296. if (ae) {
  297. if (ae.nodeName == "OBJECT") {
  298. l = g(ae);
  299. Q = null;
  300. } else {
  301. l = ae;
  302. Q = X;
  303. }
  304. aa.id = R;
  305. if (typeof aa.width == D || (!/%$/.test(aa.width) && parseInt(aa.width, 10) < 310)) {
  306. aa.width = "310";
  307. }
  308. if (typeof aa.height == D || (!/%$/.test(aa.height) && parseInt(aa.height, 10) < 137)) {
  309. aa.height = "137";
  310. }
  311. j.title = j.title.slice(0, 47) + " - Flash Player Installation";
  312. var ad = M.ie && M.win ? "ActiveX" : "PlugIn",
  313. ac = "MMredirectURL=" + O.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + ad + "&MMdoctitle=" + j.title;
  314. if (typeof ab.flashvars != D) {
  315. ab.flashvars += "&" + ac;
  316. } else {
  317. ab.flashvars = ac;
  318. }
  319. if (M.ie && M.win && ae.readyState != 4) {
  320. var Y = C("div");
  321. X += "SWFObjectNew";
  322. Y.setAttribute("id", X);
  323. ae.parentNode.insertBefore(Y, ae);
  324. ae.style.display = "none";
  325. (function () {
  326. if (ae.readyState == 4) {
  327. try {
  328. ae.parentNode.removeChild(ae);
  329. } catch (ignore) { }
  330. } else {
  331. setTimeout(arguments.callee, 10);
  332. }
  333. })();
  334. }
  335. u(aa, ab, X);
  336. }
  337. }
  338. function p(Y) {
  339. if (M.ie && M.win && Y.readyState != 4) {
  340. var X = C("div");
  341. Y.parentNode.insertBefore(X, Y);
  342. X.parentNode.replaceChild(g(Y), X);
  343. Y.style.display = "none";
  344. (function () {
  345. if (Y.readyState == 4) {
  346. try {
  347. Y.parentNode.removeChild(Y);
  348. } catch (ignore) { }
  349. } else {
  350. setTimeout(arguments.callee, 10);
  351. }
  352. })();
  353. } else {
  354. Y.parentNode.replaceChild(g(Y), Y);
  355. }
  356. }
  357. function g(ab) {
  358. var aa = C("div");
  359. if (M.win && M.ie) {
  360. aa.innerHTML = ab.innerHTML;
  361. } else {
  362. var Y = ab.getElementsByTagName(r)[0];
  363. if (Y) {
  364. var ad = Y.childNodes;
  365. if (ad) {
  366. var X = ad.length;
  367. for (var Z = 0; Z < X; Z++) {
  368. if (!(ad[Z].nodeType == 1 && ad[Z].nodeName == "PARAM") && !(ad[Z].nodeType == 8)) {
  369. aa.appendChild(ad[Z].cloneNode(true));
  370. }
  371. }
  372. }
  373. }
  374. }
  375. return aa;
  376. }
  377. function u(ai, ag, Y) {
  378. var X,
  379. aa = c(Y);
  380. if (M.wk && M.wk < 312) {
  381. return X;
  382. }
  383. if (aa) {
  384. if (typeof ai.id == D) {
  385. ai.id = Y;
  386. }
  387. if (M.ie && M.win) {
  388. var ah = "";
  389. for (var ae in ai) {
  390. if (ai[ae] != Object.prototype[ae]) {
  391. if (ae.toLowerCase() == "data") {
  392. ag.movie = ai[ae];
  393. } else {
  394. if (ae.toLowerCase() == "styleclass") {
  395. ah += ' class="' + ai[ae] + '"';
  396. } else {
  397. if (ae.toLowerCase() != "classid") {
  398. ah += " " + ae + '="' + ai[ae] + '"';
  399. }
  400. }
  401. }
  402. }
  403. }
  404. var af = "";
  405. for (var ad in ag) {
  406. if (ag[ad] != Object.prototype[ad]) {
  407. af += '<param name="' + ad + '" value="' + ag[ad] + '" />';
  408. }
  409. }
  410. aa.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + ah + ">" + af + "</object>";
  411. N[N.length] = ai.id;
  412. X = c(ai.id);
  413. } else {
  414. var Z = C(r);
  415. Z.setAttribute("type", q);
  416. for (var ac in ai) {
  417. if (ai[ac] != Object.prototype[ac]) {
  418. if (ac.toLowerCase() == "styleclass") {
  419. Z.setAttribute("class", ai[ac]);
  420. } else {
  421. if (ac.toLowerCase() != "classid") {
  422. Z.setAttribute(ac, ai[ac]);
  423. }
  424. }
  425. }
  426. }
  427. for (var ab in ag) {
  428. if (ag[ab] != Object.prototype[ab] && ab.toLowerCase() != "movie") {
  429. e(Z, ab, ag[ab]);
  430. }
  431. }
  432. aa.parentNode.replaceChild(Z, aa);
  433. X = Z;
  434. }
  435. }
  436. return X;
  437. }
  438. function e(Z, X, Y) {
  439. var aa = C("param");
  440. aa.setAttribute("name", X);
  441. aa.setAttribute("value", Y);
  442. Z.appendChild(aa);
  443. }
  444. function y(Y) {
  445. var X = c(Y);
  446. if (X && X.nodeName == "OBJECT") {
  447. if (M.ie && M.win) {
  448. X.style.display = "none";
  449. (function () {
  450. if (X.readyState == 4) {
  451. try {
  452. b(Y);
  453. } catch (ignore) { }
  454. } else {
  455. setTimeout(arguments.callee, 10);
  456. }
  457. })();
  458. } else {
  459. X.parentNode.removeChild(X);
  460. }
  461. }
  462. }
  463. function b(Z) {
  464. var Y = c(Z);
  465. if (Y) {
  466. for (var X in Y) {
  467. if (typeof Y[X] == "function") {
  468. Y[X] = null;
  469. }
  470. }
  471. Y.parentNode.removeChild(Y);
  472. }
  473. }
  474. function c(Z) {
  475. var X = null;
  476. try {
  477. X = j.getElementById(Z);
  478. } catch (Y) { }
  479. return X;
  480. }
  481. function C(X) {
  482. return j.createElement(X);
  483. }
  484. function i(Z, X, Y) {
  485. Z.attachEvent(X, Y);
  486. I[I.length] = [Z, X, Y];
  487. }
  488. function F(Z) {
  489. var Y = M.pv,
  490. X = Z.split(".");
  491. X[0] = parseInt(X[0], 10);
  492. X[1] = parseInt(X[1], 10) || 0;
  493. X[2] = parseInt(X[2], 10) || 0;
  494. 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;
  495. }
  496. function v(ac, Y, ad, ab) {
  497. if (M.ie && M.mac) {
  498. return;
  499. }
  500. var aa = j.getElementsByTagName("head")[0];
  501. if (!aa) {
  502. return;
  503. }
  504. var X = (ad && typeof ad == "string") ? ad : "screen";
  505. if (ab) {
  506. n = null;
  507. G = null;
  508. }
  509. if (!n || G != X) {
  510. var Z = C("style");
  511. Z.setAttribute("type", "text/css");
  512. Z.setAttribute("media", X);
  513. n = aa.appendChild(Z);
  514. if (M.ie && M.win && typeof j.styleSheets != D && j.styleSheets.length > 0) {
  515. n = j.styleSheets[j.styleSheets.length - 1];
  516. }
  517. G = X;
  518. }
  519. if (M.ie && M.win) {
  520. if (n && typeof n.addRule == r) {
  521. n.addRule(ac, Y);
  522. }
  523. } else {
  524. if (n && typeof j.createTextNode != D) {
  525. n.appendChild(j.createTextNode(ac + " {" + Y + "}"));
  526. }
  527. }
  528. }
  529. function w(Z, X) {
  530. if (!m) {
  531. return;
  532. }
  533. var Y = X ? "visible" : "hidden";
  534. if (J && c(Z)) {
  535. c(Z).style.visibility = Y;
  536. } else {
  537. v("#" + Z, "visibility:" + Y);
  538. }
  539. }
  540. function L(Y) {
  541. var Z = /[\\\"<>\.;]/;
  542. var X = Z.exec(Y) != null;
  543. return X && typeof encodeURIComponent != D ? encodeURIComponent(Y) : Y;
  544. }
  545. var d = function () {
  546. if (M.ie && M.win) {
  547. window.attachEvent("onunload", function () {
  548. var ac = I.length;
  549. for (var ab = 0; ab < ac; ab++) {
  550. I[ab][0].detachEvent(I[ab][1], I[ab][2]);
  551. }
  552. var Z = N.length;
  553. for (var aa = 0; aa < Z; aa++) {
  554. y(N[aa]);
  555. }
  556. for (var Y in M) {
  557. M[Y] = null;
  558. }
  559. M = null;
  560. for (var X in swfobject) {
  561. swfobject[X] = null;
  562. }
  563. swfobject = null;
  564. });
  565. }
  566. }
  567. ();
  568. return {
  569. registerObject: function (ab, X, aa, Z) {
  570. if (M.w3 && ab && X) {
  571. var Y = {};
  572. Y.id = ab;
  573. Y.swfVersion = X;
  574. Y.expressInstall = aa;
  575. Y.callbackFn = Z;
  576. o[o.length] = Y;
  577. w(ab, false);
  578. } else {
  579. if (Z) {
  580. Z({
  581. success: false,
  582. id: ab
  583. });
  584. }
  585. }
  586. },
  587. getObjectById: function (X) {
  588. if (M.w3) {
  589. return z(X);
  590. }
  591. },
  592. embedSWF: function (ab, ah, ae, ag, Y, aa, Z, ad, af, ac) {
  593. var X = {
  594. success: false,
  595. id: ah
  596. };
  597. if (M.w3 && !(M.wk && M.wk < 312) && ab && ah && ae && ag && Y) {
  598. w(ah, false);
  599. K(function () {
  600. ae += "";
  601. ag += "";
  602. var aj = {};
  603. if (af && typeof af === r) {
  604. for (var al in af) {
  605. aj[al] = af[al];
  606. }
  607. }
  608. aj.data = ab;
  609. aj.width = ae;
  610. aj.height = ag;
  611. var am = {};
  612. if (ad && typeof ad === r) {
  613. for (var ak in ad) {
  614. am[ak] = ad[ak];
  615. }
  616. }
  617. if (Z && typeof Z === r) {
  618. for (var ai in Z) {
  619. if (typeof am.flashvars != D) {
  620. am.flashvars += "&" + ai + "=" + Z[ai];
  621. } else {
  622. am.flashvars = ai + "=" + Z[ai];
  623. }
  624. }
  625. }
  626. if (F(Y)) {
  627. var an = u(aj, am, ah);
  628. if (aj.id == ah) {
  629. w(ah, true);
  630. }
  631. X.success = true;
  632. X.ref = an;
  633. } else {
  634. if (aa && A()) {
  635. aj.data = aa;
  636. P(aj, am, ah, ac);
  637. return;
  638. } else {
  639. w(ah, true);
  640. }
  641. }
  642. if (ac) {
  643. ac(X);
  644. }
  645. });
  646. } else {
  647. if (ac) {
  648. ac(X);
  649. }
  650. }
  651. },
  652. switchOffAutoHideShow: function () {
  653. m = false;
  654. },
  655. ua: M,
  656. getFlashPlayerVersion: function () {
  657. return {
  658. major: M.pv[0],
  659. minor: M.pv[1],
  660. release: M.pv[2]
  661. };
  662. },
  663. hasFlashPlayerVersion: F,
  664. createSWF: function (Z, Y, X) {
  665. if (M.w3) {
  666. return u(Z, Y, X);
  667. } else {
  668. return undefined;
  669. }
  670. },
  671. showExpressInstall: function (Z, aa, X, Y) {
  672. if (M.w3 && A()) {
  673. P(Z, aa, X, Y);
  674. }
  675. },
  676. removeSWF: function (X) {
  677. if (M.w3) {
  678. y(X);
  679. }
  680. },
  681. createCSS: function (aa, Z, Y, X) {
  682. if (M.w3) {
  683. v(aa, Z, Y, X);
  684. }
  685. },
  686. addDomLoadEvent: K,
  687. addLoadEvent: s,
  688. getQueryParamValue: function (aa) {
  689. var Z = j.location.search || j.location.hash;
  690. if (Z) {
  691. if (/\?/.test(Z)) {
  692. Z = Z.split("?")[1];
  693. }
  694. if (aa == null) {
  695. return L(Z);
  696. }
  697. var Y = Z.split("&");
  698. for (var X = 0; X < Y.length; X++) {
  699. if (Y[X].substring(0, Y[X].indexOf("=")) == aa) {
  700. return L(Y[X].substring((Y[X].indexOf("=") + 1)));
  701. }
  702. }
  703. }
  704. return "";
  705. },
  706. expressInstallCallback: function () {
  707. if (a) {
  708. var X = c(R);
  709. if (X && l) {
  710. X.parentNode.replaceChild(l, X);
  711. if (Q) {
  712. w(Q, true);
  713. if (M.ie && M.win) {
  714. l.style.display = "block";
  715. }
  716. }
  717. if (E) {
  718. E(B);
  719. }
  720. }
  721. a = false;
  722. }
  723. }
  724. };
  725. }
  726. ();
  727. /*
  728. SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
  729. mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
  730. SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
  731. http://www.opensource.org/licenses/mit-license.php
  732. SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
  733. http://www.opensource.org/licenses/mit-license.php
  734. */
  735. var SWFUpload;
  736. if (SWFUpload == undefined) {
  737. SWFUpload = function (a) {
  738. this.initSWFUpload(a)
  739. }
  740. }
  741. SWFUpload.prototype.initSWFUpload = function (b) {
  742. try {
  743. this.customSettings = {};
  744. this.settings = b;
  745. this.eventQueue = [];
  746. this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
  747. this.movieElement = null;
  748. SWFUpload.instances[this.movieName] = this;
  749. this.initSettings();
  750. this.loadFlash();
  751. this.displayDebugInfo()
  752. } catch (a) {
  753. delete SWFUpload.instances[this.movieName];
  754. throw a
  755. }
  756. };
  757. SWFUpload.instances = {};
  758. SWFUpload.movieCount = 0;
  759. SWFUpload.version = "2.2.0 2009-03-25";
  760. SWFUpload.QUEUE_ERROR = {
  761. QUEUE_LIMIT_EXCEEDED: -100,
  762. FILE_EXCEEDS_SIZE_LIMIT: -110,
  763. ZERO_BYTE_FILE: -120,
  764. INVALID_FILETYPE: -130
  765. };
  766. SWFUpload.UPLOAD_ERROR = {
  767. HTTP_ERROR: -200,
  768. MISSING_UPLOAD_URL: -210,
  769. IO_ERROR: -220,
  770. SECURITY_ERROR: -230,
  771. UPLOAD_LIMIT_EXCEEDED: -240,
  772. UPLOAD_FAILED: -250,
  773. SPECIFIED_FILE_ID_NOT_FOUND: -260,
  774. FILE_VALIDATION_FAILED: -270,
  775. FILE_CANCELLED: -280,
  776. UPLOAD_STOPPED: -290
  777. };
  778. SWFUpload.FILE_STATUS = {
  779. QUEUED: -1,
  780. IN_PROGRESS: -2,
  781. ERROR: -3,
  782. COMPLETE: -4,
  783. CANCELLED: -5
  784. };
  785. SWFUpload.BUTTON_ACTION = {
  786. SELECT_FILE: -100,
  787. SELECT_FILES: -110,
  788. START_UPLOAD: -120
  789. };
  790. SWFUpload.CURSOR = {
  791. ARROW: -1,
  792. HAND: -2
  793. };
  794. SWFUpload.WINDOW_MODE = {
  795. WINDOW: "window",
  796. TRANSPARENT: "transparent",
  797. OPAQUE: "opaque"
  798. };
  799. SWFUpload.completeURL = function (a) {
  800. if (typeof (a) !== "string" || a.match(/^https?:\/\//i) || a.match(/^\//)) {
  801. return a
  802. }
  803. var c = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
  804. var b = window.location.pathname.lastIndexOf("/");
  805. if (b <= 0) {
  806. path = "/"
  807. } else {
  808. path = window.location.pathname.substr(0, b) + "/"
  809. }
  810. return path + a
  811. };
  812. SWFUpload.prototype.initSettings = function () {
  813. this.ensureDefault = function (b, a) {
  814. this.settings[b] = (this.settings[b] == undefined) ? a : this.settings[b]
  815. };
  816. this.ensureDefault("upload_url", "");
  817. this.ensureDefault("preserve_relative_urls", false);
  818. this.ensureDefault("file_post_name", "Filedata");
  819. this.ensureDefault("post_params", {});
  820. this.ensureDefault("use_query_string", false);
  821. this.ensureDefault("requeue_on_error", false);
  822. this.ensureDefault("http_success", []);
  823. this.ensureDefault("assume_success_timeout", 0);
  824. this.ensureDefault("file_types", "*.*");
  825. this.ensureDefault("file_types_description", "All Files");
  826. this.ensureDefault("file_size_limit", 0);
  827. this.ensureDefault("file_upload_limit", 0);
  828. this.ensureDefault("file_queue_limit", 0);
  829. this.ensureDefault("flash_url", "swfupload.swf");
  830. this.ensureDefault("prevent_swf_caching", true);
  831. this.ensureDefault("button_image_url", "");
  832. this.ensureDefault("button_width", 1);
  833. this.ensureDefault("button_height", 1);
  834. this.ensureDefault("button_text", "");
  835. this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
  836. this.ensureDefault("button_text_top_padding", 0);
  837. this.ensureDefault("button_text_left_padding", 0);
  838. this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
  839. this.ensureDefault("button_disabled", false);
  840. this.ensureDefault("button_placeholder_id", "");
  841. this.ensureDefault("button_placeholder", null);
  842. this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
  843. this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
  844. this.ensureDefault("debug", false);
  845. this.settings.debug_enabled = this.settings.debug;
  846. this.settings.return_upload_start_handler = this.returnUploadStart;
  847. this.ensureDefault("swfupload_loaded_handler", null);
  848. this.ensureDefault("file_dialog_start_handler", null);
  849. this.ensureDefault("file_queued_handler", null);
  850. this.ensureDefault("file_queue_error_handler", null);
  851. this.ensureDefault("file_dialog_complete_handler", null);
  852. this.ensureDefault("upload_start_handler", null);
  853. this.ensureDefault("upload_progress_handler", null);
  854. this.ensureDefault("upload_error_handler", null);
  855. this.ensureDefault("upload_success_handler", null);
  856. this.ensureDefault("upload_complete_handler", null);
  857. this.ensureDefault("debug_handler", this.debugMessage);
  858. this.ensureDefault("custom_settings", {});
  859. this.customSettings = this.settings.custom_settings;
  860. if (!!this.settings.prevent_swf_caching) {
  861. this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime()
  862. }
  863. if (!this.settings.preserve_relative_urls) {
  864. this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
  865. this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url)
  866. }
  867. delete this.ensureDefault
  868. };
  869. SWFUpload.prototype.loadFlash = function () {
  870. var a,
  871. b;
  872. if (document.getElementById(this.movieName) !== null) {
  873. throw "ID " + this.movieName + " is already in use. The Flash Object could not be added"
  874. }
  875. a = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
  876. if (a == undefined) {
  877. throw "Could not find the placeholder element: " + this.settings.button_placeholder_id
  878. }
  879. b = document.createElement("div");
  880. b.innerHTML = this.getFlashHTML();
  881. a.parentNode.replaceChild(b.firstChild, a);
  882. if (window[this.movieName] == undefined) {
  883. window[this.movieName] = this.getMovieElement()
  884. }
  885. };
  886. SWFUpload.prototype.getFlashHTML = function () {
  887. return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">', '<param name="wmode" value="', this.settings.button_window_mode, '" />', '<param name="movie" value="', this.settings.flash_url, '" />', '<param name="quality" value="high" />', '<param name="menu" value="false" />', '<param name="allowScriptAccess" value="always" />', '<param name="flashvars" value="' + this.getFlashVars() + '" />', "</object>"].join("")
  888. };
  889. SWFUpload.prototype.getFlashVars = function () {
  890. var b = this.buildParamString();
  891. var a = this.settings.http_success.join(",");
  892. return ["movieName=", encodeURIComponent(this.movieName), "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url), "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string), "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), "&amp;httpSuccess=", encodeURIComponent(a), "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), "&amp;params=", encodeURIComponent(b), "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name), "&amp;fileTypes=", encodeURIComponent(this.settings.file_types), "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled), "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url), "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width), "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height), "&amp;buttonText=", encodeURIComponent(this.settings.button_text), "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), "&amp;buttonAction=", encodeURIComponent(this.settings.button_action), "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled), "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)].join("")
  893. };
  894. SWFUpload.prototype.getMovieElement = function () {
  895. if (this.movieElement == undefined) {
  896. this.movieElement = document.getElementById(this.movieName)
  897. }
  898. if (this.movieElement === null) {
  899. throw "Could not find Flash element"
  900. }
  901. return this.movieElement
  902. };
  903. SWFUpload.prototype.buildParamString = function () {
  904. var c = this.settings.post_params;
  905. var b = [];
  906. if (typeof (c) === "object") {
  907. for (var a in c) {
  908. if (c.hasOwnProperty(a)) {
  909. b.push(encodeURIComponent(a.toString()) + "=" + encodeURIComponent(c[a].toString()))
  910. }
  911. }
  912. }
  913. return b.join("&amp;")
  914. };
  915. SWFUpload.prototype.destroy = function () {
  916. try {
  917. this.cancelUpload(null, false);
  918. var a = null;
  919. a = this.getMovieElement();
  920. if (a && typeof (a.CallFunction) === "unknown") {
  921. for (var c in a) {
  922. try {
  923. if (typeof (a[c]) === "function") {
  924. a[c] = null
  925. }
  926. } catch (e) { }
  927. }
  928. try {
  929. a.parentNode.removeChild(a)
  930. } catch (b) { }
  931. }
  932. window[this.movieName] = null;
  933. SWFUpload.instances[this.movieName] = null;
  934. delete SWFUpload.instances[this.movieName];
  935. this.movieElement = null;
  936. this.settings = null;
  937. this.customSettings = null;
  938. this.eventQueue = null;
  939. this.movieName = null;
  940. return true
  941. } catch (d) {
  942. return false
  943. }
  944. };
  945. SWFUpload.prototype.displayDebugInfo = function () {
  946. this.debug(["---SWFUpload Instance Info---\n", "Version: ", SWFUpload.version, "\n", "Movie Name: ", this.movieName, "\n", "Settings:\n", "\t", "upload_url: ", this.settings.upload_url, "\n", "\t", "flash_url: ", this.settings.flash_url, "\n", "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n", "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n", "\t", "http_success: ", this.settings.http_success.join(", "), "\n", "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n", "\t", "file_post_name: ", this.settings.file_post_name, "\n", "\t", "post_params: ", this.settings.post_params.toString(), "\n", "\t", "file_types: ", this.settings.file_types, "\n", "\t", "file_types_description: ", this.settings.file_types_description, "\n", "\t", "file_size_limit: ", this.settings.file_size_limit, "\n", "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n", "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n", "\t", "debug: ", this.settings.debug.toString(), "\n", "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n", "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n", "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n", "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n", "\t", "button_width: ", this.settings.button_width.toString(), "\n", "\t", "button_height: ", this.settings.button_height.toString(), "\n", "\t", "button_text: ", this.settings.button_text.toString(), "\n", "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n", "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n", "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", "\t", "button_action: ", this.settings.button_action.toString(), "\n", "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n", "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n", "Event Handlers:\n", "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"].join(""))
  947. };
  948. SWFUpload.prototype.addSetting = function (b, c, a) {
  949. if (c == undefined) {
  950. return (this.settings[b] = a)
  951. } else {
  952. return (this.settings[b] = c)
  953. }
  954. };
  955. SWFUpload.prototype.getSetting = function (a) {
  956. if (this.settings[a] != undefined) {
  957. return this.settings[a]
  958. }
  959. return ""
  960. };
  961. SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
  962. argumentArray = argumentArray || [];
  963. var movieElement = this.getMovieElement();
  964. var returnValue,
  965. returnString;
  966. try {
  967. returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + "</invoke>");
  968. returnValue = eval(returnString)
  969. } catch (ex) {
  970. throw "Call to " + functionName + " failed"
  971. }
  972. if (returnValue != undefined && typeof returnValue.post === "object") {
  973. returnValue = this.unescapeFilePostParams(returnValue)
  974. }
  975. return returnValue
  976. };
  977. SWFUpload.prototype.selectFile = function () {
  978. this.callFlash("SelectFile")
  979. };
  980. SWFUpload.prototype.selectFiles = function () {
  981. this.callFlash("SelectFiles")
  982. };
  983. SWFUpload.prototype.startUpload = function (a) {
  984. this.callFlash("StartUpload", [a])
  985. };
  986. SWFUpload.prototype.cancelUpload = function (a, b) {
  987. if (b !== false) {
  988. b = true
  989. }
  990. this.callFlash("CancelUpload", [a, b])
  991. };
  992. SWFUpload.prototype.stopUpload = function () {
  993. this.callFlash("StopUpload")
  994. };
  995. SWFUpload.prototype.getStats = function () {
  996. return this.callFlash("GetStats")
  997. };
  998. SWFUpload.prototype.setStats = function (a) {
  999. this.callFlash("SetStats", [a])
  1000. };
  1001. SWFUpload.prototype.getFile = function (a) {
  1002. if (typeof (a) === "number") {
  1003. return this.callFlash("GetFileByIndex", [a])
  1004. } else {
  1005. return this.callFlash("GetFile", [a])
  1006. }
  1007. };
  1008. SWFUpload.prototype.addFileParam = function (a, b, c) {
  1009. return this.callFlash("AddFileParam", [a, b, c])
  1010. };
  1011. SWFUpload.prototype.removeFileParam = function (a, b) {
  1012. this.callFlash("RemoveFileParam", [a, b])
  1013. };
  1014. SWFUpload.prototype.setUploadURL = function (a) {
  1015. this.settings.upload_url = a.toString();
  1016. this.callFlash("SetUploadURL", [a])
  1017. };
  1018. SWFUpload.prototype.setPostParams = function (a) {
  1019. this.settings.post_params = a;
  1020. this.callFlash("SetPostParams", [a])
  1021. };
  1022. SWFUpload.prototype.addPostParam = function (a, b) {
  1023. this.settings.post_params[a] = b;
  1024. this.callFlash("SetPostParams", [this.settings.post_params])
  1025. };
  1026. SWFUpload.prototype.removePostParam = function (a) {
  1027. delete this.settings.post_params[a];
  1028. this.callFlash("SetPostParams", [this.settings.post_params])
  1029. };
  1030. SWFUpload.prototype.setFileTypes = function (a, b) {
  1031. this.settings.file_types = a;
  1032. this.settings.file_types_description = b;
  1033. this.callFlash("SetFileTypes", [a, b])
  1034. };
  1035. SWFUpload.prototype.setFileSizeLimit = function (a) {
  1036. this.settings.file_size_limit = a;
  1037. this.callFlash("SetFileSizeLimit", [a])
  1038. };
  1039. SWFUpload.prototype.setFileUploadLimit = function (a) {
  1040. this.settings.file_upload_limit = a;
  1041. this.callFlash("SetFileUploadLimit", [a])
  1042. };
  1043. SWFUpload.prototype.setFileQueueLimit = function (a) {
  1044. this.settings.file_queue_limit = a;
  1045. this.callFlash("SetFileQueueLimit", [a])
  1046. };
  1047. SWFUpload.prototype.setFilePostName = function (a) {
  1048. this.settings.file_post_name = a;
  1049. this.callFlash("SetFilePostName", [a])
  1050. };
  1051. SWFUpload.prototype.setUseQueryString = function (a) {
  1052. this.settings.use_query_string = a;
  1053. this.callFlash("SetUseQueryString", [a])
  1054. };
  1055. SWFUpload.prototype.setRequeueOnError = function (a) {
  1056. this.settings.requeue_on_error = a;
  1057. this.callFlash("SetRequeueOnError", [a])
  1058. };
  1059. SWFUpload.prototype.setHTTPSuccess = function (a) {
  1060. if (typeof a === "string") {
  1061. a = a.replace(" ", "").split(",")
  1062. }
  1063. this.settings.http_success = a;
  1064. this.callFlash("SetHTTPSuccess", [a])
  1065. };
  1066. SWFUpload.prototype.setAssumeSuccessTimeout = function (a) {
  1067. this.settings.assume_success_timeout = a;
  1068. this.callFlash("SetAssumeSuccessTimeout", [a])
  1069. };
  1070. SWFUpload.prototype.setDebugEnabled = function (a) {
  1071. this.settings.debug_enabled = a;
  1072. this.callFlash("SetDebugEnabled", [a])
  1073. };
  1074. SWFUpload.prototype.setButtonImageURL = function (a) {
  1075. if (a == undefined) {
  1076. a = ""
  1077. }
  1078. this.settings.button_image_url = a;
  1079. this.callFlash("SetButtonImageURL", [a])
  1080. };
  1081. SWFUpload.prototype.setButtonDimensions = function (c, a) {
  1082. this.settings.button_width = c;
  1083. this.settings.button_height = a;
  1084. var b = this.getMovieElement();
  1085. if (b != undefined) {
  1086. b.style.width = c + "px";
  1087. b.style.height = a + "px"
  1088. }
  1089. this.callFlash("SetButtonDimensions", [c, a])
  1090. };
  1091. SWFUpload.prototype.setButtonText = function (a) {
  1092. this.settings.button_text = a;
  1093. this.callFlash("SetButtonText", [a])
  1094. };
  1095. SWFUpload.prototype.setButtonTextPadding = function (b, a) {
  1096. this.settings.button_text_top_padding = a;
  1097. this.settings.button_text_left_padding = b;
  1098. this.callFlash("SetButtonTextPadding", [b, a])
  1099. };
  1100. SWFUpload.prototype.setButtonTextStyle = function (a) {
  1101. this.settings.button_text_style = a;
  1102. this.callFlash("SetButtonTextStyle", [a])
  1103. };
  1104. SWFUpload.prototype.setButtonDisabled = function (a) {
  1105. this.settings.button_disabled = a;
  1106. this.callFlash("SetButtonDisabled", [a])
  1107. };
  1108. SWFUpload.prototype.setButtonAction = function (a) {
  1109. this.settings.button_action = a;
  1110. this.callFlash("SetButtonAction", [a])
  1111. };
  1112. SWFUpload.prototype.setButtonCursor = function (a) {
  1113. this.settings.button_cursor = a;
  1114. this.callFlash("SetButtonCursor", [a])
  1115. };
  1116. SWFUpload.prototype.queueEvent = function (b, c) {
  1117. if (c == undefined) {
  1118. c = []
  1119. } else {
  1120. if (!(c instanceof Array)) {
  1121. c = [c]
  1122. }
  1123. }
  1124. var a = this;
  1125. if (typeof this.settings[b] === "function") {
  1126. this.eventQueue.push(function () {
  1127. this.settings[b].apply(this, c)
  1128. });
  1129. setTimeout(function () {
  1130. a.executeNextEvent()
  1131. }, 0)
  1132. } else {
  1133. if (this.settings[b] !== null) {
  1134. throw "Event handler " + b + " is unknown or is not a function"
  1135. }
  1136. }
  1137. };
  1138. SWFUpload.prototype.executeNextEvent = function () {
  1139. var a = this.eventQueue ? this.eventQueue.shift() : null;
  1140. if (typeof (a) === "function") {
  1141. a.apply(this)
  1142. }
  1143. };
  1144. SWFUpload.prototype.unescapeFilePostParams = function (c) {
  1145. var e = /[$]([0-9a-f]{4})/i;
  1146. var f = {};
  1147. var d;
  1148. if (c != undefined) {
  1149. for (var a in c.post) {
  1150. if (c.post.hasOwnProperty(a)) {
  1151. d = a;
  1152. var b;
  1153. while ((b = e.exec(d)) !== null) {
  1154. d = d.replace(b[0], String.fromCharCode(parseInt("0x" + b[1], 16)))
  1155. }
  1156. f[d] = c.post[a]
  1157. }
  1158. }
  1159. c.post = f
  1160. }
  1161. return c
  1162. };
  1163. SWFUpload.prototype.testExternalInterface = function () {
  1164. try {
  1165. return this.callFlash("TestExternalInterface")
  1166. } catch (a) {
  1167. return false
  1168. }
  1169. };
  1170. SWFUpload.prototype.flashReady = function () {
  1171. var a = this.getMovieElement();
  1172. if (!a) {
  1173. this.debug("Flash called back ready but the flash movie can't be found.");
  1174. return
  1175. }
  1176. this.cleanUp(a);
  1177. this.queueEvent("swfupload_loaded_handler")
  1178. };
  1179. SWFUpload.prototype.cleanUp = function (a) {
  1180. try {
  1181. if (this.movieElement && typeof (a.CallFunction) === "unknown") {
  1182. this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
  1183. for (var c in a) {
  1184. try {
  1185. if (typeof (a[c]) === "function") {
  1186. a[c] = null
  1187. }
  1188. } catch (b) { }
  1189. }
  1190. }
  1191. } catch (d) { }
  1192. window.__flash__removeCallback = function (e, f) {
  1193. try {
  1194. if (e) {
  1195. e[f] = null
  1196. }
  1197. } catch (g) { }
  1198. }
  1199. };
  1200. SWFUpload.prototype.fileDialogStart = function () {
  1201. this.queueEvent("file_dialog_start_handler")
  1202. };
  1203. SWFUpload.prototype.fileQueued = function (a) {
  1204. a = this.unescapeFilePostParams(a);
  1205. this.queueEvent("file_queued_handler", a)
  1206. };
  1207. SWFUpload.prototype.fileQueueError = function (a, c, b) {
  1208. a = this.unescapeFilePostParams(a);
  1209. this.queueEvent("file_queue_error_handler", [a, c, b])
  1210. };
  1211. SWFUpload.prototype.fileDialogComplete = function (b, c, a) {
  1212. this.queueEvent("file_dialog_complete_handler", [b, c, a])
  1213. };
  1214. SWFUpload.prototype.uploadStart = function (a) {
  1215. a = this.unescapeFilePostParams(a);
  1216. this.queueEvent("return_upload_start_handler", a)
  1217. };
  1218. SWFUpload.prototype.returnUploadStart = function (a) {
  1219. var b;
  1220. if (typeof this.settings.upload_start_handler === "function") {
  1221. a = this.unescapeFilePostParams(a);
  1222. b = this.settings.upload_start_handler.call(this, a)
  1223. } else {
  1224. if (this.settings.upload_start_handler != undefined) {
  1225. throw "upload_start_handler must be a function"
  1226. }
  1227. }
  1228. if (b === undefined) {
  1229. b = true
  1230. }
  1231. b = !!b;
  1232. this.callFlash("ReturnUploadStart", [b])
  1233. };
  1234. SWFUpload.prototype.uploadProgress = function (a, c, b) {
  1235. a = this.unescapeFilePostParams(a);
  1236. this.queueEvent("upload_progress_handler", [a, c, b])
  1237. };
  1238. SWFUpload.prototype.uploadError = function (a, c, b) {
  1239. a = this.unescapeFilePostParams(a);
  1240. this.queueEvent("upload_error_handler", [a, c, b])
  1241. };
  1242. SWFUpload.prototype.uploadSuccess = function (b, a, c) {
  1243. b = this.unescapeFilePostParams(b);
  1244. this.queueEvent("upload_success_handler", [b, a, c])
  1245. };
  1246. SWFUpload.prototype.uploadComplete = function (a) {
  1247. a = this.unescapeFilePostParams(a);
  1248. this.queueEvent("upload_complete_handler", a)
  1249. };
  1250. SWFUpload.prototype.debug = function (a) {
  1251. this.queueEvent("debug_handler", a)
  1252. };
  1253. SWFUpload.prototype.debugMessage = function (c) {
  1254. if (this.settings.debug) {
  1255. var a,
  1256. d = [];
  1257. if (typeof c === "object" && typeof c.name === "string" && typeof c.message === "string") {
  1258. for (var b in c) {
  1259. if (c.hasOwnProperty(b)) {
  1260. d.push(b + ": " + c[b])
  1261. }
  1262. }
  1263. a = d.join("\n") || "";
  1264. d = a.split("\n");
  1265. a = "EXCEPTION: " + d.join("\nEXCEPTION: ");
  1266. SWFUpload.Console.writeLine(a)
  1267. } else {
  1268. SWFUpload.Console.writeLine(c)
  1269. }
  1270. }
  1271. };
  1272. SWFUpload.Console = {};
  1273. SWFUpload.Console.writeLine = function (d) {
  1274. var b,
  1275. a;
  1276. try {
  1277. b = document.getElementById("SWFUpload_Console");
  1278. if (!b) {
  1279. a = document.createElement("form");
  1280. document.getElementsByTagName("body")[0].appendChild(a);
  1281. b = document.createElement("textarea");
  1282. b.id = "SWFUpload_Console";
  1283. b.style.fontFamily = "monospace";
  1284. b.setAttribute("wrap", "off");
  1285. b.wrap = "off";
  1286. b.style.overflow = "auto";
  1287. b.style.width = "700px";
  1288. b.style.height = "350px";
  1289. b.style.margin = "5px";
  1290. a.appendChild(b)
  1291. }
  1292. b.value += d + "\n";
  1293. b.scrollTop = b.scrollHeight - b.clientHeight
  1294. } catch (c) {
  1295. alert("Exception: " + c.name + " Message: " + c.message)
  1296. }
  1297. };
  1298. /*
  1299. Uploadify v3.2
  1300. Copyright (c) 2012 Reactive Apps, Ronnie Garcia
  1301. Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
  1302. */
  1303. (function ($) {
  1304. // These methods can be called by adding them as the first argument in the uploadify plugin call
  1305. var methods = {
  1306. init: function (options, swfUploadOptions) {
  1307. return this.each(function () {
  1308. // Create a reference to the jQuery DOM object
  1309. var $this = $(this);
  1310. // Clone the original DOM object
  1311. var $clone = $this.clone();
  1312. // Setup the default options
  1313. var settings = $.extend({
  1314. // Required Settings
  1315. id: $this.attr('id'), // The ID of the DOM object
  1316. swf: 'uploadify.swf', // The path to the uploadify SWF file
  1317. uploader: 'uploadify.php', // The path to the server-side upload script
  1318. // Options
  1319. auto: true, // Automatically upload files when added to the queue
  1320. buttonClass: '', // A class name to add to the browse button DOM object
  1321. buttonCursor: 'hand', // The cursor to use with the browse button
  1322. buttonImage: null, // (String or null) The path to an image to use for the Flash browse button if not using CSS to style the button
  1323. buttonText: 'SELECT FILES', // The text to use for the browse button
  1324. checkExisting: false, // The path to a server-side script that checks for existing files on the server
  1325. debug: false, // Turn on swfUpload debugging mode
  1326. fileObjName: 'Filedata', // The name of the file object to use in your server-side script
  1327. fileSizeLimit: 0, // The maximum size of an uploadable file in KB (Accepts units B KB MB GB if string, 0 for no limit)
  1328. fileTypeDesc: 'All Files', // The description for file types in the browse dialog
  1329. fileTypeExts: '*.*', // Allowed extensions in the browse dialog (server-side validation should also be used)
  1330. height: 30, // The height of the browse button
  1331. itemTemplate: false, // The template for the file item in the queue
  1332. method: 'post', // The method to use when sending files to the server-side upload script
  1333. multi: true, // Allow multiple file selection in the browse dialog
  1334. formData: {}, // An object with additional data to send to the server-side upload script with every file upload
  1335. preventCaching: true, // Adds a random value to the Flash URL to prevent caching of it (conflicts with existing parameters)
  1336. progressData: 'percentage', // ('percentage' or 'speed') Data to show in the queue item during a file upload
  1337. queueID: false, // The ID of the DOM object to use as a file queue (without the #)
  1338. queueSizeLimit: 999, // The maximum number of files that can be in the queue at one time
  1339. removeCompleted: true, // Remove queue items from the queue when they are done uploading
  1340. removeTimeout: 3, // The delay in seconds before removing a queue item if removeCompleted is set to true
  1341. requeueErrors: false, // Keep errored files in the queue and keep trying to upload them
  1342. successTimeout: 30, // The number of seconds to wait for Flash to detect the server's response after the file has finished uploading
  1343. uploadLimit: 0, // The maximum number of files you can upload
  1344. width: 120, // The width of the browse button
  1345. // Events
  1346. overrideEvents: []// (Array) A list of default event handlers to skip
  1347. /*
  1348. onCancel // Triggered when a file is cancelled from the queue
  1349. onClearQueue // Triggered during the 'clear queue' method
  1350. onDestroy // Triggered when the uploadify object is destroyed
  1351. onDialogClose // Triggered when the browse dialog is closed
  1352. onDialogOpen // Triggered when the browse dialog is opened
  1353. onDisable // Triggered when the browse button gets disabled
  1354. onEnable // Triggered when the browse button gets enabled
  1355. onFallback // Triggered is Flash is not detected
  1356. onInit // Triggered when Uploadify is initialized
  1357. onQueueComplete // Triggered when all files in the queue have been uploaded
  1358. onSelectError // Triggered when an error occurs while selecting a file (file size, queue size limit, etc.)
  1359. onSelect // Triggered for each file that is selected
  1360. onSWFReady // Triggered when the SWF button is loaded
  1361. onUploadComplete // Triggered when a file upload completes (success or error)
  1362. onUploadError // Triggered when a file upload returns an error
  1363. onUploadSuccess // Triggered when a file is uploaded successfully
  1364. onUploadProgress // Triggered every time a file progress is updated
  1365. onUploadStart // Triggered immediately before a file upload starts
  1366. */
  1367. }, options);
  1368. // Prepare settings for SWFUpload
  1369. var swfUploadSettings = {
  1370. assume_success_timeout: settings.successTimeout,
  1371. button_placeholder_id: settings.id,
  1372. button_width: settings.width,
  1373. button_height: settings.height,
  1374. button_text: null,
  1375. button_text_style: null,
  1376. button_text_top_padding: 0,
  1377. button_text_left_padding: 0,
  1378. button_action: (settings.multi ? SWFUpload.BUTTON_ACTION.SELECT_FILES : SWFUpload.BUTTON_ACTION.SELECT_FILE),
  1379. button_disabled: false,
  1380. button_cursor: (settings.buttonCursor == 'arrow' ? SWFUpload.CURSOR.ARROW : SWFUpload.CURSOR.HAND),
  1381. button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
  1382. debug: settings.debug,
  1383. requeue_on_error: settings.requeueErrors,
  1384. file_post_name: settings.fileObjName,
  1385. file_size_limit: settings.fileSizeLimit,
  1386. file_types: settings.fileTypeExts,
  1387. file_types_description: settings.fileTypeDesc,
  1388. file_queue_limit: settings.queueSizeLimit,
  1389. file_upload_limit: settings.uploadLimit,
  1390. flash_url: settings.swf,
  1391. prevent_swf_caching: settings.preventCaching,
  1392. post_params: settings.formData,
  1393. upload_url: settings.uploader,
  1394. use_query_string: (settings.method == 'get'),
  1395. // Event Handlers
  1396. file_dialog_complete_handler: handlers.onDialogClose,
  1397. file_dialog_start_handler: handlers.onDialogOpen,
  1398. file_queued_handler: handlers.onSelect,
  1399. file_queue_error_handler: handlers.onSelectError,
  1400. swfupload_loaded_handler: settings.onSWFReady,
  1401. upload_complete_handler: handlers.onUploadComplete,
  1402. upload_error_handler: handlers.onUploadError,
  1403. upload_progress_handler: handlers.onUploadProgress,
  1404. upload_start_handler: handlers.onUploadStart,
  1405. upload_success_handler: handlers.onUploadSuccess
  1406. }
  1407. // Merge the user-defined options with the defaults
  1408. if (swfUploadOptions) {
  1409. swfUploadSettings = $.extend(swfUploadSettings, swfUploadOptions);
  1410. }
  1411. // Add the user-defined settings to the swfupload object
  1412. swfUploadSettings = $.extend(swfUploadSettings, settings);
  1413. // Detect if Flash is available
  1414. var playerVersion = swfobject.getFlashPlayerVersion();
  1415. var flashInstalled = (playerVersion.major >= 9);
  1416. if (flashInstalled) {
  1417. // Create the swfUpload instance
  1418. window['uploadify_' + settings.id] = new SWFUpload(swfUploadSettings);
  1419. var swfuploadify = window['uploadify_' + settings.id];
  1420. // Add the SWFUpload object to the elements data object
  1421. $this.data('uploadify', swfuploadify);
  1422. // Wrap the instance
  1423. var $wrapper = $('<div />', {
  1424. 'id': settings.id,
  1425. 'class': 'uploadify',
  1426. 'css': {
  1427. 'height': settings.height + 'px',
  1428. 'width': settings.width + 'px'
  1429. }
  1430. });
  1431. $('#' + swfuploadify.movieName).wrap($wrapper);
  1432. // Recreate the reference to wrapper
  1433. $wrapper = $('#' + settings.id);
  1434. // Add the data object to the wrapper
  1435. $wrapper.data('uploadify', swfuploadify);
  1436. // Create the button
  1437. var $button = $('<div />', {
  1438. 'id': settings.id + '-button',
  1439. 'class': 'uploadify-button ' + settings.buttonClass
  1440. });
  1441. if (settings.buttonImage) {
  1442. $button.css({
  1443. 'background-image': "url('" + settings.buttonImage + "')",
  1444. 'text-indent': '-9999px'
  1445. });
  1446. }
  1447. $button.html('<span class="uploadify-button-text">' + settings.buttonText + '</span>')
  1448. .css({
  1449. 'height': settings.height + 'px',
  1450. 'line-height': settings.height + 'px',
  1451. 'width': settings.width + 'px'
  1452. });
  1453. // Append the button to the wrapper
  1454. $wrapper.append($button);
  1455. // Adjust the styles of the movie
  1456. $('#' + swfuploadify.movieName).css({
  1457. 'position': 'absolute',
  1458. 'z-index': 1
  1459. });
  1460. // Create the file queue
  1461. if (!settings.queueID) {
  1462. var $queue = $('<div />', {
  1463. 'id': settings.id + '-queue',
  1464. 'class': 'uploadify-queue'
  1465. });
  1466. $wrapper.after($queue);
  1467. swfuploadify.settings.queueID = settings.id + '-queue';
  1468. swfuploadify.settings.defaultQueue = true;
  1469. }
  1470. // Create some queue related objects and variables
  1471. swfuploadify.queueData = {
  1472. files: {}, // The files in the queue
  1473. filesSelected: 0, // The number of files selected in the last select operation
  1474. filesQueued: 0, // The number of files added to the queue in the last select operation
  1475. filesReplaced: 0, // The number of files replaced in the last select operation
  1476. filesCancelled: 0, // The number of files that were cancelled instead of replaced
  1477. filesErrored: 0, // The number of files that caused error in the last select operation
  1478. uploadsSuccessful: 0, // The number of files that were successfully uploaded
  1479. uploadsErrored: 0, // The number of files that returned errors during upload
  1480. averageSpeed: 0, // The average speed of the uploads in KB
  1481. queueLength: 0, // The number of files in the queue
  1482. queueSize: 0, // The size in bytes of the entire queue
  1483. uploadSize: 0, // The size in bytes of the upload queue
  1484. queueBytesUploaded: 0, // The size in bytes that have been uploaded for the current upload queue
  1485. uploadQueue: [], // The files currently to be uploaded
  1486. errorMsg: 'Some files were not added to the queue:'
  1487. };
  1488. // Save references to all the objects
  1489. swfuploadify.original = $clone;
  1490. swfuploadify.wrapper = $wrapper;
  1491. swfuploadify.button = $button;
  1492. swfuploadify.queue = $queue;
  1493. // Call the user-defined init event handler
  1494. if (settings.onInit)
  1495. settings.onInit.call($this, swfuploadify);
  1496. } else {
  1497. // Call the fallback function
  1498. if (settings.onFallback)
  1499. settings.onFallback.call($this);
  1500. }
  1501. });
  1502. },
  1503. // Stop a file upload and remove it from the queue
  1504. cancel: function (fileID, supressEvent) {
  1505. var args = arguments;
  1506. this.each(function () {
  1507. // Create a reference to the jQuery DOM object
  1508. var $this = $(this),
  1509. swfuploadify = $this.data('uploadify'),
  1510. settings = swfuploadify.settings,
  1511. delay = -1;
  1512. if (args[0]) {
  1513. // Clear the queue
  1514. if (args[0] == '*') {
  1515. var queueItemCount = swfuploadify.queueData.queueLength;
  1516. $('#' + settings.queueID).find('.uploadify-queue-item').each(function () {
  1517. delay++;
  1518. if (args[1] === true) {
  1519. swfuploadify.cancelUpload($(this).attr('id'), false);
  1520. } else {
  1521. swfuploadify.cancelUpload($(this).attr('id'));
  1522. }
  1523. $(this).find('.data').removeClass('data').html(' - Cancelled');
  1524. $(this).find('.uploadify-progress-bar').remove();
  1525. $(this).delay(1000 + 100 * delay).fadeOut(500, function () {
  1526. $(this).remove();
  1527. });
  1528. });
  1529. swfuploadify.queueData.queueSize = 0;
  1530. swfuploadify.queueData.queueLength = 0;
  1531. // Trigger the onClearQueue event
  1532. if (settings.onClearQueue)
  1533. settings.onClearQueue.call($this, queueItemCount);
  1534. } else {
  1535. for (var n = 0; n < args.length; n++) {
  1536. swfuploadify.cancelUpload(args[n]);
  1537. $('#' + args[n]).find('.data').removeClass('data').html(' - Cancelled');
  1538. $('#' + args[n]).find('.uploadify-progress-bar').remove();
  1539. $('#' + args[n]).delay(1000 + 100 * n).fadeOut(500, function () {
  1540. $(this).remove();
  1541. });
  1542. }
  1543. }
  1544. } else {
  1545. var item = $('#' + settings.queueID).find('.uploadify-queue-item').get(0);
  1546. $item = $(item);
  1547. swfuploadify.cancelUpload($item.attr('id'));
  1548. $item.find('.data').removeClass('data').html(' - Cancelled');
  1549. $item.find('.uploadify-progress-bar').remove();
  1550. $item.delay(1000).fadeOut(500, function () {
  1551. $(this).remove();
  1552. });
  1553. }
  1554. });
  1555. },
  1556. // Revert the DOM object back to its original state
  1557. destroy: function () {
  1558. this.each(function () {
  1559. // Create a reference to the jQuery DOM object
  1560. var $this = $(this),
  1561. swfuploadify = $this.data('uploadify'),
  1562. settings = swfuploadify.settings;
  1563. // Destroy the SWF object and
  1564. swfuploadify.destroy();
  1565. // Destroy the queue
  1566. if (settings.defaultQueue) {
  1567. $('#' + settings.queueID).remove();
  1568. }
  1569. // Reload the original DOM element
  1570. $('#' + settings.id).replaceWith(swfuploadify.original);
  1571. // Call the user-defined event handler
  1572. if (settings.onDestroy)
  1573. settings.onDestroy.call(this);
  1574. delete swfuploadify;
  1575. });
  1576. },
  1577. // Disable the select button
  1578. disable: function (isDisabled) {
  1579. this.each(function () {
  1580. // Create a reference to the jQuery DOM object
  1581. var $this = $(this),
  1582. swfuploadify = $this.data('uploadify'),
  1583. settings = swfuploadify.settings;
  1584. // Call the user-defined event handlers
  1585. if (isDisabled) {
  1586. swfuploadify.button.addClass('disabled');
  1587. if (settings.onDisable)
  1588. settings.onDisable.call(this);
  1589. } else {
  1590. swfuploadify.button.removeClass('disabled');
  1591. if (settings.onEnable)
  1592. settings.onEnable.call(this);
  1593. }
  1594. // Enable/disable the browse button
  1595. swfuploadify.setButtonDisabled(isDisabled);
  1596. });
  1597. },
  1598. // Get or set the settings data
  1599. settings: function (name, value, resetObjects) {
  1600. var args = arguments;
  1601. var returnValue = value;
  1602. this.each(function () {
  1603. // Create a reference to the jQuery DOM object
  1604. var $this = $(this),
  1605. swfuploadify = $this.data('uploadify'),
  1606. settings = swfuploadify.settings;
  1607. if (typeof (args[0]) == 'object') {
  1608. for (var n in value) {
  1609. setData(n, value[n]);
  1610. }
  1611. }
  1612. if (args.length === 1) {
  1613. returnValue = settings[name];
  1614. } else {
  1615. switch (name) {
  1616. case 'uploader':
  1617. swfuploadify.setUploadURL(value);
  1618. break;
  1619. case 'formData':
  1620. if (!resetObjects) {
  1621. value = $.extend(settings.formData, value);
  1622. }
  1623. swfuploadify.setPostParams(settings.formData);
  1624. break;
  1625. case 'method':
  1626. if (value == 'get') {
  1627. swfuploadify.setUseQueryString(true);
  1628. } else {
  1629. swfuploadify.setUseQueryString(false);
  1630. }
  1631. break;
  1632. case 'fileObjName':
  1633. swfuploadify.setFilePostName(value);
  1634. break;
  1635. case 'fileTypeExts':
  1636. swfuploadify.setFileTypes(value, settings.fileTypeDesc);
  1637. break;
  1638. case 'fileTypeDesc':
  1639. swfuploadify.setFileTypes(settings.fileTypeExts, value);
  1640. break;
  1641. case 'fileSizeLimit':
  1642. swfuploadify.setFileSizeLimit(value);
  1643. break;
  1644. case 'uploadLimit':
  1645. swfuploadify.setFileUploadLimit(value);
  1646. break;
  1647. case 'queueSizeLimit':
  1648. swfuploadify.setFileQueueLimit(value);
  1649. break;
  1650. case 'buttonImage':
  1651. swfuploadify.button.css('background-image', settingValue);
  1652. break;
  1653. case 'buttonCursor':
  1654. if (value == 'arrow') {
  1655. swfuploadify.setButtonCursor(SWFUpload.CURSOR.ARROW);
  1656. } else {
  1657. swfuploadify.setButtonCursor(SWFUpload.CURSOR.HAND);
  1658. }
  1659. break;
  1660. case 'buttonText':
  1661. $('#' + settings.id + '-button').find('.uploadify-button-text').html(value);
  1662. break;
  1663. case 'width':
  1664. swfuploadify.setButtonDimensions(value, settings.height);
  1665. break;
  1666. case 'height':
  1667. swfuploadify.setButtonDimensions(settings.width, value);
  1668. break;
  1669. case 'multi':
  1670. if (value) {
  1671. swfuploadify.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILES);
  1672. } else {
  1673. swfuploadify.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILE);
  1674. }
  1675. break;
  1676. }
  1677. settings[name] = value;
  1678. }
  1679. });
  1680. if (args.length === 1) {
  1681. return returnValue;
  1682. }
  1683. },
  1684. // Stop the current uploads and requeue what is in progress
  1685. stop: function () {
  1686. this.each(function () {
  1687. // Create a reference to the jQuery DOM object
  1688. var $this = $(this),
  1689. swfuploadify = $this.data('uploadify');
  1690. // Reset the queue information
  1691. swfuploadify.queueData.averageSpeed = 0;
  1692. swfuploadify.queueData.uploadSize = 0;
  1693. swfuploadify.queueData.bytesUploaded = 0;
  1694. swfuploadify.queueData.uploadQueue = [];
  1695. swfuploadify.stopUpload();
  1696. });
  1697. },
  1698. // Start uploading files in the queue
  1699. upload: function () {
  1700. var args = arguments;
  1701. this.each(function () {
  1702. // Create a reference to the jQuery DOM object
  1703. var $this = $(this),
  1704. swfuploadify = $this.data('uploadify');
  1705. // Reset the queue information
  1706. swfuploadify.queueData.averageSpeed = 0;
  1707. swfuploadify.queueData.uploadSize = 0;
  1708. swfuploadify.queueData.bytesUploaded = 0;
  1709. swfuploadify.queueData.uploadQueue = [];
  1710. // Upload the files
  1711. if (args[0]) {
  1712. if (args[0] == '*') {
  1713. swfuploadify.queueData.uploadSize = swfuploadify.queueData.queueSize;
  1714. swfuploadify.queueData.uploadQueue.push('*');
  1715. swfuploadify.startUpload();
  1716. } else {
  1717. for (var n = 0; n < args.length; n++) {
  1718. swfuploadify.queueData.uploadSize += swfuploadify.queueData.files[args[n]].size;
  1719. swfuploadify.queueData.uploadQueue.push(args[n]);
  1720. }
  1721. swfuploadify.startUpload(swfuploadify.queueData.uploadQueue.shift());
  1722. }
  1723. } else {
  1724. swfuploadify.startUpload();
  1725. }
  1726. });
  1727. }
  1728. }
  1729. // These functions handle all the events that occur with the file uploader
  1730. var handlers = {
  1731. // Triggered when the file dialog is opened
  1732. onDialogOpen: function () {
  1733. // Load the swfupload settings
  1734. var settings = this.settings;
  1735. // Reset some queue info
  1736. this.queueData.errorMsg = 'Some files were not added to the queue:';
  1737. this.queueData.filesReplaced = 0;
  1738. this.queueData.filesCancelled = 0;
  1739. // Call the user-defined event handler
  1740. if (settings.onDialogOpen)
  1741. settings.onDialogOpen.call(this);
  1742. },
  1743. // Triggered when the browse dialog is closed
  1744. onDialogClose: function (filesSelected, filesQueued, queueLength) {
  1745. // Load the swfupload settings
  1746. var settings = this.settings;
  1747. // Update the queue information
  1748. this.queueData.filesErrored = filesSelected - filesQueued;
  1749. this.queueData.filesSelected = filesSelected;
  1750. this.queueData.filesQueued = filesQueued - this.queueData.filesCancelled;
  1751. this.queueData.queueLength = queueLength;
  1752. // Run the default event handler
  1753. if ($.inArray('onDialogClose', settings.overrideEvents) < 0) {
  1754. if (this.queueData.filesErrored > 0) {
  1755. alert(this.queueData.errorMsg);
  1756. }
  1757. }
  1758. // Call the user-defined event handler
  1759. if (settings.onDialogClose)
  1760. settings.onDialogClose.call(this, this.queueData);
  1761. // Upload the files if auto is true
  1762. if (settings.auto)
  1763. $('#' + settings.id).uploadify('upload', '*');
  1764. },
  1765. // Triggered once for each file added to the queue
  1766. onSelect: function (file) {
  1767. // Load the swfupload settings
  1768. var settings = this.settings;
  1769. // Check if a file with the same name exists in the queue
  1770. var queuedFile = {};
  1771. for (var n in this.queueData.files) {
  1772. queuedFile = this.queueData.files[n];
  1773. if (queuedFile.uploaded != true && queuedFile.name == file.name) {
  1774. var replaceQueueItem = confirm('The file named "' + file.name + '" is already in the queue.\nDo you want to replace the existing item in the queue?');
  1775. if (!replaceQueueItem) {
  1776. this.cancelUpload(file.id);
  1777. this.queueData.filesCancelled++;
  1778. return false;
  1779. } else {
  1780. $('#' + queuedFile.id).remove();
  1781. this.cancelUpload(queuedFile.id);
  1782. this.queueData.filesReplaced++;
  1783. }
  1784. }
  1785. }
  1786. // Get the size of the file
  1787. var fileSize = Math.round(file.size / 1024);
  1788. var suffix = 'KB';
  1789. if (fileSize > 1000) {
  1790. fileSize = Math.round(fileSize / 1000);
  1791. suffix = 'MB';
  1792. }
  1793. var fileSizeParts = fileSize.toString().split('.');
  1794. fileSize = fileSizeParts[0];
  1795. if (fileSizeParts.length > 1) {
  1796. fileSize += '.' + fileSizeParts[1].substr(0, 2);
  1797. }
  1798. fileSize += suffix;
  1799. // Truncate the filename if it's too long
  1800. var fileName = file.name;
  1801. if (fileName.length > 25) {
  1802. fileName = fileName.substr(0, 25) + '...';
  1803. }
  1804. // Create the file data object
  1805. itemData = {
  1806. 'fileID': file.id,
  1807. 'instanceID': settings.id,
  1808. 'fileName': fileName,
  1809. 'fileSize': fileSize
  1810. }
  1811. // Create the file item template
  1812. if (settings.itemTemplate == false) {
  1813. settings.itemTemplate = '<div id="${fileID}" class="uploadify-queue-item">\
  1814. <div class="cancel">\
  1815. <a href="javascript:$(\'#${instanceID}\').uploadify(\'cancel\', \'${fileID}\')">X</a>\
  1816. </div>\
  1817. <span class="fileName">${fileName} (${fileSize})</span><span class="data"></span>\
  1818. <div class="uploadify-progress">\
  1819. <div class="uploadify-progress-bar"><!--Progress Bar--></div>\
  1820. </div>\
  1821. </div>';
  1822. }
  1823. // Run the default event handler
  1824. if ($.inArray('onSelect', settings.overrideEvents) < 0) {
  1825. // Replace the item data in the template
  1826. itemHTML = settings.itemTemplate;
  1827. for (var d in itemData) {
  1828. itemHTML = itemHTML.replace(new RegExp('\\$\\{' + d + '\\}', 'g'), itemData[d]);
  1829. }
  1830. // Add the file item to the queue
  1831. $('#' + settings.queueID).append(itemHTML);
  1832. }
  1833. this.queueData.queueSize += file.size;
  1834. this.queueData.files[file.id] = file;
  1835. // Call the user-defined event handler
  1836. if (settings.onSelect)
  1837. settings.onSelect.apply(this, arguments);
  1838. },
  1839. // Triggered when a file is not added to the queue
  1840. onSelectError: function (file, errorCode, errorMsg) {
  1841. // Load the swfupload settings
  1842. var settings = this.settings;
  1843. // Run the default event handler
  1844. if ($.inArray('onSelectError', settings.overrideEvents) < 0) {
  1845. switch (errorCode) {
  1846. case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
  1847. if (settings.queueSizeLimit > errorMsg) {
  1848. this.queueData.errorMsg += '\nThe number of files selected exceeds the remaining upload limit (' + errorMsg + ').';
  1849. } else {
  1850. this.queueData.errorMsg += '\nThe number of files selected exceeds the queue size limit (' + settings.queueSizeLimit + ').';
  1851. }
  1852. break;
  1853. case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
  1854. this.queueData.errorMsg += '\nThe file "' + file.name + '" exceeds the size limit (' + settings.fileSizeLimit + ').';
  1855. break;
  1856. case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
  1857. this.queueData.errorMsg += '\nThe file "' + file.name + '" is empty.';
  1858. break;
  1859. case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
  1860. this.queueData.errorMsg += '\nThe file "' + file.name + '" is not an accepted file type (' + settings.fileTypeDesc + ').';
  1861. break;
  1862. }
  1863. }
  1864. if (errorCode != SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
  1865. delete this.queueData.files[file.id];
  1866. }
  1867. // Call the user-defined event handler
  1868. if (settings.onSelectError)
  1869. settings.onSelectError.apply(this, arguments);
  1870. },
  1871. // Triggered when all the files in the queue have been processed
  1872. onQueueComplete: function () {
  1873. if (this.settings.onQueueComplete)
  1874. this.settings.onQueueComplete.call(this, this.settings.queueData);
  1875. },
  1876. // Triggered when a file upload successfully completes
  1877. onUploadComplete: function (file) {
  1878. // Load the swfupload settings
  1879. var settings = this.settings,
  1880. swfuploadify = this;
  1881. // Check if all the files have completed uploading
  1882. var stats = this.getStats();
  1883. this.queueData.queueLength = stats.files_queued;
  1884. if (this.queueData.uploadQueue[0] == '*') {
  1885. if (this.queueData.queueLength > 0) {
  1886. this.startUpload();
  1887. } else {
  1888. this.queueData.uploadQueue = [];
  1889. // Call the user-defined event handler for queue complete
  1890. if (settings.onQueueComplete)
  1891. settings.onQueueComplete.call(this, this.queueData);
  1892. }
  1893. } else {
  1894. if (this.queueData.uploadQueue.length > 0) {
  1895. this.startUpload(this.queueData.uploadQueue.shift());
  1896. } else {
  1897. this.queueData.uploadQueue = [];
  1898. // Call the user-defined event handler for queue complete
  1899. if (settings.onQueueComplete)
  1900. settings.onQueueComplete.call(this, this.queueData);
  1901. }
  1902. }
  1903. // Call the default event handler
  1904. if ($.inArray('onUploadComplete', settings.overrideEvents) < 0) {
  1905. if (settings.removeCompleted) {
  1906. switch (file.filestatus) {
  1907. case SWFUpload.FILE_STATUS.COMPLETE:
  1908. setTimeout(function () {
  1909. if ($('#' + file.id)) {
  1910. swfuploadify.queueData.queueSize -= file.size;
  1911. swfuploadify.queueData.queueLength -= 1;
  1912. delete swfuploadify.queueData.files[file.id]
  1913. $('#' + file.id).fadeOut(500, function () {
  1914. $(this).remove();
  1915. });
  1916. }
  1917. }, settings.removeTimeout * 1000);
  1918. break;
  1919. case SWFUpload.FILE_STATUS.ERROR:
  1920. if (!settings.requeueErrors) {
  1921. setTimeout(function () {
  1922. if ($('#' + file.id)) {
  1923. swfuploadify.queueData.queueSize -= file.size;
  1924. swfuploadify.queueData.queueLength -= 1;
  1925. delete swfuploadify.queueData.files[file.id];
  1926. $('#' + file.id).fadeOut(500, function () {
  1927. $(this).remove();
  1928. });
  1929. }
  1930. }, settings.removeTimeout * 1000);
  1931. }
  1932. break;
  1933. }
  1934. } else {
  1935. file.uploaded = true;
  1936. }
  1937. }
  1938. // Call the user-defined event handler
  1939. if (settings.onUploadComplete)
  1940. settings.onUploadComplete.call(this, file);
  1941. },
  1942. // Triggered when a file upload returns an error
  1943. onUploadError: function (file, errorCode, errorMsg) {
  1944. // Load the swfupload settings
  1945. var settings = this.settings;
  1946. // Set the error string
  1947. var errorString = 'Error';
  1948. switch (errorCode) {
  1949. case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
  1950. errorString = 'HTTP Error (' + errorMsg + ')';
  1951. break;
  1952. case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
  1953. errorString = 'Missing Upload URL';
  1954. break;
  1955. case SWFUpload.UPLOAD_ERROR.IO_ERROR:
  1956. errorString = 'IO Error';
  1957. break;
  1958. case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
  1959. errorString = 'Security Error';
  1960. break;
  1961. case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
  1962. alert('The upload limit has been reached (' + errorMsg + ').');
  1963. errorString = 'Exceeds Upload Limit';
  1964. break;
  1965. case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
  1966. errorString = 'Failed';
  1967. break;
  1968. case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
  1969. break;
  1970. case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
  1971. errorString = 'Validation Error';
  1972. break;
  1973. case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
  1974. errorString = 'Cancelled';
  1975. this.queueData.queueSize -= file.size;
  1976. this.queueData.queueLength -= 1;
  1977. if (file.status == SWFUpload.FILE_STATUS.IN_PROGRESS || $.inArray(file.id, this.queueData.uploadQueue) >= 0) {
  1978. this.queueData.uploadSize -= file.size;
  1979. }
  1980. // Trigger the onCancel event
  1981. if (settings.onCancel)
  1982. settings.onCancel.call(this, file);
  1983. delete this.queueData.files[file.id];
  1984. break;
  1985. case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
  1986. errorString = 'Stopped';
  1987. break;
  1988. }
  1989. // Call the default event handler
  1990. if ($.inArray('onUploadError', settings.overrideEvents) < 0) {
  1991. if (errorCode != SWFUpload.UPLOAD_ERROR.FILE_CANCELLED && errorCode != SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED) {
  1992. $('#' + file.id).addClass('uploadify-error');
  1993. }
  1994. // Reset the progress bar
  1995. $('#' + file.id).find('.uploadify-progress-bar').css('width', '1px');
  1996. // Add the error message to the queue item
  1997. if (errorCode != SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND && file.status != SWFUpload.FILE_STATUS.COMPLETE) {
  1998. $('#' + file.id).find('.data').html(' - ' + errorString);
  1999. }
  2000. }
  2001. var stats = this.getStats();
  2002. this.queueData.uploadsErrored = stats.upload_errors;
  2003. // Call the user-defined event handler
  2004. if (settings.onUploadError)
  2005. settings.onUploadError.call(this, file, errorCode, errorMsg, errorString);
  2006. },
  2007. // Triggered periodically during a file upload
  2008. onUploadProgress: function (file, fileBytesLoaded, fileTotalBytes) {
  2009. // Load the swfupload settings
  2010. var settings = this.settings;
  2011. // Setup all the variables
  2012. var timer = new Date();
  2013. var newTime = timer.getTime();
  2014. var lapsedTime = newTime - this.timer;
  2015. if (lapsedTime > 500) {
  2016. this.timer = newTime;
  2017. }
  2018. var lapsedBytes = fileBytesLoaded - this.bytesLoaded;
  2019. this.bytesLoaded = fileBytesLoaded;
  2020. var queueBytesLoaded = this.queueData.queueBytesUploaded + fileBytesLoaded;
  2021. var percentage = Math.round(fileBytesLoaded / fileTotalBytes * 100);
  2022. // Calculate the average speed
  2023. var suffix = 'KB/s';
  2024. var mbs = 0;
  2025. var kbs = (lapsedBytes / 1024) / (lapsedTime / 1000);
  2026. kbs = Math.floor(kbs * 10) / 10;
  2027. if (this.queueData.averageSpeed > 0) {
  2028. this.queueData.averageSpeed = Math.floor((this.queueData.averageSpeed + kbs) / 2);
  2029. } else {
  2030. this.queueData.averageSpeed = Math.floor(kbs);
  2031. }
  2032. if (kbs > 1000) {
  2033. mbs = (kbs * .001);
  2034. this.queueData.averageSpeed = Math.floor(mbs);
  2035. suffix = 'MB/s';
  2036. }
  2037. // Call the default event handler
  2038. if ($.inArray('onUploadProgress', settings.overrideEvents) < 0) {
  2039. if (settings.progressData == 'percentage') {
  2040. $('#' + file.id).find('.data').html(' - ' + percentage + '%');
  2041. } else if (settings.progressData == 'speed' && lapsedTime > 500) {
  2042. $('#' + file.id).find('.data').html(' - ' + this.queueData.averageSpeed + suffix);
  2043. }
  2044. $('#' + file.id).find('.uploadify-progress-bar').css('width', percentage + '%');
  2045. }
  2046. // Call the user-defined event handler
  2047. if (settings.onUploadProgress)
  2048. settings.onUploadProgress.call(this, file, fileBytesLoaded, fileTotalBytes, queueBytesLoaded, this.queueData.uploadSize);
  2049. },
  2050. // Triggered right before a file is uploaded
  2051. onUploadStart: function (file) {
  2052. // Load the swfupload settings
  2053. var settings = this.settings;
  2054. var timer = new Date();
  2055. this.timer = timer.getTime();
  2056. this.bytesLoaded = 0;
  2057. if (this.queueData.uploadQueue.length == 0) {
  2058. this.queueData.uploadSize = file.size;
  2059. }
  2060. if (settings.checkExisting) {
  2061. $.ajax({
  2062. type: 'POST',
  2063. async: false,
  2064. url: settings.checkExisting,
  2065. data: {
  2066. filename: file.name
  2067. },
  2068. success: function (data) {
  2069. if (data == 1) {
  2070. var overwrite = confirm('A file with the name "' + file.name + '" already exists on the server.\nWould you like to replace the existing file?');
  2071. if (!overwrite) {
  2072. this.cancelUpload(file.id);
  2073. $('#' + file.id).remove();
  2074. if (this.queueData.uploadQueue.length > 0 && this.queueData.queueLength > 0) {
  2075. if (this.queueData.uploadQueue[0] == '*') {
  2076. this.startUpload();
  2077. } else {
  2078. this.startUpload(this.queueData.uploadQueue.shift());
  2079. }
  2080. }
  2081. }
  2082. }
  2083. }
  2084. });
  2085. }
  2086. // Call the user-defined event handler
  2087. if (settings.onUploadStart)
  2088. settings.onUploadStart.call(this, file);
  2089. },
  2090. // Triggered when a file upload returns a successful code
  2091. onUploadSuccess: function (file, data, response) {
  2092. // Load the swfupload settings
  2093. var settings = this.settings;
  2094. var stats = this.getStats();
  2095. this.queueData.uploadsSuccessful = stats.successful_uploads;
  2096. this.queueData.queueBytesUploaded += file.size;
  2097. // Call the default event handler
  2098. if ($.inArray('onUploadSuccess', settings.overrideEvents) < 0) {
  2099. $('#' + file.id).find('.data').html(' - Complete');
  2100. }
  2101. // Call the user-defined event handler
  2102. if (settings.onUploadSuccess)
  2103. settings.onUploadSuccess.call(this, file, data, response);
  2104. }
  2105. }
  2106. $.fn.uploadify = function (method) {
  2107. if (methods[method]) {
  2108. return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
  2109. } else if (typeof method === 'object' || !method) {
  2110. return methods.init.apply(this, arguments);
  2111. } else {
  2112. $.error('The method ' + method + ' does not exist in $.uploadify');
  2113. }
  2114. }
  2115. })($);