/* * Name: * secretword.js * * Description: * Defines functions for making AJAX queries via the HTTP protocol's GET method. * * Pre-conditions: * 'q' : secret word entered by the user * 'secretWordId' : from secret_word.lib * * Post-conditions: * - response from the server for the GET request * * Log: * Kripa Shenai 08/15/2006 * - Creation * Kripa Shenai 03/14/2007 * - Added handleKeystroke * Kripa Shenai 05/05/2008 * - fixed VX-1635 */ keyWordSelection = false; displayPart = ''; var secreteXmlHttpObj = ''; preQ = ""; function showLink(str1,str2,str3,str4,displayId,stnBox) { //stationurl="http://"+document.domain; if(preQ == str1 && keyWordSelection == false) { return; } displayPart = displayId; if (str1.length==0) { var disObject = document.getElementById(displayPart); if(disObject != 'undefined' && disObject) disObject.innerHTML=""; if(keyWordSelection == true) { alert("Please Select KeyWord From Drop Down"); } return; } secreteXmlHttpObj=GetXmlHttpObject(); if (secreteXmlHttpObj==null) { alert ("Browser does not support HTTP Request"); return; } preQ = str1; var url="/get_secret_word.php"; //var url=stationurl+"/get_secret_word.php"; url=url+"?q="+str1; url=url+"&secretWordId="+str2; url=url+"&liteGraphicId="+str3; url=url+"&stylePrefix="+str4; url=url+"&stnBox="+stnBox; if(keyWordSelection) { url=url+"&keyWordSelection="+keyWordSelection; } url=url+"&sid="+Math.random(); secreteXmlHttpObj.onreadystatechange= stateChangedSecretWord; secreteXmlHttpObj.open("GET", url, true); secreteXmlHttpObj.send(null); } function stateChangedSecretWord() { if (secreteXmlHttpObj.readyState==4 || secreteXmlHttpObj.readyState=="complete") { if(keyWordSelection) { // // reset the flag again // keyWordSelection = false; if(secreteXmlHttpObj.responseText){ var tmp = 'returnData='+ secreteXmlHttpObj.responseText; //alert(tmp); eval(tmp); //alert("----newWindowOption----"+returnData.openInNewWindow); newWindowOption = returnData.openInNewWindow; // // check if open in new window is true // if(newWindowOption) { window.open(returnData.url); } else { location.href = returnData.url; }// end if - open in new window is true } } else { //alert("Inside else stateChangedSecretWord"); txtLinkObj = document.getElementById("txtLink"); if(txtLinkObj && txtLinkObj !='undefined'){ txtLinkObj.innerHTML=secreteXmlHttpObj.responseText; displayPart = ''; } } } } function GetXmlHttpObject() { var objXMLHttp=null; if (window.XMLHttpRequest) { objXMLHttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP"); } return objXMLHttp; } /* * Name: * setKeyWordParameters * * Description: * function used to set the parameters for the selction keyword from drop-down * * Preconditions/Input: * * Postconditions/Output: * after setting the parameters it will call the showLink function. * * Stored Procedures: * None * * Log: * Kripa Shenai 03/14/2007 * Kripa Shenai 05/05/2008 * - fixed VX-1635 * Shailaza Shrestha * -fixed VX-3895 April 02, 2009 */ function handleKeystroke(e) { var keyPressed; //Browser compatibility check if (document.all) { //Browser used: Internet Explorer 6 keyPressed = e.keyCode; } else { //Browser used: Firefox keyPressed = e.which; } //13 = ASCII code for Enter key // if (keyPressed == 13 && (document.getElementById("secLink"))) { /////VX-3895 /// var secretWordId = document.getElementById('secretWordId').value; var goToLinkObj = document.getElementById("gotoLink"); var newWindowOption = document.getElementById("newWindow"); secretWordClicked(goToLinkObj.value,secretWordId,newWindowOption.value); } } /* * Name: * setKeyWordParameters * * Description: * function used to set the parameters for the selction keyword from drop-down * * Preconditions/Input: * * Postconditions/Output: * after setting the parameters it will call the showLink function. * * Stored Procedures: * None * * Log: * Dipak A.Basantani 04/10/2008 */ function setKeyWordParameters(graphicId,stylePrefix,selectBoxId) { var selectedKeyWordObject = document.getElementById(selectBoxId); var selectedKeyWord = selectedKeyWordObject[selectedKeyWordObject.selectedIndex].text; var selectedKeyWordId = selectedKeyWordObject[selectedKeyWordObject.selectedIndex].value; //declare global variable keyWordSelection = true; // call showlink showLink(selectedKeyWord,selectedKeyWordId,graphicId,stylePrefix,'', ''); } /* * Name: * secretWordClicked * * Description: * * * Preconditions/Input: * secretWordLink,secretWordId,openNewWindow * * Postconditions/Output: * updates clicked num by calling php page * opens up the secret work link * * Stored Procedures: * None * * Log: * Shailaza Shrestha March 05, 2009 [VX-3680] */ function secretWordClicked(secretWordLink,secretWordId,openNewWindow) { //stationurl="http://"+document.domain; httpObject = GetXmlHttpObject(); if (httpObject != null) { //httpObject.open("GET", stationurl+"/update_secretword_clicked.php?"+Math.random()+"&secretWordLink"+secretWordLink+"&secretWordId="+secretWordId, true); httpObject.open("GET", "/update_secretword_clicked.php?"+Math.random()+"&secretWordLink"+secretWordLink+"&secretWordId="+secretWordId, true); httpObject.send(null); //httpObject.onreadystatechange = setSecretWordClicked(secretWordLink,openNewWindow); httpObject.onreadystatechange=function() { if(httpObject.readyState==4 || httpObject.readyState=="complete") { // Get the data from the server's response if(openNewWindow == 1) window.open(secretWordLink); else location.href=secretWordLink; } } } } /* * Name: * keywordPulldown * * Description: * * * Preconditions/Input: * Id of the box * * Postconditions/Output: * updates num match of the selected keyword * * Stored Procedures: * None * * Log: * Shailaza Shrestha March 05, 2009 [VX-3680] */ function keywordPulldown(selectBoxId) { //stationurl="http://"+document.domain; var selectmenu=document.getElementById(selectBoxId); // var chosenoption=selectmenu.options[selectmenu.selectedIndex] //this refers to "selectmenu" var selectedsecretWordId=selectmenu.options[selectmenu.selectedIndex].value; //this refers to "selectmenu" // alert("Inside keywordPulldown"); // alert("selectedsecretWordId----"+selectedsecretWordId); keyWordSelection ="true"; var url="/get_secret_word.php"; //var url=stationurl+"/get_secret_word.php"; var dropDown = true;// //url=url+"?secretWordId="+selectedsecretWordId; url=url+"?"+Math.random()+"&secretWordId="+selectedsecretWordId; url=url+"&keyWordSelection="+keyWordSelection; url=url+"&keyWordSelection="+keyWordSelection; url=url+"&dropDown="+dropDown; secreteXmlHttpObj=GetXmlHttpObject(); if (secreteXmlHttpObj==null) { alert ("Browser does not support HTTP Request"); return; } //secreteXmlHttpObj.onreadystatechange= stateChangedSecretWordDropDown; secreteXmlHttpObj.open("GET", url, true); secreteXmlHttpObj.send(null); }