ai4r 1.1 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/README.rdoc +21 -20
  2. data/examples/decision_trees/id3_example.rb +3 -2
  3. data/examples/genetic_algorithm/genetic_algorithm_example.rb +6 -6
  4. data/examples/neural_network/backpropagation_example.rb +2 -2
  5. data/lib/ai4r/classifiers/classifier_helper.rb +54 -0
  6. data/lib/ai4r/classifiers/id3.rb +356 -0
  7. data/lib/ai4r/classifiers/one_r.rb +148 -0
  8. data/lib/ai4r/classifiers/prism.rb +231 -0
  9. data/lib/ai4r/classifiers/zero_r.rb +104 -0
  10. data/lib/ai4r/genetic_algorithm/genetic_algorithm.rb +272 -0
  11. data/lib/ai4r/neural_network/backpropagation.rb +271 -0
  12. data/site/build/tmp/locationmap.xml +14 -14
  13. data/site/build/tmp/output.xmap +23 -23
  14. data/site/build/tmp/pluginlist2fetchbuild.xml +144 -144
  15. data/site/build/tmp/plugins-1.xml +0 -11
  16. data/site/build/tmp/plugins-2.xml +54 -0
  17. data/site/build/tmp/projfilters.properties +41 -41
  18. data/site/build/webapp/WEB-INF/logs/core.log +681 -788
  19. data/site/build/webapp/WEB-INF/logs/error.log +281 -248
  20. data/site/build/webapp/WEB-INF/logs/sitemap.log +1015 -0
  21. data/site/src/documentation/content/xdocs/forum.html +9 -0
  22. data/site/src/documentation/content/xdocs/geneticAlgorithms.xml +82 -68
  23. data/site/src/documentation/content/xdocs/index.xml +47 -18
  24. data/site/src/documentation/content/xdocs/machineLearning.xml +10 -9
  25. data/site/src/documentation/content/xdocs/neuralNetworks.xml +60 -36
  26. data/site/src/documentation/content/xdocs/site.xml +8 -5
  27. data/site/src/documentation/content/xdocs/svn.xml +11 -1
  28. data/site/src/documentation/resources/images/Thumbs.db +0 -0
  29. data/site/src/documentation/resources/images/ai4r-logo.png +0 -0
  30. data/site/src/documentation/resources/images/genetic_algorithms_example.png +0 -0
  31. data/site/src/documentation/resources/images/jadeferret.png +0 -0
  32. data/site/src/documentation/resources/images/neural_network_example.png +0 -0
  33. data/site/src/documentation/resources/images/sub-dir/Thumbs.db +0 -0
  34. data/site/src/documentation/skinconf.xml +18 -18
  35. data/test/classifiers/id3_test.rb +206 -0
  36. data/test/classifiers/one_r_test.rb +62 -0
  37. data/test/classifiers/prism_test.rb +83 -0
  38. data/test/classifiers/zero_r_test.rb +48 -0
  39. data/test/genetic_algorithm/chromosome_test.rb +41 -38
  40. data/test/genetic_algorithm/genetic_algorithm_test.rb +64 -61
  41. data/test/neural_network/backpropagation_test.rb +20 -18
  42. metadata +109 -199
  43. data/lib/decision_tree/id3.rb +0 -354
  44. data/lib/genetic_algorithm/genetic_algorithm.rb +0 -268
  45. data/lib/neural_network/backpropagation.rb +0 -264
  46. data/site/build/site/en/broken-links.xml +0 -2
  47. data/site/build/site/en/downloads.html +0 -187
  48. data/site/build/site/en/downloads.pdf +0 -151
  49. data/site/build/site/en/geneticAlgorithms.html +0 -564
  50. data/site/build/site/en/geneticAlgorithms.pdf +0 -911
  51. data/site/build/site/en/images/ai4r-logo.png +0 -0
  52. data/site/build/site/en/images/built-with-forrest-button.png +0 -0
  53. data/site/build/site/en/images/c.png +0 -0
  54. data/site/build/site/en/images/c_wbn.png +0 -0
  55. data/site/build/site/en/images/c_wn.png +0 -0
  56. data/site/build/site/en/images/ero.gif +0 -0
  57. data/site/build/site/en/images/europe2.png +0 -0
  58. data/site/build/site/en/images/europe3.png +0 -0
  59. data/site/build/site/en/images/fitness.png +0 -0
  60. data/site/build/site/en/images/instruction_arrow.png +0 -0
  61. data/site/build/site/en/images/my_email.png +0 -0
  62. data/site/build/site/en/images/rubyforge.png +0 -0
  63. data/site/build/site/en/images/s.png +0 -0
  64. data/site/build/site/en/images/s_wbn.png +0 -0
  65. data/site/build/site/en/images/s_wn.png +0 -0
  66. data/site/build/site/en/images/sigmoid.png +0 -0
  67. data/site/build/site/en/images/t.png +0 -0
  68. data/site/build/site/en/images/t_wbn.png +0 -0
  69. data/site/build/site/en/images/t_wn.png +0 -0
  70. data/site/build/site/en/index.html +0 -258
  71. data/site/build/site/en/index.pdf +0 -306
  72. data/site/build/site/en/linkmap.html +0 -231
  73. data/site/build/site/en/linkmap.pdf +0 -94
  74. data/site/build/site/en/locationmap.xml +0 -72
  75. data/site/build/site/en/machineLearning.html +0 -325
  76. data/site/build/site/en/machineLearning.pdf +0 -337
  77. data/site/build/site/en/neuralNetworks.html +0 -446
  78. data/site/build/site/en/neuralNetworks.pdf +0 -604
  79. data/site/build/site/en/skin/CommonMessages_de.xml +0 -23
  80. data/site/build/site/en/skin/CommonMessages_en_US.xml +0 -23
  81. data/site/build/site/en/skin/CommonMessages_es.xml +0 -23
  82. data/site/build/site/en/skin/CommonMessages_fr.xml +0 -23
  83. data/site/build/site/en/skin/basic.css +0 -166
  84. data/site/build/site/en/skin/breadcrumbs-optimized.js +0 -90
  85. data/site/build/site/en/skin/breadcrumbs.js +0 -237
  86. data/site/build/site/en/skin/fontsize.js +0 -166
  87. data/site/build/site/en/skin/getBlank.js +0 -40
  88. data/site/build/site/en/skin/getMenu.js +0 -45
  89. data/site/build/site/en/skin/images/README.txt +0 -1
  90. data/site/build/site/en/skin/images/add.jpg +0 -0
  91. data/site/build/site/en/skin/images/built-with-forrest-button.png +0 -0
  92. data/site/build/site/en/skin/images/chapter.gif +0 -0
  93. data/site/build/site/en/skin/images/chapter_open.gif +0 -0
  94. data/site/build/site/en/skin/images/current.gif +0 -0
  95. data/site/build/site/en/skin/images/error.png +0 -0
  96. data/site/build/site/en/skin/images/external-link.gif +0 -0
  97. data/site/build/site/en/skin/images/fix.jpg +0 -0
  98. data/site/build/site/en/skin/images/forrest-credit-logo.png +0 -0
  99. data/site/build/site/en/skin/images/hack.jpg +0 -0
  100. data/site/build/site/en/skin/images/header_white_line.gif +0 -0
  101. data/site/build/site/en/skin/images/info.png +0 -0
  102. data/site/build/site/en/skin/images/instruction_arrow.png +0 -0
  103. data/site/build/site/en/skin/images/label.gif +0 -0
  104. data/site/build/site/en/skin/images/page.gif +0 -0
  105. data/site/build/site/en/skin/images/pdfdoc.gif +0 -0
  106. data/site/build/site/en/skin/images/poddoc.png +0 -0
  107. data/site/build/site/en/skin/images/printer.gif +0 -0
  108. data/site/build/site/en/skin/images/rc-b-l-15-1body-2menu-3menu.png +0 -0
  109. data/site/build/site/en/skin/images/rc-b-r-15-1body-2menu-3menu.png +0 -0
  110. data/site/build/site/en/skin/images/rc-b-r-5-1header-2tab-selected-3tab-selected.png +0 -0
  111. data/site/build/site/en/skin/images/rc-t-l-5-1header-2searchbox-3searchbox.png +0 -0
  112. data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-selected-3tab-selected.png +0 -0
  113. data/site/build/site/en/skin/images/rc-t-l-5-1header-2tab-unselected-3tab-unselected.png +0 -0
  114. data/site/build/site/en/skin/images/rc-t-r-15-1body-2menu-3menu.png +0 -0
  115. data/site/build/site/en/skin/images/rc-t-r-5-1header-2searchbox-3searchbox.png +0 -0
  116. data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-selected-3tab-selected.png +0 -0
  117. data/site/build/site/en/skin/images/rc-t-r-5-1header-2tab-unselected-3tab-unselected.png +0 -0
  118. data/site/build/site/en/skin/images/remove.jpg +0 -0
  119. data/site/build/site/en/skin/images/rss.png +0 -0
  120. data/site/build/site/en/skin/images/spacer.gif +0 -0
  121. data/site/build/site/en/skin/images/success.png +0 -0
  122. data/site/build/site/en/skin/images/txtdoc.png +0 -0
  123. data/site/build/site/en/skin/images/update.jpg +0 -0
  124. data/site/build/site/en/skin/images/valid-html401.png +0 -0
  125. data/site/build/site/en/skin/images/vcss.png +0 -0
  126. data/site/build/site/en/skin/images/warning.png +0 -0
  127. data/site/build/site/en/skin/images/xmldoc.gif +0 -0
  128. data/site/build/site/en/skin/menu.js +0 -48
  129. data/site/build/site/en/skin/note.txt +0 -50
  130. data/site/build/site/en/skin/print.css +0 -54
  131. data/site/build/site/en/skin/profile.css +0 -163
  132. data/site/build/site/en/skin/prototype.js +0 -1257
  133. data/site/build/site/en/skin/screen.css +0 -587
  134. data/site/build/site/en/svn.html +0 -223
  135. data/site/build/site/en/svn.pdf +0 -239
  136. data/site/build/site/en/wholesite.pdf +0 -1686
  137. data/site/build/tmp/brokenlinks.xml +0 -2
  138. data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.data +0 -0
  139. data/site/build/tmp/cocoon-work/cache-dir/cocoon-ehcache-1.index +0 -0
  140. data/test/decision_tree/id3_test.rb +0 -209
@@ -1,23 +0,0 @@
1
- <?xml version="1.0" encoding="ISO-8859-1"?>
2
- <!--
3
- Licensed to the Apache Software Foundation (ASF) under one or more
4
- contributor license agreements. See the NOTICE file distributed with
5
- this work for additional information regarding copyright ownership.
6
- The ASF licenses this file to You under the Apache License, Version 2.0
7
- (the "License"); you may not use this file except in compliance with
8
- the License. You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- -->
18
- <catalogue>
19
- <message key="Font size:">Schriftgr�sse:</message>
20
- <message key="Last Published:">Zuletzt ver�ffentlicht:</message>
21
- <message key="Search">Suche:</message>
22
- <message key="Search the site with">Suche auf der Seite mit</message>
23
- </catalogue>
@@ -1,23 +0,0 @@
1
- <?xml version="1.0" encoding="ISO-8859-1"?>
2
- <!--
3
- Licensed to the Apache Software Foundation (ASF) under one or more
4
- contributor license agreements. See the NOTICE file distributed with
5
- this work for additional information regarding copyright ownership.
6
- The ASF licenses this file to You under the Apache License, Version 2.0
7
- (the "License"); you may not use this file except in compliance with
8
- the License. You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- -->
18
- <catalogue>
19
- <message key="Font size:">Font size:</message>
20
- <message key="Last Published:">Last Published:</message>
21
- <message key="Search">Search</message>
22
- <message key="Search the site with">Search site with</message>
23
- </catalogue>
@@ -1,23 +0,0 @@
1
- <?xml version="1.0" encoding="ISO-8859-1"?>
2
- <!--
3
- Licensed to the Apache Software Foundation (ASF) under one or more
4
- contributor license agreements. See the NOTICE file distributed with
5
- this work for additional information regarding copyright ownership.
6
- The ASF licenses this file to You under the Apache License, Version 2.0
7
- (the "License"); you may not use this file except in compliance with
8
- the License. You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- -->
18
- <catalogue>
19
- <message key="Font size:">Tama�o del texto:</message>
20
- <message key="Last Published:">Fecha de publicaci�n:</message>
21
- <message key="Search">Buscar</message>
22
- <message key="Search the site with">Buscar en</message>
23
- </catalogue>
@@ -1,23 +0,0 @@
1
- <?xml version="1.0" encoding="ISO-8859-1"?>
2
- <!--
3
- Licensed to the Apache Software Foundation (ASF) under one or more
4
- contributor license agreements. See the NOTICE file distributed with
5
- this work for additional information regarding copyright ownership.
6
- The ASF licenses this file to You under the Apache License, Version 2.0
7
- (the "License"); you may not use this file except in compliance with
8
- the License. You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- -->
18
- <catalogue>
19
- <message key="Font size:">Taille :</message>
20
- <message key="Last Published:">Derni�re publication :</message>
21
- <message key="Search">Rechercher</message>
22
- <message key="Search the site with">Rechercher sur le site avec</message>
23
- </catalogue>
@@ -1,166 +0,0 @@
1
- /*
2
- * Licensed to the Apache Software Foundation (ASF) under one or more
3
- * contributor license agreements. See the NOTICE file distributed with
4
- * this work for additional information regarding copyright ownership.
5
- * The ASF licenses this file to You under the Apache License, Version 2.0
6
- * (the "License"); you may not use this file except in compliance with
7
- * the License. You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- /**
18
- * General
19
- */
20
-
21
- img { border: 0; }
22
-
23
- #content table {
24
- border: 0;
25
- width: 100%;
26
- }
27
- /*Hack to get IE to render the table at 100%*/
28
- * html #content table { margin-left: -3px; }
29
-
30
- #content th,
31
- #content td {
32
- margin: 0;
33
- padding: 0;
34
- vertical-align: top;
35
- }
36
-
37
- .clearboth {
38
- clear: both;
39
- }
40
-
41
- .note, .warning, .fixme {
42
- border: solid black 1px;
43
- margin: 1em 3em;
44
- }
45
-
46
- .note .label {
47
- background: #369;
48
- color: white;
49
- font-weight: bold;
50
- padding: 5px 10px;
51
- }
52
- .note .content {
53
- background: #F0F0FF;
54
- color: black;
55
- line-height: 120%;
56
- font-size: 90%;
57
- padding: 5px 10px;
58
- }
59
- .warning .label {
60
- background: #C00;
61
- color: white;
62
- font-weight: bold;
63
- padding: 5px 10px;
64
- }
65
- .warning .content {
66
- background: #FFF0F0;
67
- color: black;
68
- line-height: 120%;
69
- font-size: 90%;
70
- padding: 5px 10px;
71
- }
72
- .fixme .label {
73
- background: #C6C600;
74
- color: black;
75
- font-weight: bold;
76
- padding: 5px 10px;
77
- }
78
- .fixme .content {
79
- padding: 5px 10px;
80
- }
81
-
82
- /**
83
- * Typography
84
- */
85
-
86
- body {
87
- font-family: verdana, "Trebuchet MS", arial, helvetica, sans-serif;
88
- font-size: 100%;
89
- }
90
-
91
- #content {
92
- font-family: Georgia, Palatino, Times, serif;
93
- font-size: 95%;
94
- }
95
- #tabs {
96
- font-size: 70%;
97
- }
98
- #menu {
99
- font-size: 80%;
100
- }
101
- #footer {
102
- font-size: 70%;
103
- }
104
-
105
- h1, h2, h3, h4, h5, h6 {
106
- font-family: "Trebuchet MS", verdana, arial, helvetica, sans-serif;
107
- font-weight: bold;
108
- margin-top: 1em;
109
- margin-bottom: .5em;
110
- }
111
-
112
- h1 {
113
- margin-top: 0;
114
- margin-bottom: 1em;
115
- font-size: 1.4em;
116
- }
117
- #content h1 {
118
- font-size: 160%;
119
- margin-bottom: .5em;
120
- }
121
- #menu h1 {
122
- margin: 0;
123
- padding: 10px;
124
- background: #336699;
125
- color: white;
126
- }
127
- h2 { font-size: 120%; }
128
- h3 { font-size: 100%; }
129
- h4 { font-size: 90%; }
130
- h5 { font-size: 80%; }
131
- h6 { font-size: 75%; }
132
-
133
- p {
134
- line-height: 120%;
135
- text-align: left;
136
- margin-top: .5em;
137
- margin-bottom: 1em;
138
- }
139
-
140
- #content li,
141
- #content th,
142
- #content td,
143
- #content li ul,
144
- #content li ol{
145
- margin-top: .5em;
146
- margin-bottom: .5em;
147
- }
148
-
149
-
150
- #content li li,
151
- #minitoc-area li{
152
- margin-top: 0em;
153
- margin-bottom: 0em;
154
- }
155
-
156
- #content .attribution {
157
- text-align: right;
158
- font-style: italic;
159
- font-size: 85%;
160
- margin-top: 1em;
161
- }
162
-
163
- .codefrag {
164
- font-family: "Courier New", Courier, monospace;
165
- font-size: 110%;
166
- }
@@ -1,90 +0,0 @@
1
- /*
2
- * Licensed to the Apache Software Foundation (ASF) under one or more
3
- * contributor license agreements. See the NOTICE file distributed with
4
- * this work for additional information regarding copyright ownership.
5
- * The ASF licenses this file to You under the Apache License, Version 2.0
6
- * (the "License"); you may not use this file except in compliance with
7
- * the License. You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var PREPREND_CRUMBS=new Array();
18
- var link1="@skinconfig.trail.link1.name@";
19
- var link2="@skinconfig.trail.link2.name@";
20
- var link3="@skinconfig.trail.link3.name@";
21
- if(!(link1=="")&&!link1.indexOf( "@" ) == 0){
22
- PREPREND_CRUMBS.push( new Array( link1, @skinconfig.trail.link1.href@ ) ); }
23
- if(!(link2=="")&&!link2.indexOf( "@" ) == 0){
24
- PREPREND_CRUMBS.push( new Array( link2, @skinconfig.trail.link2.href@ ) ); }
25
- if(!(link3=="")&&!link3.indexOf( "@" ) == 0){
26
- PREPREND_CRUMBS.push( new Array( link3, @skinconfig.trail.link3.href@ ) ); }
27
- var DISPLAY_SEPARATOR=" &gt; ";
28
- var DISPLAY_PREPREND=" &gt; ";
29
- var DISPLAY_POSTPREND=":";
30
- var CSS_CLASS_CRUMB="breadcrumb";
31
- var CSS_CLASS_TRAIL="breadcrumbTrail";
32
- var CSS_CLASS_SEPARATOR="crumbSeparator";
33
- var FILE_EXTENSIONS=new Array( ".html", ".htm", ".jsp", ".php", ".php3", ".php4" );
34
- var PATH_SEPARATOR="/";
35
-
36
- function sc(s) {
37
- var l=s.toLowerCase();
38
- return l.substr(0,1).toUpperCase()+l.substr(1);
39
- }
40
- function getdirs() {
41
- var t=document.location.pathname.split(PATH_SEPARATOR);
42
- var lc=t[t.length-1];
43
- for(var i=0;i < FILE_EXTENSIONS.length;i++)
44
- {
45
- if(lc.indexOf(FILE_EXTENSIONS[i]))
46
- return t.slice(1,t.length-1); }
47
- return t.slice(1,t.length);
48
- }
49
- function getcrumbs( d )
50
- {
51
- var pre = "/";
52
- var post = "/";
53
- var c = new Array();
54
- if( d != null )
55
- {
56
- for(var i=0;i < d.length;i++) {
57
- pre+=d[i]+postfix;
58
- c.push(new Array(d[i],pre)); }
59
- }
60
- if(PREPREND_CRUMBS.length > 0 )
61
- return PREPREND_CRUMBS.concat( c );
62
- return c;
63
- }
64
- function gettrail( c )
65
- {
66
- var h=DISPLAY_PREPREND;
67
- for(var i=0;i < c.length;i++)
68
- {
69
- h+='<a href="'+c[i][1]+'" >'+sc(c[i][0])+'</a>';
70
- if(i!=(c.length-1))
71
- h+=DISPLAY_SEPARATOR; }
72
- return h+DISPLAY_POSTPREND;
73
- }
74
-
75
- function gettrailXHTML( c )
76
- {
77
- var h='<span class="'+CSS_CLASS_TRAIL+'">'+DISPLAY_PREPREND;
78
- for(var i=0;i < c.length;i++)
79
- {
80
- h+='<a href="'+c[i][1]+'" class="'+CSS_CLASS_CRUMB+'">'+sc(c[i][0])+'</a>';
81
- if(i!=(c.length-1))
82
- h+='<span class="'+CSS_CLASS_SEPARATOR+'">'+DISPLAY_SEPARATOR+'</span>'; }
83
- return h+DISPLAY_POSTPREND+'</span>';
84
- }
85
-
86
- if(document.location.href.toLowerCase().indexOf("http://")==-1)
87
- document.write(gettrail(getcrumbs()));
88
- else
89
- document.write(gettrail(getcrumbs(getdirs())));
90
-
@@ -1,237 +0,0 @@
1
- /*
2
- * Licensed to the Apache Software Foundation (ASF) under one or more
3
- * contributor license agreements. See the NOTICE file distributed with
4
- * this work for additional information regarding copyright ownership.
5
- * The ASF licenses this file to You under the Apache License, Version 2.0
6
- * (the "License"); you may not use this file except in compliance with
7
- * the License. You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- /**
18
- * This script, when included in a html file, builds a neat breadcrumb trail
19
- * based on its url. That is, if it doesn't contains bugs (I'm relatively
20
- * sure it does).
21
- *
22
- * Typical usage:
23
- * <script type="text/javascript" language="JavaScript" src="breadcrumbs.js"></script>
24
- */
25
-
26
- /**
27
- * IE 5 on Mac doesn't know Array.push.
28
- *
29
- * Implement it - courtesy to fritz.
30
- */
31
- var abc = new Array();
32
- if (!abc.push) {
33
- Array.prototype.push = function(what){this[this.length]=what}
34
- }
35
-
36
- /* ========================================================================
37
- CONSTANTS
38
- ======================================================================== */
39
-
40
- /**
41
- * Two-dimensional array containing extra crumbs to place at the front of
42
- * the trail. Specify first the name of the crumb, then the URI that belongs
43
- * to it. You'll need to modify this for every domain or subdomain where
44
- * you use this script (you can leave it as an empty array if you wish)
45
- */
46
- var PREPREND_CRUMBS = new Array();
47
-
48
- var link1 = "@skinconfig.trail.link1.name@";
49
- var link2 = "@skinconfig.trail.link2.name@";
50
- var link3 = "@skinconfig.trail.link3.name@";
51
-
52
- var href1 = "@skinconfig.trail.link1.href@";
53
- var href2 = "@skinconfig.trail.link2.href@";
54
- var href3 = "@skinconfig.trail.link3.href@";
55
-
56
- if(!(link1=="")&&!link1.indexOf( "@" ) == 0){
57
- PREPREND_CRUMBS.push( new Array( link1, href1 ) );
58
- }
59
- if(!(link2=="")&&!link2.indexOf( "@" ) == 0){
60
- PREPREND_CRUMBS.push( new Array( link2, href2 ) );
61
- }
62
- if(!(link3=="")&&!link3.indexOf( "@" ) == 0){
63
- PREPREND_CRUMBS.push( new Array( link3, href3 ) );
64
- }
65
-
66
- /**
67
- * String to include between crumbs:
68
- */
69
- var DISPLAY_SEPARATOR = " &gt; ";
70
- /**
71
- * String to include at the beginning of the trail
72
- */
73
- var DISPLAY_PREPREND = " &gt; ";
74
- /**
75
- * String to include at the end of the trail
76
- */
77
- var DISPLAY_POSTPREND = "";
78
-
79
- /**
80
- * CSS Class to use for a single crumb:
81
- */
82
- var CSS_CLASS_CRUMB = "breadcrumb";
83
-
84
- /**
85
- * CSS Class to use for the complete trail:
86
- */
87
- var CSS_CLASS_TRAIL = "breadcrumbTrail";
88
-
89
- /**
90
- * CSS Class to use for crumb separator:
91
- */
92
- var CSS_CLASS_SEPARATOR = "crumbSeparator";
93
-
94
- /**
95
- * Array of strings containing common file extensions. We use this to
96
- * determine what part of the url to ignore (if it contains one of the
97
- * string specified here, we ignore it).
98
- */
99
- var FILE_EXTENSIONS = new Array( ".html", ".htm", ".jsp", ".php", ".php3", ".php4" );
100
-
101
- /**
102
- * String that separates parts of the breadcrumb trail from each other.
103
- * When this is no longer a slash, I'm sure I'll be old and grey.
104
- */
105
- var PATH_SEPARATOR = "/";
106
-
107
- /* ========================================================================
108
- UTILITY FUNCTIONS
109
- ======================================================================== */
110
- /**
111
- * Capitalize first letter of the provided string and return the modified
112
- * string.
113
- */
114
- function sentenceCase( string )
115
- { return string;
116
- //var lower = string.toLowerCase();
117
- //return lower.substr(0,1).toUpperCase() + lower.substr(1);
118
- }
119
-
120
- /**
121
- * Returns an array containing the names of all the directories in the
122
- * current document URL
123
- */
124
- function getDirectoriesInURL()
125
- {
126
- var trail = document.location.pathname.split( PATH_SEPARATOR );
127
-
128
- // check whether last section is a file or a directory
129
- var lastcrumb = trail[trail.length-1];
130
- for( var i = 0; i < FILE_EXTENSIONS.length; i++ )
131
- {
132
- if( lastcrumb.indexOf( FILE_EXTENSIONS[i] ) )
133
- {
134
- // it is, remove it and send results
135
- return trail.slice( 1, trail.length-1 );
136
- }
137
- }
138
-
139
- // it's not; send the trail unmodified
140
- return trail.slice( 1, trail.length );
141
- }
142
-
143
- /* ========================================================================
144
- BREADCRUMB FUNCTIONALITY
145
- ======================================================================== */
146
- /**
147
- * Return a two-dimensional array describing the breadcrumbs based on the
148
- * array of directories passed in.
149
- */
150
- function getBreadcrumbs( dirs )
151
- {
152
- var prefix = "/";
153
- var postfix = "/";
154
-
155
- // the array we will return
156
- var crumbs = new Array();
157
-
158
- if( dirs != null )
159
- {
160
- for( var i = 0; i < dirs.length; i++ )
161
- {
162
- prefix += dirs[i] + postfix;
163
- crumbs.push( new Array( dirs[i], prefix ) );
164
- }
165
- }
166
-
167
- // preprend the PREPREND_CRUMBS
168
- if(PREPREND_CRUMBS.length > 0 )
169
- {
170
- return PREPREND_CRUMBS.concat( crumbs );
171
- }
172
-
173
- return crumbs;
174
- }
175
-
176
- /**
177
- * Return a string containing a simple text breadcrumb trail based on the
178
- * two-dimensional array passed in.
179
- */
180
- function getCrumbTrail( crumbs )
181
- {
182
- var xhtml = DISPLAY_PREPREND;
183
-
184
- for( var i = 0; i < crumbs.length; i++ )
185
- {
186
- xhtml += '<a href="' + crumbs[i][1] + '" >';
187
- xhtml += unescape( crumbs[i][0] ) + '</a>';
188
- if( i != (crumbs.length-1) )
189
- {
190
- xhtml += DISPLAY_SEPARATOR;
191
- }
192
- }
193
-
194
- xhtml += DISPLAY_POSTPREND;
195
-
196
- return xhtml;
197
- }
198
-
199
- /**
200
- * Return a string containing an XHTML breadcrumb trail based on the
201
- * two-dimensional array passed in.
202
- */
203
- function getCrumbTrailXHTML( crumbs )
204
- {
205
- var xhtml = '<span class="' + CSS_CLASS_TRAIL + '">';
206
- xhtml += DISPLAY_PREPREND;
207
-
208
- for( var i = 0; i < crumbs.length; i++ )
209
- {
210
- xhtml += '<a href="' + crumbs[i][1] + '" class="' + CSS_CLASS_CRUMB + '">';
211
- xhtml += unescape( crumbs[i][0] ) + '</a>';
212
- if( i != (crumbs.length-1) )
213
- {
214
- xhtml += '<span class="' + CSS_CLASS_SEPARATOR + '">' + DISPLAY_SEPARATOR + '</span>';
215
- }
216
- }
217
-
218
- xhtml += DISPLAY_POSTPREND;
219
- xhtml += '</span>';
220
-
221
- return xhtml;
222
- }
223
-
224
- /* ========================================================================
225
- PRINT BREADCRUMB TRAIL
226
- ======================================================================== */
227
-
228
- // check if we're local; if so, only print the PREPREND_CRUMBS
229
- if( document.location.href.toLowerCase().indexOf( "http://" ) == -1 )
230
- {
231
- document.write( getCrumbTrail( getBreadcrumbs() ) );
232
- }
233
- else
234
- {
235
- document.write( getCrumbTrail( getBreadcrumbs( getDirectoriesInURL() ) ) );
236
- }
237
-