silicium 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +3 -3
  3. data/.gitignore +13 -13
  4. data/.rakeTasks +8 -0
  5. data/.travis.yml +28 -25
  6. data/CODE_OF_CONDUCT.md +74 -74
  7. data/Gemfile +8 -8
  8. data/LICENSE.txt +21 -21
  9. data/Makefile +269 -269
  10. data/README.md +588 -46
  11. data/Rakefile +16 -16
  12. data/bin/console +14 -14
  13. data/bin/setup +8 -8
  14. data/docs/Object.html +117 -117
  15. data/docs/README_md.html +142 -142
  16. data/docs/Silicium/Combinatorics.html +270 -270
  17. data/docs/Silicium/Dice/Polyhedron.html +315 -315
  18. data/docs/Silicium/Dice/PolyhedronSet.html +321 -321
  19. data/docs/Silicium/Dice.html +99 -99
  20. data/docs/Silicium/Error.html +106 -106
  21. data/docs/Silicium/Geometry/Line2dCanon.html +243 -243
  22. data/docs/Silicium/Geometry/VariablesOrderException.html +106 -106
  23. data/docs/Silicium/Geometry.html +940 -940
  24. data/docs/Silicium/GraphVisualizer.html +226 -0
  25. data/docs/Silicium/Graphs/GraphError.html +106 -106
  26. data/docs/Silicium/Graphs/OrientedGraph.html +901 -775
  27. data/docs/Silicium/Graphs/UnorientedGraph.html +237 -284
  28. data/docs/Silicium/Graphs.html +374 -164
  29. data/docs/Silicium/IntegralDoesntExistError.html +106 -106
  30. data/docs/Silicium/NumericalIntegration.html +521 -521
  31. data/docs/Silicium/Optimization.html +629 -639
  32. data/docs/Silicium/Plotter/Image.html +297 -297
  33. data/docs/Silicium/Plotter.html +186 -186
  34. data/docs/Silicium.html +101 -101
  35. data/docs/created.rid +9 -9
  36. data/docs/css/fonts.css +167 -167
  37. data/docs/css/rdoc.css +619 -619
  38. data/docs/index.html +134 -132
  39. data/docs/js/darkfish.js +84 -84
  40. data/docs/js/navigation.js +105 -105
  41. data/docs/js/search.js +110 -110
  42. data/docs/js/search_index.js +1 -1
  43. data/docs/js/search_index.js.gz +0 -0
  44. data/docs/js/searcher.js +229 -229
  45. data/docs/table_of_contents.html +697 -608
  46. data/lib/algebra.rb +452 -0
  47. data/lib/algebra_diff.rb +258 -0
  48. data/lib/geometry/figure.rb +62 -0
  49. data/lib/geometry.rb +290 -236
  50. data/lib/geometry3d.rb +270 -0
  51. data/lib/graph/dfs.rb +42 -0
  52. data/lib/graph/kruskal.rb +36 -0
  53. data/lib/graph/scc.rb +97 -0
  54. data/lib/graph.rb +350 -164
  55. data/lib/graph_visualizer.rb +287 -0
  56. data/lib/ml_algorithms.rb +181 -0
  57. data/lib/numerical_integration.rb +184 -147
  58. data/lib/optimization.rb +209 -144
  59. data/lib/plotter.rb +256 -96
  60. data/lib/polynomial_division.rb +132 -0
  61. data/lib/polynomial_interpolation.rb +94 -0
  62. data/lib/regression.rb +120 -0
  63. data/lib/silicium/adding.rb +37 -0
  64. data/lib/silicium/conversions.rb +23 -0
  65. data/lib/silicium/multi.rb +82 -0
  66. data/lib/silicium/sparse.rb +76 -0
  67. data/lib/silicium/sugar.rb +37 -0
  68. data/lib/silicium/trans.rb +26 -0
  69. data/lib/silicium/version.rb +3 -3
  70. data/lib/silicium.rb +5 -5
  71. data/lib/theory_of_probability.rb +240 -226
  72. data/lib/topological_sort.rb +50 -0
  73. data/oriented_graph.png +0 -0
  74. data/plot.png +0 -0
  75. data/silicium.gemspec +38 -39
  76. metadata +38 -16
data/docs/index.html CHANGED
@@ -1,132 +1,134 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>RDoc Documentation</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "./";
11
- var index_rel_prefix = "./";
12
- </script>
13
-
14
- <script src="./js/navigation.js" defer></script>
15
- <script src="./js/search.js" defer></script>
16
- <script src="./js/search_index.js" defer></script>
17
- <script src="./js/searcher.js" defer></script>
18
- <script src="./js/darkfish.js" defer></script>
19
-
20
- <link href="./css/fonts.css" rel="stylesheet">
21
- <link href="./css/rdoc.css" rel="stylesheet">
22
-
23
-
24
-
25
-
26
- <body id="top" role="document" class="file">
27
- <nav role="navigation">
28
- <div id="project-navigation">
29
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
30
- <h2>
31
- <a href="./index.html" rel="home">Home</a>
32
- </h2>
33
-
34
- <div id="table-of-contents-navigation">
35
- <a href="./table_of_contents.html#pages">Pages</a>
36
- <a href="./table_of_contents.html#classes">Classes</a>
37
- <a href="./table_of_contents.html#methods">Methods</a>
38
- </div>
39
- </div>
40
-
41
-
42
- <div id="search-section" role="search" class="project-section initially-hidden">
43
- <form action="#" method="get" accept-charset="utf-8">
44
- <div id="search-field-wrapper">
45
- <input id="search-field" role="combobox" aria-label="Search"
46
- aria-autocomplete="list" aria-controls="search-results"
47
- type="text" name="search" placeholder="Search" spellcheck="false"
48
- title="Type to search, Up and Down to navigate, Enter to load">
49
- </div>
50
-
51
- <ul id="search-results" aria-label="Search Results"
52
- aria-busy="false" aria-expanded="false"
53
- aria-atomic="false" class="initially-hidden"></ul>
54
- </form>
55
- </div>
56
-
57
- </div>
58
-
59
- <div id="project-metadata">
60
- <div id="fileindex-section" class="nav-section">
61
- <h3>Pages</h3>
62
-
63
- <ul class="link-list">
64
-
65
- <li><a href="./README_md.html">README</a>
66
-
67
- </ul>
68
- </div>
69
-
70
- <div id="classindex-section" class="nav-section">
71
- <h3>Class and Module Index</h3>
72
-
73
- <ul class="link-list">
74
-
75
- <li><a href="./Object.html">Object</a>
76
-
77
- <li><a href="./Silicium.html">Silicium</a>
78
-
79
- <li><a href="./Silicium/Combinatorics.html">Silicium::Combinatorics</a>
80
-
81
- <li><a href="./Silicium/Dice.html">Silicium::Dice</a>
82
-
83
- <li><a href="./Silicium/Dice/Polyhedron.html">Silicium::Dice::Polyhedron</a>
84
-
85
- <li><a href="./Silicium/Dice/PolyhedronSet.html">Silicium::Dice::PolyhedronSet</a>
86
-
87
- <li><a href="./Silicium/Error.html">Silicium::Error</a>
88
-
89
- <li><a href="./Silicium/Geometry.html">Silicium::Geometry</a>
90
-
91
- <li><a href="./Silicium/Geometry/Line2dCanon.html">Silicium::Geometry::Line2dCanon</a>
92
-
93
- <li><a href="./Silicium/Geometry/VariablesOrderException.html">Silicium::Geometry::VariablesOrderException</a>
94
-
95
- <li><a href="./Silicium/Graphs.html">Silicium::Graphs</a>
96
-
97
- <li><a href="./Silicium/Graphs/GraphError.html">Silicium::Graphs::GraphError</a>
98
-
99
- <li><a href="./Silicium/Graphs/OrientedGraph.html">Silicium::Graphs::OrientedGraph</a>
100
-
101
- <li><a href="./Silicium/Graphs/UnorientedGraph.html">Silicium::Graphs::UnorientedGraph</a>
102
-
103
- <li><a href="./Silicium/IntegralDoesntExistError.html">Silicium::IntegralDoesntExistError</a>
104
-
105
- <li><a href="./Silicium/NumericalIntegration.html">Silicium::NumericalIntegration</a>
106
-
107
- <li><a href="./Silicium/Optimization.html">Silicium::Optimization</a>
108
-
109
- <li><a href="./Silicium/Plotter.html">Silicium::Plotter</a>
110
-
111
- <li><a href="./Silicium/Plotter/Image.html">Silicium::Plotter::Image</a>
112
-
113
- </ul>
114
- </div>
115
-
116
- </div>
117
- </nav>
118
-
119
- <main role="main">
120
-
121
- <p>This is the API documentation for RDoc Documentation.
122
-
123
- </main>
124
-
125
-
126
-
127
- <footer id="validator-badges" role="contentinfo">
128
- <p><a href="https://validator.w3.org/check/referer">Validate</a>
129
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
130
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
131
- </footer>
132
-
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+
25
+
26
+ <body id="top" role="document" class="file">
27
+ <nav role="navigation">
28
+ <div id="project-navigation">
29
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
30
+ <h2>
31
+ <a href="./index.html" rel="home">Home</a>
32
+ </h2>
33
+
34
+ <div id="table-of-contents-navigation">
35
+ <a href="./table_of_contents.html#pages">Pages</a>
36
+ <a href="./table_of_contents.html#classes">Classes</a>
37
+ <a href="./table_of_contents.html#methods">Methods</a>
38
+ </div>
39
+ </div>
40
+
41
+
42
+ <div id="search-section" role="search" class="project-section initially-hidden">
43
+ <form action="#" method="get" accept-charset="utf-8">
44
+ <div id="search-field-wrapper">
45
+ <input id="search-field" role="combobox" aria-label="Search"
46
+ aria-autocomplete="list" aria-controls="search-results"
47
+ type="text" name="search" placeholder="Search" spellcheck="false"
48
+ title="Type to search, Up and Down to navigate, Enter to load">
49
+ </div>
50
+
51
+ <ul id="search-results" aria-label="Search Results"
52
+ aria-busy="false" aria-expanded="false"
53
+ aria-atomic="false" class="initially-hidden"></ul>
54
+ </form>
55
+ </div>
56
+
57
+ </div>
58
+
59
+ <div id="project-metadata">
60
+ <div id="fileindex-section" class="nav-section">
61
+ <h3>Pages</h3>
62
+
63
+ <ul class="link-list">
64
+
65
+ <li><a href="./README_md.html">README</a>
66
+
67
+ </ul>
68
+ </div>
69
+
70
+ <div id="classindex-section" class="nav-section">
71
+ <h3>Class and Module Index</h3>
72
+
73
+ <ul class="link-list">
74
+
75
+ <li><a href="./Object.html">Object</a>
76
+
77
+ <li><a href="./Silicium.html">Silicium</a>
78
+
79
+ <li><a href="./Silicium/Combinatorics.html">Silicium::Combinatorics</a>
80
+
81
+ <li><a href="./Silicium/Dice.html">Silicium::Dice</a>
82
+
83
+ <li><a href="./Silicium/Dice/Polyhedron.html">Silicium::Dice::Polyhedron</a>
84
+
85
+ <li><a href="./Silicium/Dice/PolyhedronSet.html">Silicium::Dice::PolyhedronSet</a>
86
+
87
+ <li><a href="./Silicium/Error.html">Silicium::Error</a>
88
+
89
+ <li><a href="./Silicium/Geometry.html">Silicium::Geometry</a>
90
+
91
+ <li><a href="./Silicium/Geometry/Line2dCanon.html">Silicium::Geometry::Line2dCanon</a>
92
+
93
+ <li><a href="./Silicium/Geometry/VariablesOrderException.html">Silicium::Geometry::VariablesOrderException</a>
94
+
95
+ <li><a href="./Silicium/Graphs.html">Silicium::Graphs</a>
96
+
97
+ <li><a href="./Silicium/Graphs/GraphError.html">Silicium::Graphs::GraphError</a>
98
+
99
+ <li><a href="./Silicium/Graphs/OrientedGraph.html">Silicium::Graphs::OrientedGraph</a>
100
+
101
+ <li><a href="./Silicium/Graphs/UnorientedGraph.html">Silicium::Graphs::UnorientedGraph</a>
102
+
103
+ <li><a href="./Silicium/IntegralDoesntExistError.html">Silicium::IntegralDoesntExistError</a>
104
+
105
+ <li><a href="./Silicium/NumericalIntegration.html">Silicium::NumericalIntegration</a>
106
+
107
+ <li><a href="./Silicium/Optimization.html">Silicium::Optimization</a>
108
+
109
+ <li><a href="./Silicium/Plotter.html">Silicium::Plotter</a>
110
+
111
+ <li><a href="./Silicium/Plotter/Image.html">Silicium::Plotter::Image</a>
112
+
113
+ <li><a href="./Silicium/GraphVisualizer.html">Silicium::GraphVisualizer</a>
114
+
115
+ </ul>
116
+ </div>
117
+
118
+ </div>
119
+ </nav>
120
+
121
+ <main role="main">
122
+
123
+ <p>This is the API documentation for RDoc Documentation.
124
+
125
+ </main>
126
+
127
+
128
+
129
+ <footer id="validator-badges" role="contentinfo">
130
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
131
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
132
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
133
+ </footer>
134
+
data/docs/js/darkfish.js CHANGED
@@ -1,84 +1,84 @@
1
- /**
2
- *
3
- * Darkfish Page Functions
4
- * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
5
- *
6
- * Author: Michael Granger <mgranger@laika.com>
7
- *
8
- */
9
-
10
- /* Provide console simulation for firebug-less environments */
11
- /*
12
- if (!("console" in window) || !("firebug" in console)) {
13
- var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
14
- "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
15
-
16
- window.console = {};
17
- for (var i = 0; i < names.length; ++i)
18
- window.console[names[i]] = function() {};
19
- };
20
- */
21
-
22
-
23
- function showSource( e ) {
24
- var target = e.target;
25
- while (!target.classList.contains('method-detail')) {
26
- target = target.parentNode;
27
- }
28
- if (typeof target !== "undefined" && target !== null) {
29
- target = target.querySelector('.method-source-code');
30
- }
31
- if (typeof target !== "undefined" && target !== null) {
32
- target.classList.toggle('active-menu')
33
- }
34
- };
35
-
36
- function hookSourceViews() {
37
- document.querySelectorAll('.method-heading').forEach(function (codeObject) {
38
- codeObject.addEventListener('click', showSource);
39
- });
40
- };
41
-
42
- function hookSearch() {
43
- var input = document.querySelector('#search-field');
44
- var result = document.querySelector('#search-results');
45
- result.classList.remove("initially-hidden");
46
-
47
- var search_section = document.querySelector('#search-section');
48
- search_section.classList.remove("initially-hidden");
49
-
50
- var search = new Search(search_data, input, result);
51
-
52
- search.renderItem = function(result) {
53
- var li = document.createElement('li');
54
- var html = '';
55
-
56
- // TODO add relative path to <script> per-page
57
- html += '<p class="search-match"><a href="' + index_rel_prefix + result.path + '">' + this.hlt(result.title);
58
- if (result.params)
59
- html += '<span class="params">' + result.params + '</span>';
60
- html += '</a>';
61
-
62
-
63
- if (result.namespace)
64
- html += '<p class="search-namespace">' + this.hlt(result.namespace);
65
-
66
- if (result.snippet)
67
- html += '<div class="search-snippet">' + result.snippet + '</div>';
68
-
69
- li.innerHTML = html;
70
-
71
- return li;
72
- }
73
-
74
- search.select = function(result) {
75
- window.location.href = result.firstChild.firstChild.href;
76
- }
77
-
78
- search.scrollIntoView = search.scrollInWindow;
79
- };
80
-
81
- document.addEventListener('DOMContentLoaded', function() {
82
- hookSourceViews();
83
- hookSearch();
84
- });
1
+ /**
2
+ *
3
+ * Darkfish Page Functions
4
+ * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
5
+ *
6
+ * Author: Michael Granger <mgranger@laika.com>
7
+ *
8
+ */
9
+
10
+ /* Provide console simulation for firebug-less environments */
11
+ /*
12
+ if (!("console" in window) || !("firebug" in console)) {
13
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
14
+ "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
15
+
16
+ window.console = {};
17
+ for (var i = 0; i < names.length; ++i)
18
+ window.console[names[i]] = function() {};
19
+ };
20
+ */
21
+
22
+
23
+ function showSource( e ) {
24
+ var target = e.target;
25
+ while (!target.classList.contains('method-detail')) {
26
+ target = target.parentNode;
27
+ }
28
+ if (typeof target !== "undefined" && target !== null) {
29
+ target = target.querySelector('.method-source-code');
30
+ }
31
+ if (typeof target !== "undefined" && target !== null) {
32
+ target.classList.toggle('active-menu')
33
+ }
34
+ };
35
+
36
+ function hookSourceViews() {
37
+ document.querySelectorAll('.method-heading').forEach(function (codeObject) {
38
+ codeObject.addEventListener('click', showSource);
39
+ });
40
+ };
41
+
42
+ function hookSearch() {
43
+ var input = document.querySelector('#search-field');
44
+ var result = document.querySelector('#search-results');
45
+ result.classList.remove("initially-hidden");
46
+
47
+ var search_section = document.querySelector('#search-section');
48
+ search_section.classList.remove("initially-hidden");
49
+
50
+ var search = new Search(search_data, input, result);
51
+
52
+ search.renderItem = function(result) {
53
+ var li = document.createElement('li');
54
+ var html = '';
55
+
56
+ // TODO add relative path to <script> per-page
57
+ html += '<p class="search-match"><a href="' + index_rel_prefix + result.path + '">' + this.hlt(result.title);
58
+ if (result.params)
59
+ html += '<span class="params">' + result.params + '</span>';
60
+ html += '</a>';
61
+
62
+
63
+ if (result.namespace)
64
+ html += '<p class="search-namespace">' + this.hlt(result.namespace);
65
+
66
+ if (result.snippet)
67
+ html += '<div class="search-snippet">' + result.snippet + '</div>';
68
+
69
+ li.innerHTML = html;
70
+
71
+ return li;
72
+ }
73
+
74
+ search.select = function(result) {
75
+ window.location.href = result.firstChild.firstChild.href;
76
+ }
77
+
78
+ search.scrollIntoView = search.scrollInWindow;
79
+ };
80
+
81
+ document.addEventListener('DOMContentLoaded', function() {
82
+ hookSourceViews();
83
+ hookSearch();
84
+ });
@@ -1,105 +1,105 @@
1
- /*
2
- * Navigation allows movement using the arrow keys through the search results.
3
- *
4
- * When using this library you will need to set scrollIntoView to the
5
- * appropriate function for your layout. Use scrollInWindow if the container
6
- * is not scrollable and scrollInElement if the container is a separate
7
- * scrolling region.
8
- */
9
- Navigation = new function() {
10
- this.initNavigation = function() {
11
- var _this = this;
12
-
13
- document.addEventListener('keydown', function(e) {
14
- _this.onkeydown(e);
15
- });
16
-
17
- this.navigationActive = true;
18
- }
19
-
20
- this.setNavigationActive = function(state) {
21
- this.navigationActive = state;
22
- }
23
-
24
- this.onkeydown = function(e) {
25
- if (!this.navigationActive) return;
26
- switch(e.keyCode) {
27
- case 37: //Event.KEY_LEFT:
28
- if (this.moveLeft()) e.preventDefault();
29
- break;
30
- case 38: //Event.KEY_UP:
31
- if (e.keyCode == 38 || e.ctrlKey) {
32
- if (this.moveUp()) e.preventDefault();
33
- }
34
- break;
35
- case 39: //Event.KEY_RIGHT:
36
- if (this.moveRight()) e.preventDefault();
37
- break;
38
- case 40: //Event.KEY_DOWN:
39
- if (e.keyCode == 40 || e.ctrlKey) {
40
- if (this.moveDown()) e.preventDefault();
41
- }
42
- break;
43
- case 13: //Event.KEY_RETURN:
44
- if (this.current) e.preventDefault();
45
- this.select(this.current);
46
- break;
47
- }
48
- if (e.ctrlKey && e.shiftKey) this.select(this.current);
49
- }
50
-
51
- this.moveRight = function() {
52
- }
53
-
54
- this.moveLeft = function() {
55
- }
56
-
57
- this.move = function(isDown) {
58
- }
59
-
60
- this.moveUp = function() {
61
- return this.move(false);
62
- }
63
-
64
- this.moveDown = function() {
65
- return this.move(true);
66
- }
67
-
68
- /*
69
- * Scrolls to the given element in the scrollable element view.
70
- */
71
- this.scrollInElement = function(element, view) {
72
- var offset, viewHeight, viewScroll, height;
73
- offset = element.offsetTop;
74
- height = element.offsetHeight;
75
- viewHeight = view.offsetHeight;
76
- viewScroll = view.scrollTop;
77
-
78
- if (offset - viewScroll + height > viewHeight) {
79
- view.scrollTop = offset - viewHeight + height;
80
- }
81
- if (offset < viewScroll) {
82
- view.scrollTop = offset;
83
- }
84
- }
85
-
86
- /*
87
- * Scrolls to the given element in the window. The second argument is
88
- * ignored
89
- */
90
- this.scrollInWindow = function(element, ignored) {
91
- var offset, viewHeight, viewScroll, height;
92
- offset = element.offsetTop;
93
- height = element.offsetHeight;
94
- viewHeight = window.innerHeight;
95
- viewScroll = window.scrollY;
96
-
97
- if (offset - viewScroll + height > viewHeight) {
98
- window.scrollTo(window.scrollX, offset - viewHeight + height);
99
- }
100
- if (offset < viewScroll) {
101
- window.scrollTo(window.scrollX, offset);
102
- }
103
- }
104
- }
105
-
1
+ /*
2
+ * Navigation allows movement using the arrow keys through the search results.
3
+ *
4
+ * When using this library you will need to set scrollIntoView to the
5
+ * appropriate function for your layout. Use scrollInWindow if the container
6
+ * is not scrollable and scrollInElement if the container is a separate
7
+ * scrolling region.
8
+ */
9
+ Navigation = new function() {
10
+ this.initNavigation = function() {
11
+ var _this = this;
12
+
13
+ document.addEventListener('keydown', function(e) {
14
+ _this.onkeydown(e);
15
+ });
16
+
17
+ this.navigationActive = true;
18
+ }
19
+
20
+ this.setNavigationActive = function(state) {
21
+ this.navigationActive = state;
22
+ }
23
+
24
+ this.onkeydown = function(e) {
25
+ if (!this.navigationActive) return;
26
+ switch(e.keyCode) {
27
+ case 37: //Event.KEY_LEFT:
28
+ if (this.moveLeft()) e.preventDefault();
29
+ break;
30
+ case 38: //Event.KEY_UP:
31
+ if (e.keyCode == 38 || e.ctrlKey) {
32
+ if (this.moveUp()) e.preventDefault();
33
+ }
34
+ break;
35
+ case 39: //Event.KEY_RIGHT:
36
+ if (this.moveRight()) e.preventDefault();
37
+ break;
38
+ case 40: //Event.KEY_DOWN:
39
+ if (e.keyCode == 40 || e.ctrlKey) {
40
+ if (this.moveDown()) e.preventDefault();
41
+ }
42
+ break;
43
+ case 13: //Event.KEY_RETURN:
44
+ if (this.current) e.preventDefault();
45
+ this.select(this.current);
46
+ break;
47
+ }
48
+ if (e.ctrlKey && e.shiftKey) this.select(this.current);
49
+ }
50
+
51
+ this.moveRight = function() {
52
+ }
53
+
54
+ this.moveLeft = function() {
55
+ }
56
+
57
+ this.move = function(isDown) {
58
+ }
59
+
60
+ this.moveUp = function() {
61
+ return this.move(false);
62
+ }
63
+
64
+ this.moveDown = function() {
65
+ return this.move(true);
66
+ }
67
+
68
+ /*
69
+ * Scrolls to the given element in the scrollable element view.
70
+ */
71
+ this.scrollInElement = function(element, view) {
72
+ var offset, viewHeight, viewScroll, height;
73
+ offset = element.offsetTop;
74
+ height = element.offsetHeight;
75
+ viewHeight = view.offsetHeight;
76
+ viewScroll = view.scrollTop;
77
+
78
+ if (offset - viewScroll + height > viewHeight) {
79
+ view.scrollTop = offset - viewHeight + height;
80
+ }
81
+ if (offset < viewScroll) {
82
+ view.scrollTop = offset;
83
+ }
84
+ }
85
+
86
+ /*
87
+ * Scrolls to the given element in the window. The second argument is
88
+ * ignored
89
+ */
90
+ this.scrollInWindow = function(element, ignored) {
91
+ var offset, viewHeight, viewScroll, height;
92
+ offset = element.offsetTop;
93
+ height = element.offsetHeight;
94
+ viewHeight = window.innerHeight;
95
+ viewScroll = window.scrollY;
96
+
97
+ if (offset - viewScroll + height > viewHeight) {
98
+ window.scrollTo(window.scrollX, offset - viewHeight + height);
99
+ }
100
+ if (offset < viewScroll) {
101
+ window.scrollTo(window.scrollX, offset);
102
+ }
103
+ }
104
+ }
105
+