倾听王菲网站关闭的通知
作者:青锋幽灵 日期:2008-11-29 15:31
通用获取父节点/子节点/子节点下所有节点ID的存储过程
作者:青锋幽灵 日期:2008-12-26 13:34
SQL代码
- --====================================/=======================================
- --Powered By CMSDream Copyright © 2007-2008 All rights reserved.
- --13:32 2008-12-26
- --通用获取父节点/子节点/子节点下所有节点ID的存储过程
- --====================================/=======================================
- create proc [dbo].[cmsdream_SP_Navigate](
- @Type varchar(20), -- parent/sub/all
- @TableName varchar(50), --表名
- @PrimaryField varchar(50), --数据表的主ID字段
- @ParentField varchar(50), --数据表中的父ID字段
- @CurrentID int, --表中当前主ID
- @OutputField varchar(1000) = '',
- @OrderField varchar(50) = ''
- )AS
- begin
- if @CurrentID <= 0 return
- set @Type = lower(@Type)
- if @OutputField = '' set @OutputField = '*'
- declare @sql nvarchar(4000)
- declare @IDList nvarchar(2000)
- if @Type = 'all'
- begin
- set @IDList = cast(@CurrentID As nvarchar(12))
- declare @IDTemp1 nvarchar(2000) set @IDTemp1 = @IDList
- declare @IDTemp2 nvarchar(2000) set @IDTemp2 = ''
- declare @SubCount int set @SubCount = 1
- while @SubCount > 0
- begin
- set @IDTemp2 = ''
- if len(@IDTemp1) > 0
- begin
- set @sql = 'select @IDTemp2 = @IDTemp2 + '','' + cast([' + @PrimaryField + '] As nvarchar(12)) from ' + @TableName + ' where [' + @ParentField + '] IN (' + @IDTemp1 + ')'
- exec sp_executesql @sql,N'@IDTemp2 nvarchar(2000) output',@IDTemp2 output
- end
- if len(@IDTemp2) > 1
- begin
- set @IDTemp2 = substring(@IDTemp2,2,len(@IDTemp2)-1)
- set @IDList = @IDList + ',' + @IDTemp2
- end
- set @IDTemp1 = @IDTemp2
- set @SubCount = 0
- if len(@IDTemp2) > 1
- begin
- set @sql = 'select @SubCount = count(*) from ' + @TableName + ' where [' + @ParentField + '] IN (0' + @IDTemp2 + ')'
- exec sp_executesql @sql,N'@SubCount int output',@SubCount output
- end
- end
- if @OrderField = ''
- exec('select ' + @OutputField + ' from ' + @TableName + ' where [' + @PrimaryField + '] IN (' + @IDList + ')')
- else
- exec('select ' + @OutputField + ' from ' + @TableName + ' where [' + @PrimaryField + '] IN (' + @IDList + ') Order BY ' + @OrderField)
- end
- if @Type = 'parent'
- begin
- set @IDList = cast(@CurrentID As nvarchar(12)) + ','
- declare @ParentID int set @ParentID = 0
- set @sql = 'select @ParentID = [' + @ParentField + '] from ' + @TableName + ' where [' + @PrimaryField + '] = ' + cast(@CurrentID As nvarchar(12))
- exec sp_executesql @sql,N'@ParentID int output',@ParentID output
- while @ParentID > 0
- begin
- set @IDList = @IDList + cast(@ParentID As nvarchar(12)) + ','
- set @sql = 'select @ParentID = [' + @ParentField + '] from ' + @TableName + ' where [' + @PrimaryField + '] = ' + cast(@ParentID As nvarchar(12))
- exec sp_executesql @sql,N'@ParentID int output',@ParentID output
- end
- set @IDList = substring(@IDList,1,len(@IDList)-1)
- if @OrderField = ''
- exec('select ' + @OutputField + ' from ' + @TableName + ' where [' + @PrimaryField + '] IN (' + @IDList + ')')
- else
- exec('select ' + @OutputField + ' from ' + @TableName + ' where [' + @PrimaryField + '] IN (' + @IDList + ') Order BY ' + @OrderField)
- end
- if @Type = 'sub'
- begin
- if @OrderField = ''
- exec('select ' + @OutputField + ' from ' + @TableName + ' where [' + @ParentField + '] = ' + @CurrentID + ' OR [' + @PrimaryField + '] = ' + @CurrentID)
- else
- exec('select ' + @OutputField + ' from ' + @TableName + ' where [' + @ParentField + '] = ' + @CurrentID + ' OR [' + @PrimaryField + '] = ' + @CurrentID + ' Order BY ' + @OrderField)
- end
- end
- /*
- --测试
- exec cmsdream_SP_Navigate 'parent','cmsdream_Nodes','NodeID','ParentID',116,'NodeID,Name','NavSort Desc'
- exec cmsdream_SP_Navigate 'sub','cmsdream_Nodes','NodeID','ParentID',76,'NodeID,Name'
- exec cmsdream_SP_Navigate 'all','cmsdream_Nodes','NodeID','ParentID',4,'NodeID,Name'
- */
【效果】精辟的抖动效果
作者:青锋幽灵 日期:2008-12-02 10:53
XML/HTML代码
- <img id="win" style='position:relative' src="http://ghost.cmsdream.com/samples/quake/img.jpg"><br /><br />
- <button onclick="quake()">振动</button>
- <script type="text/javascript">
- var a=['top','left'],b=0;
- function quake(u){
- u=setInterval(function(){
- document.getElementById('win').style[a[b%2]]=(b++)%4<2?0:4;
- if(b>15){clearInterval(u);b=0}
- },32);
- }
- </script>
完美js模拟网页对话框效果(可拖曳)
作者:青锋幽灵 日期:2008-10-23 10:51
JavaScript代码
- /**
- Powered By CMSDream Copyright © 2007-2008 All rights reserved.
- 23:25 2008-5-3
- **/
- var msgbox_scripts = document.getElementsByTagName("script");
- msgbox_path = msgbox_path.substring(0, msgbox_path.lastIndexOf('/')+1);
- var CMSMsgBox = function(oWidth, oHeight, oSkin, oTitle){
- this.Id = 'msgbox_'+Math.random().toString().replace('\.', '_');
- /*
- * 位置
- * =================
- * ===== 1 2 3 =====
- * ===== 4 5 6 =====
- * ===== 7 8 9 =====
- * =================
- */
- this.Position = 5;
- this.Skin = oSkin || 'default';
- this.Width = oWidth || 500;
- this.Height = oHeight || 260;
- this.Title = oTitle || 'CMSDream:';
- this.Value = '';
- this.Float = true;
- this.Mask = false;
- this.Drag = true;
- this.Return = false;
- this.BoxDiv = null;
- };
- CMSMsgBox.prototype.show = function(){
- /* 加载样式表 */
- if(!this.$('msgbox_styles')){
- var css = document.createElement('link');
- css.setAttribute('href', msgbox_path + 'msgbox.css');
- css.setAttribute('id', 'msgbox_styles');
- css.setAttribute('rel', 'stylesheet');
- css.setAttribute('type', 'text/css');
- document.getElementsByTagName('head')[0].appendChild(css);
- }
- if(this.$(this.Id))return false;
- this.Return = true;
- this.BoxDiv = this.createDiv(document.body, 'div', 'block', this.Id, 'msgbox_main_div');
- if(this.Mask)this.createMask();
- this.showBox();
- };
- CMSMsgBox.prototype.showBox = function(){
- var self = this;
- var div = new Array();
- div['box'] = this.createDiv(this.BoxDiv, 'div', 'block', this.Id+'bgcolor_div', 'msgbox_box msgbox_box_'+this.Skin);
- if(this.Width)div['box'].style.width = this.Width+'px';
- if(this.Height && this.Skin != 'loading')div['box'].style.height = this.Height+'px';
- div['title'] = this.createDiv(div['box'], 'div', null, null, 'msgbox_title');
- /* =====================================
- * 拖曳效果
- *=====================================**/
- if(this.Drag){
- div['move'] = this.createDiv(this.BoxDiv, 'div', 'none', null, 'msgbox_move_div');
- div['title'].style.cursor = 'move';
- div['title'].onmousedown = function(e){
- var X = document.all ? event.clientX : e.pageX;
- var Y = document.all ? event.clientY : e.pageY;
- var T = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
- var cLeft = div['code'].offsetLeft + div['box'].offsetLeft;
- var cTop = div['code'].offsetTop + div['box'].offsetTop - T;
- if((X > cLeft && X < (cLeft + div['code'].offsetWidth)) && (Y > cTop && Y < (cTop + div['code'].offsetHeight)))
- return;
- this.style.zIndex += 10;
- this.setAttribute('MD', '1');
- this.setAttribute('XCX', parseInt(X - div['box'].offsetLeft).toString());
- this.setAttribute('XCY', parseInt(Y - div['box'].offsetTop).toString());
- div['move'].style.width = parseInt(div['box'].offsetWidth-10) + 'px';
- div['move'].style.height = parseInt(div['box'].offsetHeight - 10) + 'px';
- div['move'].style.left = div['box'].offsetLeft + 'px';
- div['move'].style.top = div['box'].offsetTop + 'px';
- div['move'].style.display = 'block';
- };
- document.onmousemove = function(e){
- if(div['title'].getAttribute('MD')!='1')return;
- var XCX = div['title'].getAttribute('XCX');
- var XCY = div['title'].getAttribute('XCY');
- var X = document.all ? event.clientX : e.pageX;
- var Y = document.all ? event.clientY : e.pageY;
- div['move'].style.left = parseInt(X - XCX) + 'px';
- div['move'].style.top = parseInt(Y - XCY) + 'px';
- };
- document.onmouseup = function(e){
- if(div['title'].getAttribute('MD')!='1')return;
- div['title'].setAttribute('MD', '0');
- div['title'].setAttribute('XCX', '0');
- div['title'].setAttribute('XCY', '0');
- div['box'].style.left = div['move'].offsetLeft + 'px';
- div['box'].style.top = div['move'].offsetTop + 'px';
- if(self.IsObject(div['mask'])){
- div['mask'].style.left = div['move'].offsetLeft + 'px';
- div['mask'].style.top = div['move'].offsetTop + 'px';
- }
- div['move'].style.display = 'none';
- };
- }
- div['span'] = this.createDiv(div['title'], 'span', 'block', this.Id+'_msgTitle');
- div['span'].innerHTML = this.Title;
- /* =====================================
- * 关闭按钮
- *=====================================**/
- div['code'] = this.createDiv(div['title'], 'code', 'block');
- div['code'].setAttribute('title', 'close');
- div['code'].style.position = 'relative';
- div['code'].innerHTML = "close";
- div['code'].onclick = function(){self.close();};
- /* =====================================
- * 文本区域
- *=====================================**/
- div['text'] = this.createDiv(div['box'], 'div', 'block', this.Id+'_msgContent', 'msgbox_content');
- div['value'] = this.createDiv(div['text'], 'div', 'block', this.Id+'_msgValue', 'msgbox_container');
- div['clear'] = this.createDiv(div['text'], 'div', 'block', null, 'msgbox_clear');
- if(this.Height && this.Skin != 'loading'){
- div['value'].style.height = (div['box'].offsetHeight - div['title'].offsetHeight - 16) + 'px';
- div['value'].style.overflowY = 'auto';
- }
- div['value'].innerHTML = this.Value;
- /* =====================================
- * 创建一个iframe档住select
- *=====================================**/
- if(document.all && !this.Mask){
- div['mask'] = this.createDiv(this.BoxDiv, 'iframe', 'block', null, 'msgbox_frame');
- div['mask'].style.width = div['box'].offsetWidth+'px';
- div['mask'].style.height = div['box'].offsetHeight+'px';
- }
- mDiv_Float();
- if(this.Float){
- if(window.addEventListener){
- window.addEventListener('resize', mDiv_Float, false);
- window.addEventListener('scroll', mDiv_Float, false);
- }else{
- window.attachEvent('onresize', mDiv_Float);
- window.attachEvent('onscroll', mDiv_Float);
- }
- }
- /* =====================================
- * 漂浮效果
- *=====================================**/
- function mDiv_Float(){
- var t = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
- var h = document.documentElement.clientHeight ? Math.min(document.documentElement.clientHeight, document.body.clientHeight) : document.body.clientHeight;
- var w = document.documentElement.clientWidth ? document.documentElement.scrollWidth : document.body.scrollWidth;
- switch(self.Position){
- case 1: {var l = 1;var r = t + 1;break;}
- case 2: {var l = parseInt((w/2)-(div['box'].offsetWidth/2));var r = t + 1;break;}
- case 3: {var l = parseInt(w-div['box'].offsetWidth-1);var r = t + 1;break;}
- case 4: {var l = 1;var r = parseInt(t+((h/2)-(div['box'].offsetHeight/2)));break;}
- case 5: {var l = parseInt((w/2)-(div['box'].offsetWidth/2));var r = parseInt(t+((h/2)-(div['box'].offsetHeight/2)));break;}
- case 6: {var l = parseInt(w-div['box'].offsetWidth-1);var r = parseInt(t+((h/2)-(div['box'].offsetHeight/2)));break;}
- case 7: {var l = 1;var r = parseInt(t+(h-div['box'].offsetHeight-1));break;}
- case 8: {var l = parseInt((w/2)-(div['box'].offsetWidth/2));var r = parseInt(t+(h-div['box'].offsetHeight-1));break;}
- case 9: {var l = parseInt(w-div['box'].offsetWidth-1);var r = parseInt(t+(h-div['box'].offsetHeight-1));break;}
- default: {var l = parseInt((w/2)-(div['box'].offsetWidth/2));var r = parseInt(t+((h/2)-(div['box'].offsetHeight/2)));break;}
- }
- div['box'].style.left = l+'px';
- div['box'].style.top = r+'px';
- if(document.all && !self.Mask){
- div['mask'].style.left = l+'px';
- div['mask'].style.top = r+'px';
- }
- }
- };
- /* 蒙板 */
- CMSMsgBox.prototype.createMask = function(){
- var self = this;
- var div = new Array(1);
- if(document.all)
- div['mask_ifr'] = this.createDiv(this.BoxDiv, 'iframe', 'block', null, 'msgbox_mask_frame');
- div['mask_div'] = this.createDiv(this.BoxDiv, 'div', 'block', null, 'msgbox_mask_div');
- function window_onresize(){
- var h = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
- var w = document.all ? Math.min(document.documentElement.scrollWidth, document.body.scrollWidth) :
- Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
- div['mask_div'].style.width = w + 'px';
- div['mask_div'].style.height = h + 'px';
- if(document.all){
- div['mask_ifr'].style.width = div['mask_div'].offsetWidth + 'px';
- div['mask_ifr'].style.height = div['mask_div'].offsetHeight + 'px';
- }
- }
- if(window.addEventListener){
- window.addEventListener('scroll', window_onresize, false);
- window.addEventListener('resize', window_onresize, false);
- }else{
- window.attachEvent('onscroll', window_onresize);
- window.attachEvent('onresize', window_onresize);
- }
- if(this.Skin=='loading')div['mask_div'].ondblclick = function(){self.close();};
- window_onresize();
- };
- /* 创建一个元素 */
- CMSMsgBox.prototype.createDiv = function(iParent, element, display, id, clsname){
- var ii = document.createElement(element);
- if(typeof(display)=='string')ii.style.display = display;
- if(typeof(clsname)=='string')ii.className = clsname;
- if(typeof(id)=='string')ii.setAttribute('id', id);
- iParent.appendChild(ii);
- return ii;
- };
- /* 关闭 */
- CMSMsgBox.prototype.close = function(){
- if(this.IsObject(this.BoxDiv) && this.BoxDiv.parentNode){
- this.BoxDiv.parentNode.removeChild(this.BoxDiv);
- }
- };
- CMSMsgBox.prototype.$ = function(o){
- return document.getElementById(o);
- };
- CMSMsgBox.prototype.IsObject = function(o){
- return typeof(o)!='undefined' && o!=null;
- };
- CMSMsgBox.prototype.setBackgroundColor=function(iColor){
- if(!this.$(this.Id+'bgcolor_div'))return;
- this.$(this.Id+'bgcolor_div').style.backgroundColor = iColor;
- };
- CMSMsgBox.prototype.setColor=function(iColor){
- if(!this.$(this.Id+'_msgValue'))return;
- this.$(this.Id+'_msgValue').style.color = iColor;
- };
- CMSMsgBox.prototype.setValue=function(iValue){
- if(!this.$(this.Id+'_msgValue'))return;
- this.$(this.Id+'_msgValue').innerHTML = iValue;
- };
- CMSMsgBox.prototype.setTitle=function(iTitle){
- if(!this.$(this.Id+'_msgTitle'))return;
- this.$(this.Id+'_msgTitle').innerHTML = iTitle;
- };
标签: javascript,拖曳,模拟
图片连续滚动(缓冲,一停一顿效果),可左右翻滚
作者:青锋幽灵 日期:2008-09-12 10:31
样式表代码(scroll.css):
CSS代码
- * {margin:0;padding:0;}
- body {width:370px;}
- a {text-decoration:none;color:#000;}
- a:hover {text-decoration:underline;color:#f00;}
- ul,li {float:left;width:100%;list-style-type:none;}
- h3,h3 a {font-size:12px;font-weight:normal;font-family:"宋体",Verdana;}
- .bc {height:90px;clear:both;overflow:hidden;padding:3px 15px 0 15px;}
- .bc a.scroll {width:12px;height:46px;overflow:hidden;text-indent:-100px;margin-top:5px;background:#333;}
- .bc a.s1 {float:left;}
- .bc a.s2 {float:rightright;}
- #scroll1 {padding:5px 8px 7px 8px;}
- .bc div.scroll {float:left;position:relative;width:318px;left:6px;overflow:hidden;}
- div.scroll ul {width:8000%;}
- div.scroll ul li {width:106px;padding:0 0 2px 0;text-align:center;}
- div.scroll ul li img {clear:both;width:90px;height:60px;border:1px solid #ccc;margin:0 auto;}
- div.scroll ul li h3 {height:20px;line-height:20px;overflow:hidden;}
- div.scroll ul li h3,div.scroll ul li h3 a {color:#c00;font-family:"宋体";}
效果JS代码(scroll.js):
JavaScript代码
- function scroll_initialize(Id){
- var self =this;
- var obj = document.getElementById(Id);
- if(obj.getElementsByTagName('li').length==0)return;
- var links = obj.getElementsByTagName('a');
- var a = links[0];
- var b = links[links.length-1];
- var ul = obj.getElementsByTagName('ul')[0];
- var div = obj.getElementsByTagName('div')[0];
- var li_width = obj.getElementsByTagName('li')[0].offsetWidth;
- var li_count = obj.getElementsByTagName('li').length;
- var ul_width = li_width * li_count;
- this.speed = 2000;
- this.mar = null;
- this.doSlide = function(n,t,d,c){
- var timers=new Array(n);
- var x=div.scrollLeft;
- for(var i=0;i<n;i++)(function(){
- if(timers[i]) clearTimeout(timers[i]);
- var j=i;
- timers[i]=setTimeout(function(){
- if(d==0){
- if(ul_width-div.scrollLeft<=0){
- div.scrollLeft-=ul_width;
- }else{
- div.scrollLeft=x+Math.round((c*li_width)*Math.sin(Math.PI*(j+1)/(2*n)));
- }
- }else{
- if(div.scrollLeft<=0){
- }else{
- div.scrollLeft=x-Math.round((c*li_width)*Math.sin(Math.PI*(j+1)/(2*n)));
- }
- }
- },(i+1)*t);
- })();
- if(ul_width-div.scrollLeft<=0 || (div.scrollLeft % li_width != 0 && div.scrollLeft != 0)){
- div.scrollLeft=0;
- }
- }
- this.istop=function(){
- clearInterval(self.mar);
- };
- this.istart=function(){
- self.mar = setInterval(function(){self.doSlide(20,40,0,1);},self.speed);
- };
- this.initialize = function(){
- ul.innerHTML+=ul.innerHTML;
- ul.style.width = parseInt(ul_width * 2) + 'px';
- a.onclick=function(e){self.doSlide(20,40,0,3);return false;};
- a.onfocus=function(){this.blur();};
- a.onmouseout=function(){self.istart();};
- a.onmouseover=function(){self.istop();};
- b.onclick=function(e){self.doSlide(20,40,1,3);return false;};
- b.onfocus=function(){this.blur();};
- b.onmouseout=function(){self.istart();};
- b.onmouseover=function(){self.istop();};
- div.onmouseout=function(){self.istart();};
- div.onmouseover=function(){self.istop();};
- this.istart();
- };
- this.initialize();
- }
页面HTML代码(scroll.html):
XML/HTML代码
- <!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">
- <head>
- <title>doc1</title>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <link href="scroll.css" rel="stylesheet" type="text/css" />
- <script type="text/javascript" src="scroll.js"></script>
- </head>
- <body>
- <div class="bc" id="scroll1">
- <a href="#left" class="scroll s1" title="向左滚动">向左滚动</a>
- <div class="scroll">
- <ul>
- <li>
- <a href="#"><img src="http://image2.766.com/res/h000/h69/img200809111627130.jpg" /></a>
- <h3><a href="#">魔幻《天地OL》</a></h3>
- </li>
- <li>
- <a href="#"><img src="http://image2.766.com/res/h000/h68/img200809091601330.jpg" /></a>
- <h3><a href="#">《名将三国》</a></h3>
- </li>
- <li>
- <a href="#"><img src="http://image2.766.com/res/h000/h67/img200809051655460.jpg" /></a>
- <h3><a href="#">变型金刚OL</a></h3>
- </li>
- <li>
- <a href="#"><img src="http://image2.766.com/res/h000/h67/img200809051653330.jpg" /></a>
- <h3><a href="#">盛大《八门OL》</a></h3>
- </li>
- <li>
- <a href="#"><img src="http://image2.766.com/res/h000/h67/img200809051650450.jpg" /></a>
- <h3><a href="#">回合制《穿越OL》</a></h3>
- </li>
- <li>
- <a href="#"><img src="http://image2.766.com/res/h000/h69/img200809111633050.jpg" /></a>
- <h3><a href="#">卡通网页游戏乐土</a></h3>
- </li>
- </ul>
- </div>
- <a href="#right" class="scroll s2" title="向右滚动">向右滚动</a>
- </div>
- </body>
- </html>
效果预览:

代码下载:点击下载
