-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcircle.html
More file actions
92 lines (81 loc) · 2.43 KB
/
circle.html
File metadata and controls
92 lines (81 loc) · 2.43 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
<!DOCTYPE html>
<html>
<head>
<title>Hacker Club Project One</title>
<script type="text/javascript" src="http://l2.io/ip.js?var=myip"></script>
<script src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="src/d3/d3.js"></script>
<script>
// Socket.io Initialization
var socket = io.connect();
var gClient = {};
// Custom metrics objects
var randId = Math.floor(Math.random()*1000000000);
// Merge - takes all properties from src and add them to dest.
function merge(dest, src) {
Object.keys(src).forEach(function(key) {dest[key] = src[key]});
}
function Shlock(kind, method, url) {
this.kind = kind;
this.method = method;
this.url = url;
this.time = new Date().toJSON();
};
// Tracking IP of visitors, logging time as well.
function Client(IP, ID) {
this.IP = IP;
this.ID = ID;
};
Client.prototype.toString = function() {
var self = this;
return this.IP+' '+this.ID;
}
function clientIp() {
console.log('Executing clientIp');
var client = new Client(myip, randId);
console.log(client);
var ev = new Shlock('web', 'client', '/circle.html');
merge(ev,client);
console.log(ev);
socket.emit('client', ev);
console.log(myip);
}
setTimeout(clientIp,1000);
</script>
</head>
<body>
<p>
This page is part of a project on <a href="https://github.com/garrettwilkin/HackerClubProjectOne">github</a>.
<br>
Authored by: <a href="https://github.com/garrettwilkin">Garrett Wilkin</a>
<br>
</p>
<div id="wow1"></div>
<script type="text/javascript">
var wow1 = d3.select("#wow1")
.append("svg")
.attr("width", 300)
.attr("height", 300);
wow1.append("circle")
.style("stroke", "gray")
.style("fill", "yellow")
.attr("r", 90)
.attr("cx", 100)
.attr("cy", 100);
socket.on('pulse', function(data) {
console.log(data.r);
console.log(data.fill);
var circle = wow1.selectAll("circle");
circle.transition()
.duration(1000)
.attr("r",data.r)
.style("fill",data.fill);
console.log(data);
});
</script>
<p>
Use this command to update the radius and color of the circle:<br>
curl -i -H "Content-type: application/json" -X POST http://hc1.goodnyou.me/pulse -d '{"r":"60","fill":"green"}'
</p>
</body>
</html>