// ***** --------------------------- ***** // ***** ajax.aw.html.list.v4.js ***** // ***** --------------------------- ***** /************************************************************************ * * Title: htmlList4Ajax() * 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: htmlList4Ajax(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 (htmlListAjax) // - your JavaScript program calls this function // --------------------------------------------------------- function htmlList4Ajax(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 0) { sTableId = sTableId.substr(0, sTableId.length-2); } // --- get a security key --- var sSecKey = document.getElementById('sec-' + sTableId).value; // -------------------------------------------------------------- // if the page is already loaded in the aCompletePage[], // simpley use it. // // put preloading feature here, too. // -------------------------------------------------------------- // var sCurPage = aCompletePage[sTableId, iPageNum]; // if (sCurPage) { // var sDivId = 'list-' + sTableId; // var oList = document.getElementById(sDivId); // // oList.innerHTML = sCurPage; // // return // } // --- initialize arguments --- if (!iPageNum) iPageNum = ''; if (!sIndex) sIndex = ''; if (!sSubmit) sSubmit = ''; if (!iSortBy) iSortBy = ''; if (!iSortBy2) iSortBy2 = ''; if (!sFilter) sFilter = ''; // --- find search keyword <2007-10-30 TAKE> --- var sKeyword = ''; if (sSubmit == 'Search') { sKeyword = document.getElementById('keyword-' + sTableId).value; } // --- loading message --- var oNaviTop = document.getElementById('navitop-' + sTableId); var oNaviBottom = document.getElementById('navibottom-' + sTableId); var oLoaderTop = document.getElementById('loadertop-' + sTableId); var oLoaderBottom = document.getElementById('loaderbottom-' + sTableId); if (oNaviTop) { oNaviTop.style.display = 'none'; oLoaderTop.style.display = ''; } if (oNaviBottom) { oNaviBottom.style.display = 'none'; oLoaderBottom.style.display = ''; } showSmoke('smokearea'); // --- execute ajax --- var sHtml = ''; sHtml += '/ajaxdata/aw.html.list?'; sHtml += Math.random(); sHtml += '&TABLEID=' + sTableId; sHtml += '&PAGENUM=' + iPageNum; sHtml += '&SECKEY=' + sSecKey; sHtml += '&NAV.INDEX=' + sIndex; sHtml += '&SUBMIT=' + sSubmit; sHtml += '&KEYWORD=' + sKeyword; sHtml += '&SORTBY=' + iSortBy; sHtml += '&SORTBY2=' + iSortBy2; sHtml += '&FILTER=' + sFilter; htmlList4Ajax(completeDownload, sHtml); } // ********************************************************************* // void completeDownload(string Text) // - set received text from Ajax into the page. // ********************************************************************* function completeDownload(sText) { var LF = String.fromCharCode(10) // --- retrieve table ID & page ID ------------------------ // first line of the sText is information used in JS. // Those are delimited by '<>' // -------------------------------------------------------- var aText = sText.split(LF); var sInfo = aText[0]; var aInfo = sInfo.split('<>'); var sTableId = aInfo[0]; var iPageNum = parseInt(aInfo[1]); var iPageMax = parseInt(aInfo[2]); var iLineStart = parseInt(aInfo[3]); var iLineEnd = parseInt(aInfo[4]); var iRecordMax = parseInt(aInfo[5]); var sDebugInfo = aInfo[6]; var sKeyword = aInfo[7]; if (location.pathname == '/iss/chad/bsq/bsq.f1') { alert(sTableId) } // --- shows debug information at the bottom --- if (!sDebugInfo) { sDebugInfo = ''; } // --- retrieve html part --- var iHtmlStartPos = sText.indexOf(LF)+1; var sHtml = sText.substr(iHtmlStartPos) + sDebugInfo; // --- insert html into a page --- var sListId = 'list-' + sTableId; var oList = document.getElementById(sListId); oList.innerHTML = sHtml; // --- storing loaded page into array for later use --- // aCompletePage[sTableId, parseInt(iPageNum)] = sHtml; // --- close loading message --- oLoading = document.getElementById('loading-' + sTableId); oList = document.getElementById('list-' + sTableId); if (oLoading) { oList.style.display = ''; oLoading.style.display = 'none'; } // --- set counter --- oCounter = document.getElementById('counter-' + sTableId); if (oCounter) { if (iRecordMax == '0') { oCounter.innerHTML = 'No Results'; } else { oCounter.innerHTML = iLineStart + ' - ' + iLineEnd + ' results out of ' + iRecordMax; } } // --- set keyword <2009-05-14 TAKE> --- if (sKeyword) { oSearchKeyword = document.getElementById('keyword-' + sTableId); if (oSearchKeyword) { oSearchKeyword.value = sKeyword; } } hideSmoke(); // --- update slider --- if (typeof(cSlider) != 'undefined') { if (cSlider[sTableId] != null) { cSlider[sTableId].refreshSlider(iPageMax, iPageNum); } if (cSlider[sTableId + '_2'] != null) { cSlider[sTableId + '_2'].refreshSlider(iPageMax, iPageNum); } } } // ***** ------------------ ***** // ***** popupsearch.js ***** // ***** ------------------ ***** /************************************************************************ * * Title: Popup Search * Category: * Program Name: popupsearch.js * WEB URL: * Created By: TAKE * Created Date: 2006-08-10 * Language: JAVASCRIPT * Description: Used in the popup search to return the selected value * to the parent window. * ************************************************************************/ var sRadioVal; var sSearchType; // used for changing search type by other javascript. /************************************************************************ * function (setRadioVal) * - set the selected radio button value ************************************************************************/ function setRadioVal(sSelected){ sRadioVal = sSelected; } /************************************************************************ * function (search_setPid) * - set the selected PID to the paranet form textbox ************************************************************************/ function search_setId(sPField, blMulti){ var oInputFld = window.opener.document.getElementById(sPField); // --- if nothing selected, return error message --- if (!sRadioVal) { errmsg = 'Please select any item.'; alert(errmsg); return 0; } if (blMulti){ // --- multiple selection --- // --- if already existing, do not add --- if (oInputFld.value.indexOf(sRadioVal) != -1) { return 0; } if (oInputFld.value){ oInputFld.value += ', '; } oInputFld.value += sRadioVal; } else { // --- single selection --- oInputFld.value = sRadioVal; oInputFld.focus(); window.close(); } } // ********************************************************************** // open small search window // ********************************************************************** function popupChildWindow(obj, sPField, sName, sOpt){ // --- check browser --- if (document.layers) { var sMsg = 'Sorry, this function does not work on Netscape 4'; alert(sMsg); return 0; } // --- build url to open --- var sUrl = '/popup/search'; sUrl += '?' + Math.random(); sUrl += '&POPUP=1'; sUrl += '&FIELDNAME=' + sPField; sUrl += '&NAME=' + sName; sUrl += '&NEWSEARCH=1' // --- choose search type PID/POS/GRP --- switch (sSearchType){ case 'POS': sUrl += '&OPT=RETURNVAL="POS"'; break; case 'GRP': sUrl += '&OPT=RETURNVAL="GRP"'; break; case 'ID.NAME': sUrl += '&OPT=RETURNVAL="ID.NAME"'; break; default: sUrl += '&OPT=' + sOpt; } // --- open window --- childwin = window.open(sUrl, 'PeopleSearch', 'width=600,height=500,resizable=yes'); childwin.focus(); } // ********************************************************************** // redirect // ********************************************************************** function search_redirect(sPField, sUrl){ var oParent = window.opener; // --- append result --- if (sUrl.indexOf('?') == -1){ sUrl += '?' + sPField + '=' + sRadioVal; } else { sUrl += '&' + sPField + '=' + sRadioVal; } // --- add random number --- sUrl += '&' + Math.random(); // --- open new page --- oParent.location.href = sUrl; } // ***** ------------- ***** // ***** Slider.js ***** // ***** ------------- ***** // ******************************************************************* // // Created By: TAKE // Created Date: 2009-06-03 // Language: JavaScript // File Name: Slider.js // Licence: MIT // Syntax: // obj = new SliderController(); // er = obj.setValue(); // val = obj.getValue(); // x = obj.onChange(); // x = obj.onMove(); // // WIN FX2: O // WIN FX3: O // WIN IE5: O // WIN IE6: O // WIN IE7: O // WIN NS8: O // WIN OP9: O // WIN SF3: O // // ******************************************************************* slider = new SliderController(''); function SliderController(sId, iMaxValue) { var iCurValue = 1; if (!sId) { return 0; } if (!iMaxValue) { iMaxVallue = 0; iCurValue = 0; } // --- set private variables --- var self = this; var sSliderId = sId; var bSliderActive = 0; var iSliderHight = 16; var iSliderWidth = 200; var iMinMarginLeft = 0; var iMaxMarginLeft = 100; var iActualWidth = 0; // --- set public variables --- this.onChange = ''; this.onMove = ''; // --- set public functions --- this.startSlider = startSlider; this.addEvent = addEvent; this.getValue = getValue; this.setValue = setValue; this.addSlider = addSlider; // --- build slider --- var aSlider = new Array(); addSlider(sId); function executeOnMove() { if (!self.onMove) { return 0; } self.onMove(); } function executeOnChange() { if (!self.onChange) { return 0; } self.onChange(); } function getValue() { return iCurValue; } function setValue(myVal) { if (iMaxValue == 0) { iCurValue = 0; return 0; } iMaxValue = parseInt(iMaxValue); if (myVal < 1) { iCurValue = 1; } else if (myVal >= iMaxValue) { iCurValue = iMaxValue; } else { iCurValue = myVal; } for (var i in aSlider) { aSlider[i].setHandle(iCurValue); } executeOnMove(); } function btnPrevClick() { iCurValue--; setValue(iCurValue); executeOnChange(); } function btnNextClick() { iCurValue++; setValue(iCurValue); executeOnChange(); } function tboxBlur() { for (var i in aSlider) { var oTextBox = document.getElementById(i + '_text'); if (oTextBox.value != iCurValue) { setValue(oTextBox.value); executeOnChange(); } } } function tboxEnter(evt, obj) { if (evt.keyCode == 13) { obj.blur(); } } function mouseDown(event) { startSlider(); iCurValue = aSlider[sSliderId].getValueFromSlider(event); setValue(iCurValue); } function mouseMove(event) { if (!bSliderActive) { return 0; } iCurValue = aSlider[sSliderId].getValueFromSlider(event); setValue(iCurValue); } function startSlider() { bSliderActive = 1; } function endSlider() { if (bSliderActive) { executeOnChange(); } bSliderActive = 0; } function addSlider(myId) { aSlider[myId] = new Slider(myId, iMaxValue); aSlider[myId].buildSlider(); setValue(iCurValue); // --- set listeners --- var oHandle = document.getElementById(myId + '_handle'); var oBase = document.getElementById(myId + '_base'); var oBtnPrev = document.getElementById(myId + '_prev'); var oBtnNext = document.getElementById(myId + '_next'); var oTextBox = document.getElementById(myId + '_text'); addEvent(document, 'mousemove', mouseMove); addEvent(document, 'mouseup', endSlider); addEvent(oHandle, 'mousedown', startSlider); addEvent(oBase, 'mousedown', mouseDown); addEvent(oBtnPrev, 'click', btnPrevClick); addEvent(oBtnNext, 'click', btnNextClick); addEvent(oTextBox, 'blur', tboxBlur); addEvent(oTextBox, 'keypress', function(evt){tboxEnter(evt, this)}); } function addEvent(obj, act, func){ if (obj.addEventListener){ obj.addEventListener(act, func, false); } else { obj.attachEvent('on' + act, func); } } } function Slider(sId, iMaxValue) { // --- set private variables --- var sSliderId = sId; var iInitValue = 1; var iSliderHight = 16; var iSliderWidth = 200; var iMinMarginLeft = 0; var iMaxMarginLeft = 100; var iActualWidth = 0; var iHandleWidth = 5; var sImgBase = '/jpegs/slider_base_yellow.jpg'; var sImgHandle = '/gifs/slider_handle.gif'; var sImgPrev = '/gifs/ico_arrow_yellow_previous_big_16.gif'; var sImgNext = '/gifs/ico_arrow_yellow_next_big_16.gif'; if (!iMaxValue) { iMaxValue = 0; iInitValue = 0; } // --- set public functions --- this.setHandle = setHandle; this.getValueFromSlider = getValueFromSlider; this.buildSlider = buildSlider; function buildSlider() { // --- build slider html --- var sHtml = ''; var sStyleBg = ' background: url(' + sImgBase + ');'; var sStyleWidth = ' width: ' + iSliderWidth + 'px;' sHtml += ''; sHtml += '
'; sHtml += 'Previous'; sHtml += ''; sHtml += '
'; sHtml += '
'; sHtml += ''; sHtml += '' sHtml += '
'; oDiv = document.getElementById('slider_' + sId); oDiv.innerHTML += sHtml; // --- set initial values --- var oSliderMax = document.getElementById(sSliderId + '_max'); var oTextBox = document.getElementById(sSliderId + '_text'); oTextBox.value = iInitValue; oSliderMax.innerHTML = iMaxValue; } function getValueFromSlider(event) { // --- get current mouse position --- var oSlider = document.getElementById(sSliderId + '_base'); var oHandle = document.getElementById(sSliderId + '_handle'); var iUnit = iSliderWidth / iMaxValue; var iMousePos = getMouseX(event) - getObjPos(oSlider).x; var iValueFromSlider = parseInt(iMousePos / iUnit) + 1; if (iValueFromSlider < 1) { iValueFromSlider = 1; } else if (iValueFromSlider > iMaxValue) { iValueFromSlider = iMaxValue; } return iValueFromSlider; } function setHandle(myValue) { // // --- get handle width ----------------------------------------- // // On IE, using clientWidth after innerHTML does not work if it // // is inserted inside of the table. // // -------------------------------------------------------------- // var oTmpHandle = new Image(); // oTmpHandle.src = sImgHandle; // var iHandleWidth = oTmpHandle.width; // --- compute current handle location --- // an = a1 + (n-1)d // --------------------------------------- var iActualWidth = iSliderWidth - iHandleWidth; var iDiff = 0; if (iMaxValue == 1) { iDiff = iActualWidth / 1; } else { iDiff = iActualWidth / (iMaxValue - 1); } iMarginLeft = (myValue-1) * iDiff; document.getElementById(sSliderId + '_handle').style.marginLeft = parseInt(iMarginLeft) + 'px'; // --- set value to the textbox --- var oTextBox = document.getElementById(sSliderId + '_text'); oTextBox.value = myValue; } //rt.11.17.11 function getMouseX(event){ //rt.11.17.11 if (window.opera) { //rt.11.17.11 return event.clientX; //rt.11.17.11 } else if (document.all) { //rt.11.17.11 return document.body.scrollLeft + event.x; //rt.11.17.11 } else if (document.layers||document.getElementById) { //rt.11.17.11 return event.pageX; //rt.11.17.11 } //rt.11.17.11 return 0; //rt.11.17.11 } function getObjPos(oElement){ var pos = {x:oElement.offsetLeft, y:oElement.offsetTop}; while(oElement = oElement.offsetParent){ pos.x += oElement.offsetLeft; pos.y += oElement.offsetTop; } return pos; } }