-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·113 lines (91 loc) · 4.04 KB
/
index.html
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
<!--
Henriksens-Algorithm: A software to visualize Henriksens Algorithm.
Copyright (C) 2016 Christian Heiden
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>Henricksens Algorithm</title>
<!-- Bootstrap -->
<link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body onload="initialize();">
<div class="container">
<h1>Henriksens Algorithm <small>built by <a href="https://github.com/BobMcFry">BobMcFry</a> (<a href="https://github.com/BobMcFry/henriksen-algorithm">Repository</a>)</small></h1>
<div class="row">
<div class="col-lg-4">
<div class="input-group">
<input id="insert-input" type="text" class="form-control" placeholder="Integer event time(s) to insert..">
<span class="input-group-btn">
<button id="help-button" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="bottom" title="Enter Integer time value greater than the current time (initially 0). Space separated lists of int values will be inserted from left to right.">?</button>
<button id="insert-button" class="btn btn-success" type="button">Insert</button>
</span>
</div>
</div>
<div class="col-lg-2">
<div class="input-group">
<button id="remove-button" type="button" class="btn btn-danger">Remove!</button>
</div>
</div>
<div class="col-lg-6">
<div class="input-group">
</div>
</div>
</div>
</div>
<div class="container">
<div id="debugCon" style="font-family:Consolas,Monaco,Lucida Console,Courier New, monospace;">
</div>
</div>
<script src="src/eventList.js"></script>
<script src="src/output.js"></script>
<script type="text/javascript" src="bower_components/jquery/dist/jquery.slim.min.js"></script>
<script type="text/javascript" src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="bower_components/sprintf/dist/sprintf.min.js"></script>
<script type="text/javascript">
function initialize() {
algo = new HenAlgorithm();
drawy = new HenAlgorithmOut(algo);
$("#insert-button").on("click", insert);
$('#insert-input').keypress(function(e){
if(e.which == 13){
$('#insert-button').click();
}
});
$("#remove-button").on("click", remove);
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
}
function insert() {
var input = $("#insert-input").val().trim().match(/\S+/g) || [];
for (var i = input.length - 1; i >= 0; i--) {
var no = Number.parseInt(input[i]);
var ret = algo.insert(no);
if (ret !== null) {
debugCon(sprintf("Inserted: %4d (current time: %6d)", no, algo.getCurrentTime()), drawy.getStringRepresentation());
}
}
}
function remove() {
var output = algo.next();
if (output !== null) {
debugCon(sprintf("Removed: %4d (current time: %6d)",output.time, algo.getCurrentTime()), drawy.getStringRepresentation());
}
}
</script>
</body>
</html>