-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
152 lines (141 loc) · 4.99 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
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
<!DOCTYBE html>
<html>
<head>
<title>Facebook System Post</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="cmaterialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</head>
<body class="light-blue" onload="post()" >
<!-- Start Contaier -->
<div class="container">
<!-- Start Row -->
<div class="row">
<!-- Start Col -->
<div class="col m10 offset-m1">
<h3 class="center white-text">Facebook Post</h3>
<br>
<!-- Start Carr-Panel -->
<div class="card-panel">
<?php
session_start();
if (isset($_SESSION['name'])){
echo " <form action='' method=''>
<div class='input-field'>
<input type='radio'name='group'>
<label for='post_msg'>What's On Your Mind</label>
<textarea id='post_msg' onkeyup='check()' class='materialize-textarea'></textarea>
</div>
<input type='ubmit' class='btn blue darken-3' value='Post' onclick='post(\"add\")'
disabled id='btn-post'>
</form>
</div>
<!-- End Carr-Panel -->
<br>
<!-- Start Cart-Panel Post -->
<div id='post_contaier'>
</div>
<!-- End Cart-Panel Post -->
</div>
<!-- End Col -->
</div>
<!-- End Row -->
</div>
<!-- End Contaier -->
<!-- Modal Structure -->
<div id='modal1' class='modal'>
<div class='modal-content'>
<form>
<div class='input-field'>
<textarea id='edit_post_msg' onkeyup='check()' autofocus
class='materialize-textarea'></textarea>
</div>
<input type='ubmit' class='btn blue darken-3 modal-close' value='Edit'
onclick='post(\"edit\")' id='edit_btn-post'>
<input type='hidden'id='post_id'>
</form>
</div>
<div class='modal-footer'>
<a href='#!' class='modal-action modal-close waves-effect waves-green btn-flat'>Cancel</a>
</div>
</div>";
}
else{
header("Refresh:5,url=login.html");
echo "So You Can't Come This Page Directly You Are Redirect To LogInl";
}
?>
<script src="jquery-3.1.1.min.js"></script>
<script src="materialize.min.js"></script>
<script>
$(document).ready(function() {
// the "href" attribute of the modal trigger must specify the modal
// ID that wants to be triggered
$('.modal').modal();
// To Run Model
/*
$(".action").click(function () {
$('#modal1').modal('open');
})
This not Worl Because ii call class not found in the same page
*/
/*
use the func on to call class not found the same page
but you should use id or class found in this page
*/
$("#post_contaier").on("click", ".action", function () {
$('#modal1').modal('open');
$("#post_id").val($(this).data("id"));
// Call The Text Found In P
$("#edit_post_msg").val($(this).siblings("p").text());
})
});
// Check at text area empty or no
function check() {
var text=document.getElementById("post_msg").value;
if(text !=""){
document.getElementById("btn-post").removeAttribute("disabled");
} else {
document.getElementById("btn-post").setAttribute("disabled","disabled");
}
//***************************************************************
}
function post(ReqTybe,id) {
var post = document.getElementById("post_msg").value,
user = "Ahmed Bakri";
var xhr = new XMLHttpRequest();
// ceck to func send para or no
if (ReqTybe == undefined && id == undefined)
{
ReqTybe = "";
id = "";
}
else if (ReqTybe == "add") {
id = "";
} else if (ReqTybe == "del") {
var a = window.confirm("Are You Sure To Delete ?")
if (a == false) {
id = "";
}
}
else if (ReqTybe == "edit") {
post = document.getElementById('edit_post_msg').value;
id = document.getElementById("post_id").value;
}
xhr.onreadystatechange=function () {
if (xhr.readyState==4&&xhr.status==200){
document.getElementById("post_contaier").innerHTML=xhr.responseText;
document.getElementById("post_msg").value="";
document.getElementById("btn-post").setAttribute("disabled","disabled");
}
}
xhr.open("GET","server.php?req="+ReqTybe+"&id="+id+"&u="+user+"&P="+post,true);
xhr.send();
}
$("form").submit(function (para1) {
para1.preventDefault();// that means stop the default work such as reload in form
})
</script>
</body>
</html>