Author: glorieux Date: 2009-12-15 10:53:57 +0100 (Tue, 15 Dec 2009) New Revision: 59 Added: trunk/src/main/webapp/fileSearch.js Log: Add File Search JavaScript Added: trunk/src/main/webapp/fileSearch.js =================================================================== --- trunk/src/main/webapp/fileSearch.js (rev 0) +++ trunk/src/main/webapp/fileSearch.js 2009-12-15 09:53:57 UTC (rev 59) @@ -0,0 +1,47 @@ +function createRequestObject() +{ + var req; + if(window.XMLHttpRequest) + { + //For Firefox, Safari, Opera + req = new XMLHttpRequest(); + } + else if(window.ActiveXObject) + { + //For IE 5+ + req = new ActiveXObject("Microsoft.XMLHTTP"); + } + else + { + //Error for an old browser + alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera'); + } + return req; +} + +//Make the XMLHttpRequest Object +var http= createRequestObject(); + +function sendRequestToFileSearchServlet(scmPath, scmEditorUrl) +{ + http.open("POST", scmEditorUrl.value, true); + http.onreadystatechange = handleResponseFromFileSearchServlet; + http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + http.send("adresse="+scmPath.value); +} + +function handleResponseFromFileSearchServlet() +{ + if(http.readyState == 4 && http.status != 401){ + alert("Can find file Continue"); + } else if (http.readyState == 4 && http.status == 401){ + alert("Cannot find files please recheck Scm path."); + } +} + +function fileSearch(scmPath, scmEditorUrl) +{ + alert(scmPath.value); + alert(scmEditorUrl.value); + sendRequestToFileSearchServlet(scmPath, scmEditorUrl); +} \ No newline at end of file