jquery.uploadify-3.1.js 73 KB

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