swfupload.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. function remove_this(obj){
  2. $('#'+obj).remove();
  3. }
  4. function clean_thumb(inputid){
  5. $('#'+inputid+'_pic').attr('src',PUBLIC+'/Images/admin_upload_thumb.png');
  6. var aid = $('#'+inputid).val();
  7. $('#'+inputid).val('');
  8. $('#'+inputid+'_aid_box').html('');
  9. }
  10. function swfupload(id,inputid,title,isadmin,more,isthumb,file_limit,file_types,file_size,moduleid,auth,yesdo,nodo){
  11. url = APP+'?g=Admin&m=Attachment&a=index&isadmin='+isadmin+'&more='+more+'&isthumb='+isthumb+'&file_limit='+file_limit+'&file_types='+file_types+'&file_size='+file_size+'&moduleid='+moduleid+'&auth='+auth;
  12. art.dialog.open(url, {
  13. id: id,
  14. title: title,
  15. lock: 'true',
  16. window: 'top',
  17. width: 600,
  18. height: 455,
  19. ok: function(){
  20. var iframeWin = this.iframe.contentWindow;
  21. var topWin = art.dialog.top;
  22. yesdo.call(this,iframeWin, topWin,id,inputid);
  23. },
  24. cancel: true
  25. });
  26. }
  27. function yesdo(iframeWin, topWin,id,inputid){
  28. var num = iframeWin.$('#myuploadform > div').length;
  29. if(num){
  30. var aids = iframeWin.$('#myuploadform #aids').attr("value");
  31. var status = iframeWin.$('#myuploadform #status').attr("value");
  32. var filedata = iframeWin.$('#myuploadform #filedata').attr("value");
  33. var namedata = iframeWin.$('#myuploadform #filedata').attr("value");
  34. //var namedata = iframeWin.document.forms["myuploadform"].elements["namedata"];
  35. if(filedata){
  36. $('#'+inputid+'_pic').attr('src',filedata);
  37. $('#'+inputid).val(filedata);
  38. if(status==0) $('#'+inputid+'_aid_box').html('<input type="hidden" name="aid[]" value="'+aids+'" />');
  39. }
  40. //$('#'+inputid+'_aid').val(aids);
  41. //$('#filelis').html(iframeWin.$('#myuploadform').html());
  42. }
  43. }
  44. function up_image(iframeWin, topWin,id,inputid){
  45. var num = iframeWin.$('#myuploadform > div').length;
  46. if(num){
  47. var aids = iframeWin.$('#myuploadform #aids').attr("value");
  48. var status = iframeWin.$('#myuploadform #status').attr("value");
  49. var filedata = iframeWin.$('#myuploadform #filedata').attr("value");
  50. var namedata = iframeWin.$('#myuploadform #filedata').attr("value");
  51. if(filedata){
  52. $('#'+inputid+'_pic').attr('src',filedata);
  53. $('#'+inputid).val(filedata);
  54. if(status==0) $('#'+inputid+'_aid_box').html('<input type="hidden" name="aid[]" value="'+aids+'" />');
  55. }
  56. }
  57. }
  58. function up_images(iframeWin, topWin,id,inputid){
  59. var data = '';
  60. var aidinput='';
  61. var num = iframeWin.$('#myuploadform > div').length;
  62. if(num){
  63. iframeWin.$('#myuploadform div ').each(function(){
  64. var status = $(this).find('#status').val();
  65. var aid = $(this).find('#aids').val();
  66. var src = $(this).find('#filedata').val();
  67. var name = $(this).find('#namedata').val();
  68. if(status==0) aidinput = '<input type="hidden" name="aid[]" value="'+aid+'"/>';
  69. data += '<div id="uplist_'+aid+'">'+aidinput+'<input type="text" size="50" class="input-text" name="'+inputid+'[]" value="'+src+'" /> <input type="text" class="input-text" name="'+inputid+'_name[]" value="'+name+'" size="30" /> &nbsp;<a href="javascript:remove_this(\'uplist_'+aid+'\');">移除</a> </div>';
  70. });
  71. $('#'+inputid+'_images').append(data);
  72. }
  73. }
  74. function insert2editor(iframeWin, topWin,id,inputid){
  75. var img = '';
  76. var data = '';
  77. var num = iframeWin.$('#myuploadform > div').length;
  78. if(num){
  79. iframeWin.$('#myuploadform div').each(function(){
  80. var status = $(this).find('#status').val();
  81. var aid = $(this).find('#aids').val();
  82. var src = $(this).find('#filedata').val();
  83. var name = $(this).find('#namedata').val();
  84. if(status==0) data += '<input type="text" name="aid[]" value="'+aid+'"/>';
  85. img += IsImg(src) ? '<img src="'+src+'" /><br />' : (IsSwf(src) ? '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="movie" value="'+src+'" /><embed pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="'+src+'" type="application/x-shockwave-flash" width="460"></embed></object>' :'<a href="'+src+'" />'+src+'</a><br />') ;
  86. });
  87. $('#'+inputid+'_aid_box').append(data);
  88. }
  89. CKEDITOR.instances[inputid].insertHtml(img);
  90. }
  91. function upokis(arrMsg){
  92. //$('#'+arrMsg[0].editorid+'_aid_box').show();
  93. var i,msg;
  94. for(i=0;i<arrMsg.length;i++)
  95. {
  96. msg=arrMsg[i];
  97. if(msg.id>0)$('#'+msg.editorid+'_aid_box').append('<input type="text" name="aid[]" value="'+msg.id+'"/>');
  98. //$("#uploadList").append('<option value="'+msg.id+'">'+msg.localname+'</option>');
  99. }
  100. }
  101. function upok(id,data){
  102. alert(id);
  103. $('#'+id+'_aid_box').append('ddddddddddddddddd');
  104. $('#'+id+'_aid_box').show();
  105. }
  106. function nodo(iframeWin, topWin){
  107. art.dialog.close();
  108. }
  109. function IsImg(url){
  110. var sTemp;
  111. var b=false;
  112. var opt="jpg|gif|png|bmp|jpeg";
  113. var s=opt.toUpperCase().split("|");
  114. for (var i=0;i<s.length ;i++ ){
  115. sTemp=url.substr(url.length-s[i].length-1);
  116. sTemp=sTemp.toUpperCase();
  117. s[i]="."+s[i];
  118. if (s[i]==sTemp){
  119. b=true;
  120. break;
  121. }
  122. }
  123. return b;
  124. }
  125. function IsSwf(url){
  126. var sTemp;
  127. var b=false;
  128. var opt="swf";
  129. var s=opt.toUpperCase().split("|");
  130. for (var i=0;i<s.length ;i++ ){
  131. sTemp=url.substr(url.length-s[i].length-1);
  132. sTemp=sTemp.toUpperCase();
  133. s[i]="."+s[i];
  134. if (s[i]==sTemp){
  135. b=true;
  136. break;
  137. }
  138. }
  139. return b;
  140. }