发布 shawl.qiu Javascript 智能无限级导航菜单类 Menu class v1.0
说明:
导航菜单...这个东西每个站点, 大大小小都有嘛.
不过每次写这个基本上都是重新码一遍代码, 很烦是吧, 对, 真的很烦.
那么, 本类可以解决您的烦恼了.
只要调用一下再设置一下就Ok, 而且你可以在一个页面使用本类显示N个菜单, 本类的特点是把各个设置都细分成小功能, 因此可以无限多兼容.
菜单内容格式为:
id列间隔符,str列间隔符,...列间隔符...
如:
23##海纳百川##12##办公软件##@
一般使用 sql 视图获取和设置菜单字串格式, 也就是 join 表.
如:
- SELECT a.cat1id, a.cat1, b.cat2id, b.cat2, c.cat3id, c.cat3
- FROM (sqCat1 AS a LEFT JOIN sqCat2 AS b ON a.cat1id=b.cat1id) LEFT JOIN sqCat3 AS c ON b.cat2id=c.cat2id
- ORDER BY a.cat1OdrH, a.cat1id, b.cat2OdrH, b.cat2id, c.cat3OdrH, c.cat3id;
如果是使用 asp, 可以使用 Ado RecordSet GetString 快速获取, 见 调用演示.
如果使用 aspx , 也可以用 Ado RecordSet GetString 获取内容, 不过比较麻烦, 请参见鄙人以前的文章:
asp.net 中 使用 ado 的 Recordset GetString 函数 By shawl.qiu
http://blog.csdn.net/btbtd/archive/2007/03/04/1520102.aspx
嗯, 本类有点复杂, 但是调用很简单.
有什么不明白的, 看调用演示, 因为调用演示已经把一切都表述得非常非常清楚.
目录:
1. 调用演示
2. Menu class 核心源码
shawl.qiu
2007-05-21
http://blog.csdn.net/btbtd
下载: http://shawl.qiu.googlepages.com/sq_js_class_Menu_v1.0.7z
演示: http://shawl.qiu.googlepages.com/Menu_1.0_demo.htm
内容:
1. 调用演示
- shawl.qiu framework javascript client-side
- 类 Menu
- ---/------------------------------------------------------------------------------
- 目录:
- 0. 数据查询语句
- 0.1 二级分类
- 0.1.1 查询名
- 0.1.2 查询串
- 0.2 三级分类
- 0.2.1 查询名
- 0.2.2 查询串
- 1. 调用
- 1.1 调用 1
- 1.2 调用 2 (Vbscript)
- 1.3 调用 3 (Jscript)
- 2. 演示
- 2.1 动态水平垂直显示菜单演示
- ---/---------------------------------------
- 内容:
- 0. 数据查询语句
- 0.1 二级分类
- 0.1.1 查询名
- v_news_cat
- 0.1.2 查询串
- SELECT a.classid, a.class, b.nclassid, b.nclass
- FROM ctclass AS a INNER JOIN ctnclass AS b ON a.classid=b.classid
- ORDER BY a.classorder, a.classid, b.nclassorder;
- 0.2 三级分类
- 0.2.1 查询名
- v_cat_query_3tbl
- 0.2.2 查询串
- SELECT a.cat1id, a.cat1, b.cat2id, b.cat2, c.cat3id, c.cat3
- FROM (sqCat1 AS a LEFT JOIN sqCat2 AS b ON a.cat1id=b.cat1id) LEFT JOIN sqCat3 AS c ON b.cat2id=c.cat2id
- ORDER BY a.cat1OdrH, a.cat1id, b.cat2OdrH, b.cat2id, c.cat3OdrH, c.cat3id;
- 1. 调用
- 1.1 调用 1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <!-- DW6 -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>shawl.qiu template</title>
- </head>
- <body>
- <div id="MenuBar"> </div>
- <script type='text/javascript' src='/sqFwJsCs/default.js'></script>
- <script type="text/javascript">
- //<![CDATA[
- im.go('UI.Menu');
- //im.help('UI.Menu');
- /*--------------------------end sqFwJsCs----------------------------------*/
- //]]>
- </script>
- <script type="text/javascript">
- //<![CDATA[
- var MenuStr3 =
- "1##JScript##1##函数库##2##文件##@1##JScript##1##函数库##3##测试##@1##JScript##4##类库##6##数据操作##@1##JScript##9##prototype库######@1##JScript##16##模板库######@1##JScript##8##杂类######@1##JScript##14##函数收藏######@5##JavaScript##39##枚举######@5##JavaScript##41##收藏######@5##JavaScript##12##函数库######@5##JavaScript##11##类库######@5##JavaScript##7##小工具######@7##VBScript##10##类库######@7##VBScript##18##函数库##7##文件函数##@15##ActionScript##34##函数库######@15##ActionScript##35##类库######@12##CSharp .Net##23##函数库##9##文件操作##@12##CSharp .Net##23##函数库##10##数据操作##@12##CSharp .Net##31##函数收藏######@12##CSharp .Net##29##控件库######@12##CSharp .Net##24##static 库######@12##CSharp .Net##22##类库######@12##CSharp .Net##32##名称空间######@12##CSharp .Net##40##开发小工具######@12##CSharp .Net##38##杂类######@12##CSharp .Net##27##模板库##8##数据绑定##@12##CSharp .Net##27##模板库##11##aspx 页模板##@12##CSharp .Net##27##模板库##12##ascx 页模板##@11##JScript .Net##20##函数库######@11##JScript .Net##21##类库######@10##Sql##15##Access######@10##Sql##33##MsSql######@10##Sql##36##数据表模板######@13##xhtml##25##普通应用######@14##xml##28##模板库######@9##CSS##13##导航######@9##CSS##17##模板库######@16##Utility##37##Server######@8##测试类##########@"
- ;
- var menu = new Menu();
- menu.Debug.Bool = false;
- // menu.String = MenuStr2;
- menu.String = MenuStr3;
- menu.Main.ID = "MenuBar";
- menu.Direction.Horizontal.Bool = true;
- menu.Direction.Horizontal.Main.Width = "99.5%";
- // menu.Direction.Vertical.Bool = true;
- menu.Symbol.Item = "##";
- menu.Symbol.Column = "##@";
- //function fAddLink(sLink, bInherit)
- menu.Link.Add("?level1=", false);
- menu.Link.Add("&level2=", true);
- menu.Link.Add("&level3=", true);
- //function fAddLinkhighlight(sQuery, sBgColor, sFgColor)
- menu.Query.Highlight.Add("level1", "black", "white");
- menu.Query.Highlight.Add("level2", "brown", "white");
- menu.Query.Highlight.Add("level3", "red", "white");
- menu.Go();
- menu = null;
- //]]>
- </script>
- </body>
- </html>
- 1.2 调用 2 (Vbscript)
- <div id="MenuBar"> </div>
- <%
- dim MyMenuStr
- MyMenuStr = fGetString1("select * from v_news_cat", conn)
- 'Response.write("var str='"&MyMenuStr&"'"&chr(13))
- function fGetString1(sQuery, sConn)
- fGetString1 = fGetString(sQuery, sConn, -1, "##", "##@", "empty...")
- end function
- function fGetString(sQuery, sConn, iRos, sColDelimeter, sRowDelimeter, sNull)
- dim str, Rs
- set Rs = CreateObject("adodb.recordset")
- Rs.Open sQuery, sConn, 1
- str = rs.GetString(2, iRos, sColDelimeter, sRowDelimeter, sNull)
- Rs.Close
- set Rs = Nothing
- fGetString = str
- end function
- %>
- <script type='text/javascript' src='/sqFwJsCs/default.js'></script>
- <script type="text/javascript">
- //<![CDATA[
- im.go('UI.Menu');
- //im.help('UI.Menu');
- /*--------------------------end sqFwJsCs----------------------------------*/
- //]]>
- </script>
- <script type="text/javascript">
- //<![CDATA[
- var MenuStr2 =
- "<%Response.Write(MyMenuStr)%>"
- ;
- var menu = new Menu();
- menu.Debug.Bool = false;
- menu.String = MenuStr2;
- // menu.String = MenuStr3;
- menu.Main.ID = "MenuBar";
- menu.Direction.Horizontal.Bool = true;
- //menu.Direction.Vertical.Bool = true;
- menu.Direction.Horizontal.Main.Width = "99.5%";
- menu.Symbol.Item = "##";
- menu.Symbol.Column = "##@";
- //function fAppendSubLink(sId, sCat)
- menu.Addition.AppendSubLink.Bool = true;
- menu.Addition.AppendSubLink.Add("0", "无分类");
- //function fAddLink(sLink, bInherit)
- menu.Link.Add("/class.asp?classid=", false);
- menu.Link.Add("&nclassid=", true);
- //function fAddLinkhighlight(sQuery, sBgColor, sFgColor)
- menu.Query.Highlight.Add("classid", "black", "white");
- menu.Query.Highlight.Add("nclassid", "brown", "white");
- menu.Go();
- menu = null;
- //]]>
- </script>
- 1.3 调用 3 (Jscript)
- <%
- var MyMenuStr = fGetString("select * from v_cat_query_3tbl", conn);
- //Response.Write(MyMenuStr);
- function fGetString(sQuery, sConn, iRow, sColumnDelimeter, sRowDelimeter, sNullStr)
- {// shawl.qiu code
- var MyRs = null;
- var bClose = true;
- var sReturn = "";
- if(!iRow) iRow = -1;
- if(!sColumnDelimeter) sColumnDelimeter = "##";
- if(!sRowDelimeter) sRowDelimeter = "##@";
- if(!sNullStr) sNullStr = "";
- if(typeof(sQuery)=="object")
- {
- MyRs = sQuery;
- bClose = false;
- }
- else
- {
- MyRs = new ActiveXObject("adodb.recordset");
- MyRs.Open(sQuery, sConn, 1);
- }
- sReturn = MyRs.GetString(2, iRow, sColumnDelimeter, sRowDelimeter, sNullStr);
- if(bClose)
- {
- MyRs.Close();
- MyRs = null;
- }
- return sReturn;
- } // end function fGetString
- %>
- <div id="MenuBar"> </div>
- <script type='text/javascript' src='/sqFwJsCs/default.js'></script>
- <script type="text/javascript">
- //<![CDATA[
- im.go('UI.Menu');
- //im.help('UI.Menu');
- /*--------------------------end sqFwJsCs----------------------------------*/
- //]]>
- </script>
- <script type="text/javascript">
- //<![CDATA[
- var MenuStr3 =
- "<% Response.Write(MyMenuStr); %>"
- ;
- var menu = new Menu();
- menu.Debug.Bool = false;
- // menu.String = MenuStr2;
- menu.String = MenuStr3;
- menu.Main.ID = "MenuBar";
- menu.Direction.Horizontal.Bool = true;
- menu.Direction.Horizontal.Main.Width = "99.5%";
- // menu.Direction.Vertical.Bool = true;
- menu.Symbol.Item = "##";
- menu.Symbol.Column = "##@";
- //function fAppendSubLink(sId, sCat)
- menu.Addition.AppendSubLink.Bool = true;
- menu.Addition.AppendSubLink.Add("0", "无分类");
- //function fAddLink(sLink, bInherit)
- menu.Link.Add("category.asp?cat1id=", false);
- menu.Link.Add("&cat2id=", true);
- menu.Link.Add("&cat3id=", true);
- //function fAddLinkhighlight(sQuery, sBgColor, sFgColor)
- menu.Query.Highlight.Add("cat1id", "black", "white");
- menu.Query.Highlight.Add("cat2id", "brown", "white");
- menu.Query.Highlight.Add("cat3id", "red", "white");
- menu.Go();
- menu = null;
- //]]>
- </script>
- 2. 演示
- 2.1 动态水平垂直显示菜单演示
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <!-- DW6 -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>shawl.qiu template</title>
- <script type="text/javascript">
- //<![CDATA
- var MenuStr2 = '23##海纳百川##12##办公软件##@23##海纳百川##13##网页制作##@23##海纳百川##14##图象处理##@23##海纳百川##88##服务器篇##@23##海纳百川##126##功能测试##@23##海纳百川##156##FromXoopsNewbb##@23##海纳百川##158##FromXoopsXphpbbi##@23##海纳百川##159##有容乃大##@23##海纳百川##160##FromXoopsGipbb##@23##海纳百川##161##FromXoopsGiss##@23##海纳百川##162##FromXoopsGiArticles##@23##海纳百川##166##FromXoopsNews##@23##海纳百川##167##FromPhpbbForum##@23##海纳百川##170##设计##@23##海纳百川##171##网站##@23##海纳百川##172##调查##@23##海纳百川##173##金融##@23##海纳百川##197##FromLeadBBS##@23##海纳百川##206##投稿/撰稿/征文##@23##海纳百川##219##操作系统/OS##@23##海纳百川##223##丛书##@50##技术记##127##开发-本站##@50##技术记##179##C##@50##技术记##180##Linux##@50##技术记##183##RegExp-正则表达式##@50##技术记##193##Javascript/Jscript##@50##技术记##194##SQL/数据库##@50##技术记##195##ASP##@50##技术记##196##HTML##@50##技术记##203##技术翻译##@50##技术记##210##技术趣味##@50##技术记##211##草稿箱##@50##技术记##212##WebServices##@50##技术记##214##CSS##@50##技术记##215##XHTML##@50##技术记##229##MS-SQL Server##@50##技术记##233##Javascript/Jscript(client-side)##@50##技术记##241##Ajax##@50##技术记##243##XML##@50##技术记##247##c#/.net##@14##读书记##177##文学手记##@14##读书记##178##文学札记##@14##读书记##220##IT-札记##@14##读书记##221##WSJ##@14##读书记##231##杂文##@14##读书记##234##优美歌词/诗词##@56##英语角##96##基础资料##@56##英语角##198##英文/歌词&诗词##@56##英语角##199##英-英阅读##@56##英语角##200##英-汉阅读##@56##英语角##202##语法&写作##@51##工具箱##64##实用链接##@51##工具箱##66##在线工具##@51##工具箱##71##配色方案##@51##工具箱##72##设计概念##@51##工具箱##175##行业常识##@51##工具箱##184##模板##@51##工具箱##204##基层工具##@51##工具箱##230##文件头/File Header##@59##人工智能##228##基础资料##@57##程序设计##185##C语言##@57##程序设计##186##C++##@57##程序设计##187##C###@57##程序设计##188##VB##@57##程序设计##189##VF##@57##程序设计##190##Delphi##@6##数据库##36##Access##@6##数据库##37##Oracle##@6##数据库##38##SQL Server##@6##数据库##39##MySQL##@6##数据库##208##ADO##@6##数据库##213##书##@6##数据库##218##Postgresql##@4##网络编程##15##Flash##@4##网络编程##20##HTML##@4##网络编程##21##XML##@4##网络编程##22##ASP##@4##网络编程##23##JSP##@4##网络编程##24##PHP##@4##网络编程##25##CGI##@4##网络编程##26##.NET##@4##网络编程##27##Script##@4##网络编程##87##CSS##@4##网络编程##154##RegExp-正则##@4##网络编程##191##Java ##@4##网络编程##192##Perl ##@4##网络编程##207##Ajax##@4##网络编程##209##XHTML##@4##网络编程##217##书##@4##网络编程##225##shtml##@4##网络编程##226##安全信息##@4##网络编程##227##RBAC/权限设计##@4##网络编程##232##JScript/Server-Side##@4##网络编程##239##DOM##@4##网络编程##240##DHTML##@4##网络编程##248##多媒体##@4##网络编程##249##SSI##@60##.Net##235##相关文摘##@60##.Net##236##C#/CSharp .net##@60##.Net##237##JScript .Net##@60##.Net##238##VB .net##@60##.Net##242##ASP.NET##@61##架构/概念##244##面向对象##@61##架构/概念##245##开发##@10##站点大事记##61##绿色进化 E-Studio_2004##@10##站点大事记##155##绿色学院 - Green Institute_2006##@';
- var MenuStr3 =
- "1##JScript##1##函数库##2##文件##@1##JScript##1##函数库##3##测试##@1##JScript##4##类库##6##数据操作##@1##JScript##9##prototype库######@1##JScript##16##模板库######@1##JScript##8##杂类######@1##JScript##14##函数收藏######@5##JavaScript##39##枚举######@5##JavaScript##41##收藏######@5##JavaScript##12##函数库######@5##JavaScript##11##类库######@5##JavaScript##7##小工具######@7##VBScript##10##类库######@7##VBScript##18##函数库##7##文件函数##@15##ActionScript##34##函数库######@15##ActionScript##35##类库######@12##CSharp .Net##23##函数库##9##文件操作##@12##CSharp .Net##23##函数库##10##数据操作##@12##CSharp .Net##31##函数收藏######@12##CSharp .Net##29##控件库######@12##CSharp .Net##24##static 库######@12##CSharp .Net##22##类库######@12##CSharp .Net##32##名称空间######@12##CSharp .Net##40##开发小工具######@12##CSharp .Net##38##杂类######@12##CSharp .Net##27##模板库##8##数据绑定##@12##CSharp .Net##27##模板库##11##aspx 页模板##@12##CSharp .Net##27##模板库##12##ascx 页模板##@11##JScript .Net##20##函数库######@11##JScript .Net##21##类库######@10##Sql##15##Access######@10##Sql##33##MsSql######@10##Sql##36##数据表模板######@13##xhtml##25##普通应用######@14##xml##28##模板库######@9##CSS##13##导航######@9##CSS##17##模板库######@16##Utility##37##Server######@8##测试类##########@"
- ;
- function fVertical(sId)
- {
- var EleDiv = document.getElementById(sId);
- if(sId==null)
- {
- alert("菜单主域为null!");
- }
- var bMenuStr2 = confirm("确定显示二级分类, 否显示三级分类.");
- var MyMenuStr = "";
- if(bMenuStr2) MyMenuStr = MenuStr2;
- else MyMenuStr = MenuStr3;
- if(EleDiv.parentNode.nodeName=="SPAN")
- {
- var EleGrandfather = EleDiv.parentNode.parentNode;
- var NewEleDiv = document.createElement("div");
- NewEleDiv.id = sId;
- EleGrandfather.replaceChild(NewEleDiv, EleDiv.parentNode);
- var EleStyleId = sId+"sqMenuStyleId";
- var EleStyle = document.getElementById(EleStyleId);
- if(EleStyle!=null) EleStyle.parentNode.removeChild(EleStyle);
- // return;
- var menu = new Menu();
- menu.Debug.Bool = false;
- menu.String = MyMenuStr;
- menu.Main.ID = "MenuBar";
- //menu.Direction.Horizontal.Bool = true;
- //menu.Direction.Horizontal.Main.Width = "99.5%";
- menu.Direction.Vertical.Bool = true;
- menu.Direction.Style.Width = 120;
- menu.Symbol.Item = "##";
- menu.Symbol.Column = "##@";
- //function fAppendSubLink(sId, sCat)
- menu.Addition.AppendSubLink.Bool = true;
- menu.Addition.AppendSubLink.Add("0", "无分类");
- //function fAddLink(sLink, bInherit)
- menu.Link.Add("?level1=", false);
- menu.Link.Add("&level2=", true);
- menu.Link.Add("&level3=", true);
- //function fAddLinkhighlight(sQuery, sBgColor, sFgColor)
- menu.Query.Highlight.Add("level1", "black", "white");
- menu.Query.Highlight.Add("level2", "brown", "white");
- menu.Query.Highlight.Add("level3", "red", "white");
- menu.Go();
- menu = null;
- }
- } // end function fVertical;
- function fHorizontal(sId)
- {
- var EleDiv = document.getElementById(sId);
- if(sId==null)
- {
- alert("菜单主域为null!");
- }
- var bMenuStr2 = confirm("确定显示二级分类, 否显示三级分类.");
- var MyMenuStr = "";
- if(bMenuStr2) MyMenuStr = MenuStr2;
- else MyMenuStr = MenuStr3;
- if(EleDiv.parentNode.nodeName=="SPAN")
- {
- var EleGrandfather = EleDiv.parentNode.parentNode;
- var NewEleDiv = document.createElement("div");
- NewEleDiv.id = sId;
- EleGrandfather.replaceChild(NewEleDiv, EleDiv.parentNode);
- var EleStyleId = sId+"sqMenuStyleId";
- var EleStyle = document.getElementById(EleStyleId);
- if(EleStyle!=null) EleStyle.parentNode.removeChild(EleStyle);
- // return;
- var menu = new Menu();
- menu.Debug.Bool = false;
- menu.String = MyMenuStr;
- menu.Main.ID = "MenuBar";
- menu.Direction.Horizontal.Bool = true;
- menu.Direction.Horizontal.Main.Width = "99.5%";
- /*
- menu.Direction.Vertical.Bool = true;
- menu.Direction.Style.Width = 120;
- */
- menu.Symbol.Item = "##";
- menu.Symbol.Column = "##@";
- //function fAppendSubLink(sId, sCat)
- menu.Addition.AppendSubLink.Bool = true;
- menu.Addition.AppendSubLink.Add("0", "无分类");
- //function fAddLink(sLink, bInherit)
- menu.Link.Add("?level1=", false);
- menu.Link.Add("&level2=", true);
- menu.Link.Add("&level3=", true);
- //function fAddLinkhighlight(sQuery, sBgColor, sFgColor)
- menu.Query.Highlight.Add("level1", "black", "white");
- menu.Query.Highlight.Add("level2", "brown", "white");
- menu.Query.Highlight.Add("level3", "red", "white");
- menu.Go();
- menu = null;
- }
- } // end function fVertical;
- //]]>
- </script>
- </head>
- <body>
- <div id="MenuBar"> </div>
- <div style="text-align:right; ">
- <button onclick="fHorizontal('MenuBar');">Horizontal Demo</button>
- <button onclick="fVertical('MenuBar');">Vertical Demo</button>
- </div>
- <script type='text/javascript' src='/sqFwJsCs/default.js'></script>
- <script type="text/javascript">
- //<![CDATA[
- im.go('UI.Menu');
- //im.help('UI.Menu');
- /*--------------------------end sqFwJsCs----------------------------------*/
- //]]>
- </script>
- <script type="text/javascript">
- //<![CDATA[
- var menu = new Menu();
- menu.Debug.Bool = false;
- // menu.String = MenuStr2;
- menu.String = MenuStr3;
- menu.Main.ID = "MenuBar";
- menu.Direction.Horizontal.Bool = true;
- menu.Direction.Horizontal.Main.Width = "99.5%";
- // menu.Direction.Vertical.Bool = true;
- menu.Symbol.Item = "##";
- menu.Symbol.Column = "##@";
- //function fAppendSubLink(sId, sCat)
- menu.Addition.AppendSubLink.Bool = true;
- menu.Addition.AppendSubLink.Add("0", "无分类");
- //function fAddLink(sLink, bInherit)
- menu.Link.Add("?level1=", false);
- menu.Link.Add("&level2=", true);
- menu.Link.Add("&level3=", true);
- //function fAddLinkhighlight(sQuery, sBgColor, sFgColor)
- menu.Query.Highlight.Add("level1", "black", "white");
- menu.Query.Highlight.Add("level2", "brown", "white");
- menu.Query.Highlight.Add("level3", "red", "white");
- menu.Go();
- menu = null;
- //]]>
- </script>
- </body>
- </html>
2. Menu class 核心源码
- // shawl.qiu JavaScript Document
- /*-----------------------------------------------------------------------------------*/
- * shawl.qiu Javascript Menu class v1.0
- /*-----------------------------------------------------------------------------------*/
- //---------------------------------begin class Menu()-------------------------------//
- function Menu()
- { // shawl.qiu code
- //------------------------------------begin public variable
- //---------------begin about
- this.au = {}
- this.au.Subject = "shawl.qiu Javascript Menu class";
- this.au.Version = "v1.0";
- this.au.Name = "shawl.qiu";
- this.au.Email = "shawl.qiu@gmail.com";
- this.au.Blog = "http://blog.csdn.net/btbtd";
- this.au.CreatedDate = "2007-5-18";
- this.au.Update = {};
- this.au.Update["1"] = "";
- //---------------end about
- this.String = "";
- this.Main = {}
- this.Main.ID = "";
- this.Symbol = {};
- this.Symbol.Item = "##";
- this.Symbol.Column = "##@";
- this.Set = [];
- this.Prefix = "sfdqewrterg8987sfdasdf";
- this.Postfix = "JHjhifsadfyuyhjhasjkdf77";
- this.Addition = {};
- this.Addition.AppendSubLink = {}
- this.Addition.AppendSubLink.Bool = false;
- this.Addition.AppendSubLink.Set = []; // array [iId, sCat]
- this.Addition.AppendSubLink.Add = fAppendSubLink;
- this.Link = {};
- this.Link.Set = [];
- this.Link.Add = fAddLink;
- this.Query = {}
- this.Query.Highlight = {};
- this.Query.Highlight.Set = [];
- this.Query.Highlight.Add = fAddLinkhighlight;
- this.Level = {};
- this.Level.Count = 0;
- this.Level.ClassNamePrefix = "sqMenuLevalClassPrefix";
- this.Class = {}
- this.Class.Display = "sqMenuDisplaySubItem";
- this.Class.Hidden = "sqMenuHiddenSubItem";
- this.Class.MenuMain = "Layout";
- this.Style = {};
- this.Style.ID = "sqMenuStyleId";
- this.Count = 1;
- this.Debug = {}
- this.Debug.Bool = false;
- this.Debug.Element = null;
- this.ClearFloat = true;
- this.Direction = {}
- this.Direction.Style = {}
- this.Direction.Style.Width = 100;
- this.Direction.Style.PlusLeft = 4;
- this.Direction.Style.BgColor = "whitesmoke";
- this.Direction.Style.Padding = "2px 0px 2px 0px";
- // begin Direction Vertical css style definition
- this.Direction.Vertical = {}
- this.Direction.Vertical.Bool = false;
- this.Direction.Vertical.A = {}
- this.Direction.Vertical.A.Top ={}
- this.Direction.Vertical.A.Top.Link = {};
- this.Direction.Vertical.A.Top.Link.Color = "black";
- this.Direction.Vertical.A.Top.Link.Padding = "2px 0px 2px 2px";
- this.Direction.Vertical.A.Top.Link.Addition = "";
- this.Direction.Vertical.A.Top.Hover = {}
- this.Direction.Vertical.A.Top.Hover.Color = "#fff";
- this.Direction.Vertical.A.Top.Hover.BgColor = "#002BB8";
- this.Direction.Vertical.A.Top.Hover.Addition = "";
- this.Direction.Vertical.A.Top.Visited = {}
- this.Direction.Vertical.A.Top.Visited.Paddding = "2px 0px 2px 2px";
- this.Direction.Vertical.A.Top.Visited.Addition = "";
- this.Direction.Vertical.A.SubItem = {}
- this.Direction.Vertical.A.SubItem.Link = {}
- this.Direction.Vertical.A.SubItem.Link.Color = "gray";
- this.Direction.Vertical.A.SubItem.Link.WhiteSpace = "nowrap";
- this.Direction.Vertical.A.SubItem.Link.Overflow = "hidden";
- this.Direction.Vertical.A.SubItem.Link.Addition = "";
- this.Direction.Vertical.A.SubItem.Hover = {}
- this.Direction.Vertical.A.SubItem.Hover.Color = "white";
- this.Direction.Vertical.A.SubItem.Hover.BgColor = "blue";
- this.Direction.Vertical.A.SubItem.Hover.Addition = "";
- this.Direction.Vertical.A.SubItem.Visited = {}
- this.Direction.Vertical.A.SubItem.Visited.Color = "gainsboro";
- this.Direction.Vertical.A.SubItem.Visited.BgColor = "whitesmoke";
- this.Direction.Vertical.A.SubItem.Visited.Padding = "2px";
- this.Direction.Vertical.A.SubItem.Visited.WhiteSpace = "nowrap";
- this.Direction.Vertical.A.SubItem.Visited.Overflow = "hidden";
- this.Direction.Vertical.A.SubItem.Visited.Addition = "";
- this.Direction.Vertical.Item = {}
- this.Direction.Vertical.Item.Overflow = "visible";
- this.Direction.Vertical.Item.Border = "0px";
- this.Direction.Vertical.Item.BottomStyle = "1px solid black";
- this.Direction.Vertical.Item.Addition = "";
- // end Direction Vertical css style definition
- // begin Direction Horizontal css style definition
- this.Direction.Horizontal = {}
- this.Direction.Horizontal.Bool = false;
- this.Direction.Horizontal.Main = {}
- this.Direction.Horizontal.Main.Float = "left";
- this.Direction.Horizontal.Main.Width = "99.5%";
- this.Direction.Horizontal.A = {}
- this.Direction.Horizontal.A.Top ={}
- this.Direction.Horizontal.A.Top.Link = {};
- this.Direction.Horizontal.A.Top.Link.Color = "black";
- this.Direction.Horizontal.A.Top.Link.Padding = "2px 5px";
- this.Direction.Horizontal.A.Top.Link.Addition = "";
- this.Direction.Horizontal.A.Top.Hover = {}
- this.Direction.Horizontal.A.Top.Hover.Color = "#fff";
- this.Direction.Horizontal.A.Top.Hover.BgColor = "#002BB8";
- this.Direction.Horizontal.A.Top.Hover.Addition = "";
- this.Direction.Horizontal.A.Top.Visited = {}
- this.Direction.Horizontal.A.Top.Visited.Paddding = "2px 5px";
- this.Direction.Horizontal.A.Top.Visited.Addition = "";
- this.Direction.Horizontal.A.SubItem = {}
- this.Direction.Horizontal.A.SubItem.Link = {}
- this.Direction.Horizontal.A.SubItem.Link.Color = "gray";
- this.Direction.Horizontal.A.SubItem.Link.WhiteSpace = "nowrap";
- this.Direction.Horizontal.A.SubItem.Link.BorderLeft = "4px solid whitesmoke";
- this.Direction.Horizontal.A.SubItem.Link.Overflow = "hidden";
- this.Direction.Horizontal.A.SubItem.Link.Addition = "";
- this.Direction.Horizontal.A.SubItem.Hover = {}
- this.Direction.Horizontal.A.SubItem.Hover.Color = "white";
- this.Direction.Horizontal.A.SubItem.Hover.BgColor = "blue";
- this.Direction.Horizontal.A.SubItem.Hover.Addition = "";
- this.Direction.Horizontal.A.SubItem.Visited = {}
- this.Direction.Horizontal.A.SubItem.Visited.Color = "gainsboro";
- this.Direction.Horizontal.A.SubItem.Visited.BgColor = "whitesmoke";
- this.Direction.Horizontal.A.SubItem.Visited.Padding = "2px";
- this.Direction.Horizontal.A.SubItem.Visited.WhiteSpace = "nowrap";
- this.Direction.Horizontal.A.SubItem.Visited.BorderLeft = "4px solid whitesmoke";
- this.Direction.Horizontal.A.SubItem.Visited.Overflow = "hidden";
- this.Direction.Horizontal.A.SubItem.Visited.Addition = "";
- this.Direction.Horizontal.Item = {}
- this.Direction.Horizontal.Item.Overflow = "visible";
- this.Direction.Horizontal.Item.Border = "0px";
- this.Direction.Horizontal.Item.BottomStyle = "1px solid black";
- this.Direction.Horizontal.Item.BgColor = "whitesmoke";
- this.Direction.Horizontal.Item.Addition = "";
- this.Direction.Horizontal.Item.A = {}
- this.Direction.Horizontal.Item.A.Color = "";
- this.Direction.Horizontal.Item.A.BgColor = "whitesmoke";
- this.Direction.Horizontal.Item.A.Margin = "0px 0px 1px 0px";
- this.Direction.Horizontal.Item.A.Padding = "1px 0px";
- this.Direction.Horizontal.Item.A.BorderBottom = "1px solid black";
- this.Direction.Horizontal.Item.A.Addition = "";
- // end Direction Horizontal css style definition
- //------------------------------------end public variable
- //------------------------------------begin private variable
- var Tl = this;
- var pMain = null;
- var pStyleId = "";
- var pLocationSearch = "";
- //------------------------------------end private variable
- //------------------------------------begin public method
- this.Go = fGo;
- //------------------------------------end public method
- //------------------------------------begin private method
- function fGo()
- {
- if(Tl.String=="")
- {
- alert("菜单字串为空!");
- return;
- }
- Tl.String = fEncode(Tl.String);
- pMain = document.getElementById(Tl.Main.ID);
- if(pMain==null)
- {
- alert("菜单主域为空!");
- return;
- }
- pLocationSearch = location.search;
- // appending css style
- fAppendDirectionCss();
- pStyleId = Tl.Main.ID+Tl.Style.ID;
- pMain.innerHTML = "";
- var EleMenuMain = document.createElement("span");
- EleMenuMain.className = pMain.id+Tl.Class.MenuMain;
- fPutNodeInOther(pMain, EleMenuMain);
- pMain.style.zIndex = 9999;
- //pMain.style.width = Tl.Direction.Horizontal.Main.Width;
- var aColumn = Tl.String.split(Tl.Symbol.Column);
- var TotalItem = aColumn.length;
- var aTopLevel = [];
- var reGetTopLevel = new RegExp("^(.*?)"+Tl.Symbol.Item+"(.*?)"+Tl.Symbol.Item, "i");
- var iAColumnLen=aColumn.length;
- var iAColumnCount = 0;
- var iAddEle = 0;
- while(iAColumnCount++<iAColumnLen)
- {
- aColumn[iAColumnCount-1].replace
- (
- reGetTopLevel
- ,
- function($1, $2, $3)
- {
- aTopLevel[iAddEle++] = $2+Tl.Symbol.Item+$3;
- }
- );
- } // end while(aColumn[iAColumn++])
- aTopLevel = fClearArrayRepeats(aTopLevel);
- var iATopLevel = 0;
- var iATopLevelLength = aTopLevel.length;
- var iATopLevelCount = 0;
- while(iATopLevel++<iATopLevelLength)
- {
- var Items = aTopLevel[iATopLevelCount].split(Tl.Symbol.Item);
- if(Items.length!=2)continue;
- var EleSpanTop = document.createElement("span");
- EleSpanTop["title"] = Items[1];
- EleSpanTop.className = Tl.Main.ID+Tl.Level.ClassNamePrefix+1;
- var EleA = document.createElement("a");
- EleA.innerHTML = fDecode(Items[1]);
- if(Tl.Link.Set.length>0)
- {
- if(Tl.Link.Set[0]["Link"]!=null)
- {
- EleA.href = Tl.Link.Set[0]["Link"]+Items[0];
- fHighlightCurrentCat(EleA, Tl.Link.Set[0]["Link"], Items[0]);
- }
- }
- EleSpanTop.appendChild(EleA);
- // recursive sub menu
- fGetSubMenu(aTopLevel[iATopLevelCount], EleSpanTop, Items[0], 1, [Items[0]]);
- if(!Tl.Direction.Vertical.Bool)
- {
- EleSpanTop.onmouseover =
- function()
- {
- if(this.childNodes.length<2) return;
- var Span = this.childNodes[1];
- if(fCkBrs()==1)
- {
- var MyParent = Span.parentNode;
- var MyTop = fFindPos(MyParent, true)+MyParent.offsetHeight;
- var MyLeft = fFindPos(MyParent);
- Span.style.top = MyTop;
- Span.style.left = MyLeft;
- }
- Span.className = Tl.Class.Display;
- } // end EleSpanTop.onmouseover
- }
- else
- {
- EleSpanTop.onmouseover =
- function()
- {
- if(this.childNodes.length<2) return;
- var Span = this.childNodes[1];
- if(true)//fCkBrs()==1
- {
- var MyParent = Span.parentNode;
- var MyTop = fFindPos(MyParent, true)+MyParent.offsetHeight;
- var MyLeft = fFindPos(MyParent);
- Span.style.top = fFindPos(MyParent,true)+"px";
- Span.style.left = fFindPos(MyParent)+MyParent.offsetWidth+"px";
- }
- Span.className = Tl.Class.Display;
- } // end EleSpanTop.onmouseover
- } // end if(Tl.Direction.Vertical.Bool)
- EleSpanTop.onmouseout =
- function()
- {
- if(this.childNodes.length<2) return;
- var Span = this.childNodes[1];
- Span.className = Tl.Class.Hidden;
- } // end EleSpanTop.onmouseout
- pMain.appendChild(EleSpanTop);
- iATopLevelCount++;
- // break;
- } // end while((iATopLevel++)<iATopLevelLength)
- if(Tl.ClearFloat&&Tl.Direction.Horizontal.Bool)
- {
- var EleBr = document.createElement("br");
- EleBr.style.clear = "both";
- pMain.appendChild(EleBr);
- }
- try{ onunload = null;}catch(e){}
- onunload = function()
- {
- fFixMemoryLeak();
- };
- } // end function fGo
- function fGetSubMenu(sPrefix, Ele, sParam, iIndex, aInheritParam)
- {
- var iNextIndex = iIndex+1;
- var aInheritParamNext = fCopyStringArray(aInheritParam);
- var ReGetItem =
- new RegExp
- (
- sPrefix+Tl.Symbol.Item
- +"(.*?)"+Tl.Symbol.Item
- +"(.*?)("+Tl.Symbol.Item+"|"+Tl.Symbol.Column+")"
- ,
- "gi"
- );
- var ItemSet = [];
- var ItemSetCount = 0;
- Tl.String.replace
- (
- ReGetItem,
- function($1,$2,$3)
- {
- if(($2+$3).indexOf(Tl.Symbol.Column)>-1)return;
- ItemSet[ItemSetCount++] = $2+Tl.Symbol.Item+$3;
- }
- );
- var ItemSetLen = ItemSet.length;
- if(ItemSetLen<1) return;
- ItemSet = fClearArrayRepeats(ItemSet);
- var EleSpan = document.createElement("span");
- EleSpan.className = Tl.Class.Hidden;
- var iItemSetLen = ItemSet.length;
- var iItemSetCount = 0;
- var iAppendItemCount = 0;
- while(iItemSetCount++<iItemSetLen)
- {
- var iItemSetCurIndex = iItemSetCount - 1;
- var MyPrefix = sPrefix+Tl.Symbol.Item+ItemSet[iItemSetCurIndex];
- if(MyPrefix.indexOf(Tl.Symbol.Column)>-1)return;
- var Items = ItemSet[iItemSetCurIndex].split(Tl.Symbol.Item);
- if(Items.length!=2)continue;
- if(Items[0]==""||Items[1]=="")continue;
- iAppendItemCount++;
- aInheritParamNext[iIndex] = Items[0];
- var EleA = document.createElement("a");
- EleA.innerHTML = fDecode(Items[1]);
- if(Tl.Link.Set.length>=iNextIndex)
- {
- if(Tl.Link.Set[iIndex]["Link"]!=null)
- {
- var sLinkPrefix = "";
- if(Tl.Link.Set[iIndex]["Inherit"])
- {
- var iaInheritParamNextLen = aInheritParamNext.length;
- var iaInheritParamNextCount = 0;
- while(iaInheritParamNextCount++<iaInheritParamNextLen)
- {
- if(Tl.Link.Set[iaInheritParamNextCount-1]["Link"]!=null)
- {
- sLinkPrefix +=
- Tl.Link.Set[iaInheritParamNextCount-1]["Link"]
- +aInheritParamNext[iaInheritParamNextCount-1];
- }
- } // end while(iaInheritParamNextCount++<iaInheritParamNextLen)
- }
- else
- {
- sLinkPrefix =
- Tl.Link.Set[iIndex]["Link"]
- +aInheritParamNext[aInheritParamNext.length-1];
- } // end if
- fHighlightCurrentCat(EleA, Tl.Link.Set[iIndex]["Link"], Items[0]);
- EleA.href = sLinkPrefix;
- } // end if 1
- } // end if
- var EleSpanContainer = document.createElement("span");
- EleSpanContainer.className = Tl.Main.ID+"EleSpanContainer";
- EleSpanContainer.onmouseover =
- function(e)
- {
- if(!e) e = window.event;
- var Parent = this.parentNode;
- var ChildLen = this.childNodes.length;
- if(ChildLen<1)return;
- var EleA = this.childNodes[0];
- var iChildLen= 0 ;
- var iChildLenCount = 0;
- while(iChildLen++<ChildLen)
- {
- if(this.childNodes[iChildLenCount].nodeName=="SPAN")
- {
- this.childNodes[iChildLenCount].className = Tl.Class.Display;
- this.childNodes[iChildLenCount].style.left =
- Tl.Direction.Style.Width+Tl.Direction.Style.PlusLeft+"px";
- this.childNodes[iChildLenCount].onmouseout =
- function()
- {
- this.className = Tl.Class.Hidden;
- }
- }
- iChildLenCount++;
- } // end while(iChildLen++<ChildLen)
- } // end EleSpanContainer.onmouseover
- EleSpanContainer.onmouseout =
- function(e)
- {
- var ChildLen = this.childNodes.length;
- var iChildLen = 0;
- while(iChildLen++<ChildLen)
- {
- if(this.childNodes[iChildLen-1].nodeName=="SPAN")
- {
- this.childNodes[iChildLen-1].className = Tl.Class.Hidden;
- }
- } // end while(iChildLen++<ChildLen)
- } // end EleSpanContainer.onmouseout
- arguments.callee
- (
- MyPrefix,
- EleSpanContainer,
- Items[0],
- iNextIndex,
- fCopyStringArray(aInheritParamNext)
- );
- EleSpanContainer.appendChild(EleA);
- EleSpanContainer["title"] = Items[1];
- EleSpanContainer.className = Tl.Main.ID+Tl.Level.ClassNamePrefix+iNextIndex;
- EleSpan.appendChild(EleSpanContainer);
- } // end while(iItemSetCount++<iItemSetLen)
- // append addition item
- if(Tl.Addition.AppendSubLink.Bool&&Tl.Addition.AppendSubLink.Set.length>0)
- {
- var aInheritParamLen = aInheritParam.length;
- var aInheritParamCount = 0;
- var iLinkSetLenTemp = Tl.Link.Set.length;
- if(iLinkSetLenTemp>aInheritParamLen) iLinkSetLenTemp = aInheritParamLen+1;
- var sLinkPrefix = "";
- while(aInheritParamCount++<iLinkSetLenTemp)
- {
- var aInheritParamCurIndex = aInheritParamCount-1;
- if(Tl.Link.Set[aInheritParamCurIndex]!=null)
- {
- sLinkPrefix +=Tl.Link.Set[aInheritParamCurIndex]["Link"]
- +(aInheritParam[aInheritParamCurIndex]||"");
- }
- } // end while
- var iSubLinkLength = Tl.Addition.AppendSubLink.Set.length;
- var iSubLinkCount = 0;
- while(iSubLinkCount++<iSubLinkLength)
- {
- if(Tl.Addition.AppendSubLink.Set[iSubLinkCount-1].length!=2)continue;
- var MyEleA = document.createElement("a");
- var MyEleAHref = sLinkPrefix+Tl.Addition.AppendSubLink.Set[iSubLinkCount-1][0];
- MyEleA.href= MyEleAHref;
- MyEleA.innerHTML = Tl.Addition.AppendSubLink.Set[iSubLinkCount-1][1];
- var EleSpanTemp = document.createElement("span");
- // EleSpanTemp.className = Tl.Class.Display;
- EleSpanTemp.appendChild(MyEleA);
- var sComp1 = pLocationSearch.replace(/^.*?/?/, "");
- var sComp2 = MyEleAHref.replace(/^.*?/?/, "");
- if(sComp1==sComp2)
- {
- var aComp = sComp1.split("&");
- var EleAAddiQuery = aComp[aComp.length-1].split("=")[0];
- var iHighlightLen = Tl.Query.Highlight.Set.length;
- var iHighlightCount = 0;
- while(iHighlightCount++<iHighlightLen)
- {
- if(Tl.Query.Highlight.Set[iHighlightCount-1][0]==EleAAddiQuery)
- {
- MyEleA.style.backgroundColor = Tl.Query.Highlight.Set[iHighlightCount-1][1];
- MyEleA.style.color = Tl.Query.Highlight.Set[iHighlightCount-1][2];
- break;
- }
- } // end while
- } // end if(sComp1==sComp2)
- EleSpan.appendChild(EleSpanTemp);
- iAppendItemCount = iAppendItemCount+1;
- } // end while(iSubLinkCount++<iSubLinkLength)
- } // end if
- if(iAppendItemCount>0)
- {
- Ele.appendChild(EleSpan);
- }
- } // end function fGetSubMenu
- function fClearArrayRepeats(array, pram)
- {// shawl.qiu script
- var temp = '';
- var mark='$$$###';
- array=array.join(mark);
- var re=new RegExp('.*?'+mark.replace(/(.)/g,'//$1')+'|.*?$','g');
- var re_=new RegExp(mark.replace(/(.)/g,'//$1')+'$');
- array.replace
- (
- re,
- function()
- {
- if(temp.indexOf(arguments[0]) == -1) temp += arguments[0];
- }
- ); // end array.replace
- array=temp.replace(re_,'').split(mark);
- if(!pram)return array;
- return fArOdr(array, pram);
- function fArOdr(array, pram)
- {
- if(!pram)var pram=1;
- switch(pram)
- {
- case 2: return array.reverse();
- case 3: return array.sort(function(a,b){return a-b;});
- case 4: return array.sort(function(a,b){return b-a;});
- default: return array.sort();
- } // end switch
- } // end function fArOdr
- } // function fClearArrayRepeats
- function fFindPos(oEle, bReturnY)
- { // shawl.qiu script
- if(!oEle)
- {
- alert("对象不能为空!");
- return;
- }
- if(bReturnY)
- {
- return fFindPosY(oEle);
- }
- else
- {
- return fFindPosX(oEle);
- }
- function fFindPosX(oEle)
- { // shawl.qiu script
- var iLeft = 0;
- if(oEle.offsetParent)
- {
- while(true)
- {
- iLeft += oEle.offsetLeft;
- if(!oEle.offsetParent)
- {
- break;
- } // end if 1
- oEle = oEle.offsetParent;
- } // end while
- }
- else if(oEle.x)
- {
- iLeft += oEle.x;
- }
- return iLeft;
- } // end function fFindPosX
- function fFindPosY(oEle)
- { // shawl.qiu script
- var iTop = 0;
- if(oEle.offsetParent)
- {
- while(true)
- {
- iTop += oEle.offsetTop;
- if(!oEle.offsetParent)
- {
- break;
- } // end if 1
- oEle = oEle.offsetParent;
- } // end while
- }
- else if(oEle.y)
- {
- iTop += oEle.y;
- }
- return iTop;
- } // end function fFindPosX
- } // end function fFindPos
- function fAddLink(sLink, bInherit)
- {
- if(!bInherit) bInherit = false;
- var iIndex = Tl.Link.Set.length;
- Tl.Link.Set[iIndex] = {};
- Tl.Link.Set[iIndex]["Link"] = sLink;
- Tl.Link.Set[iIndex]["Inherit"] = bInherit;
- } // end function fAddLink
- function fInsertNode(OldNode, NewNode, bBefore)
- {// shawl.qiu script
- var ParentNode = OldNode.parentNode;
- if(!ParentNode)return false;
- if(bBefore)
- {
- ParentNode.insertBefore(NewNode,OldNode);
- return false;
- } // end if
- ParentNode.replaceChild(NewNode, OldNode);
- ParentNode.insertBefore(OldNode, NewNode);
- } // end function fInsertNode
- function fPutNodeInOther(OldNode, NewNode)
- {// shawl.qiu script
- fInsertNode(OldNode, NewNode, true);
- OldNode.parentNode.removeChild(OldNode);
- NewNode.appendChild(OldNode);
- function fInsertNode(OldNode, NewNode, bBefore)
- {// shawl.qiu script
- var ParentNode = OldNode.parentNode;
- if(!ParentNode)return false;
- if(bBefore)
- {
- ParentNode.insertBefore(NewNode,OldNode);
- return false;
- } // end if
- ParentNode.replaceChild(NewNode, OldNode);
- ParentNode.insertBefore(OldNode, NewNode);
- } // end function fInsertNode
- } // end function fPutNodeInOther
- function fCkBrs()
- {// shawl.qiu script
- switch (navigator.appName)
- {
- case 'Opera': return 2;
- case 'Netscape': return 3;
- default: return 1;
- }
- } // end function fCkBrs
- function fEncode(sIpt)
- {
- return sIpt.
- replace(//+/g, "XXXXXPlus")
- ;
- }
- function fDecode(sIpt)
- {
- return sIpt.
- replace(/XXXXXPlus/g, "+")
- ;
- }
- function fAddLinkhighlight(sQuery, sBgColor, sFgColor)
- {
- if(!sQuery||!sBgColor||!sFgColor) return;
- var iIndex = Tl.Query.Highlight.Set.length;
- Tl.Query.Highlight.Set[iIndex] = [];
- Tl.Query.Highlight.Set[iIndex][0] = sQuery;
- Tl.Query.Highlight.Set[iIndex][1] = sBgColor;
- Tl.Query.Highlight.Set[iIndex][2] = sFgColor;
- } // end function fAddLinkhighlight
- function fFixMemoryLeak(oEle)
- {// shawl.qiu script
- if(!oEle)oEle=document.body;
- var AtrSet=oEle.attributes;
- if(AtrSet)
- {
- var AtrLen = AtrSet.length;
- var iAtrLen = 0;
- while(iAtrLen++<AtrLen)
- {
- if(typeof oEle[AtrSet[iAtrLen-1].name]=='function')
- {
- oEle[AtrSet[iAtrLen-1].name]=null;
- }
- } // end while(iAtrLen++<AtrLen)
- } // end if(AtrSet)
- if(oEle.childNodes)
- {
- var ChildLen = oEle.childNodes.length;
- var iChildLen = 0;
- while(iChildLen++<ChildLen)
- {
- arguments.callee(oEle.childNodes[iChildLen-1]);
- } // end while(iChildLen++<ChildLen)
- } // end if(oEle.childNodes)
- } // end function fFixMemoryLeak
- function fQueryString(sKey, bDecode, bDebug)
- {
- var Debug = bDebug;
- if(!sKey)
- {
- return location.search;
- }
- var sTemp = location.search.replace(/^/?/,"");
- if(Debug)
- {
- alert(sTemp);
- }
- if(sTemp=="")
- {
- alert("页面 Url 没有查询参数!");
- return false;
- }
- var ar = sTemp.split("&");
- var sFinal = "";
- var iArLen = ar.length;
- var iArCount = 0;
- while(iArCount++<iArLen)
- {
- if(Debug)
- {
- alert("ar[iArCount-1].toLowerCase(): "+ar[iArCount-1].toLowerCase());
- alert("sKey.toLowerCase()+'=': "+sKey.toLowerCase());
- }
- var arQsByPart = ar[iArCount-1].split("=");
- if(arQsByPart[0].toLowerCase()==sKey.toLowerCase())
- {
- if(arQsByPart.length==1) continue;
- sFinal = arQsByPart[1];
- if(bDecode)
- {
- sFinal = decodeURI(sFinal);
- }
- break;
- }
- } // end while(iArCount++iArLen)
- if(sFinal=="")
- {
- alert("没有键为 "+sKey+" 的查询参数!");
- }
- return sFinal;
- } // end function fQueryString
- function fHighlightCurrentCat(EleA, sLinkSetLinkStr, sParam)
- {
- var LocationSearch = location.search;
- if(LocationSearch==""&&LocationSearch.replace("?", "")=="")return;
- var iSetLen = Tl.Query.Highlight.Set.length;
- var iSetCount = 0;
- while(iSetCount++<iSetLen)
- {
- var QSet = Tl.Query.Highlight.Set[iSetCount-1];
- var sQuery = QSet[0];
- var MyHighRe = new RegExp("//b"+sQuery+"//b", "i")
- if(MyHighRe.test(LocationSearch)&&MyHighRe.test(sLinkSetLinkStr))
- {
- var sQueryValue = fQueryString(sQuery, true);
- if(sParam==sQueryValue)
- {
- EleA.style.backgroundColor = QSet[1];
- EleA.style.color = QSet[2];
- break;
- } // end if 1
- } // end if
- } // end while(iSetCount++<iSetLen)
- } // end function fHighlightCurrentCat
- function fAddStyleFromStr(sIpt, sId)
- {// shawl.qiu script
- var EleStyle = document.createElement("style");
- EleStyle.type = "text/css";
- if(sId&&sId!="")
- {
- EleStyle.id = sId;
- }
- if(fCkBrs()==1)
- {
- EleStyle.styleSheet.cssText = sIpt;
- }
- else
- {
- EleStyle.innerHTML = sIpt;
- }
- function fCkBrs()
- {
- switch (navigator.appName)
- {
- case 'Opera': return 2;
- case 'Netscape': return 3;
- default: return 1;
- }
- } // end function fCkBrs
- var EleHead=document.getElementsByTagName("head")[0]
- if(!EleHead) EleHead=document.body;
- EleHead.insertBefore(EleStyle, EleHead.firstChild);
- } // end function fAddStyleFromStr
- function fAppendSubLink(sId, sCat)
- {
- if(typeof(sId)!="string"||!sCat)return;
- if(sId===""||sCat==="")return;
- var iIndex = Tl.Addition.AppendSubLink.Set.length;
- Tl.Addition.AppendSubLink.Set[iIndex] = [];
- Tl.Addition.AppendSubLink.Set[iIndex][0] = sId;
- Tl.Addition.AppendSubLink.Set[iIndex][1] = sCat;
- } // end function fAppendSubLink
- function fAppendDirectionCss()
- {
- var sMenuStyle = "";
- var sId = Tl.Main.ID+Tl.Style.ID;
- if(!Tl.Direction.Vertical.Bool)
- {
- sMenuStyle =
- "."+Tl.Main.ID+Tl.Class.MenuMain
- +"{"
- +" display:block;"
- +" padding:"+Tl.Direction.Style.Padding+";"
- +" background-color:"+Tl.Direction.Style.BgColor+";"
- + "width:"+Tl.Direction.Horizontal.Main.Width+";"
- //+" width:"+Tl.Direction.Horizontal.Main.Width+";";
- +"}"
- +""
- +"#"+Tl.Main.ID+" span"
- +"{"
- +" float:"+Tl.Direction.Horizontal.Main.Float+";"
- +"}"
- +""
- +"#"+Tl.Main.ID+" span a:link"
- +"{"
- +" padding:"+Tl.Direction.Horizontal.A.Top.Link.Padding+";"
- +Tl.Direction.Horizontal.A.Top.Link.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span a:hover"
- +"{"
- +" background-color:"+Tl.Direction.Horizontal.A.Top.Hover.BgColor+";"
- +" color:"+Tl.Direction.Horizontal.A.Top.Hover.Color+"!important;"
- +Tl.Direction.Horizontal.A.Top.Hover.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span a:visited"
- +"{"
- +" padding:"+Tl.Direction.Horizontal.A.Top.Visited.Paddding+";"
- +Tl.Direction.Horizontal.A.Top.Visited.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span span * a:link"
- +"{"
- +" display:block;"
- +" overflow:"+Tl.Direction.Horizontal.A.SubItem.Link.Overflow+";"
- +" width:"+Tl.Direction.Style.Width+"px;"
- +" white-space:"+Tl.Direction.Horizontal.A.SubItem.Link.WhiteSpace+";"
- +" color:"+Tl.Direction.Horizontal.A.SubItem.Link.Color+";"
- +" border-left:"+Tl.Direction.Horizontal.A.SubItem.Link.BorderLeft+";"
- +Tl.Direction.Horizontal.A.SubItem.Link.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span span * a:hover"
- +"{"
- +" background-color: "+Tl.Direction.Horizontal.A.SubItem.Hover.BgColor+";"
- +" color:"+Tl.Direction.Horizontal.A.SubItem.Hover.Color+"!important;"
- +Tl.Direction.Horizontal.A.SubItem.Hover.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span span * a:visited"
- +"{"
- +" display:block;"
- +" width:"+Tl.Direction.Style.Width+"px;"
- +" overflow:"+Tl.Direction.Horizontal.A.SubItem.Visited.Overflow+";"
- +" white-space:"+Tl.Direction.Horizontal.A.SubItem.Visited.WhiteSpace+";"
- +" background:"+Tl.Direction.Horizontal.A.SubItem.Visited.BgColor+";"
- +" color:"+Tl.Direction.Horizontal.A.SubItem.Visited.Color+"!important;"
- +" border-left:"+Tl.Direction.Horizontal.A.SubItem.Visited.BorderLeft+";"
- +Tl.Direction.Horizontal.A.SubItem.Visited.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" * span.sqMenuDisplaySubItem"
- +"{"
- +" display:block;"
- +" position:absolute;"
- +" width:"+Tl.Direction.Style.Width+"px;"
- +" overflow:"+Tl.Direction.Horizontal.Item.Overflow+";"
- +" background-color: "+Tl.Direction.Horizontal.Item.BgColor+";"
- +Tl.Direction.Horizontal.Item.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" * span.sqMenuDisplaySubItem a"
- +"{"
- +" display:block;"
- +" background-color:"+Tl.Direction.Horizontal.Item.A.BgColor+";"
- +" margin:"+Tl.Direction.Horizontal.Item.A.Margin+";"
- +" padding:"+Tl.Direction.Horizontal.Item.A.Padding+";"
- +" border-bottom:"+Tl.Direction.Horizontal.Item.A.BorderBottom+";"
- +Tl.Direction.Horizontal.Item.A.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" * span.sqMenuHiddenSubItem"
- +"{"
- +" display:none;"
- +"}"
- ;
- }
- else
- {
- sMenuStyle =
- "."+Tl.Main.ID+Tl.Class.MenuMain
- +"{"
- +" width:"+Tl.Direction.Style.Width+"px;"
- +" display:block;"
- +"}"
- +""
- +"#"+Tl.Main.ID+" span"
- +"{"
- +" display:block;"
- +" border-bottom:"+Tl.Direction.Vertical.Item.BottomStyle+";"
- +" background-color:"+Tl.Direction.Style.BgColor+";"
- +"}"
- +""
- +"#"+Tl.Main.ID+" span a:link"
- +"{"
- +" display:block;"
- +" padding:"+Tl.Direction.Vertical.A.Top.Link.Padding+";"
- +" color:"+Tl.Direction.Vertical.A.Top.Link.Color+";"
- +" width:"+Tl.Direction.Style.Width+"px;"
- +Tl.Direction.Vertical.A.Top.Link.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span a:hover"
- +"{"
- +" background-color:"+Tl.Direction.Vertical.A.Top.Hover.BgColor+";"
- +" color:"+Tl.Direction.Vertical.A.Top.Hover.Color+"!important;"
- +Tl.Direction.Vertical.A.Top.Hover.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span a:visited"
- +"{"
- +" padding:"+Tl.Direction.Vertical.A.Top.Visited+";"
- +" display:block;"
- +" width:"+Tl.Direction.Style.Width+"px;"
- +Tl.Direction.Vertical.A.Top.Visited.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span span * a:link"
- +"{"
- +" display:block;"
- +" width:"+Tl.Direction.Style.Width+"px;"
- +" color:"+Tl.Direction.Vertical.A.SubItem.Link.Color+";"
- +" white-space:"+Tl.Direction.Vertical.A.SubItem.Link.WhiteSpace+";"
- +" overflow:"+Tl.Direction.Vertical.A.SubItem.Link.Overflow+";"
- +Tl.Direction.Vertical.A.SubItem.Link.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span span * a:hover"
- +"{"
- +" background-color:"+Tl.Direction.Vertical.A.SubItem.Hover.BgColor+"!important;"
- +" color:"+Tl.Direction.Vertical.A.SubItem.Hover.Color+"!important;"
- +Tl.Direction.Vertical.A.SubItem.Hover.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" span span * a:visited"
- +"{"
- +" display:block;"
- +" width:"+Tl.Direction.Style.Width+"px;"
- +" white-space:"+Tl.Direction.Vertical.A.SubItem.Visited.WhiteSpace+";"
- +" overflow:"+Tl.Direction.Vertical.A.SubItem.Visited.WhiteSpace+";"
- +" background:"+Tl.Direction.Vertical.A.SubItem.Visited.Overflow+";"
- +" color:"+Tl.Direction.Vertical.A.SubItem.Visited.Color+"!important;"
- +" padding:"+Tl.Direction.Vertical.A.SubItem.Visited.Padding+";"
- +Tl.Direction.Vertical.A.SubItem.Visited.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" * span.sqMenuDisplaySubItem"
- +"{"
- +" display:block;"
- +" position:absolute;"
- +" width:"+Tl.Direction.Style.Width+"px;"
- +" overflow:"+Tl.Direction.Vertical.Item.Overflow+";"
- +" border:"+Tl.Direction.Vertical.Item.Border+";"
- +Tl.Direction.Vertical.Item.Addition
- +"}"
- +""
- +"#"+Tl.Main.ID+" * span.sqMenuDisplaySubItem a"
- +"{"
- +" display:block;"
- +" background:"+Tl.Direction.Style.BgColor+";"
- +"}"
- +""
- +"#"+Tl.Main.ID+" * span.sqMenuHiddenSubItem"
- +"{"
- +" display:none;"
- +"}"
- ;
- }
- fAddStyleFromStr(sMenuStyle, sId);
- } // end function fAppendDirectionCss
- function fCopyStringArray(ar)
- {
- var sDelimiter = "x*&*sdfj;li()*009lkk7O*U(*&89";
- var sAr = ar.join(sDelimiter);
- return sAr.split(sDelimiter);
- }
- //------------------------------------end private method
- } // shawl.qiu code
- //---------------------------------end class Menu()---------------------------------//
- var menu = new Menu();