整理成:/*Mapbar Maplet Engine (C)2005 Mapbar Inc*/
var strImgsvrUrl="http://192.168.0.2/maps/";
document.writeln('<div id="myalert" style="position:absolute;z-index:100;filter:alpha(opacity=90);-moz-opacity:0.9;visibility:hidden;"></div>');
function W2Usr(x,y,Llg9)
{
document.getElementById("myalert").style.top=parseInt(y)-60;
document.getElementById("myalert").style.left=parseInt(x)-100;
document.getElementById("myalert").innerHTML='<table width="196" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #CCCCCC;"><tr><td height="19" bgcolor="#8888FF"></td></tr><tr><td height="100" align="center" valign="middle" bgcolor="#FFFFFF"><table width="167" height="79" border="0" cellpadding="0" cellspacing="0"><tr><td height="55" align="center" valign="middle" style="font-size: 12px;color: #0065AD;">'+Llg9+'</td></tr><tr><td height="24" align="center" valign="middle"><input type="button" value="ر" onClick="document.getElementById(\'myalert\').style.visibility = \'hidden\'"onMouseOver="style.background=\'#DEE7EF\';style.cursor=\'hand\'"onMouseOut="this.style.background=\'FDFAF3\'" style="font-size: 9pt; width: 38; height:18; border: 1px solid #4A799C;background-color: #FDFAF3"></td></tr></table></td></tr></table>';
document.getElementById("myalert").style.visibility="visible"
}
;
document.write('<iframe src="'+strImgsvrUrl+'images/mask.gif" width=0 height=0></iframe>');
var F4E9=document.all?1:0;
var sijd=document.it3?1:0;
var OuO1=(F4E9)?"document.all.":"document.";
var ac052=(F4E9)?".style":"";
var fk5$K=0;
function CreateToolTip(Xt3G,rP4,Llg9)
{
var PT9='<table border="0" width="150" cellspacing="0" cellpadding="0">'+'<tr><td width="100%" bgcolor="#000000">'+'<table border="0" width="100%" cellspacing="1" cellpadding="0">'+'<tr><td width="100%" bgcolor='+topColor+'>'+'<table border="0" width="90%" cellspacing="0" cellpadding="0" align="center">'+'<tr><td id="mytooltiptitle"width="100%" class="tooltiptitle"> '+rP4+'</td>'+'<td style="cursor:hand" valign="top">'+'<a href="javascript:hideToolTipMenu();"><font color=#ffffff size=2 face=arial style="text-decoration:none">x</font></a>'+'</td>'+'</tr>'+'</table>'+'</td></tr>'+'<tr><td width="100%" bgcolor='+subColor+'>'+'<table border="0" width="100%" cellpadding="0" cellspacing="1" align="center">'+'<tr><td id="mytooltipcontent" width="100%" class="tooltipcontent">'+Llg9+'</td></tr>'+'</table>'+'</td></tr>'+'</table>'+'</td></tr>'+'</table>';
document.getElementById(Xt3G).innerHTML=PT9
}
;
function MoveToolTip(Xt3G,N$lQ2,Q735,H694)
{
if(F4E9)
{
document.getElementById(Xt3G).style.top=(eval(N$lQ2)+document.body.scrollTop)
}
else
{
document.getElementById(Xt3G).style.top=eval(N$lQ2)
}
document.getElementById(Xt3G).style.left=eval(Q735)
}
;
function UpdateContent(Xt3G,rP4,Llg9)
{
if(fk5$K==0)
{
CreateToolTip(Xt3G,rP4,Llg9);
fk5$K=1
}
else
{
if(document.getElementById("mytooltiptitle"))document.getElementById("mytooltiptitle").innerHTML=' '+rP4;
if(document.getElementById("mytooltipcontent"))document.getElementById("mytooltipcontent").innerHTML=Llg9
}
}
;
function setToolTipMenu(x,y,rP4,Llg9)
{
UpdateContent("ToolTip",rP4,Llg9);
var AP8=document.getElementById("ToolTip").clientWidth;
var Qy$03=document.getElementById("ToolTip").clientHeight;
if(x>mapwidth-AP8)
{
x=x-AP8
}
;
if(y>mapheight-Qy$03)
{
y=y-Qy$03
}
;
MoveToolTip("ToolTip",y+yoffset,x+xoffset);
document.getElementById("ToolTip").style.visibility='visible'
}
;
........
var strImgsvrUrl="http://192.168.0.2/maps/";
document.writeln('<div id="myalert" style="position:absolute;z-index:100;filter:alpha(opacity=90);-moz-opacity:0.9;visibility:hidden;"></div>');
function W2Usr(x,y,Llg9)
{
document.getElementById("myalert").style.top=parseInt(y)-60;
document.getElementById("myalert").style.left=parseInt(x)-100;
document.getElementById("myalert").innerHTML='<table width="196" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #CCCCCC;"><tr><td height="19" bgcolor="#8888FF"></td></tr><tr><td height="100" align="center" valign="middle" bgcolor="#FFFFFF"><table width="167" height="79" border="0" cellpadding="0" cellspacing="0"><tr><td height="55" align="center" valign="middle" style="font-size: 12px;color: #0065AD;">'+Llg9+'</td></tr><tr><td height="24" align="center" valign="middle"><input type="button" value="ر" onClick="document.getElementById(\'myalert\').style.visibility = \'hidden\'"onMouseOver="style.background=\'#DEE7EF\';style.cursor=\'hand\'"onMouseOut="this.style.background=\'FDFAF3\'" style="font-size: 9pt; width: 38; height:18; border: 1px solid #4A799C;background-color: #FDFAF3"></td></tr></table></td></tr></table>';
document.getElementById("myalert").style.visibility="visible"
}
;
document.write('<iframe src="'+strImgsvrUrl+'images/mask.gif" width=0 height=0></iframe>');
var F4E9=document.all?1:0;
var sijd=document.it3?1:0;
var OuO1=(F4E9)?"document.all.":"document.";
var ac052=(F4E9)?".style":"";
var fk5$K=0;
function CreateToolTip(Xt3G,rP4,Llg9)
{
var PT9='<table border="0" width="150" cellspacing="0" cellpadding="0">'+'<tr><td width="100%" bgcolor="#000000">'+'<table border="0" width="100%" cellspacing="1" cellpadding="0">'+'<tr><td width="100%" bgcolor='+topColor+'>'+'<table border="0" width="90%" cellspacing="0" cellpadding="0" align="center">'+'<tr><td id="mytooltiptitle"width="100%" class="tooltiptitle"> '+rP4+'</td>'+'<td style="cursor:hand" valign="top">'+'<a href="javascript:hideToolTipMenu();"><font color=#ffffff size=2 face=arial style="text-decoration:none">x</font></a>'+'</td>'+'</tr>'+'</table>'+'</td></tr>'+'<tr><td width="100%" bgcolor='+subColor+'>'+'<table border="0" width="100%" cellpadding="0" cellspacing="1" align="center">'+'<tr><td id="mytooltipcontent" width="100%" class="tooltipcontent">'+Llg9+'</td></tr>'+'</table>'+'</td></tr>'+'</table>'+'</td></tr>'+'</table>';
document.getElementById(Xt3G).innerHTML=PT9
}
;
function MoveToolTip(Xt3G,N$lQ2,Q735,H694)
{
if(F4E9)
{
document.getElementById(Xt3G).style.top=(eval(N$lQ2)+document.body.scrollTop)
}
else
{
document.getElementById(Xt3G).style.top=eval(N$lQ2)
}
document.getElementById(Xt3G).style.left=eval(Q735)
}
;
function UpdateContent(Xt3G,rP4,Llg9)
{
if(fk5$K==0)
{
CreateToolTip(Xt3G,rP4,Llg9);
fk5$K=1
}
else
{
if(document.getElementById("mytooltiptitle"))document.getElementById("mytooltiptitle").innerHTML=' '+rP4;
if(document.getElementById("mytooltipcontent"))document.getElementById("mytooltipcontent").innerHTML=Llg9
}
}
;
function setToolTipMenu(x,y,rP4,Llg9)
{
UpdateContent("ToolTip",rP4,Llg9);
var AP8=document.getElementById("ToolTip").clientWidth;
var Qy$03=document.getElementById("ToolTip").clientHeight;
if(x>mapwidth-AP8)
{
x=x-AP8
}
;
if(y>mapheight-Qy$03)
{
y=y-Qy$03
}
;
MoveToolTip("ToolTip",y+yoffset,x+xoffset);
document.getElementById("ToolTip").style.visibility='visible'
}
;
........
.NetFramework V1.1 C#下编译通过 using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;namespace FormatCode
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox2; string[] strI;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.LinkLabel linkLabel2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.linkLabel2 = new System.Windows.Forms.LinkLabel();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(40, 152);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(96, 30);
this.button1.TabIndex = 0;
this.button1.Text = "打开文件";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Enabled = false;
this.textBox1.Location = new System.Drawing.Point(40, 120);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(376, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// button2
//
this.button2.Location = new System.Drawing.Point(40, 232);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(96, 32);
this.button2.TabIndex = 2;
this.button2.Text = "整理保存代码";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(40, 200);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(376, 21);
this.textBox2.TabIndex = 3;
this.textBox2.Text = "";
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.panel1.Controls.Add(this.linkLabel2);
this.panel1.Controls.Add(this.linkLabel1);
this.panel1.Controls.Add(this.label1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(520, 88);
this.panel1.TabIndex = 4;
//
// label1
//
this.label1.Font = new System.Drawing.Font("黑体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Location = new System.Drawing.Point(32, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(336, 23);
this.label1.TabIndex = 0;
this.label1.Text = "JavaScript代码整理程序.net V1.0";
//
// panel2
//
this.panel2.BackColor = System.Drawing.SystemColors.Desktop;
this.panel2.Location = new System.Drawing.Point(0, 88);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(504, 2);
this.panel2.TabIndex = 5;
//
// linkLabel1
//
this.linkLabel1.LinkArea = new System.Windows.Forms.LinkArea(5, 4);
this.linkLabel1.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
this.linkLabel1.Location = new System.Drawing.Point(360, 48);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(120, 16);
this.linkLabel1.TabIndex = 1;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "版权所有:任丘热线";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// linkLabel2
//
this.linkLabel2.LinkArea = new System.Windows.Forms.LinkArea(5, 3);
this.linkLabel2.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
this.linkLabel2.Location = new System.Drawing.Point(360, 64);
this.linkLabel2.Name = "linkLabel2";
this.linkLabel2.Size = new System.Drawing.Size(120, 16);
this.linkLabel2.TabIndex = 3;
this.linkLabel2.TabStop = true;
this.linkLabel2.Text = "程序设计:CLX";
this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);
//
// Form1
//
this.AutoScale = false;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(498, 303);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.button2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Text = "Javascript代码整理程序";
this.panel1.ResumeLayout(false);
this.ResumeLayout(false); }
#endregion
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void button1_Click(object sender, System.EventArgs e)
{
this.openFileDialog1 =new OpenFileDialog();
this.openFileDialog1.ShowDialog();
this.textBox1.Text=this.openFileDialog1 .FileName;
if(this.textBox1.Text != "")
{
strI=this.textBox1.Text.Split('\\');
strI[strI.Length-1]="Temp_"+strI[strI.Length-1];
this.textBox2.Text=strI[strI.Length-1];
}
else
{
this.textBox2.Text="";
}
} private void textBox2_TextChanged(object sender, System.EventArgs e)
{
} private void button2_Click(object sender, System.EventArgs e)
{
if(this.textBox1.Text!="" && this.textBox2.Text!="" )
{
this.strI[this.strI.Length-1]=this.textBox2.Text;
System.IO .StreamReader sr=new System.IO.StreamReader(this.textBox1.Text);
int i;
string line;
string xg="";
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
bool j=true;
bool a=true;
bool b=true;
int t=0;
for(i=0;i<line.Length ;i++)
{
if(line[i]=='\'')
j=!j;
if(line[i]=='"')
b=!b;
if(line[i]=='(' || line[i]==')')
a=!a; if(line[i]!=';')
{
if(line[i]=='{' )
{
xg=xg+'\n';
for(int s=0;s<t;s++)
{xg=xg+" ";}
t+=2;
xg=xg + line[i]+'\n';
for(int s=0;s<t;s++)
{xg=xg+" ";}
}
else
{
if( line[i]=='}')
{
t-=2;
xg=xg+'\n';
for(int s=0;s<t;s++)
{xg=xg+" ";}
xg=xg + line[i]+'\n';
for(int s=0;s<t;s++)
{xg=xg+" ";}
}
else
{
xg=xg+line[i];
}
}
}
else
{
if(j && a && b)
{
xg=xg+line[i]+'\n';
for(int s=0;s<t;s++)
{xg=xg+" ";}
}
else
xg=xg+line[i];
}
}
} string FILE_NAME=this.strI[0]; for(i=1;i<this.strI.Length;i++)
FILE_NAME=FILE_NAME+'\\'+this.strI[i]; StreamWriter sr1 = File.CreateText(FILE_NAME);
sr1.WriteLine (xg); sr1.Close();
}
else
{
this.textBox2.Text="请先选择一个代码文件!"; }
} private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{ System.Diagnostics.Process.Start("www.rqrx.cn"); } private void linkLabel2_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("mailto:[email protected]");
} }
}