-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
101 lines (94 loc) · 3.89 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
<html>
<head>
<script type="text/javascript" src="mogman1/encodings/models/EncodingView.js"></script>
<script type="text/javascript" src="mogman1/encodings/models/AbstractEncoding.js"></script>
<script type="text/javascript" src="mogman1/encodings/models/NRZ.js"></script>
<script type="text/javascript" src="mogman1/encodings/models/NRZI.js"></script>
<script type="text/javascript" src="mogman1/encodings/models/Manchester.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
<style type="text/css">
i {
color: red; cursor: pointer;
}
</style>
</head>
<body>
<div id="encodingDiv" style="width: 500px;"></div>
<div>
<input type="text" id="sequence" value="0110100" />
<button id="updateSequenceButton" onclick="updateSequence();">Update Sequence</button>
<br />
<br />
<select id="encodingType" onchange="showSequenceOptions();">
<option value=""></option>
<option value="NRZ">NRZ</option>
<option value="NRZI">NRZI</option>
<option value="Manchester">Manchester</option>
</select>
<select id="startPosition" style="display: none;">
<option value="">Start Position</option>
<option value="high">High</option>
<option value="low">Low</option>
</select>
<select id="bitWidth" style="display: none;">
<option value="">Bit Width</option>
<option value="40">Normal</option>
<option value="20">Half</option>
</select>
<button id="addEncoding" onclick="addEncoding();">Add Encoding</button>
<br />
<br />
Speed:
<input type="range" min="0" max="10" step="1" id="speed" value="2" onchange="updateSpeed();" />
</div>
<div id="errors" style="color: red;"></div>
<script type="text/javascript">
clock = new mogman1.encodings.models.EncodingView(document.getElementById('encodingDiv'), 500);
updateSpeed();
updateSequence();
clock.addEncoding('Manchester', '', '40');
clock.addEncoding('Manchester', '', '20');
clock.addEncoding('NRZ', '');
clock.addEncoding('NRZI', 'high');
function addEncoding() {
var type = document.getElementById('encodingType').value;
var startPosition = document.getElementById('startPosition').value;
var bitWidth = document.getElementById('bitWidth').value;
if (type) {
try {
clock.addEncoding(type, startPosition, bitWidth);
document.getElementById('encodingType').value = '';
document.getElementById('startPosition').value = '';
document.getElementById('startPosition').style.display = 'none';
document.getElementById('bitWidth').value = '';
document.getElementById('bitWidth').style.display = 'none';
} catch (e) {
console.log(e);
document.getElementById('errors').innerHTML = e;
setTimeout(function() { document.getElementById('errors').innerHTML = ''; }, 5000);
}
}
}
function updateSequence() {
clock.setSequence(document.getElementById('sequence').value);
}
function updateSpeed() {
clock.setSpeed(document.getElementById('speed').value);
}
function removeEncoding(encodingId) {
clock.removeEncoding(encodingId);
}
function showSequenceOptions() {
document.getElementById('startPosition').style.display = 'none';
document.getElementById('bitWidth').style.display = 'none';
var type = document.getElementById('encodingType').value;
switch (type) {
case 'NRZI':
document.getElementById('startPosition').style.display = ''; break;
case 'Manchester':
document.getElementById('bitWidth').style.display = ''; break;
}
}
</script>
</body>
</html>