-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseven_segment_display_page.js
More file actions
93 lines (76 loc) · 3.25 KB
/
seven_segment_display_page.js
File metadata and controls
93 lines (76 loc) · 3.25 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
let APP =
{
SSD: null,
Counting: false,
Interval: null
}
window.onload = function()
{
APP.SSD = new SevenSegmentDisplay("SVGSSD");
SetEventHandlers();
}
function SetEventHandlers()
{
document.getElementById("udNumberOfDigits").onchange = function(){APP.SSD.NumberOfDigits = parseInt(document.getElementById("udNumberOfDigits").value);};
document.getElementById("udNumberOfDecimalPlaces").onchange = function(){APP.SSD.NumberOfDecimalPlaces = parseInt(document.getElementById("udNumberOfDecimalPlaces").value);};
document.getElementById("udValue").onchange = function(){APP.SSD.Value = parseFloat(document.getElementById("udValue").value);};
document.getElementById("colBackgroundColor").onchange = function () { APP.SSD.BackgroundColor = document.getElementById("colBackgroundColor").value; };
document.getElementById("colLitSegmentColor").onchange = function () { APP.SSD.LitSegmentColor = document.getElementById("colLitSegmentColor").value; };
document.getElementById("colUnlitSegmentColor").onchange = function () { APP.SSD.UnlitSegmentColor = document.getElementById("colUnlitSegmentColor").value; };
let decimalpoint_radios = document.getElementsByName("rdoDecimalPointType");
for(let i = 0; i < decimalpoint_radios.length; decimalpoint_radios[i].onchange = function(Sender){SetDecimalPointType(this);}, i++);
let color_radios = document.getElementsByName("rdoColorScheme");
for(let i = 0; i < color_radios.length; color_radios[i].onchange = function(Sender){SetColorScheme(this);}, i++);
document.getElementById("btnStart").onclick = function(){Start();};
}
function SetDecimalPointType(Sender)
{
if (Sender.value == "Fixed")
APP.SSD.DecimalPointType = APP.SSD.DecimalPointTypes.Fixed;
else
APP.SSD.DecimalPointType = APP.SSD.DecimalPointTypes.Floating;
}
function SetColorScheme(Sender)
{
switch (Sender.value)
{
case "LCD":
APP.SSD.ColorScheme = APP.SSD.ColorSchemes.LCD;
break;
case "Green":
APP.SSD.ColorScheme = APP.SSD.ColorSchemes.Green;
break;
case "Orange":
APP.SSD.ColorScheme = APP.SSD.ColorSchemes.Orange;
break;
case "Blue":
APP.SSD.ColorScheme = APP.SSD.ColorSchemes.Blue;
break;
case "Sky":
APP.SSD.ColorScheme = APP.SSD.ColorSchemes.Sky;
break;
case "Red":
APP.SSD.ColorScheme = APP.SSD.ColorSchemes.Red;
break;
default:
break;
}
document.getElementById("colBackgroundColor").value = APP.SSD.BackgroundColor;
document.getElementById("colLitSegmentColor").value = APP.SSD.LitSegmentColor;
document.getElementById("colUnlitSegmentColor").value = APP.SSD.UnlitSegmentColor;
}
function Start()
{
if (APP.Counting == true)
{
APP.Counting = false;
clearInterval(APP.Interval);
document.getElementById("btnStart").innerHTML = "Start";
}
else
{
APP.Interval = setInterval(function () { APP.SSD.Value = APP.SSD.Value + 1; }, 1000);
APP.Counting = true;
document.getElementById("btnStart").innerHTML = "Stop";
}
}