-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.html
202 lines (178 loc) · 5.64 KB
/
client.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="mainDiv">
<ul id="duyurular">
</ul>
</div>
<!--<p id="servIp">WHEEEY</p>-->
<script type="text/javascript">
var socket = null;
var isopen = false;
var currentSlide = 0;
var myInterval = null;
window.onload = function () {
//socket = new WebSocket("ws://192.168.0.17:9001");
socket = new WebSocket("ws://127.0.0.1:9001");
socket.binaryType = "arraybuffer";
socket.onopen = function () {
console.log("Connected!");
isopen = true;
sendText("aktif");
sendText("ayarlar");
sendText("ip");
}
socket.onmessage = function (e) {
if (typeof e.data == "string") {
var veri = JSON.parse(e.data);
if (veri["duyuruCheck"] == true) {
console.log("Yeni veri girişi!!!");
console.log("Bağlantı açıksa güncel listeyi almaya gidiyorum");
sendText("aktif");
}
else if (veri["ayarCheck"] == true) {
console.log("Ayarlar değişti");
sendText("ayarlar");
}
else {
if ("ayarlar" in veri) {
ayarlar = veri["ayarlar"];
currentSlide = 0;
clearInterval(myInterval);
ayarYap(ayarlar);
var newInterval = ayarlar[4];
myInterval = setInterval(nextSlide, newInterval);
}
if ("duyurular" in veri) {
var aktif_duyurular = veri["duyurular"];
duyuruYereles(aktif_duyurular);
sendText("ayarlar");
}
if ("ip" in veri) {
var ipAddr = veri["ip"];
document.getElementById("servIp").innerHTML = ipAddr;
}
}
}
}
socket.onclose = function (e) {
//console.log("Connection closed.");
socket = null;
isopen = false;
}
};
function duyuruYereles(duyurular) {
console.log(duyurular);
var node = document.getElementById('duyurular');
while (node.hasChildNodes()) {
node.removeChild(node.firstChild);
}
//console.log(duyurular)
for (ind = 0; ind < duyurular.length; ++ind) {
var element = document.createElement('p');
if (ind == 0) {
element.className = "duyuru showing";
}
else {
var element = document.createElement('p');
element.className = "duyuru";
}
element.innerHTML = duyurular[ind];
document.getElementById("duyurular").appendChild(element);
}
}
function nextSlide() {
//console.log(currentSlide)
var slides = document.querySelectorAll("#duyurular .duyuru");
slides[currentSlide].className = "duyuru";
currentSlide = (currentSlide + 1) % slides.length;
slides[currentSlide].className = "duyuru showing";
}
;
function sendText(komut) {
if (isopen) {
socket.send(komut);
} else {
console.log("Bağlantı açık değil");
}
}
;
function ayarYap(ayarlar) {
console.log(ayarlar);
document.body.style.backgroundColor = ayarlar[0];
//console.log(document.getElementsByClassName("duyuru showing"));
document.getElementsByClassName("duyuru showing")[0].style.backgroundColor = ayarlar[1];
var cols = document.getElementsByClassName('duyuru');
for (i = 0; i < cols.length; i++) {
cols[i].style.backgroundColor = ayarlar[1];
}
document.getElementsByClassName("duyuru showing")[0].style.color = ayarlar[2];
for (i = 0; i < cols.length; i++) {
cols[i].style.color = ayarlar[2];
}
document.getElementsByClassName("duyuru showing")[0].style.boxShadow = "0 0 5px 10px " + ayarlar[1];
for (i = 0; i < cols.length; i++) {
cols[i].style.boxShadow = "0 0 5px 10px " + ayarlar[1];
}
document.getElementsByClassName("duyuru showing")[0].style.fontFamily = ayarlar[3];
for (i = 0; i < cols.length; i++) {
cols[i].style.fontFamily = ayarlar[3];
}
}
</script>
<style>
#duyurular {
position: relative;
height: 300px;
padding: 0px;
margin: 0px;
list-style-type: none;
}
.duyuru {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
opacity: 0;
z-index: 1;
-webkit-transition: opacity 1s;
-moz-transition: opacity 1s;
-o-transition: opacity 1s;
transition: opacity 1s;
}
.showing {
opacity: 1;
z-index: 2;
}
.duyuru {
word-break: break-all;
font-size: 40px;
padding: 40px;
box-sizing: border-box;
/*
box-shadow: 0 0 5px 10px rgb(100, 174, 219);
background: rgb(100, 174, 219);
color: rgb(230, 230, 230);*/
text-align: center;
}
body {
background: rgb(211, 211, 211);
}
.mainDiv {
/*yeni div ekleyince benzer css kullan*/
width: 100%;
height: 50%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
</style>
</body>
</html>