-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.xhtml
107 lines (93 loc) · 2.62 KB
/
index.xhtml
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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
pure-knob: Test
</title>
<script src="pureknob.js" type="text/javascript"></script>
<script type="text/javascript">
// <![CDATA[
/*
* Demo code for knob element.
*/
function demoKnob() {
// Create knob element, 300 x 300 px in size.
const knob = pureknob.createKnob(300, 300);
// Set properties.
knob.setProperty('angleStart', -0.75 * Math.PI);
knob.setProperty('angleEnd', 0.75 * Math.PI);
knob.setProperty('colorFG', '#88ff88');
knob.setProperty('trackWidth', 0.4);
knob.setProperty('valMin', 0);
knob.setProperty('valMax', 100);
// Set initial value.
knob.setValue(50);
/*
* Event listener.
*
* Parameter 'knob' is the knob object which was
* actuated. Allows you to associate data with
* it to discern which of your knobs was actuated.
*
* Parameter 'value' is the value which was set
* by the user.
*/
const listener = function(knob, value) {
console.log(value);
};
knob.addListener(listener);
// Create element node.
const node = knob.node();
// Add it to the DOM.
const elem = document.getElementById('some_element');
elem.appendChild(node);
}
/*
* Demo code for bar graph element.
*/
function demoBarGraph() {
const body = document.getElementsByTagName('body')[0];
const graph = pureknob.createBarGraph(400, 40);
graph.setProperty('colorFG', '#44ff44');
graph.setProperty('colorMarkers', '#ffffff');
graph.setProperty('markerStart', -60);
graph.setProperty('markerEnd', 0);
graph.setProperty('markerStep', 10);
graph.setProperty('valMin', -145);
graph.setProperty('valMax', 0);
graph.setValue(-25);
graph.setPeaks([-18]);
const node = graph.node();
body.appendChild(node);
window.graph = graph;
/*
* This is executed on each timer tick.
*/
const t = function(e) {
let v = graph.getValue();
/*
* As long as value is greater than -80, decrement it.
*/
if (v > -80) {
v--;
graph.setValue(v);
}
};
window.setInterval(t, 200);
}
/*
* This is executed after the document finished loading.
*/
function ready() {
demoKnob();
demoBarGraph();
}
document.addEventListener('DOMContentLoaded', ready, false);
// ]]>
</script>
</head>
<body style="background-color: #444444">
<div id="some_element"/>
</body>
</html>