Home >Backend Development >PHP Tutorial >[Original] PHP+ajax implements simulated Win file management system 8_PHP tutorial
I have been quite busy during this period, so I took some time off to finish it. Now I will continue to talk about the js.js file renaming function
function edit(e,path){
var text=e.innerHTML;
var eT=document.createElement("input");//The file name is rewritten according to the user's click
e.innerHTML="";
e.appendChild(eT);
eT.value=text;
eT.select();
e.onclick="";
eT.onblur=function(){
CreateAjax();
if(text == this.value){
e.innerHTML=this.value;
e.onclick=function(){edit(this,path)};
Return false;
}else{
e.innerHTML=this.value;
Re_name(path,this.value,e);
e.onclick=function(){edit(this,path)};
}
};
}
function CreateAjax(){//I won’t say much about this function, it has been discussed many times.
try { xmlhttp = new XMLHttpRequest();}
catch (e){
try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e2){
try { xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); }
catch(e3){ xmlhttp = false; }
}
}
function Re_name(o_name,n_name,e){ //Renamed here.
var name=o_name.replace(/.*/(.+)$/i,"$1");
if(name.match(/^w{1,255}.w{1,8}$/i)){//Use regular rules to determine the legality of the file name.
if(!n_name.match(/^w{1,250}.w{1,8}$/i)){
e.innerHTML=name;
document.getElementById("t").innerHTML="
setInterval("func()",3000);
Return false;
}
}else if(name.match(/^w{1,255}$/i)){
if(!n_name.match(/^w{1,250}$/i)){
e.innerHTML=name;
document.getElementById("t").innerHTML="
}
}else{
alert('illegal operation');
e.innerHTML=name;
return false;
}
var url="rename.php?path="+encodeURI(o_name.replace("/","/"))+"&nname="+encodeURI(n_name)+"&rd="+Math.random();
Senddata('GET',url,ReturnValue,null); //Send to rename.php
http://www.bkjia.com/PHPjc/631848.html