never-online's Tech Blog In cnblog
Everlasting Love For Angela
博客园
首页
新随笔
联系
订阅
管理
6 Posts :: 3 Stories :: 1 Comments :: 0 Trackbacks
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的新闻
最新评论
我的标签
留言簿
给我留言
查看留言
随笔分类
(6)
.net
Javascript(6)
随笔档案
(6)
2006年7月 (3)
2006年6月 (3)
我的网站与Blog
我的网站的blog
我网站的blog主要的方向是我的never modules和SOA
我在CSDN的blog
准备慢慢转移到cnblog,现在暂且还用着,放一些代码在上面
最新评论
阅读排行榜
1. Javascript - HTML的request类(1558)
2. 简单的做了一个像126邮箱那样的模拟模态框(217)
3. [how to] googlemap 之 javascript实现方法(211)
4. NCC Tools(never code counter tools) V1.0.1代码统计工具源码[hta](196)
5. 以前写的客户端(DHTML)的分页,一个Object。(92)
评论排行榜
1. 简单的做了一个像126邮箱那样的模拟模态框(1)
2. 我的cnblog刚开张,这里就专写些.net和JS的文章了...(0)
3. 以前写的客户端(DHTML)的分页,一个Object。(0)
4. [how to] googlemap 之 javascript实现方法(0)
5. NCC Tools(never code counter tools) V1.0.1代码统计工具源码[hta](0)
NCC Tools(never code counter tools) V1.0.1代码统计工具源码[hta]
代码统计工具
把源代码存为(hta)文件,因为hta文件没有状态栏,所以我这里建议大家存为html文件,这样可以在状态栏下看到
NCC扫描的进度,我这里把NCC的maxloop设置为3000,所以文件统计到3000的时候,会自动终止,以防文件夹中文件太多造成运行的负担。
主要功能有-
1。可自己选择文件夹,或者单个文件。
2。自己选择文件后缀名进行统计
3。output information输出的数据有:
文件个数,
文件的代码字节数,
单词个数,
代码行数,
总代码字节数
总代码行数。
4。可以把代码统计结果用SaveAs存为html或者txt文件。
<?
xml version
=
"
1.0
"
encoding
=
"
UTF-8
"
?>
<!
DOCTYPE HTML PUBLIC
"
-//W3C//DTD HTML 4.01//EN
"
"
http://www.w3.org/TR/html4/strict.dtd
"
>
<
html xmlns
=
"
http://www.w3.org/1999/xhtml
"
>
<
head
>
<
title
>
NCC Tools
-
http:
//
www.never-online.net </title>
<
hta:application id
=
"
NCC
"
applicationname
=
"
NCC application
"
border
=
"
thin
"
borderstyle
=
"
normal
"
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
"
/>
<
meta http
-
equiv
=
"
ImageToolbar
"
content
=
"
no
"
/>
<
meta name
=
"
author
"
content
=
"
BlueDestiny, never-online
"
/>
<
meta name
=
"
keywords
"
content
=
"
never modules, Mozilla CSS, C#, .net, Refercence, BlueDestiny, never-online, www.never-online.net
"
/>
<
meta name
=
"
description
"
content
=
"
BlueDestiny, never-online
"
/>
<
meta name
=
"
title
"
content
=
"
never code counter (NCC) - http://www.never-online.net
"
/>
<
meta name
=
"
creator.name
"
content
=
"
Genius Lau, never-online, blueDestiny
"
/>
<
style type
=
"
text/css
"
media
=
"
all
"
title
=
"
Default
"
>
body
{ background
-
color:buttonface; }
body,td,input
{ font:9pt tahoma; }
h1
{ text
-
align:center; font
-
weight: bold; font
-
family: tahoma; font
-
size: 16pt; }
fieldset
{ height:300px; }
legend
{ font
-
weight: bolder; }
.btn
{ border
-
left:4px solid #
444
; border
-
top:1px solid #
444
; border
-
bottom:1px solid #
444
; border
-
right:1px solid #
444
; }
.two
{ width:200px; }
.txt
{ border:1px solid #
444
; }
.file
{ display:none; width:300px; border
-
left:4px solid #
444
; border
-
top:1px solid #
444
; border
-
bottom:1px solid #
444
; border
-
right:1px solid #
444
; }
#loading
{ display:none; filter:alpha(opacity
=
70
); border:1px solid #
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; }
#left ul
{ margin:
0
0
0
10px; }
#left li
{ list
-
style
-
type: decimal; margin:20px 10px 15px 10px; }
#footer
{ font
-
size:11px; text
-
align:center; }
#right
{ padding:20px; width:
50
%
; }
#outputWrapper
{ padding:10px; }
</
style
>
<
script type
=
"
text/javascript
"
>
//
<![CDATA[
//
======================================================================================
//
//
Module : NCC - never code counter V1.01 beta
//
Script by : never-online, blueDestiny
//
Updated : 2006-6-25
//
Copyright : Miracle technology all reserved
//
Website : http://www.never-online.net
//
Email : blueDestiny@126.com
//
Blog : http://blog.csdn.net/blueDestiny, http://blog.never-online.net/
//
Comment : Permission given to use this script in ANY kind of applications if
//
header lines are left unchanged.
//
//
======================================================================================
//
====================================================================================
//
Ultity Function
var
doc
=
document, wnd
=
window;
String.prototype.trim
=
function
()
{
return
this
.replace(
/
(
^
\s
*
)
|
(\s
*
$)
/
g, ''); }
;
Array.prototype.push
=
function
(x)
{
this
[
this
.length]
=
x; }
;
Array.prototype.pop
=
function
()
{
return
this
[
this
.length
-
1
]; }
;
//
====================================================================================
var
NCC
=
{
//
Private Variables
_maxloop :
3000
,
_version :
"
1.02 beta
"
,
_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 :
new
ActiveXObject(
"
Scripting.FileSystemObject
"
)
//
make sure Your fso activeXObject is availd. otherwise can not runing next code
}
;
//
Public Functions API
NCC.splash
=
function
()
{
}
;
NCC.init
=
function
()
{
var
fileDlgObjStr
=
'
<
object id
=
"
filepathDlg
"
'
+
' width
=
"
0px
"
height
=
"
0px
"
'
+
' classid
=
"
CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB
"
'
+
' codebase
=
"
http://activex.microsoft.com/controls/vb5/comdlg32.cab
"
>
'
+
'
</
object
>
';
var
folderDlgObjStr
=
'
<
object id
=
"
folderpathDlg
"
'
+
' classid
=
"
CLSID:13709620-C279-11CE-A49E-444553540000
"
'
+
' width
=
"
0
"
height
=
"
0
"
>
'
+
'
</
object
>
';
var
loadingObjStr
=
'
<
div id
=
"
loading
"
></
div
>
';
doc.body.insertAdjacentHTML(
"
beforeEnd
"
, fileDlgObjStr);
doc.body.insertAdjacentHTML(
"
beforeEnd
"
, folderDlgObjStr);
doc.body.insertAdjacentHTML(
"
beforeEnd
"
, loadingObjStr);
}
NCC.chkFileExts
=
function
(filenameStr)
{
var
a
=
this
._filesExts.trim().split(
"
,
"
);
var
f
=
this
.getFileExts(filenameStr);
for
(
var
i
=
0
; i
<
a.length; i
++
)
if
(f.toLowerCase()
==
a[i].toLowerCase())
return
true
;
return
false
;
}
;
NCC.output
=
function
(wrapperID)
{
var
k, x; x
=
[];
x.push(
"
------------- Files -------------
"
);
//
-- part of files --
for
(k
in
this
._files)
x.push(
"
[
"
+
k
+
"
]:
"
+
this
._files[k]
+
""
);
//
-- part of words --
x.push(
"
------------- Words -------------
"
);
for
(k
in
this
._words)
x.push(
"
[
"
+
k
+
"
]:
"
+
this
._words[k]
+
""
);
//
-- part of bytes --
x.push(
"
------------- Bytes -------------
"
);
for
(k
in
this
._bytes)
x.push(
"
[
"
+
k
+
"
]:
"
+
this
._bytes[k]
+
""
);
//
-- part of lines --
x.push(
"
------------- Lines -------------
"
);
for
(k
in
this
._lines)
x.push(
"
[
"
+
k
+
"
]:
"
+
this
._lines[k]
+
""
);
x
=
x.join(
"
\n
"
);
if
(wrapperID)
{
var
a
=
doc.all(wrapperID), t
=
a.tagName.toLowerCase();
if
(
!
a)
return
wnd.alert(
"
HTMLElement ID \
""
+wrapperID+
"
\
"
is not valid!
"
);
if
(t
==
"
input
"
||
t
==
"
textarea
"
) a.value
=
x;
else
a.innerHTML
=
x.replace(
/
\n
/
,
"
<br/>
"
);
}
return
x;
}
;
NCC.saveAs
=
function
(elIdorStr)
{
var
dlg
=
doc.all(
"
filepathDlg
"
);
var
a
=
doc.all(elIdorStr);
if
(a)
{
var
t
=
a.tagName.toLowerCase();
var
fileStr
=
(t
==
"
input
"
||
t
==
"
textarea
"
)
?
a.value : a.innerHTML.replace(
/<
br(\
/
)
?>/
g,
"
\n
"
);
}
else
{
fileStr
=
elIdorStr;
}
dlg.cancelError
=
true
;
try
{
dlg.filter
=
"
Text Files (*.txt)|*.txt|HTM Files (*.htm)|*.htm
"
;
dlg.showSave();
var
f
=
this
._fsoObj.CreateTextFile(dlg.filename,
true
);
f.write(fileStr);
f.Close();
}
catch
(ex)
{}
;
}
;
NCC.setFilesExt
=
function
(filesExtsStr)
{
this
._filesExts
=
filesExtsStr;
return
true
;
}
;
NCC.getFilesExts
=
function
()
{
return
this
._filesExts;
}
;
NCC.getFileExts
=
function
(filenameStr)
{
var
a
=
filenameStr.split(
"
.
"
);
return
a[a.length
-
1
].toLowerCase();
//
a.pop()
}
;
NCC.selectSingleFile
=
function
()
{
var
dlg
=
doc.all(
"
filepathDlg
"
);
var
fps
=
doc.all(
"
filepathStr
"
);
var
fes
=
this
._filesExts;
var
filename
=
""
, filter
=
""
, arr
=
[];
arr
=
fes.trim().split(
"
,
"
);
for
(
var
i
=
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()
==
""
)
return
false
;
fps.value
=
filename;
if
(
!
this
.chkFileExts(filename))
return
wnd.alert(
"
File Extension name \
""
+filename+
"
\
"
is not valid!
"
);
return
filename;
}
;
NCC.selectFolder
=
function
()
{
var
dlg
=
doc.all(
"
folderpathDlg
"
);
try
{
var
pathObj
=
dlg.browseForFolder(
0
,
"
Please Select Folder:
"
,
0
);
var
pathStr
=
pathObj.parentFolder.parseName(pathObj.Title).path;
return
pathStr;
}
catch
(ex)
{
return
false
}
;
}
;
NCC.countFolder
=
function
(folderpathStr)
{
var
ldg
=
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
=
"
<div align=\
"
center\
"
>Now Counting
</div>
"
;
wnd.status
=
"
NCC Counting
"
;
if
(
!
this
._fsoObj.FolderExists(folderpathStr))
{