-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex3.html
More file actions
172 lines (158 loc) · 4.98 KB
/
index3.html
File metadata and controls
172 lines (158 loc) · 4.98 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
<!DOCTYPE html>
<html>
<head>
<title>球面ディスプレイ画面</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="/socket.io/socket.io.js"></script>
</head>
<body>
<script>
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
// Socket.IOを使って接続
var socket = io.connect(location.origin);
var label;
var roomID;
$(function () {
// ルームID(1234)を作成
roomID = 1234;
// roomIDに入室
socket.emit("pairingFromMain", {
"roomID": roomID
});
// サーバーからsuccessPairingというデータを受信
socket.on("successPairing", function(){
//
});
// サーバーからresChatというデータを受信
//user1
var width = 1000;
var height = 800;
var nodes = [
{id:0, label:socket.on("resChat", function (data) {
$("#chatLogs1").append("<div>" + data.value + "</div>");
}).value},
{id:1, label:socket.on("resChat1", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:2, label:socket.on("resChat2", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:3, label:socket.on("resChat3", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:4, label:socket.on("resChat0-2", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:5, label:socket.on("resChat4", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:6, label:socket.on("resChat5", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:7, label:socket.on("resChat6", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:8, label:socket.on("resChat0-3", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:9, label:socket.on("resChat7", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:10, label:socket.on("resChat8", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
{id:11, label:socket.on("resChat9", function (data) {
$("#chatLogs").append("<div>" + data.value + "</div>");
})},
];
var links = [
{source:0, target:1},
{source:0, target:2},
{source:0, target:3},
{source:1, target:2},
{source:3, target:1},
{source:2, target:3},
{source:4, target:5},
{source:4, target:6},
{source:4, target:7},
{source:5, target:6},
{source:7, target:5},
{source:6, target:7},
{source:8, target:9},
{source:8, target:10},
{source:8, target:11},
{source:9, target:10},
{source:11, target:9},
{source:10, target:11},
];
var force = d3.layout.force()
.nodes(nodes)
.links(links)
.size([width, height])
.distance(150) // node同士の距離
.charge(-1000)
.start();
var svg = d3.select("body")
.append("svg")
.attr({width:width, height:height});
var link = svg.selectAll("line")
.data(links)
.enter()
.append("line")
.style({stroke: "#ccc",
"stroke-width": 1.0
});
var node = svg.selectAll("circle")
.data(nodes)
.enter()
.append("circle")
.attr("r", 48)
.style({
fill: "grey"
})
.call(force.drag);
// nodeのラベル周りの設定
var label = svg.selectAll('text')
.data(nodes)
.enter()
.append('text')
.attr({
"text-anchor":"middle",
"fill":"white",
"font-size": "18px"
})
.text(function(data) { return data.label; });
// tickイベント(力学計算が起こるたびに呼ばれるらしいので、座標追従などはここで)
force.on("tick", function() {
link.attr({
x1: function(data) { return data.source.x;},
y1: function(data) { return data.source.y;},
x2: function(data) { return data.target.x;},
y2: function(data) { return data.target.y;}
});
node.attr({
cx: function(data) { return data.x;},
cy: function(data) { return data.y;}
});
label.attr({
x: function(data) { return data.x;},
y: function(data) { return data.y;}
});
});
});
</script>
<div id="main">
<div id="chatLogs"></div>
</div>
</body>
</html>