-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
104 lines (96 loc) · 2.4 KB
/
index.php
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
<?php include('session.php'); ?>
<?php include('header.php'); ?>
<body>
<?php include('navbar.php'); ?>
<div class="container">
<div class="row">
<?php include('chatlist.php'); ?>
</div>
</div>
<?php include('crudroom_modal.php'); ?>
<?php include('modal.php'); ?>
<script src="../js/jquery.dataTables.min.js"></script>
<script src="../js/dataTables.bootstrap.min.js"></script>
<script src="../js/dataTables.responsive.js"></script>
<script>
$(document).ready(function(){
$('#chatRoom').DataTable({
"bLengthChange": true,
"bInfo": true,
"bPaginate": true,
"bFilter": true,
"bSort": false,
"pageLength": 7
});
$(document).on('click', '#addchatroom', function(){
chatname=$('#chat_name').val();
chatpass=$('#chat_password').val();
$.ajax({
url:"add_chatroom.php",
method:"POST",
data:{
chatname: chatname,
chatpass: chatpass,
},
success:function(data){
window.location.href='chatroom.php?id='+data;
}
});
});
//
$(document).on('click', '.delete', function(){
var rid=$(this).val();
$('#delete_room').modal('show');
$('.modal-footer #confirm_delete').val(rid);
});
$(document).on('click', '#confirm_delete', function(){
var nrid=$(this).val();
$('#delete_room').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
$.ajax({
url:"deleteroom.php",
method:"POST",
data:{
id: nrid,
del: 1,
},
success:function(){
window.location.href='index.php';
}
});
});
$(document).on('click', '.edit', function(){
var rid=$(this).val();
var name=$('#name'+rid).val();
var pass=$('#pass'+rid).val();
$('#edit_room').modal('show');
$('.modal-body #room_name').val(name);
$('.modal-body #room_password').val(pass);
$('.modal-footer #confirm_update').val(rid);
});
$(document).on('click', '#confirm_update', function(){
var nrid=$(this).val();
var roomname=$('#room_name').val();
var roompass=$('#room_password').val();
$('#edit_room').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
$.ajax({
url:"update_room.php",
method:"POST",
data:{
id: nrid,
name: roomname,
pass: roompass,
edit: 1,
},
success:function(){
window.location.href='index.php';
}
});
});
});
</script>
</body>
</html>