-
Notifications
You must be signed in to change notification settings - Fork 0
/
Question.php
140 lines (103 loc) · 4.69 KB
/
Question.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Question</title>
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<link rel="icon" type="image/png" href="images/icons/favicon.ico" />
<!-- Custom styles for this template -->
<link href="css/home_main.css" rel="stylesheet">
<link href="css/forum.css" rel="stylesheet">
</head>
<body>
<?php
include 'navbar2.php';
if (!isset($_SESSION["user_id"])) {
session_destroy();
header("Location: /HBz/Login.php",TRUE,302);
die();
}
include "php/forum_php/components/post.php";
$id = $_GET["id"];
?>
<script>changeActiveLink("forum-link");</script>
<div class="container-fluid">
<div class="main-body p-0">
<div class="container">
<!-- Inner main -->
<div class ="card mb-2">
<?php include "php/forum_php/loadSelectedQuestion.php"?>
<!-- Answers -->
<div id="answer"><?php include "php/forum_php/loadAnswers.php" ?></div>
<!-- /Answers -->
<form id="form">
<div class="inner-main-body p-2 p-sm-3 collapse forum-content show">
<div id="answer"></div>
<div class="card mb-2">
<div class="card-body p-2 p-sm-3">
<div>
<div class="row">
<label for="editor"> <h2 class="h3 pt-4">Your Idea</h3></label>
<div class="container-fluid">
<textarea name="text" id="editor"></textarea>
</div>
<button name="submit" id="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div> <!-- /Inner main -->
</div>
</div>
</div>
</body>
</html>
<script src="js/forum_js/question.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
document.getElementById("form").addEventListener("submit", function(event) {
try{
console.log(event.srcElement[0].value);
if (event.srcElement[0].value === "" || event.srcElement[0].value ==='<p><br data-mce-bogus="1"></p>' || event.srcElement[0].value ==="<p><br></p>"){
console.log(event.srcElement[0].value);
throw( "Empty Answer");
}
else{
insertAnswer(<?php echo $id?>);
event.preventDefault();
}
} catch(e){
alert("Error: "+ e);
}
}, true);</script>
<!-- Text Editor Template -->
<script src="https://cdn.tiny.cloud/1/6qotqw98ccr1b86gtt4n68fo95mv1vbgdr3ov36z6cm83qxu/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<script>
tinymce.init({
selector: 'textarea#editor',
plugins: [
'advlist autolink link lists charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime nonbreaking',
'table emoticons template paste'
],
toolbar: 'styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | ' +
'bullist numlist outdent indent | link | print preview media fullpage | ' +
'forecolor backcolor emoticons',
menubar: 'file edit view insert format tools table',
mobile: {
menubar: true
},
setup: function (editor) {
editor.on('change', function () {
tinymce.triggerSave();
});
}
});
</script>