-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.php
More file actions
executable file
·253 lines (213 loc) · 10.2 KB
/
main.php
File metadata and controls
executable file
·253 lines (213 loc) · 10.2 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
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
<?php
/**
* Created by PhpStorm.
* User: lukas
* Date: 15.01.17
* Time: 12:49
*/
// Auf dieser Seite befindet sich der Chat
session_start();
include_once 'dbconnect.php';
include_once 'chatFunctions.php';
isLoggedIn();
?>
<html lang="de">
<head>
<title>CHAT</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<meta name="description" content="Chat.">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="material.min.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<style>
/* Preloader - Quelle unbekannt */
#preloader {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #fff; /* change if the mask should have another color then white */
z-index: 99; /* makes sure it stays on top */
}
#status {
width: 200px;
height: 200px;
position: absolute;
left: 50%; /* centers the loading animation horizontally one the screen */
top: 50%; /* centers the loading animation vertically one the screen */
background-repeat: no-repeat;
background-position: center;
margin: -100px 0 0 -100px; /* is width and height divided by two */
}
<!--
Platz für CSS für jquery UI
-->
</style>
<script>
//<!--JS Preload - Quelle unbekannt -->
// Nachfolgend wird der Loader ausgebelendet, sobald die Seite geladen ist
//<![CDATA[
$(window).load(function () { // makes sure the whole site is loaded
$('#status').fadeOut(); // will first fade out the loading animation
$('#preloader').delay(3).fadeOut('slow'); // will fade out the white DIV that covers the website.
$('body').delay(3).css({'overflow': 'visible'});
})
//]]>
<!-- JS Funktionen -->
window.setInterval(function () { // Alle 5000 ms werden die Funktion updateelement ausgeführt -> Elemente wird neu geladen
updateelement('room2');
console.log("Chat erfolgreich neu geladen");
focusChat();
updateelement("onlist");
console.log("OnlineListe erfolgreich neu geladen");
}, 5000);
var scroll = false; // Daktiviert das automatische Scrollen zum input
function focusChat() { // Automatisches Scrollen zum input, wenn scroll = true
if (scroll == true) {
var speed = 1000;
var target = $(room2in);
var position = target.offset().top;
$(".mdl-layout__content").animate({scrollTop: position}, speed, "swing",);
}
}
function updateelement(id) { // Läd betreffendes Element neu
$('#' + id).load(document.URL + ' #' + id);
}
jQuery(document).ready(function () {
$("#onlistbutton").click(function () { // Lässt die online-list verschwinden beim Klick auf den Button
$("#onlist").toggle();
});
$("#onscroll").click(function () { // Setzt scroll auf den jeweils anderen Wert beim Klick auf den Button -> AutoScroll aus / an
if (scroll == true) {
scroll = false; // AUS
}
else {
scroll = true; // AN
}
});
});
function send(id) { // Versendet die Nachricht
var message = document.getElementById(id).value; // Holt sich den Wert => Nachricht aus dem Input
var rooomid = id.substr(4); // String muss Format "RoomXxxx" erfüllen um X zu bekommen => Raum-Nummer
var typeid = 1; // typeid = 1 => normaler Text
var posting = $.post("ReST/send.php", {message: message, roomid: rooomid, typeid: typeid}); // Sendet die Nachricht mit den anderen Parametern an "send.php" => an den Chat
posting.done(function (data) {
if (data == "success") {
console.log("Success");
document.getElementById(id).value = ""; // Input-Feld wird leer gemacht
updateelement("room2"); // Läd den Chat neu, damit die Nachricht dirket angezeicht wird
}
else {
console.log("Failed ID:" + data); // Bei Fehlern wird der Fehler-Code in den Log geschrieben
}
});
}
</script>
</head>
<body class="mdl-base" onload="focusChat()">
<div id="preloader">
<div id="status">
<iframe src="loader.html" seamless sandbox="allow-scripts"></iframe>
</div>
</div>
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-tabs">
<!-- Header -->
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<!-- Title -->
<button onclick="location.href='https://chat.alpix.eu/index.php?logout=true';"
class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
<i class="material-icons">exit_to_app</i>
</button>
<span class="mdl-layout-title">Chat</span>
</div>
<!-- Tabs -->
<div class="mdl-layout__tab-bar mdl-js-ripple-effect">
<!-- <a href="#fixed-tab-1" class="mdl-layout__tab is-active"><span class="mdl-badge" >Raum 1 </span></a>-->
<a href="#fixed-tab-2" class="mdl-layout__tab"><span class="mdl-badge">Hauptraum </span></a>
<!-- <a href="#fixed-tab-3" class="mdl-layout__tab"><span class="mdl-badge" >Raum 3 </span></a> -->
</header>
<main class="mdl-layout__content">
<!-- Haupcontent -->
<section class="mdl-layout__tab-panel" id="fixed-tab-1">
<div class="page-content">
<!-- Raum 1 -->
<div class="mdl-grid">
<div class="mdl-layout-spacer"></div>
<iframe style="margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0;"
src="loader.html" seamless></iframe>
<div class="mdl-layout-spacer"></div>
</div>
</div>
</section>
<section class="mdl-layout__tab-panel is-active" id="fixed-tab-2">
<div class="page-content">
<div class="mdl-grid">
<div id="onlistdiv">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored"
id="onlistbutton">
Verbergen / Anzeigen
</button>
<ul class="mdl-list" id="onlist">
<li style="text-align: center;"> Nutzer online in diesem Raum</li>
<?php // Bindet die online Liste ein
include 'includes/onlinelist.php';
?>
</ul>
</div>
<div class="mdl-layout-spacer"></div>
<div1 style="overflow: auto;">
<br>
<br>
<div id="room2" style="overflow: auto;">
<table class="mdl-data-table mdl-js-data-table" style="display: table-row;overflow: auto;">
<thead>
<tr>
<th class="mdl-data-table__cell">Uhrzeit</th>
<th style=>Name</th>
<th style="
max-width: 50%;
">Nachricht
</th>
</tr>
</thead>
<tbody>
<?php // Bindet die Nachrichten ein => Chat wird angezeigt
include 'includes/messages.php';
?>
</tbody>
</table>
</div>
<br>
<form action="" method="get" onsubmit="send('room2in');return false;">
<div class="mdl-textfield mdl-js-textfield" style="width: 100%;z-index: 200;">
<input class="mdl-textfield__input" type="text" id="room2in">
<label class="mdl-textfield__label" for="sample1">Nachricht...</label>
</div>
</form>
<div id="onscroll" style="text-align:center;">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored"
id="onscroll">
Automatisch Scrollen AN / AUS
</button>
</div>
</div1>
<div class="mdl-layout-spacer"></div>
</div>
</div>
</section>
<section class="mdl-layout__tab-panel" id="fixed-tab-3">
<div class="page-content">
<!-- Raum 3 -->
</div>
</section>
<!-- Footer -->
</main>
</div>
<script src="https://code.getmdl.io/1.3.0/material.min.js"></script>
</body>
</html>