📄 spmenu.js
字号:
return spm_getMenuImage('spacer.gif', me, null, ' ');
}
function spm_getItemHTML(oNode, sSide, sDef)
{
if (sDef == null) sDef = '';
return spm_getAttr(oNode, sSide + "html", sDef);
}
function spm_getMenuImage(sImage, me, bForce, sAlt)
{
//'generates html for image using the SystemImagesPath property
return spm_getHTMLImage(sImage, me.systemImagesPath, bForce, sAlt);
}
function spm_getHTMLImage(sImage, sPath, bForce, sAlt)
{
//'generates html for image using the SystemImagesPath property
if (spm_browserNeedsSpacer() == false && sImage == 'spacer.gif' && bForce != true)
return ' ';
else
return "<IMG SRC=\"" + sPath + sImage + "\" " + spm_getAlt(sAlt) + ">";
}
function spm_getAlt(sAlt)
{
if (sAlt != null && sAlt.rtrim().length > 0)
return ' ALT="' + sAlt + '" ';
else
return '';
}
function spm_browserNeedsSpacer()
{
if (spm_browserType() == 'ie')
return false;
else
return true;
}
function MyIIf(bFlag, sTrue, sFalse)
{
if (bFlag)
return sTrue;
else
return sFalse;
}
function spm_getArrow(sImg, me)
{
//FIX
if (sImg.length)
return spm_getMenuImage(sImg, me, null, '>');
else
{
if (me.direction == 'rtl')
return "3";
else
return "4"; //'defaults to using wingdings font (4 = arrow)
}
}
function spm_getMenuBorderStyle(me, shColor, hlColor, width)
{
if (shColor == null) shColor = me.shColor;
if (hlColor == null) hlColor = me.hlColor;
if (width == null) width = me.borderWidth;
//border-bottom: Gray 1px solid; border-left: White 1px solid; border-top: White 1px solid; border-right: Gray 1px solid;
//return 'border-bottom: ' + shColor + ' ' + width + 'px solid; border-left: ' + hlColor + ' ' + width + 'px solid; border-top: ' + hlColor + ' ' + width + 'px solid; border-right: ' + shColor + ' ' + width + 'px solid;';
return getBorderStyle('border-bottom', shColor, width) + getBorderStyle('border-left', hlColor, width) + getBorderStyle('border-top', hlColor, width) + getBorderStyle('border-right', shColor, width);
}
function getBorderStyle(type, color, width)
{
return type + ': ' + color + ' ' + width + 'px solid; ';
}
//------------------------//
String.prototype.ltrim = function () { return this.replace(/^\s*/, "");}
String.prototype.rtrim = function () { return this.replace(/\s*$/, "");}
String.prototype.trim = function () { return this.ltrim().rtrim(); }
if (spm_browserType() == 'safari') //Safari Hack
var Document = null;
if (spm_browserType() != 'ie' && spm_browserType() != 'op' && Document != null)
{
Document.prototype.loadXML = function (s)
{
// parse the string to a new doc
var doc2 = (new DOMParser()).parseFromString(s, "text/xml");
// remove all initial children
while (this.hasChildNodes())
this.removeChild(this.lastChild);
// insert and import nodes
for (var i = 0; i < doc2.childNodes.length; i++)
{
this.appendChild(this.importNode(doc2.childNodes[i], true));
}
}
function _Node_getXML()
{
//create a new XMLSerializer
var objXMLSerializer = new XMLSerializer;
//get the XML string
var strXML = objXMLSerializer.serializeToString(this);
//return the XML string
return strXML;
}
Node.prototype.__defineGetter__("xml", _Node_getXML);
}
function spm_createDOMDoc()
{
if (spm_browserType() == 'ie')
{
var o = new ActiveXObject('MSXML.DOMDocument');
o.async = false;
return o;
}
else
return document.implementation.createDocument("", "", null);
}
function spm_getById(sID)
{
if (document.all == null)
return document.getElementById(sID);
else
return document.all(sID);
}
function spm_getTags(sTag, oCtl)
{
if (oCtl == null)
oCtl = document;
if (spm_browserType() == 'ie')
return oCtl.all.tags(sTag);
else
return oCtl.getElementsByTagName(sTag);
}
function spm_browserType()
{
if (m_spm_sBrowser == null)
{
var agt=navigator.userAgent.toLowerCase();
if (agt.toLowerCase().indexOf('konqueror') != -1)
m_spm_sBrowser = 'kq';
else if (agt.toLowerCase().indexOf('opera') != -1)
m_spm_sBrowser = 'op';
else if (agt.toLowerCase().indexOf('netscape') != -1)
m_spm_sBrowser = 'ns';
else if (agt.toLowerCase().indexOf('msie') != -1)
m_spm_sBrowser = 'ie';
else if (agt.toLowerCase().indexOf('safari') != -1)
m_spm_sBrowser = 'safari';
if (m_spm_sBrowser == null)
m_spm_sBrowser = 'mo';
}
//window.status = m_spm_sBrowser;
return m_spm_sBrowser;
}
function spm_browserVersion()
{
//Please offer a better solution if you have one!
var sType = spm_browserType();
var iVersion = parseFloat(navigator.appVersion);
var sAgent = navigator.userAgent.toLowerCase();
if (sType == 'ie')
{
var temp=navigator.appVersion.split("MSIE");
iVersion=parseFloat(temp[1]);
}
if (sType == 'ns')
{
var temp=sAgent.split("netscape");
iVersion=parseFloat(temp[1].split("/")[1]);
}
return iVersion;
}
function spm_needsSubMenuDelay()
{
if (spm_browserType() == 'ie')
return true;
else
return false;
}
function spm_supportsIFrameTrick()
{
var sType = spm_browserType();
var sVersion = spm_browserVersion();
if ((sType == 'ie' && sVersion < 5.5) || (sType == 'ns' && sVersion < 7) || (spm_browserType() == 'safari') || spm_isMac('ie'))
{
return false;
}
return true;
}
function spm_isMac(sType)
{
//return true;
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf('mac') != -1)
{
if (sType == null || spm_browserType() == sType)
return true;
}
else
return false;
}
//taken from http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&threadm=b42qj3%24r8s1%40ripley.netscape.com&rnum=1&prev=/groups%3Fq%3Dmozilla%2B%2522currentstyle%2522%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26safe%3Doff%26scoring%3Dd
function spm_getCurrentStyle(el, property) {
if (document.defaultView)
{
// Get computed style information:
if (el.nodeType != el.ELEMENT_NODE) return null;
return document.defaultView.getComputedStyle(el,'').getPropertyValue(property.split('-').join(''));
}
if (el.currentStyle)
{
// Get el.currentStyle property value:
return el.currentStyle[property.split('-').join('')];
//return el.currentStyle.getAttribute(property.split('-').join('')); //We need to get rid of slashes
}
if (el.style)
{
// Get el.style property value:
return el.style.getAttribute(property.split('-').join('')); // We need to get rid of slashes
} return null;
}
function spm_getAttr(o, sAttr, sDef)
{
if (sDef == null)
sDef = '';
var s = o.getAttribute(sAttr);
if (s != null && s.length > 0)
return o.getAttribute(sAttr);
else
return sDef;
}
function spm_setAttr(o, sAttr, sVal)
{
if (sVal.length > 0)
o.setAttribute(sAttr, sVal);
else
o.removeAttribute(sAttr);
}
function spm_fixUnit(s)
{
if (s.length && isNaN(s) == false)
return s + 'px';
}
function spm_nodeHasChildren(node)
{
if (typeof(node.selectSingleNode) != 'undefined') //(node.selectSingleNode != null) //(spm_browserType() == 'ie')
return node.selectSingleNode('./menuitem') != null;
else
{
if (node.childNodes.length > 0)
{
//Netscape/Mozilla counts an empty <menuitem id></menuitem> as having a child...
for (var i=0; i< node.childNodes.length; i++)
{
if (node.childNodes[i].nodeName == 'menuitem')
return true;
}
}
}
return false;
}
function spm_findNode(oParent, sID)
{
for (var i = 0; i < oParent.childNodes.length; i++)
{
oNode = oParent.childNodes[i];
if (oNode.nodeType != 3) //exclude nodeType of Text (Netscape/Mozilla) issue!
{
if ((oNode.nodeName == "menuitem" || oNode.nodeName == "menubreak") && oNode.getAttribute("id") == sID)
return oNode;
if (oNode.childNodes.length > 0)
{
var o = spm_findNode(oNode, sID);
if (o != null)
return o;
}
}
}
}
function spm_getSibling(oNode, iOffset)
{
var sID = spm_getAttr(oNode, 'id');
var o;
for (var i=0; i<oNode.parentNode.childNodes.length; i++)
{
o = oNode.parentNode.childNodes[i];
if (o.nodeType != 3)
{
if (spm_getAttr(o, 'id') == sID)
return getOffsetNode(o.parentNode, i, iOffset);
}
}
}
function spm_stopEventBubbling(e)
{
if (spm_browserType() == 'ie')
window.event.cancelBubble = true;
else
e.stopPropagation();
}
//--- if you have a better solution send me an email - jhenning@solpart.com ---//
function spm_appendFunction(from_func, to_func)
{
if (from_func == null)
return new Function ( to_func );
return new Function ( spm_parseFunctionContents(from_func) + '\n' + spm_parseFunctionContents(to_func) );
}
function spm_parseFunctionContents(fnc)
{
var s =String(fnc).trim();
if (s.indexOf('{') > -1)
s = s.substring(s.indexOf('{') + 1, s.length - 1);
return s;
}
//--- For JS DOM ---//
function SPJSXMLNode(sNodeName, sID, oParent, sTitle, sURL, sImage, sImagePath, sRightHTML, sLeftHTML, sRunAtServer, sItemStyle, sImageStyle, sToolTip, sItemCSS, sItemSelCSS)
{
this.nodeName = sNodeName;
this.id=sID;
this.childNodes = new Array();
//this.nodeType = 3;
this.parentNode = oParent;
if (oParent != null)
{
oParent.childNodes[oParent.childNodes.length] = this;
if (oParent.documentElement == null)
this.documentElement = oParent;
else
this.documentElement = oParent.documentElement;
}
else
this.documentElement = this;
this.title = sTitle;
this.url = sURL;
this.image = sImage;
this.imagepath = sImagePath;
this.righthtml = sRightHTML;
this.lefthtml = sLeftHTML;
this.server = sRunAtServer;
this.itemstyle = sItemStyle;
this.imagestyle = sImageStyle;
this.tooltip = sToolTip;
this.css = sItemCSS;
this.selcss = sItemSelCSS;
}
SPJSXMLNode.prototype.getAttribute = function(s)
{
return this[s];
}
var m_iSPTimer;
var m_iSPTotalTimer=0;
var m_sSPDebugText;
var m_oSPDebugCtl;
var m_b
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -