hm_scriptdom.js
来自「FM MUDULATION SYSTEM COMUNICATION」· JavaScript 代码 · 共 845 行 · 第 1/3 页
JS
845 行
/*HM_ScriptDOM.js
* by Peter Belesis. v4.0.13 010712
* Copyright (c) 2001 Peter Belesis. All Rights Reserved.
* Originally published and documented at http://www.dhtmlab.com/
* You may use this code only if this entire
* copyright notice appears unchanged and you publicly display
* a link to http://www.dhtmlab.com/.
*
* Contact peterbelesis@yahoo.co.uk for all other uses.
*/
HM_IE5M = HM_IE && HM_Mac;
HM_IE5W = HM_IE && !HM_Mac;
HM_NS6 = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
HM_IEDTD = (HM_IE && document.doctype) ? document.doctype.name.indexOf(".dtd")!=-1 : false;
HM_IEnoDTD = HM_IE && !HM_IEDTD;
HM_a_Parameters = [
["MenuWidth", 150, "number"],
["FontFamily", "Arial,sans-serif"],
["FontSize", 10, "number"],
["FontBold", false, "boolean"],
["FontItalic", false, "boolean"],
["FontColor", "black"],
["FontColorOver", "white"],
["BGColor", "white"],
["BGColorOver", "black"],
["ItemPadding", 3, "number"],
["BorderWidth", 2, "number"],
["BorderColor", "red"],
["BorderStyle", "solid"],
["SeparatorSize", 1, "number"],
["SeparatorColor", "yellow"],
["ImageSrc", "HM_More_black_right.gif"],
["ImageSrcOver", null],
["ImageSrcLeft", "HM_More_black_left.gif"],
["ImageSrcLeftOver", null],
["ImageSize", 5, "number"],
["ImageHorizSpace", 0, "number"],
["ImageVertSpace", 0, "number"],
["KeepHilite", false, "boolean"],
["ClickStart", false, "boolean"],
["ClickKill", true, "boolean"],
["ChildOverlap", 20, "number"],
["ChildOffset", 10, "number"],
["ChildPerCentOver", null, "number"],
["TopSecondsVisible", .5, "number"],
["ChildSecondsVisible",.3, "number"],
["StatusDisplayBuild", 1, "boolean"],
["StatusDisplayLink", 1, "boolean"],
["UponDisplay", null, "delayed"],
["UponHide", null, "delayed"],
["RightToLeft", false, "boolean"],
["CreateTopOnly", 0, "boolean"],
["ShowLinkCursor", false, "boolean"]
]
HM_MenuIDPrefix = "HM_Menu";
HM_ItemIDPrefix = "HM_Item";
HM_ArrayIDPrefix = "HM_Array";
Function.prototype.isFunction = true;
Function.prototype.isString = false;
String.prototype.isFunction = false;
String.prototype.isString = true;
String.prototype.isBoolean = false;
String.prototype.isNumber = false;
Number.prototype.isString = false;
Number.prototype.isFunction = false;
Number.prototype.isBoolean = false;
Number.prototype.isNumber = true;
Boolean.prototype.isString = false;
Boolean.prototype.isFunction = false;
Boolean.prototype.isBoolean = true;
Boolean.prototype.isNumber = false;
Array.prototype.itemValidation = false;
Array.prototype.isArray = true;
function HM_f_AssignParameters(paramarray){
var ParamName = paramarray[0];
var DefaultValue = paramarray[1];
var FullParamName = "HM_" + ParamName;
if (typeof eval("window.HM_PG_" + ParamName) == "undefined") {
if (typeof eval("window.HM_GL_" + ParamName) == "undefined") {
eval(FullParamName + "= DefaultValue");
}
else {
eval(FullParamName + "= HM_GL_" + ParamName);
}
}
else {
eval(FullParamName + "= HM_PG_" + ParamName);
}
paramarray[0] = FullParamName;
paramarray[1] = eval(FullParamName);
}
function HM_f_EvalParameters(valuenew,valueold,valuetype){
var TestString, ParPosition;
if(typeof valuenew == "undefined" || valuenew == null || (valuenew.isString && valuenew.length == 0)){
return valueold;
}
if(valuetype != "delayed"){
while(valuenew.isString) {
ParPosition = valuenew.indexOf("(");
if(ParPosition !=-1) {
TestString = "window." + valuenew.substr(0,ParPosition);
if (typeof eval(TestString) != "undefined" && eval(TestString).isFunction) {
valuenew = eval(valuenew);
}
}
else break
}
}
while(valuenew.isFunction) {valuenew = valuenew()}
switch(valuetype){
case "number":
while (valuenew.isString) {valuenew = eval(valuenew)}
break;
case "boolean":
while (!valuenew.isBoolean) {
valuenew = (valuenew.isNumber) ? valuenew ? true : false : eval(valuenew);
}
break;
}
return valuenew;
}
for (i=0;i<HM_a_Parameters.length;i++) {
HM_f_AssignParameters(HM_a_Parameters[i]);
eval(HM_a_Parameters[i][0] + "= HM_f_EvalParameters("+ HM_a_Parameters[i][0] +",null,HM_a_Parameters[i][2])")
}
HM_ChildPerCentOver = (isNaN(parseFloat(HM_ChildPerCentOver))) ? null : parseFloat(HM_ChildPerCentOver)/100;
HM_ChildMilliSecondsVisible = HM_ChildSecondsVisible * 1000;
function HM_f_ValidateArray(arrayname){
var MenuArrayIsValid = false;
var MenuArrayIsObject = (typeof eval("window." + arrayname) == "object");
if(MenuArrayIsObject) {
var TheMenuArray = eval(arrayname);
if(TheMenuArray.isArray && TheMenuArray.length > 1) {
MenuArrayIsValid = true;
if(!TheMenuArray.itemValidation) {
while((typeof TheMenuArray[TheMenuArray.length-1] != "object") || (!TheMenuArray[TheMenuArray.length-1].isArray)) {
TheMenuArray.length--;
}
TheMenuArray.itemValidation = true;
}
}
}
return MenuArrayIsValid;
}
if(!window.HM_a_TreesToBuild) {
HM_a_TreesToBuild = [];
for(i=1; i<100; i++){
if(HM_f_ValidateArray(HM_ArrayIDPrefix + i)) HM_a_TreesToBuild[HM_a_TreesToBuild.length] = i;
}
}
HM_CurrentArray = null;
HM_CurrentTree = null;
HM_CurrentMenu = null;
HM_CurrentItem = null;
HM_a_TopMenus = [];
HM_AreLoaded = false;
HM_AreCreated = false;
HM_BeingCreated = false;
HM_UserOverMenu = false;
HM_HideAllTimer = null;
HM_TotalTrees = 0;
HM_ZIndex = 5000;
function HM_f_StartIt() {
if(HM_AreCreated) return;
if((typeof(document.body) == "undefined") || (document.body == null)) return;
HM_AreLoaded = true;
if (HM_ClickKill) {
HM_f_OtherMouseDown = (document.onmousedown) ? document.onmousedown : new Function;
document.onmousedown = function(){HM_f_PageClick();HM_f_OtherMouseDown()}
}
else {
HM_TopMilliSecondsVisible = HM_TopSecondsVisible * 1000;
}
HM_f_MakeTrees();
HM_f_OtherOnLoad();
}
function HM_f_MakeTrees(){
HM_BeingCreated = true;
var TreeParams = null;
var TreeHasChildren = false;
var ItemArray = null;
for(var t=0; t<HM_a_TreesToBuild.length; t++) {
if(!HM_f_ValidateArray(HM_ArrayIDPrefix + HM_a_TreesToBuild[t])) continue;
HM_CurrentArray = eval(HM_ArrayIDPrefix + HM_a_TreesToBuild[t]);
TreeParams = HM_CurrentArray[0];
TreeHasChildren = false;
for(var i=1; i<HM_CurrentArray.length; i++) {
ItemArray = HM_CurrentArray[i];
if(ItemArray[ItemArray.length-1]) {TreeHasChildren = true; break}
}
HM_CurrentTree = {
MenuWidth : MenuWidth = HM_f_EvalParameters(TreeParams[0],HM_MenuWidth,"number"),
MenuLeft : MenuLeft = HM_f_EvalParameters(TreeParams[1],null,"delayed"),
MenuTop : MenuTop = HM_f_EvalParameters(TreeParams[2],null,"delayed"),
ItemWidth : ItemWidth = MenuWidth - (HM_BorderWidth*2),
ItemTextWidth : TreeHasChildren ? (ItemWidth - (HM_ImageSize + HM_ImageHorizSpace + HM_ItemPadding)) : ItemWidth,
HorizOffsetRight : HorizOffsetRight = (parseInt((HM_ChildPerCentOver != null) ? (HM_ChildPerCentOver * ItemWidth) : HM_ChildOverlap)),
HorizOffsetLeft : (MenuWidth - HorizOffsetRight),
FontColor : HM_f_EvalParameters(TreeParams[3],HM_FontColor),
FontColorOver : HM_f_EvalParameters(TreeParams[4],HM_FontColorOver),
BGColor : HM_f_EvalParameters(TreeParams[5],HM_BGColor),
BGColorOver : HM_f_EvalParameters(TreeParams[6],HM_BGColorOver),
BorderColor : HM_f_EvalParameters(TreeParams[7],HM_BorderColor),
SeparatorColor : HM_f_EvalParameters(TreeParams[8],HM_SeparatorColor),
TopIsPermanent : ((MenuLeft == null) || (MenuTop == null)) ? false : HM_f_EvalParameters(TreeParams[9],false,"boolean"),
TopIsHorizontal : TopIsHorizontal = HM_f_EvalParameters(TreeParams[10],false,"boolean"),
TreeIsHorizontal : TreeHasChildren ? HM_f_EvalParameters(TreeParams[11],false,"boolean") : false,
PositionUnder : (!TopIsHorizontal || !TreeHasChildren) ? false : HM_f_EvalParameters(TreeParams[12],false,"boolean"),
TopImageShow : TreeHasChildren ? HM_f_EvalParameters(TreeParams[13],true,"boolean") : false,
TreeImageShow : TreeHasChildren ? HM_f_EvalParameters(TreeParams[14],true,"boolean") : false,
UponDisplay : HM_f_EvalParameters(TreeParams[15],HM_UponDisplay,"delayed"),
UponHide : HM_f_EvalParameters(TreeParams[16],HM_UponHide,"delayed"),
RightToLeft : HM_f_EvalParameters(TreeParams[17],HM_RightToLeft,"boolean"),
ClickStart : HM_f_EvalParameters(TreeParams[18],HM_ClickStart,"boolean")
}
HM_CurrentMenu = null;
HM_f_MakeMenu(HM_a_TreesToBuild[t]);
HM_a_TopMenus[HM_TotalTrees] = HM_CurrentTree.treeParent;
HM_TotalTrees++;
if(HM_CurrentTree.TopIsPermanent){
with(HM_CurrentTree.treeParent) {
HM_CurrentTree.treeParent.xPos = eval(HM_CurrentTree.MenuLeft);
HM_CurrentTree.treeParent.yPos = eval(HM_CurrentTree.MenuTop);
moveTo(HM_CurrentTree.treeParent.xPos,HM_CurrentTree.treeParent.yPos);
style.zIndex = 5000;
}
if(HM_IE5M) setTimeout(HM_CurrentTree.treeParent.id + ".fixSize(true)",10);
else HM_CurrentTree.treeParent.style.visibility = "visible";
}
}
if(HM_StatusDisplayBuild) status = HM_TotalTrees + " Hierarchical Menu Trees Created";
HM_AreCreated = true;
HM_BeingCreated = false;
}
function HM_f_SetItemProperties(itemidsuffix) {
this.tree = HM_CurrentTree;
this.index = HM_CurrentMenu.itemCount - 1;
this.isLastItem = (HM_CurrentMenu.itemCount == HM_CurrentMenu.maxItems);
this.array = HM_CurrentMenu.array[HM_CurrentMenu.itemCount];
this.dispText = this.array[0];
this.linkText = this.array[1];
this.permHilite = HM_f_EvalParameters(this.array[3],false,"boolean");
this.hasRollover = (!this.permHilite && HM_f_EvalParameters(this.array[2],true,"boolean"));
this.hasMore = HM_f_EvalParameters(this.array[4],false,"boolean") && HM_f_ValidateArray(HM_ArrayIDPrefix + itemidsuffix);
this.childID = this.hasMore ? (HM_MenuIDPrefix + itemidsuffix) : null;
this.child = null;
this.onmouseover = HM_f_ItemOver;
this.onmouseout = HM_f_ItemOut;
this.setItemStyle = HM_f_SetItemStyle;
this.showChild = HM_f_ShowChild;
this.ClickStart = this.hasMore && this.tree.ClickStart && (this.tree.TopIsPermanent && (this.tree.treeParent==this.menu));
if(this.ClickStart) {
this.linkText = "";
this.onclick = this.showChild;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?