Fix up for current browser...
This commit is contained in:
268
webRequest.js
Normal file → Executable file
268
webRequest.js
Normal file → Executable file
@@ -1,243 +1,25 @@
|
||||
var g_filePKey=null;
|
||||
|
||||
function makeRequest(tgtPage,requesttext){
|
||||
// Mozilla
|
||||
if (window.XMLHttpRequest) {
|
||||
var oXML=new XMLHttpRequest();
|
||||
} else {
|
||||
// IE
|
||||
var oXML=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
|
||||
oXML.open("POST",tgtPage,false);
|
||||
// alert("req" + requesttext);
|
||||
oXML.send(requesttext);
|
||||
|
||||
var theResponse = oXML.responseText;
|
||||
// alert("resp" + theResponse);
|
||||
|
||||
// Generic Webservice Error handling...
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(theResponse,"text/xml");
|
||||
if ((doc.documentElement.getAttribute("success")!="true")
|
||||
&& (doc.documentElement.getAttribute("fileformat")==null)
|
||||
&& (doc.documentElement.getAttribute("errorclass")!="AppError")) {
|
||||
alert("Problem: (" + doc.documentElement.getAttribute("success") + ")\n" + theResponse);
|
||||
}
|
||||
return(theResponse);
|
||||
}
|
||||
|
||||
|
||||
function loadMap(filePKey) {
|
||||
setBusyWait();
|
||||
window.scrollTo(0,0);
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","OPENFILE");
|
||||
xmlDoc.documentElement.setAttribute("filepkey",filePKey);
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
g_filePKey=filePKey;
|
||||
dataTools.setPKey(doc.documentElement.getAttribute("nextpkey"));
|
||||
deleteAllRootNodes();
|
||||
for (var i=0;i<doc.documentElement.firstChild.childNodes.length;i++){
|
||||
rootNode[i]=new node().fromXML(doc.documentElement.firstChild.childNodes[i]);
|
||||
}
|
||||
|
||||
// Freelinks need to be loaded when it's guaranteed that all nodes are loaded.
|
||||
// otherwise they have nothing to link to...
|
||||
createFreeRelations(doc.documentElement);
|
||||
|
||||
unsetBusyWait();
|
||||
}
|
||||
|
||||
// Traverse the tree and draw freeRelations
|
||||
function createFreeRelations(docEle){
|
||||
var allChilds=docEle.childNodes;
|
||||
for (var i=0;i<allChilds.length;i++){
|
||||
var theChild=allChilds[i];
|
||||
if (theChild.childNodes.length>0){
|
||||
createFreeRelations(theChild);
|
||||
}
|
||||
if (theChild.nodeName=="NODEREL"){
|
||||
if (theChild.getAttribute("relationtype")!="main"){
|
||||
var newNodeRel=new nodeRel().fromXML(theChild);
|
||||
newNodeRel.redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveMap(description) {
|
||||
setBusyWait();
|
||||
var xmlDoc=document.implementation.createDocument('','ALL',null);
|
||||
xmlDoc.documentElement.setAttribute("fileformat","1");
|
||||
xmlDoc.documentElement.setAttribute("nextpkey",dataTools.getNewPKey());
|
||||
xmlDoc.documentElement.setAttribute("function","SAVEFILE");
|
||||
xmlDoc.documentElement.setAttribute("filepkey",g_filePKey);
|
||||
xmlDoc.documentElement.setAttribute("description",description);
|
||||
var nodeSets=xmlDoc.createElement("NODESET");
|
||||
for (var i=0;i<rootNode.length;i++){
|
||||
nodeSets.appendChild(xmlDoc.importNode(rootNode[i].toXML(),true));
|
||||
}
|
||||
|
||||
xmlDoc.documentElement.appendChild(nodeSets);
|
||||
|
||||
var txtResp=makeRequest("requestTarget.php",xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
g_filePKey=doc.documentElement.getAttribute("filepkey");
|
||||
unsetBusyWait();
|
||||
return(xmlDoc);
|
||||
}
|
||||
|
||||
function deleteMap(filePKey){
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","DELETEFILE");
|
||||
xmlDoc.documentElement.setAttribute("filepkey",filePKey);
|
||||
var txtResp=makeRequest("requestTarget.php",xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(xmlDoc);
|
||||
}
|
||||
|
||||
function getIconList() {
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","GETICONLIST");
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(document.importNode(doc.firstChild,true));
|
||||
}
|
||||
|
||||
function getFileList() {
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","LISTFILES");
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(document.importNode(doc.firstChild,true));
|
||||
}
|
||||
|
||||
function openFileSelector() {
|
||||
var fsControl=new fileSelectorControl(getFileList());
|
||||
document.getElementById("body").appendChild(fsControl);
|
||||
fsControl.style.position="absolute";
|
||||
fsControl.style.top="100px";
|
||||
dragNDrop.activateForObject(fsControl);
|
||||
}
|
||||
|
||||
function tokenLoginUser(){
|
||||
var mail=dataTools.getCookie("autoLoginMail");
|
||||
var loginToken=dataTools.getCookie("autoLoginToken");
|
||||
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","TOKENLOGIN");
|
||||
xmlDoc.documentElement.setAttribute("mail",mail);
|
||||
xmlDoc.documentElement.setAttribute("token",loginToken);
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(doc.documentElement.getAttribute("success")=="true");
|
||||
|
||||
}
|
||||
|
||||
function loginUser(mail,password,isAutoLogin) {
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","LOGIN");
|
||||
xmlDoc.documentElement.setAttribute("mail",mail);
|
||||
xmlDoc.documentElement.setAttribute("password",password);
|
||||
xmlDoc.documentElement.setAttribute("isautologin",(isAutoLogin)?"1":"0");
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
if (isAutoLogin) {
|
||||
var loginToken=doc.documentElement.getAttribute("autologintoken");
|
||||
dataTools.setCookie("autoLoginToken",loginToken,10000);
|
||||
dataTools.setCookie("autoLoginMail",mail,10000);
|
||||
}
|
||||
return(doc.documentElement.getAttribute("success")=="true");
|
||||
}
|
||||
function logOutUser(){
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","LOGOUT");
|
||||
xmlDoc.documentElement.setAttribute("autologintoken",dataTools.getCookie("autoLoginToken"));
|
||||
dataTools.setCookie("autoLoginToken","",-1);
|
||||
dataTools.setCookie("autoLoginMail","",-1);
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
window.location='login.php';
|
||||
return(doc.documentElement.getAttribute("success")=="true");
|
||||
}
|
||||
|
||||
function optinUser(mail,password) {
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","OPTINUSER");
|
||||
xmlDoc.documentElement.setAttribute("mail",mail);
|
||||
xmlDoc.documentElement.setAttribute("password",password);
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(doc.documentElement.getAttribute("success")=="true");
|
||||
}
|
||||
|
||||
function mailPassword(mail) {
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","MAILPASSWORD");
|
||||
xmlDoc.documentElement.setAttribute("mail",mail);
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(doc.documentElement.getAttribute("success")=="true");
|
||||
}
|
||||
|
||||
function confirmOptin(token) {
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","CONFIRMOPTIN");
|
||||
xmlDoc.documentElement.setAttribute("token",token);
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(doc.documentElement.getAttribute("success")=="true");
|
||||
}
|
||||
|
||||
function changePassword(mail,newPass,oldPass,token) {
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","CHANGEPASSWORD");
|
||||
xmlDoc.documentElement.setAttribute("mail",mail);
|
||||
xmlDoc.documentElement.setAttribute("newpass",newPass);
|
||||
xmlDoc.documentElement.setAttribute("oldpass",oldPass);
|
||||
xmlDoc.documentElement.setAttribute("token",token);
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(doc.documentElement.getAttribute("success")=="true");
|
||||
}
|
||||
|
||||
function updateUserProfile(name,mail,password) {
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","UPDATEUSERPROFILE");
|
||||
xmlDoc.documentElement.setAttribute("mail",mail);
|
||||
xmlDoc.documentElement.setAttribute("password",password);
|
||||
xmlDoc.documentElement.setAttribute("name",name);
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(doc.documentElement.getAttribute("success")=="true");
|
||||
}
|
||||
|
||||
function deleteAllRootNodes() {
|
||||
for (var i=rootNode.length-1;i>=0;i--){
|
||||
rootNode[i].erase();
|
||||
}
|
||||
}
|
||||
|
||||
function getUserInfo(attribute) {
|
||||
var xmlDoc=document.implementation.createDocument('','X',null);
|
||||
xmlDoc.documentElement.setAttribute("function","GETUSERINFO");
|
||||
var txtResp=makeRequest('requestTarget.php',xmlDoc);
|
||||
var parser=new DOMParser();
|
||||
var doc=parser.parseFromString(txtResp,"text/xml");
|
||||
return(doc.documentElement.getAttribute(attribute));
|
||||
}
|
||||
var g_filePKey=null;function makeRequest(aa,ba){if(window.XMLHttpRequest){var ca=new XMLHttpRequest();}
|
||||
else{var ca=new ActiveXObject("Microsoft.XMLHTTP");}
|
||||
ca.open("POST",aa,false);ca.send(ba);var da=ca.responseText;var ea=new DOMParser();var fa=ea.parseFromString(da,"text/xml");if((fa.documentElement.getAttribute("success")!="true")&&(fa.documentElement.getAttribute("fileformat")==null)&&(fa.documentElement.getAttribute("errorclass")!="AppError")){alert("Problem: ("+fa.documentElement.getAttribute("success")+")\n"+da);}
|
||||
return(da);}
|
||||
function loadMap(ga){setBusyWait();window.scrollTo(0,0);var ha=document.implementation.createDocument('','X',null);ha.documentElement.setAttribute("function","OPENFILE");ha.documentElement.setAttribute("filepkey",ga);var ia=makeRequest('requestTarget.php',ha);var ja=new DOMParser();var ka=ja.parseFromString(ia,"text/xml");g_filePKey=ga;dataTools.setPKey(ka.documentElement.getAttribute("nextpkey"));deleteAllRootNodes();for(var i=0;i<ka.documentElement.firstChild.childNodes.length;i++){rootNode[i]=new node().fromXML(ka.documentElement.firstChild.childNodes[i]);}
|
||||
createFreeRelations(ka.documentElement);unsetBusyWait();}
|
||||
function createFreeRelations(la){var ma=la.childNodes;for(var i=0;i<ma.length;i++){var na=ma[i];if(na.childNodes.length>0){createFreeRelations(na);}
|
||||
if(na.nodeName=="NODEREL"){if(na.getAttribute("relationtype")!="main"){var oa=new nodeRel().fromXML(na);oa.redraw();}}}}
|
||||
function saveMap(pa){setBusyWait();var qa=document.implementation.createDocument('','ALL',null);qa.documentElement.setAttribute("fileformat","1");qa.documentElement.setAttribute("nextpkey",dataTools.getNewPKey());qa.documentElement.setAttribute("function","SAVEFILE");qa.documentElement.setAttribute("filepkey",g_filePKey);qa.documentElement.setAttribute("description",pa);var ra=qa.createElement("NODESET");for(var i=0;i<rootNode.length;i++){ra.appendChild(qa.importNode(rootNode[i].toXML(),true));}
|
||||
qa.documentElement.appendChild(ra);var sa=makeRequest("requestTarget.php",qa);var ta=new DOMParser();var ua=ta.parseFromString(sa,"text/xml");g_filePKey=ua.documentElement.getAttribute("filepkey");unsetBusyWait();return(qa);}
|
||||
function deleteMap(va){var wa=document.implementation.createDocument('','X',null);wa.documentElement.setAttribute("function","DELETEFILE");wa.documentElement.setAttribute("filepkey",va);var xa=makeRequest("requestTarget.php",wa);var ya=new DOMParser();var za=ya.parseFromString(xa,"text/xml");return(wa);}
|
||||
function getIconList(){var Aa=document.implementation.createDocument('','X',null);Aa.documentElement.setAttribute("function","GETICONLIST");var Ba=makeRequest('requestTarget.php',Aa);var Ca=new DOMParser();var Da=Ca.parseFromString(Ba,"text/xml");return(document.importNode(Da.firstChild,true));}
|
||||
function getFileList(){var Ea=document.implementation.createDocument('','X',null);Ea.documentElement.setAttribute("function","LISTFILES");var Fa=makeRequest('requestTarget.php',Ea);var Ga=new DOMParser();var Ha=Ga.parseFromString(Fa,"text/xml");return(document.importNode(Ha.firstChild,true));}
|
||||
function openFileSelector(){var Ia=new fileSelectorControl(getFileList());document.getElementById("body").appendChild(Ia);Ia.style.position="absolute";Ia.style.top="100px";dragNDrop.activateForObject(Ia);}
|
||||
function tokenLoginUser(){var Ja=dataTools.getCookie("autoLoginMail");var Ka=dataTools.getCookie("autoLoginToken");var La=document.implementation.createDocument('','X',null);La.documentElement.setAttribute("function","TOKENLOGIN");La.documentElement.setAttribute("mail",Ja);La.documentElement.setAttribute("token",Ka);var Ma=makeRequest('requestTarget.php',La);var Na=new DOMParser();var Oa=Na.parseFromString(Ma,"text/xml");return(Oa.documentElement.getAttribute("success")=="true");}
|
||||
function loginUser(Pa,Qa,Ra){var Sa=document.implementation.createDocument('','X',null);Sa.documentElement.setAttribute("function","LOGIN");Sa.documentElement.setAttribute("mail",Pa);Sa.documentElement.setAttribute("password",Qa);Sa.documentElement.setAttribute("isautologin",(Ra)?"1":"0");var Ta=makeRequest('requestTarget.php',Sa);var Ua=new DOMParser();var Va=Ua.parseFromString(Ta,"text/xml");if(Ra){var Wa=Va.documentElement.getAttribute("autologintoken");dataTools.setCookie("autoLoginToken",Wa,10000);dataTools.setCookie("autoLoginMail",Pa,10000);}
|
||||
return(Va.documentElement.getAttribute("success")=="true");}
|
||||
function logOutUser(){var Xa=document.implementation.createDocument('','X',null);Xa.documentElement.setAttribute("function","LOGOUT");Xa.documentElement.setAttribute("autologintoken",dataTools.getCookie("autoLoginToken"));dataTools.setCookie("autoLoginToken","",-1);dataTools.setCookie("autoLoginMail","",-1);var Ya=makeRequest('requestTarget.php',Xa);var Za=new DOMParser();var $a=Za.parseFromString(Ya,"text/xml");window.location='login.php';return($a.documentElement.getAttribute("success")=="true");}
|
||||
function optinUser(ab,bb){var cb=document.implementation.createDocument('','X',null);cb.documentElement.setAttribute("function","OPTINUSER");cb.documentElement.setAttribute("mail",ab);cb.documentElement.setAttribute("password",bb);var db=makeRequest('requestTarget.php',cb);var eb=new DOMParser();var fb=eb.parseFromString(db,"text/xml");return(fb.documentElement.getAttribute("success")=="true");}
|
||||
function mailPassword(gb){var hb=document.implementation.createDocument('','X',null);hb.documentElement.setAttribute("function","MAILPASSWORD");hb.documentElement.setAttribute("mail",gb);var ib=makeRequest('requestTarget.php',hb);var jb=new DOMParser();var kb=jb.parseFromString(ib,"text/xml");return(kb.documentElement.getAttribute("success")=="true");}
|
||||
function confirmOptin(lb){var mb=document.implementation.createDocument('','X',null);mb.documentElement.setAttribute("function","CONFIRMOPTIN");mb.documentElement.setAttribute("token",lb);var nb=makeRequest('requestTarget.php',mb);var ob=new DOMParser();var pb=ob.parseFromString(nb,"text/xml");return(pb.documentElement.getAttribute("success")=="true");}
|
||||
function changePassword(qb,rb,sb,tb){var ub=document.implementation.createDocument('','X',null);ub.documentElement.setAttribute("function","CHANGEPASSWORD");ub.documentElement.setAttribute("mail",qb);ub.documentElement.setAttribute("newpass",rb);ub.documentElement.setAttribute("oldpass",sb);ub.documentElement.setAttribute("token",tb);var vb=makeRequest('requestTarget.php',ub);var wb=new DOMParser();var xb=wb.parseFromString(vb,"text/xml");return(xb.documentElement.getAttribute("success")=="true");}
|
||||
function updateUserProfile(yb,zb,Ab){var Bb=document.implementation.createDocument('','X',null);Bb.documentElement.setAttribute("function","UPDATEUSERPROFILE");Bb.documentElement.setAttribute("mail",zb);Bb.documentElement.setAttribute("password",Ab);Bb.documentElement.setAttribute("name",yb);var Cb=makeRequest('requestTarget.php',Bb);var Db=new DOMParser();var Eb=Db.parseFromString(Cb,"text/xml");return(Eb.documentElement.getAttribute("success")=="true");}
|
||||
function deleteAllRootNodes(){try {for(var i=rootNode.length-1;i>=0;i--){rootNode[i].erase();}} catch (ex) { console.log("ERROR in erase...",ex) }}
|
||||
function getUserInfo(Fb){var Gb=document.implementation.createDocument('','X',null);Gb.documentElement.setAttribute("function","GETUSERINFO");var Hb=makeRequest('requestTarget.php',Gb);var Ib=new DOMParser();var Jb=Ib.parseFromString(Hb,"text/xml");return(Jb.documentElement.getAttribute(Fb));}
|
||||
|
||||
Reference in New Issue
Block a user