| 1 | var swfu; |
|---|
| 2 | var holder = new Array() ; |
|---|
| 3 | var current_name ; |
|---|
| 4 | Event.observe(window, 'load', function () |
|---|
| 5 | { |
|---|
| 6 | swfu = new SWFUpload({ |
|---|
| 7 | upload_url : flutter_path+"RCCWP_GetFile.php", |
|---|
| 8 | flash_url : flutter_path+"js/swfupload/swfupload_f9.swf", |
|---|
| 9 | file_size_limit : "20480", |
|---|
| 10 | debug : false, |
|---|
| 11 | file_queued_handler : startUploading, |
|---|
| 12 | upload_start_handler : adjust, |
|---|
| 13 | upload_progress_handler : progress, |
|---|
| 14 | upload_success_handler : completed, |
|---|
| 15 | post_params : { |
|---|
| 16 | "auth_cookie" : swf_authentication, |
|---|
| 17 | "_wpnonce" : swf_nonce |
|---|
| 18 | } |
|---|
| 19 | }); |
|---|
| 20 | }); |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | function openFile(input_name) |
|---|
| 24 | { |
|---|
| 25 | swfu.selectFile() ; |
|---|
| 26 | current_name = input_name ; |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | function startUploading(file) |
|---|
| 30 | { |
|---|
| 31 | holder[file.id] = current_name ; |
|---|
| 32 | var progr = document.getElementById("upload_progress_"+current_name) ; |
|---|
| 33 | progr.style.visibility = "visible" ; |
|---|
| 34 | progr.style.height = "auto" ; |
|---|
| 35 | progr.innerHTML = "Waiting ... " ; |
|---|
| 36 | var h = swfu.getStats() ; |
|---|
| 37 | swfu.startUpload() ; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | function adjust(file) |
|---|
| 41 | { |
|---|
| 42 | var progr = document.getElementById("upload_progress_"+holder[file.id]) ; |
|---|
| 43 | progr.style.visibility = "visible" ; |
|---|
| 44 | progr.style.height = "auto" ; |
|---|
| 45 | progr.innerHTML = "<img src="+flutter_path+"images/spinner.gif /> uploading ... <img src='"+flutter_path+"images/bar.jpg' height=10 width=0 />" ; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | function progress(file,compl,total) |
|---|
| 49 | { |
|---|
| 50 | var progr = document.getElementById("upload_progress_"+holder[file.id]) ; |
|---|
| 51 | progr.innerHTML = "<img src="+flutter_path+"images/spinner.gif />uploading ... " + parseInt(100*compl/total) + "% <img src='"+flutter_path+"images/bar.jpg' height=10 width="+(100*compl/total)+" />" ; |
|---|
| 52 | |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | function completed(file,server_data) |
|---|
| 56 | { |
|---|
| 57 | var progr = document.getElementById("upload_progress_"+holder[file.id]) ; |
|---|
| 58 | progr.style.visibility = "visible" ; |
|---|
| 59 | progr.style.height = "auto" ; |
|---|
| 60 | var hold = new Array() ; |
|---|
| 61 | hold = server_data.split("*") ; |
|---|
| 62 | progr.innerHTML = hold[0] ; |
|---|
| 63 | document.getElementById(holder[file.id]).value = hold[1] ; |
|---|
| 64 | if (document.getElementById( "img_thumb_"+holder[file.id] )) |
|---|
| 65 | { |
|---|
| 66 | document.getElementById( "img_thumb_"+holder[file.id] ).src = flutter_path+"phpThumb.php?&w=150&h=120&src="+"files_flutter/"+hold[1] ; |
|---|
| 67 | var s = "<a href='#impossible_location' onclick=call_thickbox('"+hold[2]+"')>" ; |
|---|
| 68 | var e = "<strong onclick=prepareUpdatePhoto('"+holder[file.id]+"')>Edit</strong> </a>" ; |
|---|
| 69 | document.getElementById( "photo_edit_link_"+holder[file.id] ).innerHTML = s + e ; |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | function call_thickbox(url) |
|---|
| 74 | { |
|---|
| 75 | tb_show("Flutter",url,false) ; |
|---|
| 76 | } |
|---|
| 77 | function uploadurl(input_name,file_type) |
|---|
| 78 | { |
|---|
| 79 | var url = document.getElementById( "upload_url_"+input_name).value ; |
|---|
| 80 | var progr = document.getElementById("upload_progress_"+input_name) ; |
|---|
| 81 | var h ; |
|---|
| 82 | progr.style.visibility = "visible" ; |
|---|
| 83 | progr.style.height = "auto" ; |
|---|
| 84 | progr.innerHTML = "<img src="+flutter_path+"images/spinner.gif /> Downlaoding File ..." ; |
|---|
| 85 | new Ajax.Request(flutter_path+'RCCWP_GetFile.php', |
|---|
| 86 | { |
|---|
| 87 | method:'post', |
|---|
| 88 | onSuccess: function(transport){ |
|---|
| 89 | h = transport.responseText.split("*") ; |
|---|
| 90 | document.getElementById(input_name).value = h[1] ; |
|---|
| 91 | progr.innerHTML = h[0] ; |
|---|
| 92 | if( document.getElementById( "img_thumb_"+input_name ) ) |
|---|
| 93 | { |
|---|
| 94 | document.getElementById( "img_thumb_"+input_name ).src = flutter_path+"phpThumb.php?&w=150&h=120&src="+"files_flutter/"+h[1] ; |
|---|
| 95 | var s = "<a href='#impossible_location' onclick=call_thickbox('"+h[2]+"')>" ; |
|---|
| 96 | var e = "<strong onclick=prepareUpdatePhoto('"+input_name+"')>Edit</strong> </a>" ; |
|---|
| 97 | document.getElementById( "photo_edit_link_"+input_name ).innerHTML = s + e ; |
|---|
| 98 | } |
|---|
| 99 | }, |
|---|
| 100 | parameters: "upload_url="+url+"&input_name="+input_name+"&type="+file_type |
|---|
| 101 | }); |
|---|
| 102 | } |
|---|