-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicClock.html
More file actions
207 lines (178 loc) · 7.64 KB
/
basicClock.html
File metadata and controls
207 lines (178 loc) · 7.64 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>My Graphs</title>
<link rel="stylesheet" href="">
<style>
.line-svg{
background-color: yellowgreen;
}
.line-class{
stroke: black;
stroke-width: 2
}
#myCanvas{
border: 1px solid red;
}
#cy {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
}
#cyline {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
}
</style>
</head>
<body>
<h1>Welcome to my Graphs....</h1>
<p>It's My TIME!!..... :) :)</p>
<!-- <canvas id="myCanvas" width="400" height="200"></canvas>
<svg width="500" height="210" class="line-svg">
<line class="line-class" x1="0" y1="0" x2="200" y2="200" />
</svg> -->
<div id="cyline"></div>
<!-- <div id="cy"></div> -->
<script>
// for Canvas....
// var canvas = document.getElementById("myCanvas");
// var ctx = canvas.getContext("2d");
// ctx.moveTo(0,0);
// ctx.lineTo(200,100);
// ctx.stroke();
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.2.20/cytoscape.min.js"></script>
<script>
// for Cytoscape....
// var cy = cytoscape({
// container: document.getElementById('cy')
// });
var cyline = cytoscape({
container: document.getElementById('cyline'),
style: [
{
selector: 'node',
style: {
'background-color': 'darkgray'
// 'label': 'h',
// 'text-valign': i
}
},
{
selector: 'edge',
style: {
'width': 2,
'line-color': 'white',
'target-arrow-color': '#808000',
'target-arrow-shape': 'triangle',
'curve-style': 'bezier'
}
}
]
});
function drawCircle(){
cyline.add({
data: { id: 'smcenter'}
}
);
cyline.$('#smcenter').style({'label': 'Clock', 'text-valign': 'center', 'text-halign': 'center', 'color': 'white', 'font-size': '10px'})
// For Hours-12
cyline.add({
data: { id: 'hour-12'}
}
);
cyline.add({
data: {
id: 'line-12',
source: 'smcenter',
target: 'hour-12'
}
});
cyline.$('#hour-12').style({'label': '12', 'text-valign': 'center', 'text-halign': 'center'})
// For Hours
for (var i = 1; i <= 11; i++) {
cyline.add({
data: { id: 'hour-' + i }
}
);
var target = 'hour-' + i;
cyline.add({
data: {
id: 'line-' + i,
source: 'smcenter',
target: target
}
});
cyline.$('#hour-'+i).style({'label': i, 'text-valign': 'center', 'text-halign': 'center'})
}
// cyline.$("#smcenter")
// .style('background-color', 'white');
// cyline.$("#line-10")
// .style('line-color', 'red');
}
function setTimeLine(){
cyline.$('edge').style({'width': 2,'line-color': 'white',
'target-arrow-shape': 'triangle',
'target-arrow-color': 'white',
'line-color': 'white'});
cyline.$('node').style({'border-color': 'darkgray', 'border-width': 1, 'background-color': 'white', 'color': 'black'});
cyline.$("#smcenter")
.style({'background-color': '#F4D03F', 'border-color': '#616A6B', 'border-width': 1, 'color': '#3498DB'});
var hours = new Date().getHours();
hours = ((hours + 11) % 12 + 1);
var mins = new Date().getMinutes();
mins = Math.round(mins/5);
mins = mins || 1;
var secnds = new Date().getSeconds();
secnds = Math.round(secnds/5);
secnds = secnds || 1;
var mins = new Date().getMinutes();
var secnds = new Date().getSeconds();
var secndslineid = '#line-'+secnds;
var minslineid = '#line-'+mins;
var hourslineid = '#line-'+hours;
var secndsid = '#hour-'+secnds;
var minsid = '#hour-'+mins;
var hoursid = '#hour-'+hours;
cyline.$(secndslineid)
.style({'line-color': '#A569BD', 'width': 2,
'target-arrow-shape': 'triangle',
'target-arrow-color': '#A569BD',
'line-color': '#A569BD'});
cyline.$(minslineid)
.style({'line-color': '#27AE60', 'width': 3,
'target-arrow-shape': 'triangle',
'target-arrow-color': '#27AE60',
'line-color': '#27AE60'});
cyline.$(hourslineid)
.style({'line-color': '#E74C3C ', 'width': 4,
'target-arrow-shape': 'triangle',
'target-arrow-color': '#E74C3C ',
'line-color': '#E74C3C '});
cyline.$(secndsid)
.style({'background-color': '#A569BD', 'color': 'white'});
cyline.$(minsid)
.style({'background-color': '#27AE60', 'color': 'white'});
cyline.$(hoursid)
.style({'background-color': '#E74C3C ', 'color': 'white'});
}
function initializeClock(){
drawCircle();
setTimeLine();
cyline.layout({
name: 'concentric'
}).run();
}
initializeClock();
setInterval(function(){
setTimeLine();
}, 3000);
</script>
</body>
</html>