-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrolx.html
277 lines (258 loc) · 7.69 KB
/
controlx.html
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://code.interactjs.io/v1.3.4/interact.min.js"></script>
<script>
// target elements with the "draggable" class
interact('.draggable')
.draggable({
// enable inertial throwing
inertia: true,
// keep the element within the area of it's parent
restrict: {
restriction: "parent",
endOnly: true,
elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
},
// enable autoScroll
autoScroll: true,
// call this function on every dragmove event
onmove: dragMoveListener,
// call this function on every dragend event
onend: function (event) {
var textEl = event.target.querySelector('p');
textEl && (textEl.textContent =
'moved a distance of '
+ (Math.sqrt(Math.pow(event.pageX - event.x0, 2) +
Math.pow(event.pageY - event.y0, 2) | 0))
.toFixed(2) + 'px');
}
});
var ws = new WebSocket("ws://127.0.0.1:5678/")
var yValue2 = "";
var ycurrentwindow = "";
var currentvalue = 0;
ws.onmessage = function (event) {
var wholedata = event.data;
alert(event.data)
var res2 = wholedata;
yValue2 = res2;
};
function dragMoveListener (event) {
var target = event.target,
// keep the dragged position in the data-x/data-y attributes
x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
// translate the element
target.style.webkitTransform =
target.style.transform =
'translate(' + x + 'px, ' + y + 'px)';
// update the posiion attributes
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
}
// this is used later in the resizing and gesture demos
window.dragMoveListener = dragMoveListener;
$.change1 = function() {
if ($('#d3').width="25%"){
$('#d3').animate({width: "0%",height: "0%"});
}
if ($('#d2').width="25%"){
$('#d2').animate({width: "0%",height: "0%"});
}
if ($('container').width<="100%"){
$('container').animate({width: "100%",height: "100%"});
}
if ($('#d1').width=100){
$('#d1').animate({width: "1400px",height: "700px"});
}
};
$.change2 = function() {
if ($('#d1').width="25%"){
$('#d1').animate({width: "0%",height: "0%"});
}
if ($('#d3').width="25%"){
$('#d3').animate({width: "0%",height: "0%"});
}
if ($('container').width<="100%"){
$('container').animate({width: "100%",height: "100%"});
}
if ($('#d2').width=100){
$('#d2').animate({width: "1650px",height: "700px"});
}
};
$.change3 = function() {
if ($('#d1').width="25%"){
$('#d1').animate({width: "0%",height: "0%"});
}
if ($('#d2').width="25%"){
$('#d2').animate({width: "0%",height: "0%"});
}
if ($('container').width<="100%"){
$('container').animate({width: "100%",height: "100%"});
}
if ($('#d3').width=100){
$('#d3').animate({width: "1650px",height: "700px"});
}
};
function change1html() {
$.change1();
};
function change2html() {
$.change2();
};
function change3html() {
$.change3();
};
$(document).ready(function() {
$('#d1').hover(function(){
if ($('#d3').width="25%"){
$('#d3').animate({width: "0%",height: "0%"});
}
if ($('#d2').width="25%"){
$('#d2').animate({width: "0%",height: "0%"});
}
if ($('container').width<="100%"){
$('container').animate({width: "100%",height: "100%"});
}
if ($('#d1').width=100){
$('#d1').animate({width: "1400px",height: "700px"});
}
});
$('#d2').hover(function(){
if ($('#d1').width="25%"){
$('#d1').animate({width: "0%",height: "0%"});
}
if ($('#d3').width="25%"){
$('#d3').animate({width: "0%",height: "0%"});
}
if ($('container').width<="100%"){
$('container').animate({width: "100%",height: "100%"});
}
if ($('#d2').width=100){
$('#d2').animate({width: "1650px",height: "700px"});
}
});
$('#d3').hover(function(){
if ($('#d1').width="25%"){
$('#d1').animate({width: "0%",height: "0%"});
}
if ($('#d2').width="25%"){
$('#d2').animate({width: "0%",height: "0%"});
}
if ($('container').width<="100%"){
$('container').animate({width: "100%",height: "100%"});
}
if ($('#d3').width=100){
$('#d3').animate({width: "1650px",height: "700px"});
}
});
</script>
<style>
.container {
display: grid;
grid-template-columns: 1fr 1fr;
}
.container > div {
flex: 1; /*grow*/
}
.container div{
position: relative;
width: 500px;
height: 350px;
background-color: transparent;
}
#d1{
background:transparent;
border-style: solid;
border-color:#20C20E;
font-size:large;
text-align:center;
line-height:150px;
user-select: none;
display : block;
width: "25%";
height: "25%";
margin: 5px auto;
}
#d2{
background:transparent;
border-style: solid;
border-color:#20C20E;
font-size:large;
text-align:center;
line-height:150px;
user-select: none;
display : block;
width: "25%";
height: "25%";
margin: 5px auto;
}
#d3{
background:transparent;
border-style: solid;
border-color:#20C20E;
font-size:large;
text-align:center;
line-height:150px;
user-select: none;
display : block;
width: "25%";
height: "25%";
margin: 5px auto;
}
</style>
<head>
<title>
webpage
</title>
<link rel="stylesheet" href="http://anijs.github.io/lib/anicollection/anicollection.css">
<link rel="stylesheet" href="magic.css">
</head>
<body style="background-color:black;text-align:center">
<script>
var ws = new WebSocket("ws://127.0.0.1:5678/"),
messages = document.createElement('ul');
ws.onmessage = function (event) {
alert(yValue2)
if (yValue2 == "0"){
document.getElementById('d1').style.borderColor = "pink"
document.getElementById('d2').style.borderColor = "#20C20E"
document.getElementById('d3').style.borderColor = "#20C20E"
}
if (yValue2 == "1"){
document.getElementById('d2').style.borderColor = "pink"
document.getElementById('d1').style.borderColor = "#20C20E"
document.getElementById('d3').style.borderColor = "#20C20E"
}
if (yValue2 == "2"){
document.getElementById('d3').style.borderColor = "pink"
document.getElementById('d1').style.borderColor = "#20C20E"
document.getElementById('d2').style.borderColor = "#20C20E"
}
ycurrentwindow = yValue2
if (yValue2 == "100" && ycurrentwindow == "1"){
change1html();
}
if (yValue2 == "100" && ycurrentwindow == "2"){
change2html();
}
if (yValue2 == "100" && ycurrentwindow == "3"){
change3html();
}
};
document.body.appendChild(messages);
</script>
<div class="container" style="width:100%; height:90%">
<div id="d1" class="draggable">
<p><img src="C:\Users\martlee2\Downloads\sample1.jpg" style="width:100%; height:90%" ></a></p>
</div>
<div id="d2" class="draggable">
<p><img src="C:\Users\martlee2\Downloads\sample2.png" style="width:100%; height:90%" ></a></p>
</div>
<div id="d3" class="draggable">
<p><img src="C:\Users\martlee2\Downloads\sample3.jpg" style="width:100%; height:90%" ></a></p>
</div>
<br style="clear: left;" />
</div>
</body>
</html>