7aa20866c5cab45de569c0218c3f5666969b1058.svn-base
5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
function getXMLDoc(url)
{
var agnt=navigator.userAgent.toLowerCase();
var isChrome = false;
var isIE = (agnt.indexOf("msie")>0 || agnt.indexOf("trident")>0) ? true : false;
if(!isIE) {
if(agnt.indexOf("chrome")>0) isChrome = true;
}
var xmlDoc;
if(isChrome) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, false);
xhr.send(null);
xmlDoc = xhr.responseXML;
}
else {
if(isIE)
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
else
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.async=false;
xmlDoc.load(url);
}
return xmlDoc;
}
function inserttable(funcname, usage, ret, memo, arrPara, example, illu, divFuncTable)
{
if(illu != "") illu = '<img src="documentg.bmp" title="' +illu+ '"> ';
var str = '<div id="' +divFuncTable+funcname+ '"></div><br>';
str += '<table class="funcTable" width=98% cols=3 cellpadding=4 cellspacing=0 border=1 borderColorLight=#999999 borderColorDark=#999999 align="center">';
str += '<col width=120><col><col width=64 align=right>';
str += '<tr bgcolor=#d8d8f8><td style="border-right:0px;font-size:18px;color:#008899;font-weight:900" align=center>' +funcname+ '</td><td style="border-right:0px;"><b>' +usage+ '</b></td>';
str += '<td style="border-left:0px;">' +illu+ '<a href="#func_' +divFuncTable+funcname+ '"><img border=0 src="arrowup.gif" title="回到目錄"/> </a> </td></tr>';
var paras = arrPara.length;
if(paras==0)
str += '<tr><td align=right>參數</td><td colspan=2>(無)</td></tr>';
else if(paras==1)
str += '<tr><td align=right>參數</td><td colspan=2>' +arrPara[0]+ '</td></tr>';
else {
for(var i=1; i<=paras; i++) {
str += '<tr><td align=right>參數' +i+ '</td><td colspan=2>' +arrPara[i-1]+ '</td></tr>';
}
}
if(ret=="") ret = "(無)";
str += '<tr><td align=right>返回值</td><td colspan=2>' +ret+ '</td></tr>';
if(memo != "") str += '<tr><td align=right>備註</td><td colspan=2>' +memo+ '</td></tr>';
if(example != "") str += '<tr bgColor=yellow><td align=right>示例</td><td colspan=2>' +example+ '</td></tr>';
str += '</table><br>';
return str;
}
function genfunctable(divFuncTable, divFunc, xmldoc)
{
if(xmldoc==null) return;
var root = xmldoc.documentElement; if(root==null) return;
var x=xmldoc.getElementsByTagName('category'); if(x==null) return;
var cats = x.length;
var str = '<table class="funcTable" width=94% cellpadding=2 cellspacing=0 border=1 borderColorLight=#999999 borderColorDark=#999999 align="center">';
str += '<tr bgcolor=#eaeaea><th>分類</th><th>函數名</th><th>用途</th></tr>';
for(i=0; i<cats; i++) {
var cat = x[i];
var catName = cat.attributes.getNamedItem("name").nodeValue;
var xx = cat.getElementsByTagName("function");
var funcs = xx.length;
for(j=0; j<funcs; j++) {
var func = xx[j];
var funcname = func.attributes.getNamedItem("name").nodeValue;
var usage = func.getElementsByTagName("usage")[0].childNodes[0].nodeValue;
var s = '<tr>';
if(j==0) s+= '<td rowspan=' +funcs+ '>' +catName+ '</td>';
s +='<td><a href="#' +divFuncTable+funcname+ '"><div id="func_' +divFuncTable+funcname+ '"/>' +funcname+ '</a></td><td>' +usage+ '</td></tr>';
str += s;
}
}
document.getElementById(divFuncTable).innerHTML = str + '</table>';
str=' 函數詳解:';
for(i=0; i<cats; i++) {
var cat = x[i];
var xx = cat.getElementsByTagName("function");
var funcs = xx.length;
for(j=0; j<funcs; j++) {
var paras=0;
var usage="";
var detail="";
var ret="";
var memo="";
var example="";
var illu="";
var arrPara=new Array();
var func = xx[j];
var funcname = func.attributes.getNamedItem("name").nodeValue;
var childs = func.childNodes.length;
for(k=0; k<childs; k++) {
var xxx = func.childNodes[k];
if(xxx.nodeType!=1) continue;
var text = xxx.childNodes[0].nodeValue;
if(xxx.nodeName == "usage") usage = text;
else if(xxx.nodeName == "detail") detail = text;
else if(xxx.nodeName == "return") ret = text;
else if(xxx.nodeName == "memo") memo = text;
else if(xxx.nodeName == "example") example = text;
else if(xxx.nodeName == "illu") illu = text;
else if(xxx.nodeName == "para") arrPara[paras++]=text;
}
if(detail != "") usage=detail;
str += inserttable(funcname, usage, ret, memo, arrPara, example, illu, divFuncTable);
}
}
document.getElementById(divFunc).innerHTML = str;
}
function genetr(eventname, meaning, arrp)
{
var str = '<tr><td>' + eventname + '</td><td>' +meaning+ '</td>';
for(var i=0; i<4; i++) {
var s=' ';
if(i<arrp.length) s = arrp[i];
str += '<td>' + s + '</td>';
}
str += '</tr>';
return str;
}
function geneventtable(divTag, xmldoc, nodename)
{
if(xmldoc==null) return;
var x=xmldoc.getElementsByTagName(nodename); if(x==null) return;
var str = '<table width=98% cellpadding=4 cellspacing=0 border=1 borderColorLight=#999999 borderColorDark=#999999 align="center">';
str += '<tr bgcolor=#eaeaea><td>Event</td><td>漪砱</td><td>p1</td><td>p2</td><td>p3</td><td>p4</td></tr>';
var ele = x[0];
var count = ele.childNodes.length;
for(i=0; i<count; i++) {
var c = ele.childNodes[i];
if(c.nodeType==3) continue;
var eventname = c.nodeName;
var meaning="";
var arrp = new Array(0);
for(j=0; j<c.childNodes.length; j++) {
var d=c.childNodes[j];
if(d.nodeName=="meaning")
meaning = d.childNodes[0].nodeValue;
else if(d.nodeName == "p")
arrp.push(d.childNodes[0].nodeValue);
}
str += genetr(eventname, meaning, arrp);
}
str += '</table>';
document.getElementById(divTag).innerHTML = str;
}