// ***** -------------------- ***** // ***** ajax.psupopup.js ***** // ***** -------------------- ***** /************************************************************************ * * Title: ajax() * Category: AJAX * File Name: ajax.js * WEB URL: * Created By: TAKE * Created Date: 2006-03-13 * Language: JavaScript * Description: Use AJAX(Asynchronous JavaScript + XML) * technology to download files and execute * callback function asynchronously. * * Syntax: ajax(sCallBack, URI, async) * * Parameters: sCallBack - callback function (no quotes) * URI - any URI where the source exists. * * Example: /example/ajax * * Browsers that support Ajax * -------------------------- * (Note that this is a general list, and support of Ajax * applications will depend on the features the browser supports.) * * Microsoft Internet Explorer version 5.0 and above, and browsers * based on it (Mac OS versions not supported) * Gecko-based browsers like Mozilla, Mozilla Firefox, SeaMonkey, * Epiphany, Galeon and Netscape version 7.1 and above * Browsers implementing the KHTML API version 3.2 and above, * including Konqueror version 3.2 and above, and Apple Safari * version 1.2 and above * Opera browsers version 8.0 and above, including Opera Mobile * Browser version 8.0 and above * (Reference: http://en.wikipedia.org/wiki/Ajax_%28programming%29) * * (Mac OS X 10.3 is required for the Apple Safari 1.2) * ***********************************************************************/ var AJAX_bPageLoaded = false; var AJAX_aCallBack = Array(); var AJAX_aRtnText = Array(); // --------------------------------------------------------- // function (ajax) // - your JavaScript program calls this function // --------------------------------------------------------- function ajax_psupopup(sCallBack, sUri, bAsync, sParam) { var oAjax = createHttpRequest(); var sBrowser = getBrowser(); if (arguments[2] == null) { bAsync = true; } if (!sParam) { sParam = null; } // --- error messages --- var sError01 = ''; sError01 += 'ERROR: This function does not work on your browser\n\n'; sError01 += 'Please use one of the latest browsers. '; sError01 += 'Some PC compatible browsers: '; sError01 += 'IE5+, Netscape 7.1+, Firefox, etc. '; sError01 += 'MAC users are safe with Netscape or Firefox. '; sError01 += 'These are all free downloads!'; // --- unknown browser --- if (!oAjax) { alert(sError01); return false; } // --- callback function ------------------------------- // "oAjax.onload" is safer for opera, mozilla, konqueror // "oAjax.onload" does not work on IE // ----------------------------------------------------- switch (sBrowser) { case 'IE': oAjax.onreadystatechange = function(){ if (oAjax.readyState == 4 && oAjax.status == 200) { // --- session check --- var mixRtnValue = ''; if (oAjax.responseText.indexOf(" -1) { mixRtnValue = oAjax.responseXML; } else { mixRtnValue = oAjax.responseText; mixRtnValue = removeChar10(mixRtnValue); // see the definition if (mixRtnValue.indexOf('Log In Credentials')>-1){ mixRtnValue = 'ERROR: Session Timed Out.' } } if (sCallBack) { if (AJAX_bPageLoaded == true) { sCallBack(mixRtnValue); } else { AJAX_aCallBack.push(sCallBack); AJAX_aRtnText.push(mixRtnValue); } } } } break; default: oAjax.onload = function(){ // --- session check --- var mixRtnValue = ''; if (oAjax.responseText.indexOf(" -1) { var mixRtnValue = oAjax.responseXML; } else { var mixRtnValue = oAjax.responseText; mixRtnValue = removeChar10(mixRtnValue); // see the definition if (mixRtnValue.indexOf("Log In Credentials")>-1){ mixRtnValue = 'ERROR: Session Timed Out.' } } if (sCallBack) { sCallBack(mixRtnValue); } } break; } oAjax.open('POST', sUri, bAsync); oAjax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); oAjax.send(sParam); } function ajaxsubmit(sCallBack, sFormId, bAsync) { if (arguments[2] == null) { bAsync = true; } if (!sFormId) { sFormId = ''; } var aVar = Array(); var aVal = Array(); // --- input elements --- var cInput = document.getElementsByTagName('input'); for (var i=0; i and z-index // --------------------------------------------------------------------- function setShim(){ // in the rodpsupopup.js file // --- move shim --- oWinTable = document.getElementById('wintable'); oShim = document.getElementById('shim'); aArea = getElementArea(oWinTable); oShim.style.left = oWinTable.style.left; oShim.style.top = oWinTable.style.top; oShim.style.width = aArea[0] + 'px'; oShim.style.height = aArea[1] + 'px'; } // ******************************************************************** // getOffset() // ******************************************************************** function getOffset(evt){ // in the rodpsupopup.js file obj = document.getElementById('wintable'); if (document.all) { iOffsetX = event.offsetX + 2; iOffsetY = event.offsetY + 2; } else { iOffsetX = evt.pageX - parseInt(obj.style.left); iOffsetY = evt.pageY - parseInt(obj.style.top); } return 0; } var gText = ''; // ******************************************************************** // psupopup() // ******************************************************************** function psupopup(sContent, sTitle, sButton, sPos, bModal, sWinClass, bForceClose, bEncode, bIframe) { // in the rodpsupopup.js file // --- set defaults --- if (!sContent) sContent = ''; if (!sTitle) sTitle = 'Pittsburg State University - Pittsburg, KS'; if (!sButton) sButton = ''; if (!sPos) sPos = ''; if (!bModal) bModal = ''; if (!sWinClass) sWinClass = ''; if (!bEncode) bEncode = ''; if (!bIframe) bIframe = ''; // ---------------------------------------------------------------- // set the behavior of when user clicks on outside of popup window // ---------------------------------------------------------------- if (bForceClose) { bForceCloseFlag = true; } else { bForceClose = false; } // --- build close button --- var sHtmlButton = ''; if (sButton) { sHtmlButton += '

'; sHtmlButton += '
'; sHtmlButton += ' --- var sPopupStyle = ''; if (bIframe) { sPopupStyle = 'iframe'; } else { if (sContent.substring(0,1) == '/' || sContent.substring(0,4) == 'http') { sPopupStyle = 'ajax' } else { sPopupStyle = 'direct' } } // --- build content depended on its popup style <2010-01-26 TAKE> --- var sUrl = sContent; switch (sPopupStyle){ case 'iframe': sContent = ''; sContent += '' break; case 'ajax': ajax_psupopup(setContent, sContent, false); sContent = gText; break; default: if (bEncode) { sContent = Base64.decode(sContent) } } // --- build title bar <2009-11-16 TAKE> --- var sHtmlTitlebar = ''; if (sTitle != 'none') { sHtmlTitlebar += ' iViewableX) { iStyleLeft = iMouseX - oWinTable.clientWidth; if (iStyleLeft < 0) { iStyleLeft = 0; } } else { iStyleLeft = iMouseX; } var iStyleTop = ''; if (iCornerBottom > iViewableY) { iStyleTop = iMouseY - oWinTable.clientHeight; if (iStyleTop < 0) { iStyleTop = 0; } } else { iStyleTop = iMouseY; } oPopup.style.left = iStyleLeft + 'px'; oPopup.style.top = iStyleTop + 'px'; } setShim(); } function setContent(sText){ // in the rodpsupopup.js file gText = sText; } // ********************************************************************* // Created: TAKE <2008-05-21> // removePsuPopup() // ********************************************************************* function removePsuPopup(){ // in the rodpsupopup.js file // --- remove modal block --- var oModal = document.getElementById('modal'); if (oModal) { document.body.removeChild(oModal); } // --- remove psu popup --- var oShim = document.getElementById('shimframe'); if (oShim) { document.body.removeChild(oShim); } var oDiv = document.getElementById('psupopup'); if (oDiv) { document.body.removeChild(oDiv); } bForceCloseFlag = false; } // ********************************************************************* // Created: TAKE <2006-11-22> // // int getMouseX(e) // - return mouse's x position // ********************************************************************* //rt.11.17.11function getMouseX(e){ // in the rodpsupopup.js file //rt.11.04.11 if(window.opera){ //rt.11.04.11 return e.clientX; //rt.11.04.11 } else if(document.all){ //rt.11.04.11 return document.body.scrollLeft + event.x; //rt.11.04.11 } else if(document.layers||document.getElementById){ //rt.11.04.11 return e.pageX; //rt.11.04.11 } //rt.11.04.11 return 0; //rt.11.17.11 myBrowserType = client_Browser_Info.browserPropertyName; //rt.11.17.11 myBrowserVersionNum = client_Browser_Info.browserPropertyMajorVersion; // if (e.pageX == null) //rt.11.17.11 if (myBrowserType == "IE") //rt.11.17.11 { // IE case //rt.11.17.11 var d = (document.documentElement && document.documentElement.scrollLeft != null) ? document.documentElement : document.body; //rt.11.17.11 return e.clientX + d.scrollLeft; //rt.11.17.11 } //rt.11.17.11 else //rt.11.17.11 { // all other browsers //rt.11.17.11 return e.pageX; //rt.11.17.11 } //rt.11.17.11} // ********************************************************************* // Created: TAKE <2006-11-22> // // int getMouseY(e) // - return mouse's y position // ********************************************************************* //rt.11.17.11function getMouseY(e){ // in the rodpsupopup.js file //rt.11.04.11 if(window.opera){ //rt.11.04.11 return e.clientY; //rt.11.04.11 } else if(document.all){ //rt.11.04.11 return document.body.scrollTop + event.y; //rt.11.04.11 } else if(document.layers||document.getElementById){ //rt.11.04.11 return e.pageY; //rt.11.04.11 } //rt.11.04.11 return 0; //rt.11.17.11 myBrowserType = client_Browser_Info.browserPropertyName; //rt.11.17.11 myBrowserVersionNum = client_Browser_Info.browserPropertyMajorVersion; // if (e.pageY == null) //rt.11.17.11 if (myBrowserType == "IE") //rt.11.17.11 { // IE case //rt.11.17.11 var d = (document.documentElement && document.documentElement.scrollLeft != null) ? document.documentElement : document.body; //rt.11.17.11 return e.clientY + d.scrollLeft; //rt.11.17.11 } //rt.11.17.11 else //rt.11.17.11 { // all other browsers //rt.11.17.11 return e.pageY; //rt.11.17.11 } //rt.11.17.11} function getViewableArea() { // in the rodpsupopup.js file // --- get viewable size --- var windowWidth, windowHeight; if (self.innerHeight) { // --- all except IE --- if (document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // --- IE6 Strict Mode --- windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // --- other IE --- windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } return [windowWidth, windowHeight]; } // ********************************************************************* // Created By: TAKE // Created Date: 2008-07-07 // ********************************************************************* function getElementArea(oBase) { // in the rodpsupopup.js file // --- partial box --- if (!oBase.clientHeight) { // --------------------------------------- // this is needed for IE to have LAYOUT // --------------------------------------- oBase.style.display = 'inline-block'; } sBoxWidth = oBase.clientWidth; sBoxHeight = oBase.clientHeight; return [sBoxWidth, sBoxHeight]; } // ********************************************************************* // addEvent() // Created Date: 2008-10-15 // ********************************************************************* function addEvent(obj, act, func){ // in the rodpsupopup.js file if (obj.addEventListener){ obj.addEventListener(act, func, false); } else { obj.attachEvent('on' + act, func); } } function removeEvent(obj, act, func){ // in the rodpsupopup.js file if (obj.addEventListener){ obj.removeEventListener(act, func, false); } else { obj.detachEvent('on' + act, func); } } // ******************************************************************************* // // Language: JavaScript // Modified By: TAKE // Description: Adjust iframe depended on the size of the contents. // Original: yomotsu-net // http://www.yomotsu.net/lab/javascripts/iframe-height // // ******************************************************************************* function iframeHeight(){ // in the rodpsupopup.js file var oFrame = document.getElementById('psupopupframe'); if (!oFrame) { return 0; } var oContent = oFrame.contentWindow; if (!oContent) { setTimeout('iframeHeight()',750); return 0;} if (navigator.userAgent.indexOf('MSIE') > -1) { oContent.document.styleSheets[0].addRule('html', '{overflow:hidden;}'); } else { if (!oContent.document.styleSheets[0]) { // if it falls in here, check if the code is full HTML or not. return 0; } oContent.document.styleSheets[0].insertRule('html' + '{overflow:hidden;}', oContent.document.styleSheets[0].cssRules.length); } var height = oContent.document.getElementsByTagName('html')[0].offsetHeight; oFrame.style.height = height + 'px'; setTimeout('iframeHeight()',750) } // in the rodpsupopup.js file // ***** ------------------------------ ***** // ***** NoSpecialCharacterInput.js ***** // ***** ------------------------------ ***** // // // There are the charCodes we consider valid. // NOTE: These charCodes should match the codes on the // CONTROL.POINT VALID.CHARS.ARRAY record. That // record is used to construct the error information // when an invalid character is submitted to // our server. // // 58 is : // 38 is & // 32 is space // 45 is - // 40 is ( // 41 is ) // 47 is / // 39 is ' // 44 is , // 48 through 57 are digits 0,1,2,3,4,5,6,7,8,9 // 65 through 90 are upper case characters A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,X.Y,Z // 97 through 122 are4 lower case characters a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,x,y,z // // These are the keyCodes we consider valid. // keyCodes ARE DIFFERENT from charCodes!!! // var specialKeys = new Array(); specialKeys.push(8); //Backspace specialKeys.push(9); //Tab specialKeys.push(46); //Delete specialKeys.push(45); //Insert specialKeys.push(36); //Home specialKeys.push(35); //End specialKeys.push(37); //Left specialKeys.push(39); //Right function IsAlphaNumeric(e) { document.getElementById("SpecialCharsMsg").style.display = "none"; var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode; // alert(keyCode); // alert(specialKeys.indexOf(e.keyCode)); // alert(e.charCode); // alert(e.keyCode); var ret = ((keyCode == 47 || keyCode == 39 || keyCode == 58 || keyCode == 38 || keyCode == 44 || keyCode == 32 || keyCode == 40 || keyCode == 41) || (keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122) || (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode)); document.getElementById("SpecialCharsMsg").style.display = ret ? "none" : "inline"; return ret; } // ***** -------------------- ***** // ***** isValidDateCK.js ***** // ***** -------------------- ***** function isValidDateCK(obj) { var val = obj.value; if(val == "")return false; val = val.replace(/\-/g, "/"); var dt = new Date(val); if(isNaN(dt)) { alert("Invalid Date!"); obj.value = ""; obj.focus(); return false; } else { var month = dt.getMonth() + 1; var day = dt.getDate(); var arr = val.split("/"); var month2 = parseFloat(arr[0]); var day2 = parseFloat(arr[1]); if((month == month2) && (day == day2)) { return true; } else { alert("Invalid Date!"); obj.value = ""; obj.focus(); return false; } } }