内容显示页
 
类别:JavaScript | 浏览(224) | 2007-8-28 17:30:24 | 关闭广告
/*=========================================================================
 * Intro       打开CSS文件,然后运行这个宏
 * FileName    CSSFormat.jsee
 * Author      yongfa365
 * Version     v2.0
 * WEB         http://www.yongfa365.com
 * Email       yongfa365[at]qq.com
 * FirstWrite  http://www.yongfa365.com/Item/CSS-Format-Tool-CSSFormat-For-Emeditor-Macros-yongfa365.html
 * LastModify  2007-10-06 03:47:31
 *==========================================================================*/

editor.ExecuteCommandByID(4105);//转为CR+LF格式,如果文件没有保存会提示保存
xPos = document.selection.GetActivePointX( eePosLogical ); 
yPos = document.selection.GetActivePointY( eePosLogical ); 

function CSSformat(n){
    if (document.selection.Text=="") document.selection.SelectAll();
    if (n==1){
        document.selection.Text = document.selection.Text.replace(/\r\n/g,"").replace(/}/g,"}\r\n").replace(/\*\//g,"*/\r\n").replace(/\t/g,"").replace(/\s*(:|;)\s*/g,"$1").replace(/ {2,}/g," ").replace(/\{ *(.+) *\}/g,"{$1}");
    }
    if (n==2){
        document.selection.Text = document.selection.Text.replace(/\r\n/g,"").replace(/}/g,"}\r\n").replace(/\s*(:|;)\s*/g,"$1").replace(/;/g,";\r\n\t").replace(/{/g,"{\r\n\t").replace(/}/g,"\r\n}").replace(/\*\//g,"*/\r\n");
    }
    document.selection.SetActivePoint( eePosLogical, xPos, yPos, false ); 
}

mainMenu=CreatePopupMenu();
mainMenu.Add("功能:对选中文字或全文CSS格式化",0);
mainMenu.Add("一行",1);
mainMenu.Add("多行",2);
mainMenu.Add("关于",3);
mainMenu.Add( "", 0, eeMenuSeparator );
var witchItem=mainMenu.Track();
switch(witchItem)
{
	case 1:
		CSSformat(1);
		break;
	case 2:
		CSSformat(2);
		break;
	case 3:
		alert("哈哈哈哈,柳永法制作,\nhttp://www.yongfa365.com");
		break;
	default:
		break;
}



引用本页地址:http://www.yongfa365.com/item/CSS-Format-Tool-CSSFormat-For-Emeditor-Macros-yongfa365.html
 
 
相关链接
 
网友评论:
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片看不清? 换张图试试
 
   
 
 
文章分类
 
   

power by :柳永法(yongfa365)'Blog | model by :hibaidu | css by:众网友 | 京ICP备07011491号   我要统计  

本空间赞助商:北京中科兴联信息技术有限公司

QQ:64049027    E-mail:64049027<at>qq.com