⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dhtml.js

📁 数据仓库建设参考
💻 JS
📖 第 1 页 / 共 4 页
字号:
        return aHexadecimalValues[iDecimalValue];

}

function getMouse(e) {
//*********************************************************************************************
//Purpose: Store the x and y coordinates of the mouse in global variables.
//Inputs:  e - the event for Netscape.
//Outputs: None.
//*********************************************************************************************
    if (bIsNN4) {
        lMouseX = e.pageX - 5;
        lMouseY = e.pageY - 5;
    }
    else if (bIsIE4) {
        lMouseX = event.clientX - 5 + document.body.scrollLeft;
        lMouseY = event.clientY - 5 + document.body.scrollTop;;
    }
    else if (bIsW3C) {
        lMouseX = e.pageX - 5;
        lMouseY = e.pageY - 5;
    }
}

function writeToDiv(sMessage, sDivID) {
//*********************************************************************************************
//Purpose: Write the supplied message into the supplied DIV.
//Inputs:  sMessage - the message to be displayed, sDivID - the div to display the message
//Outputs: None.
//*********************************************************************************************
    if (bIsNN4) {
        var oDiv = getObj(sDivID);
        oDiv.document.write(sMessage);
        oDiv.document.close();
    }
    else if (bIsIE4 || bIsW3C) {
        var oDiv = getObj(sDivID);
        if (oDiv)
            oDiv.innerHTML = sMessage;
    }
}

function getEventTarget(e) {
//*********************************************************************************************
//Purpose: Returns the target of the event passed in.
//Inputs:  Event
//Outputs: Element
//*********************************************************************************************
    if (bIsDHTML) {
        if (bIsW3C) {
            return e.target;
        }
        else if (bIsIE4) {
            return event.srcElement;
        }
    }
    return null;
}

function cancelEvent(e) {
//*********************************************************************************************
//Purpose: Cancels the event
//Inputs:  Event
//Outputs: None
//*********************************************************************************************
    if (bIsDHTML) {
        if (bIsW3C)
            e.preventDefault();
        else if (bIsIE4)
            event.returnValue = false;
    }
}

function findTarget(oTarget, sFind) {
//*********************************************************************************************
//Purpose: Steps up through all parent nodes looking for a node with
//              the attribute value supplied.
//Inputs:  oTarget - the beginning object; sFind - the name of the attribute to look for.
//Outputs: Found object or null if not found.
//*********************************************************************************************

    // Step from the target object up through it's parents until you either find a valid target or there is no more parent.
    if (!bIsW3C) {
        while (oTarget.parentNode) {
            if (oTarget.getAttribute(sFind))
                return oTarget;
            oTarget = oTarget.parentNode;
        }
    }
    else {
        while(oTarget.parentNode) {
        		// For NN6 it has to be a table element to use the get attribute function.
            if ((oTarget.toString() == '[object HTMLTableCellElement]') ||
            		(oTarget.toString() == '[object HTMLTableElement]') ||
            		(oTarget.toString() == '[object HTMLDivElement]') ||
            		(oTarget.toString() == '[object HTMLSpanElement]') ||
            		(oTarget.toString() == '[object HTMLBodyElement]') ) {
                if (oTarget.getAttribute(sFind))
                    return oTarget;
            }
            oTarget = oTarget.parentNode;
        }
    }
    return null;
}

function disableElement(vObject, disabledClass){
//*********************************************************************************************
//Purpose: Disables the element indicated.
//Inputs:  Name of the element, or pointer to the object to disable
//Outputs: None - the object's disabled property is set to true.
//*********************************************************************************************
    var oObj = getObj(vObject);
    if (oObj){
        if (disabledClass.length>0){
            oObj.className = disabledClass;
        }
        oObj.disabled = true;
    }
}

function enableElement(vObject, enabledClass){
//*********************************************************************************************
//Purpose: Enables the element indicated.
//Inputs:  Name of the element, or pointer to the object to enable
//Outputs: None - the object's disabled property is set to false.
//*********************************************************************************************
    var oObj = getObj(vObject);
    if (oObj){
        oObj.disabled = false;
        if (enabledClass.length>0){
            oObj.className = enabledClass;
        }
    }
}


function addURLAsHiddenInputsToForm(oForm, URL){
        URL = URL.substring(URL.indexOf("?") + 1,URL.length);
        var URLParameters = URL.split("&");
        var temp = "";
        var parameterName = "";
        var parameterValue = "";
        var oNewItem;

        //Replace ALL + characters with space. The reason for that is the unescape function does not take care of this conversion.
        //That function just converts all strings of format %HH to the character value of the HH hex value
        //Our URL encoding codes spaces to + characters. Hence we have to reverse that effect over here.
        var myRegExp = /\+/g;

        for (var i=0; i<URLParameters.length; i++){
            temp = URLParameters[i].split("=");
            parameterName = temp[0];
            parameterValue = temp[1];
            oNewItem = document.createElement("INPUT");
            oNewItem.type="HIDDEN";
            oForm.insertAdjacentElement("beforeEnd", oNewItem);
            oNewItem.name=parameterName;
            if (parameterValue){
	        oNewItem.value=unescape(parameterValue.replace(myRegExp, ' '));
	    }else{
	        oNewItem.value=parameterValue;
	    }
        }

        return true;
}

//**DHTMLJSPAPI

function isDisplayed(vObject){
//*********************************************************************************************
//Purpose: Verify if requested object is currently being displayed or not
//Inputs:  vObject - object name or object reference
//Outputs: TRUE if the object is currently visible/displayed. Otherwise, FALSE
//*********************************************************************************************
    if (bIsDHTML) {
    var obj = getObj(vObject);
        if (bIsIE4 || bIsW3C) {
            return((obj.style.visibility == "visible") || (obj.style.visibility.length == 0));
        } else {
            return((document.layers[obj.id].visibility == "show") || (document.layers[obj.id].visibility.length == 0));
        }
    }
}


function panelHandler(sObjName, openToolTip, openImg, closeToolTip, closeImg){
//*********************************************************************************************
//Purpose: Handle the webPanel's show/expand and hide/collapse. Should be used through one
//         of its interfaces: sPanelHandler, xPanelHandler.
//Inputs:  sObjName - main name of the control to handle
//         openToolTip - tooltip to display when panel is hidden/collapsed
//         openImg - image to show when panel is hidden/collapsed
//         closeToolTip - tooltip to display when panel is shown/expanded
//         closeImg - image to show when panel is shown/expanded
//*********************************************************************************************
    var oTitleArray;
    var oContentArray;
    var oImageArray;
    var i;
    var j;
    var displayed;

    oContentArray = document.getElementsByName(sObjName + "_Content");

    if(oContentArray.length > 0) {
        displayed =  (isDisplayed(oContentArray.item(0)));
    }

    for(i = 0; i < oContentArray.length; i ++) {
        if (displayed){

            if (bIsIE4 || bIsW3C) {
                oContentArray.item(i).style.display = "none";
                oContentArray.item(i).style.visibility = "hidden";
            }
            else {
                document.layers[oContentArray.item(i).id].visibility = "hide";
            }

            oTitleArray = document.getElementsByName(sObjName);

            for(j = 0; j < oTitleArray.length; j ++) {
                oTitleArray.item(j).title = openToolTip;
            }

            oImageArray = document.getElementsByName(sObjName + "_Image");

            for(j = 0; j < oImageArray.length; j ++) {
                oImageArray.item(j).src = openImg;
                oImageArray.item(j).alt = openToolTip;
            }

        }
        else {
            if (bIsIE4 || bIsW3C) {
                oContentArray.item(i).style.display = "block";
                oContentArray.item(i).style.visibility = "visible";
            }
            else {
                document.layers[oContentArray.item(i).id].visibility = "show";
            }

            oTitleArray = document.getElementsByName(sObjName);

            for(j = 0; j < oTitleArray.length; j ++) {
                oTitleArray.item(j).title = closeToolTip;
            }

            oImageArray = document.getElementsByName(sObjName + "_Image");

            for(j = 0; j < oImageArray.length; j ++) {
                oImageArray.item(j).src = closeImg;
                oImageArray.item(j).alt = closeToolTip;
            }

        }

    }

    if(oContentArray.length > 0) {

        if (displayed){
            updateState(sObjName, "0");
        }
        else{
            updateState(sObjName, "1");
        }

    }

}

function panelRefresh(sObjName, openToolTip, openImg, closeToolTip, closeImg){
//*********************************************************************************************
//Purpose: Re-read the value of the cookie and adjust the requrested panel as indicated by the
//         cookie
//Inputs:  sObjName - main name of the control to handle
//         openToolTip - tooltip to display when panel is hidden/collapsed
//         openImg - image to show when panel is hidden/collapsed
//         closeToolTip - tooltip to display when panel is shown/expanded
//         closeImg - image to show when panel is shown/expanded
//*********************************************************************************************
    var oTitle;
    var oContent;
    var oImage;

    oTitle = getObj(sObjName);
    oContent = getObj(sObjName + "_Content");
    oImage = getObj(sObjName + "_Image");

    var cookie = document.cookie;
    var mgrCookie = getBrowserSettingCookie(cookie);
    var cookieValue = getCookieValueFromBrowserSetting(mgrCookie, sObjName);

    alert(cookieValue + " - Is it on? " + cookieValue.equals("1"));

    if (cookieValue.length > 0) {
        if (cookieValue.equals("1")){
            displayObj(oContent);
            oTitle.title = closeToolTip;
            oImage.src = closeImg;
        } else {
            removeObj(oContent);
            oTitle.title = openToolTip;
            oImage.src = openImg;
        }
    }
}


function getCookieValueFromBrowserSetting(sCookies, sCookieName){
//*********************************************************************************************
//Purpose: Process the browserSetting cookie value, getting the value of the sCookieName
//         cookie
//Inputs:  sCookies    - value of the browserSetting cookie
//         sCookieName - name of the cookie to remove from the browserSetting string
//Outputs: a String with the value of the requested -sub- cookie
//*********************************************************************************************
    var toSearch = sCookieName + "=";
    var found = "";
    var end;
    var temp;

    var start = sCookies.indexOf(toSearch);
    if (start != -1){
        // cookie found, remove it
        end = sCookies.indexOf("&",start);
        start = start+toSearch.length;
        if (end == -1)
            end=sCookies.length;
        found = sCookies.substring(start,end);
    }

    return found;
}


function removeCookieFromBrowserSetting(sCookies, sCookieName){
//*********************************************************************************************
//Purpose: Process the browserSetting cookie value, extracting the value of the sCookieName
//         cookie
//Inputs:  sCookies    - value of the browserSetting cookie
//         sCookieName - name of the cookie to remove from the browserSetting string
//Outputs: a String with the new value of the browserSetting cookie without the requested cookie
//*********************************************************************************************
    var toSearch = sCookieName + "=";
    var start = sCookies.indexOf(toSearch);
    var end;
    var temp;

    if (start != -1){
        // cookie found, remove it
        end = sCookies.indexOf("&",start);
        if (start == 0){ // first cookie
            if (end == sCookies.length-1) // only cookie
                return "";
            else  // return last portion of the cookie value
                return (sCookies.substring(end+1, sCookies.length));
        }

        if (end == sCookies.lenght-1){
            // last cookie, return substring
            return(sCookies.substring(0,start));
        }
        else{
            // build up the string to return
            temp = sCookies.substring(0,start) + sCookies.substring(end+1,sCookies.length);
            return temp;
        }
    }
    else{
        // not found, return as is
        return sCookies
    }
}


function getBrowserSettingCookie(sCookie){
//*********************************************************************************************
//Purpose: From all the existing cookies, return the browserSetting cookie value
//Inputs:  sCookie - String with the value of the current document cookie
//Outputs: a String with the value of the browserSetting cookie
//*********************************************************************************************
    var toSearch = "bSet" + "=";
    var start = sCookie.indexOf(toSearch);
    var end;
    var temp;
    if (start != -1){
        // if cookie exists
        start = start + toSearch.length;
        end = sCookie.indexOf(";", start);
        if (end == -1)
            end = sCookie.length;

        return unescape(sCookie.substring(start,end));
    }
    else{
        // if it does not exist, return empty string
        return "";
    }
}


function updateState(sObject, sState){
//*********************************************************************************************
//Purpose: Update the browserSetting cookie with the new state value for the indicated object
//Inputs:  sObject - name of the DHTML component to update
//         sState  - new value of the state attribute for the object
//Outputs: document cookie modified.
//*********************************************************************************************
    var cookie, mgrCookie;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -