NCC Tools(never code counter tools) V1.0.1发布代码-代码统计工具_hta教程-查字典教程网
NCC Tools(never code counter tools) V1.0.1发布代码-代码统计工具
NCC Tools(never code counter tools) V1.0.1发布代码-代码统计工具
发布时间:2016-12-28 来源:查字典编辑
摘要:界面如下图:把源代码存为(hta)文件,因为hta文件没有状态栏,所以我这里建议大家存为html文件,这样可以在状态栏下看到NCC扫描的进度...

界面如下图:把源代码存为(hta)文件,因为hta文件没有状态栏,所以我这里建议大家存为html文件,这样可以在状态栏下看到

NCC扫描的进度,我这里把NCC的maxloop设置为3000,所以文件统计到3000的时候,会自动终止,以防文件夹中文件太多造成运行的负担。

如果大家喜欢这样的代码,就请关注"NeverModules"

主要功能有-

1。可自己选择文件夹,或者单个文件。

2。自己选择文件后缀名进行统计

3。outputinformation输出的数据有:

文件个数,

文件的代码字节数,

单词个数,

代码行数,

总代码字节数

总代码行数。

4。可以把代码统计结果用SaveAs存为html或者txt文件。复制代码 代码如下:<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01//EN""http://www.w3.org/TR/html4/strict.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<title>NCCTools-http://www.never-online.net</title>

<hta:applicationid="NCC"

applicationname="NCCapplication"

border="thin"

border

caption="yes"

icon="http://www.never-online.net/images/icon.ico"

maximizebutton="no"

minimizebutton="yes"

showintaskbar="no"

singleinstance="yes"

sysmenu="yes"

version="1.01"

windowState="normal"/>

<metahttp-equiv="ImageToolbar"content="no"/>

<metaname="author"content="BlueDestiny,never-online"/>

<metaname="keywords"content="nevermodules,MozillaCSS,C#,.net,Refercence,BlueDestiny,never-online,www.never-online.net"/>

<metaname="description"content="BlueDestiny,never-online"/>

<metaname="title"content="nevercodecounter(NCC)-http://www.never-online.net"/>

<metaname="creator.name"content="GeniusLau,never-online,blueDestiny"/>

<styletype="text/css"media="all"title="Default">

body{background-color:buttonface;}

body,td,input{font:9pttahoma;}

h1{text-align:center;font-weight:bold;font-family:tahoma;font-size:16pt;}

fieldset{height:300px;}

legend{font-weight:bolder;}

.btn{border-left:4pxsolid#444;border-top:1pxsolid#444;border-bottom:1pxsolid#444;border-right:1pxsolid#444;}

.two{width:200px;}

.txt{border:1pxsolid#444;}

.file{display:none;width:300px;border-left:4pxsolid#444;border-top:1pxsolid#444;border-bottom:1pxsolid#444;border-right:1pxsolid#444;}

#loading{display:none;filter:alpha(opacity=70);border:1pxsolid#444444;background-color:appworkspace;color:#ffffff;width:300px;font-size:13px;font-weight:bold;font-family:arial;padding:10px;position:absolute;top:0;left:0;}

#left{line-height:200%;width:50%;padding:20px;}

#leftul{margin:00010px;}

#leftli{list-style-type:decimal;margin:20px10px15px10px;}

#footer{font-size:11px;text-align:center;}

#right{padding:20px;width:50%;}

#outputWrapper{padding:10px;}

</style>

<scripttype="text/javascript">

//<![CDATA[

//======================================================================================

//

//Module:NCC-nevercodecounterV1.01beta

//Scriptby:never-online,blueDestiny

//Updated:2006-6-25

//Copyright:Miracletechnologyallreserved

//Website:http://www.never-online.net

//Email:blueDestiny@126.com

//Blog:http://blog.csdn.net/blueDestiny,http://blog.never-online.net/

//Comment:PermissiongiventousethisscriptinANYkindofapplicationsif

//headerlinesareleftunchanged.

//

//======================================================================================

//====================================================================================

//UltityFunction

vardoc=document,wnd=window;

String.prototype.trim=function(){returnthis.replace(/(^s*)|(s*$)/g,'');};

Array.prototype.push=function(x){this[this.length]=x;};

Array.prototype.pop=function(){returnthis[this.length-1];};

//====================================================================================

varNCC=

{

//PrivateVariables

_maxloop:3000,

_version:"1.02beta",

_author:"BlueDestiny,never-online",

_webURI:"http://www.never-online.net",

_lines:{"total":0},

_bytes:{"total":0},

_files:{"total":0},

_words:{"total":0},

_error:{},

_filesExts:"cs,js,asp,xml,aspx",

_fsoObj:newActiveXObject("Scripting.FileSystemObject")

//makesureYourfsoactiveXObjectisavaild.otherwisecannotruningnextcode

};

//PublicFunctionsAPI

NCC.splash=function()

{

};

NCC.init=function()

{

varfileDlgObjStr='<objectid="filepathDlg"'

+'width="0px"height="0px"'

+'classid="CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB"'

+'codebase="http://activex.microsoft.com/controls/vb5/comdlg32.cab">'

+'</object>';

varfolderDlgObjStr='<objectid="folderpathDlg"'

+'classid="CLSID:13709620-C279-11CE-A49E-444553540000"'

+'width="0"height="0">'

+'</object>';

varloadingObjStr='<divid="loading"></div>';

doc.body.insertAdjacentHTML("beforeEnd",fileDlgObjStr);

doc.body.insertAdjacentHTML("beforeEnd",folderDlgObjStr);

doc.body.insertAdjacentHTML("beforeEnd",loadingObjStr);

}

NCC.chkFileExts=function(filenameStr)

{

vara=this._filesExts.trim().split(",");

varf=this.getFileExts(filenameStr);

for(vari=0;i<a.length;i++)

if(f.toLowerCase()==a[i].toLowerCase())returntrue;

returnfalse;

};

NCC.output=function(wrapperID)

{

vark,x;x=[];

x.push("-------------Files-------------");

//--partoffiles--

for(kinthis._files)

x.push("["+k+"]:"+this._files[k]+"");

//--partofwords--

x.push("-------------Words-------------");

for(kinthis._words)

x.push("["+k+"]:"+this._words[k]+"");

//--partofbytes--

x.push("-------------Bytes-------------");

for(kinthis._bytes)

x.push("["+k+"]:"+this._bytes[k]+"");

//--partoflines--

x.push("-------------Lines-------------");

for(kinthis._lines)

x.push("["+k+"]:"+this._lines[k]+"");

x=x.join("n");

if(wrapperID){

vara=doc.all(wrapperID),t=a.tagName.toLowerCase();

if(!a)returnwnd.alert("HTMLElementID""+wrapperID+""isnotvalid!");

if(t=="input"||t=="textarea")a.value=x;

elsea.innerHTML=x.replace(/n/,"<br/>");

}

returnx;

};

NCC.saveAs=function(elIdorStr)

{

vardlg=doc.all("filepathDlg");

vara=doc.all(elIdorStr);

if(a){

vart=a.tagName.toLowerCase();

varfileStr=(t=="input"||t=="textarea")?a.value:a.innerHTML.replace(/<br(/)?>/g,"n");

}else{

fileStr=elIdorStr;

}

dlg.cancelError=true;

try{

dlg.filter="TextFiles(*.txt)|*.txt|HTMFiles(*.htm)|*.htm";

dlg.showSave();

varf=this._fsoObj.CreateTextFile(dlg.filename,true);

f.write(fileStr);

f.Close();

}catch(ex){};

};

NCC.setFilesExt=function(filesExtsStr)

{

this._filesExts=filesExtsStr;

returntrue;

};

NCC.getFilesExts=function()

{

returnthis._filesExts;

};

NCC.getFileExts=function(filenameStr)

{

vara=filenameStr.split(".");

returna[a.length-1].toLowerCase();//a.pop()

};

NCC.selectSingleFile=function()

{

vardlg=doc.all("filepathDlg");

varfps=doc.all("filepathStr");

varfes=this._filesExts;

varfilename="",filter="",arr=[];

arr=fes.trim().split(",");

for(vari=0;i<arr.length;i++)

filter+=arr[i].toUpperCase()+"Files(*."+arr[i]+")|*."+arr[i]+""+(i==arr.length-1?"":"|");

dlg.cancelError=true;

try{

dlg.filter=filter;

dlg.showOpen();

filename=dlg.filename;

}catch(ex){};

if(filename.trim()=="")returnfalse;

fps.value=filename;

if(!this.chkFileExts(filename))returnwnd.alert("FileExtensionname""+filename+""isnotvalid!");

returnfilename;

};

NCC.selectFolder=function()

{

vardlg=doc.all("folderpathDlg");

try{

varpathObj=dlg.browseForFolder(0,"PleaseSelectFolder:",0);

varpathStr=pathObj.parentFolder.parseName(pathObj.Title).path;

returnpathStr;

}catch(ex){returnfalse};

};

NCC.countFolder=function(folderpathStr)

{

varldg=doc.all("loading");

with(ldg.style){

display="block";

top=parseInt((doc.body.clientHeight-ldg.offsetHeight)/2);

left=parseInt((doc.body.clientWidth-ldg.offsetWidth)/2);

};ldg.innerHTML="<divalign="center">NowCounting...</div>";

wnd.status="NCCCounting...";

if(!this._fsoObj.FolderExists(folderpathStr)){

this.countSingleFile(folderpathStr);

}else{

varcnt=0;

functioniterator(folderpathStr){

vara=NCC._fsoObj.getFolder(folderpathStr);

vare=newEnumerator(a.files)

for(;!e.atEnd();e.moveNext()){

NCC.countSingleFile(e.item());

if(cnt++>=NCC._maxloop)return;

}

varf=newEnumerator(a.subFolders)

for(;!f.atEnd();f.moveNext()){

iterator(f.item());

if(cnt++>=NCC._maxloop)return;

}

}

iterator(folderpathStr);

}

ldg.innerHTML="<divalign="center">NCCCountCompletely.</div>"

wnd.status="NCCCountCompletely.";

wnd.setTimeout(function(){ldg.style.display="none";},3000);

};

NCC.countSingleFile=function(filepathStr)

{

varx,a,f,e;

varldg=doc.all("loading");

if(!this._fsoObj.FileExists(filepathStr))returnfalse;

f=this._fsoObj.GetFile(filepathStr);

if(this.chkFileExts(f.name))

{

varo=f.openAsTextStream(1);

if(o.atEndOfStream){x="";}else{x=o.ReadAll();}

x=x.replace(/(n|r)+/mg,"$1");

a=x.split("n");

e=this.getFileExts(f.name);

this._bytes["total"]+=x.length;

this._bytes[e]?this._bytes[e]+=x.length:this._bytes[e]=x.length;

this._lines["total"]+=a.length;

this._lines[e]?this._lines[e]+=a.length:this._lines[e]=a.length;

a=x.replace(/(s|t|)+/g,"").split("");

this._words["total"]+=a.length;

this._words[e]?this._words[e]+=a.length:this._words[e]=a.length;

this._files["total"]++;

this._files[e]?this._files[e]++:this._files[e]=1;

}

wnd.status="NCC(""+f.path+"")";

ldg.innerHTML="nowcount""+f.name+""."

returnthis.chkFileExts(f.name)

};

NCC.formatSingleFile=function(filepathStr)

{

};

//====================================================================================

functionwindow.onload(){

NCC.init();

wnd.resizeTo(800,480);

doc.all("outputWrapper").value="";

setFilesExts();//setFilesExts.call(this);

}

functionsetFilesExts(){

doc.all("filesExts").value=NCC.getFilesExts();

}

functionoutput(){

/*

vare=event.srcElement;

vara=doc.body.all;

for(vari=0;i<a.length;i++){

if(a[i].tagName.toLowerCase()=="input"){

if(a[i]!=e)a[i].disabled=true;

}

}

*/

NCC.setFilesExt(doc.all("filesExts").value)

NCC.countFolder(doc.all('filepathStr').value);

NCC.output('outputWrapper');

}

functionchangeFileExt(){

vargroupfileExts=doc.all("groupfileExt");

varfileExtStr=[];

for(vari=0;i<groupfileExts.length;i++){

if(groupfileExts[i].checked)

fileExtStr.push(groupfileExts[i].value);

}

NCC.setFilesExt(fileExtStr.join(","));

setFilesExts();

}

functionselectSingleFile(val){

if(!NCC.selectSingleFile())return"";

doc.all(val).value=NCC.selectSingleFile();

}

functionselectFolder(val){

vara=NCC.selectFolder();

if(a==false)return"";

doc.all(val).value=a;

}

functionsaveAs(){

NCC.saveAs('outputWrapper');

//NCC.saveAs(NCC.output());

}

//]]>

</script>

</head>

<bodyid="www.never-online.net">

<h1>NCC(nevercodecounter)tools-http://www.never-online.net</h1>

<fieldset>

<legend>-ApplicationNCC(nevercodecounter)-</legend>

<tablewidth="100%"border="0"cellpadding="0"cellspacing="0">

<tr>

<tdalign="left"valign="top"id="left">

<ul>

<li>

<inputname="filepathStr"type="text"class="txt"value="typeyourfileorfolderpath"size="30">

<inputclass="btn"type="button"value="FILE"onclick="selectSingleFile('filepathStr')"/>

<inputclass="btn"type="button"value="FOLDER"onclick="selectFolder('filepathStr')"/>

</li>

<li>

<inputname="groupfileExt"value="asp"type="checkbox"checkedonclick="changeFileExt()"/>

.asp

<inputname="groupfileExt"value="js"type="checkbox"checkedonclick="changeFileExt()"/>

.js

<inputname="groupfileExt"value="xml"type="checkbox"checkedonclick="changeFileExt()"/>

.xml

<inputname="groupfileExt"value="aspx"type="checkbox"checkedonclick="changeFileExt()"/>

.aspx

<inputname="groupfileExt"value="cs"type="checkbox"checkedonclick="changeFileExt()"/>

.cs

<br/>

<inputname="filesExts"type="text"class="txt"id="filesExts"value=""size="40">

</li>

<li>

<inputclass="btntwo"type="button"value="OutputInformation"onclick="output()"/>

<>

</li>

<li>

<inputclass="btntwo"type="button"value="InformationSaveAs"onclick="saveAs();"/>

</li>

</ul>

<divid="footer">

<p>

NCCV1.01betaPowerByBlueDestiny,never-online

<br/>

Morecodepleasevisit<ahref="http://www.never-online.net"target="_blank"title="visitmysite">http://www.never-online.net</a>

</p>

</div>

</td>

<tdalign="left"valign="top"id="right">

<fieldset>

<legend>-OutputInformation-</legend>

<textareaid="outputWrapper"></textarea>

</fieldset>

</td>

</tr>

</table>

</fieldset>

</body>

</html>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新hta学习
    热门hta学习
    脚本专栏子分类