function.js
上传用户:yttaitong
上传日期:2009-05-10
资源大小:128k
文件大小:16k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

PHP

  1. /*
  2. --------------------------
  3. Copyright by T.muqiao(39号天堂桥)
  4. 本程序仅供学习讨论使用,在未通知作者作为任何商业用途
  5.          视为中华人民共和国不道德公民
  6. 联系方式:442536278@qq.com
  7. -------------------------*/
  8. //兼容microsoft的IE和mozilla的FireFox(2月5日搞定)
  9. //*****************右键菜单******************/
  10. //
  11. var y = null;
  12. var x = null;
  13. var z = null;
  14. var w = null;
  15. var type   = 0;
  16. var path   = ".";
  17. var ID     = null;
  18. var menu   = null;
  19. var ns6=(document.getElementById&&!document.all);
  20. var ie=(document.all);
  21. if (ns6){
  22. window.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
  23. document.releaseEvents(Event.MOUSEMOVE);
  24. }
  25. if (ie||document.getElementById){
  26. document.onmousedown = down;
  27. }
  28. if(ie||ns6){
  29. document.oncontextmenu = oncontext; 
  30. }
  31. if(ie){
  32. document.onmouseup = microie;
  33. }
  34. if(ns6){
  35. document.onmouseup = mozilla;
  36. }
  37. function oncontext(){
  38. return false;
  39. }
  40. function setvars(n,value,Idvalue){
  41. type   = n;
  42. path   = value;
  43. ID     = Idvalue;
  44. }
  45. function start(obj){
  46. if (ie||ns6){
  47. z = document.getElementById(obj).style; 
  48. }
  49. ID = null;
  50. }
  51. function down(e){
  52. for(i=1;i<Elements;i++){
  53. if(i==ID){
  54. document.getElementById("element_"+i).className = 'selected';
  55. }else{
  56. document.getElementById("element_"+i).className = 'default';
  57. }
  58. }
  59. document.onmousemove = move;
  60. if (ie){
  61. y=window.event.offsetY;
  62. x=window.event.offsetX;
  63. }
  64. if (ns6){
  65. x=e.clientX - parseInt(z.left);
  66. y=e.clientY - parseInt(z.top);
  67. }
  68. return false;
  69. }
  70. function move(e){
  71. if(z){
  72. if (ns6){
  73. z.top  = parseInt(e.clientY)-y;
  74. z.left = parseInt(e.clientX)-x;
  75. }
  76. if (ie){
  77. z.posLeft = window.event.clientX-x;
  78. z.posTop  = window.event.clientY-y;
  79. }
  80. }
  81. return false;
  82. }
  83. function microie(e){
  84. if(z){
  85. document.onmousemove=null;
  86. }
  87. if(ie){
  88. menu = document.getElementById("rightmenu");
  89. if(event.button==2){
  90. makemenu();
  91. var rightedge  = document.body.clientWidth-event.clientX;
  92. var bottomedge = document.body.clientHeight-event.clientY;
  93. if (rightedge < menu.offsetWidth){
  94. menu.style.left = document.body.scrollLeft + event.clientX - menu.offsetWidth;
  95. }else{
  96. menu.style.left = document.body.scrollLeft + event.clientX;
  97. }
  98. if (bottomedge < menu.offsetHeight){
  99. menu.style.top = document.body.scrollTop + event.clientY - menu.offsetHeight;
  100. }else{
  101. menu.style.top = document.body.scrollTop + event.clientY;
  102. }
  103. menu.style.visibility = "visible";
  104. return false;
  105. }
  106. if(event.button==1){
  107. hidemenu();
  108. }
  109. }
  110. }
  111. function mozilla(e){
  112. if(z){
  113. document.onmousemove=null;
  114. }
  115. if(ns6){
  116. menu = document.getElementById("rightmenu");
  117. if(e.which==3){
  118. makemenu();
  119. var rightedge  = document.body.clientWidth-parseInt(e.clientX);
  120. var bottomedge = document.body.clientHeight-parseInt(e.clientY);
  121. if (rightedge < menu.offsetWidth){
  122. menu.style.left = document.body.scrollLeft + parseInt(e.clientX) - menu.offsetWidth;
  123. }else{
  124. menu.style.left = document.body.scrollLeft + parseInt(e.clientX);
  125. }
  126. if (bottomedge < menu.offsetHeight){
  127. menu.style.top = document.body.scrollTop + parseInt(e.clientY) - menu.offsetHeight;
  128. }else{
  129. menu.style.top = document.body.scrollTop + parseInt(e.clientY);
  130. }
  131. menu.style.visibility = "visible";
  132. }
  133. if(e.which==1){
  134. hidemenu();
  135. }
  136. }
  137. return false;
  138. }
  139. function hidemenu() {
  140. menu.style.visibility = "hidden";
  141. }
  142. //
  143. //******************浮动窗口*******************/
  144. //
  145. function Tclose(obj){
  146. document.getElementById(obj).innerHTML = '';
  147. document.getElementById(obj).style.visibility = 'hidden';
  148. z=null;
  149. }
  150. function newwindow(title,content){
  151. var str = '<table style="border: 1px solid #000000;width:100%;height:100%;" cellpadding="0" cellspacing="0">'
  152.   +'<tr class="divheader">'
  153.     +'<td style="padding-left:5px;width:400px;color:#FFFFFF" onMouseUp="z=null;" onMouseMove="if(window.event.button==1){start('float');}">'+title+'</td>'
  154.     +'<td width="41px" onclick="Tclose('float')" title="'+T_lang[0]+'" class="slow" onMouseMove="if(window.event.button==0){this.className='light';}" onMouseOut="this.className='slow'"></td>'
  155.   +'</tr>'
  156.   +'<tr ><td colspan="2" style="background:#666666;"><center>'+content+'</center></td></tr></table>';
  157. document.getElementById("float").innerHTML = str;
  158. document.getElementById("float").style.visibility = 'visible';
  159. }
  160. function editwindow(filename,content){
  161. var str = '<table style="border: 1px solid #7AC4EA;width:100%;height:100%;background:#FFFFFF;" cellpadding="1" cellspacing="0">'
  162.   +'<tr class="memberheader">'
  163.     +'<td style="padding-left:5px;width:700px;color:#154BA0;" >'+filename+'</td>'
  164.     +'<td width="35px" onclick="Tclose('edit')" title="'+T_lang[0]+'" class="eslow" onMouseOver="this.className='elight'" onMouseOut="this.className='eslow'"></td>'
  165.   +'</tr>'
  166.   +'<tr ><td colspan="2" style="background:#FFFFFF;height:480px;">'+content+'</td></tr></table>';
  167. document.getElementById("edit").innerHTML = str;
  168. document.getElementById("edit").style.visibility = 'visible';
  169. }
  170. //
  171. //*****************文件夹及文件任务******************/
  172. //
  173. function makemenu(){
  174. if(type==1){
  175. var str = 
  176.          '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','rewrite')">'+T_lang[1]+'</div>'
  177.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','copy')">'+T_lang[2]+'</div>'
  178.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','scissor')">'+T_lang[3]+'</div>'
  179.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','crush')">'+T_lang[4]+'</div>'
  180.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','rename')">'+T_lang[5]+'</div>'
  181.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','attribute')">'+T_lang[6]+'</div>'
  182.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','download')">'+T_lang[7]+'</div>'
  183.    ;
  184. }else if(type==4){
  185. var str = 
  186.              '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','rewrite')">'+T_lang[1]+'</div>'
  187.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','copy')">'+T_lang[2]+'</div>'
  188.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','scissor')">'+T_lang[3]+'</div>'
  189.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','delete')">'+T_lang[8]+'</div>'
  190.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','return')">'+T_lang[9]+'</div>'
  191.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','rename')">'+T_lang[5]+'</div>'
  192.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','attribute')">'+T_lang[6]+'</div>'
  193.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','download')">'+T_lang[7]+'</div>'
  194.    ;
  195. }else if(type==2){
  196. var str = 
  197.              '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="window.location=''+T_main+'?path='+path+''">'+T_lang[10]+'</div>'
  198.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','copy')">'+T_lang[2]+'</div>'
  199.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','scissor')">'+T_lang[3]+'</div>'
  200.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','crush')">'+T_lang[4]+'</div>'
  201.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','rename')">'+T_lang[5]+'</div>'
  202.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','attribute')">'+T_lang[6]+'</div>'
  203.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','download')">'+T_lang[11]+'</div>'
  204.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','shortcut')">'+"创建快捷方式"+'</div>'
  205.            ;
  206. }else if(type==5){
  207. var str = 
  208.              '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="window.location=''+T_main+'?path='+path+''">'+T_lang[10]+'</div>'
  209.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','copy')">'+T_lang[2]+'</div>'
  210.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','scissor')">'+T_lang[3]+'</div>'
  211.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','delete')">'+T_lang[8]+'</div>'
  212.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','return')">'+T_lang[9]+'</div>'
  213.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','rename')">'+T_lang[5]+'</div>'
  214.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','attribute')">'+T_lang[6]+'</div>'
  215.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','download')">'+T_lang[11]+'</div>'
  216.            ;
  217. }else if(type==3){
  218. var str = 
  219.              '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="window.location=''+T_main+'?path='+path+''">'+T_lang[10]+'</div>'
  220.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','attribute')">'+T_lang[6]+'</div>'
  221.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="T_clear(''+path+'')">'+T_lang[12]+'</div>'
  222.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','download')">'+T_lang[11]+'</div>'
  223.            ;
  224. }else if(type==0){
  225. var str = 
  226.      '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="window.location=''+T_main+'?path='+path+''">'+T_lang[13]+'</div>'
  227.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="PreDir(''+path+'')">'+T_lang[14]+'</div>'
  228.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','stepstick')">'+T_lang[15]+'</div>'
  229.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="T_newstepone(''+path+'','newfolder')">'+T_lang[16]+'</div>'
  230.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="T_newstepone(''+path+'','newfile')">'+T_lang[17]+'</div>'
  231.    + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="T_setnum(''+path+'')">'+T_lang[18]+'</div>'
  232.            + '<div class="menuinit" onMouseover="this.className='menuover'" onMouseOut="this.className='menuinit'" onclick="Tasks(''+path+'','attribute')">'+T_lang[6]+'</div>'
  233.    ;
  234. }
  235. menu.innerHTML = str;
  236. }
  237. function Tasks(xpath,taskname){
  238. if(taskname=="stick"){
  239. document.passform.type.value = "cover";
  240. }
  241. document.passform.path.value = xpath;
  242. document.passform.action.value = taskname;
  243. document.passform.submit();
  244. if(taskname=="attribute"||taskname=="download"||taskname=="stepstick"||taskname=="stick"){
  245. holdwin();
  246. }
  247. }
  248. function holdwin(){
  249. document.getElementById("float").innerHTML="<font color=red size=5>正在处理,请稍后……</font>";
  250. document.getElementById("float").style.visibility = 'visible';
  251. }
  252. function PreDir(xpath){
  253. var route  = xpath.split("%2F");
  254. var newdir = route[0];
  255. for(i=1;i<route.length-1;i++){
  256. newdir += "%2F"+route[i];
  257. }
  258. window.location=(T_main+'?path='+newdir);
  259. }
  260. function T_setnum(xpath){//上传文件到xpath
  261. var title   = T_lang[19];
  262. var content = '<font color=#FFFFFF>'+T_lang[20]+':</font><form name=upnum><input name="num" value=1 size="40" /><br />'
  263. +'<input type="button" onclick="T_setfiles(''+xpath+'',document.upnum.num.value);" value="'+T_lang[21]+'" />&nbsp;&nbsp;&nbsp;'
  264. +'<input type="button" onclick="Tclose('float')" value="'+T_lang[22]+'"></form>';
  265. newwindow(title,content);
  266. }
  267. function T_setfiles(xpath,num){
  268. var title   = T_lang[23];
  269. var content = '<form action="'+T_task+'" method="post" enctype="multipart/form-data"  target="passframe">'
  270. +'<br><input type="hidden" name="path" value='+xpath+'>';
  271. //+'<input type="hidden" name="MAX_FILE_SIZE" value="$T_max_size">';
  272. if(num>20){
  273. num=20;
  274. }
  275. for(i=1;i<=num;i++){
  276. var number='';
  277. if(i<10){
  278. number='0'+i;
  279. }else{
  280. number=i;
  281. }
  282. content +='<font color=#FFFFFF>'+T_lang[24]+number+':</font><input type="file" name="file[]"><font color="red">*</font><br />';
  283. }
  284. content +='<input type="submit" value="'+T_lang[25]+'">&nbsp;'
  285. +'<input type="hidden" name="action" value="upload">'
  286. +'<input type=button onclick="Tclose('float')" value="'+T_lang[22]+'" /><br><br></form>';
  287. newwindow(title,content);
  288. }
  289. function T_clear(xpath){
  290. var title   = ''+T_lang[26];
  291. var content =  '<font color=#FFFFFF>'+T_lang[27]+'</font><br />'
  292. +'<input type="button" onclick="Tasks(''+xpath+'','recycled');Tclose('float')" value="'+T_lang[28]+'">&nbsp;&nbsp;';
  293. +'<input type="button" onclick="Tclose('float')" value="'+T_lang[22]+'"></form>';
  294. newwindow(title,content);
  295. }
  296. function T_newstepone(xpath,xtype){
  297. if(xtype=="newfolder"){
  298. var title      = T_lang[29];
  299. var content =  '<form action="'+T_task+'" method="post" target="passframe">'
  300. +'<input type="hidden" name="path" value="'+xpath+'">'
  301. +'<input type="hidden" name="action" value="'+xtype+'">'
  302. +'<input name="foldername" value="newfoldername" size=50/><br>'
  303. +'<input type="button" onclick="this.form.submit();Tclose('float')" value="'+T_lang[31]+'">&nbsp;&nbsp;'
  304. +'<input type="button" onclick="Tclose('float')" value="'+T_lang[22]+'"></form>';
  305. }else if(xtype=="newfile"){
  306. var title      = T_lang[30];
  307. var hiddenname = "filename";
  308. var content =  '<form action="'+T_task+'" method="post" target="passframe">'
  309. +'<input type="hidden" name="path" value="'+xpath+'">'
  310. +'<input type="hidden" name="action" value="'+xtype+'">'
  311. +'<input name="filename" value="newfilename" size=30 />.<input name="exttype" value="txt" size=10 /><br />'
  312. +'<input type="button" onclick="this.form.submit();Tclose('float')" value="'+T_lang[31]+'">&nbsp;&nbsp;'
  313. +'<input type="button" onclick="Tclose('float')" value="'+T_lang[22]+'"></form>';
  314. }
  315. if(xpath&&xtype){
  316. newwindow(title,content);
  317. }
  318. }
  319. //
  320. //*****************文件夹及文件任务结束******************/
  321. //