-
Notifications
You must be signed in to change notification settings - Fork 0
/
formEdit.php
274 lines (234 loc) · 11.7 KB
/
formEdit.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
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?php
include 'mysql.php';
include 'files-manager.php';
include 'form-classes.php';
include 'redirect.php';
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$user = get_email($_COOKIE['Login_Token']);
$form_name = $_GET['title'];
$form = getOForm($user, $form_name);
}
?>
<!DOCTYPE html>
<html lang="pt-PT">
<head>
<script src="jquery-3.5.1.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Super WebForms - <?php echo $form->title; ?></title>
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="dashboard.css">
<link rel="stylesheet" href="form.css">
<link rel="stylesheet" href="formBlocks.css">
<link rel="icon" href="img/logo/favicon.png">
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//superwebforms.infinityfreeapp.com/matomo/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
<noscript>
<!-- Matomo Image Tracker-->
<img src="https://superwebforms.infinityfreeapp.com/matomo/matomo.php?idsite=1&rec=1" style="border:0" alt="" />
<!-- End Matomo -->
</noscript>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'pt-PT',
layout: google.translate.TranslateElement.InlineLayout.SIMPLE
}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit">
</script>
<script src="main.js"></script>
</head>
<body>
<header <?php
if ($form->title == null) {
echo 'style="display:none;"';
} else {
echo 'style="position:static;opacity:1;"';
}
?>></header>
<div></div>
<div id="head">
<table>
<tr>
<th>
<h1 style="text-align:left;"><?php echo $form->title; ?></h1>
</th>
<td>
<h3 style="text-align:right;">Copia e partilha:</h3>
<input style="width:180px;float:right;" type="text" name="share_id" id="share_id" onclick="this.focus();this.select()" readonly="readonly" value="<?php echo url . '/form.php?id=' . get_formID($user, $form->title); ?>">
</td>
<th>
<button style="position:fixed;" class="obtn main-btn right new">+</button>
</th>
</tr>
</table>
</div>
<div style="text-align:center">
<section id="form">
<h3><?php echo $form->description; ?></h3>
</section>
</div>
<div class="flex-container">
<a href="submissions.php?title=<?php echo $form->title; ?>"><button id="submitted" class="obtn flex-button">Entregues</button></a>
<button id="formConfig-btn" class="flex-button">Configurações do Formulário</button>
<!--
<button id="pageConfig-btn" class="flex-button">Configurações da página</button>
<button id="newPage-btn" class="flex-button">Nova página</button>
-->
</div>
<div id="modal1" class="modal">
<div id="new-block" class="modal-content animatezoom">
<form action="saveBlock.php" method="get">
<input style="width:10px;float:right;visibility:hidden;" type="text" name="form_title" id="form_title" onclick="this.focus();this.select()" readonly="readonly" value="<?php echo $form->title; ?>"></td>
<input style="width:10px;float:right;visibility:hidden;" type="text" name="page" id="page" onclick="this.focus();this.select()" readonly="readonly" value="<?php echo 0; ?>"></td>
<label for="question">Questão:</label><br>
<input type="text" name="question" id="question"><br>
<label for="type">Tipo:</label><br>
<select id="type" name="type">
<option value="text">Resposta de Texto</option>
</select><br>
<div class="shortQ">
<label for="rows">Linhas:</label><br>
<input type="number" name="rows" id="rows"></div>
<br><br>
<button class="rect obtn main-btn right" type="submit">Confirmar</button>
</form>
</div>
</div>
<div id="modal2" class="modal">
<div id="form-config" class="modal-content animatezoom">
<form id="newform" action="changeFormConf.php" method="get">
<input style="width:10px;float:right;visibility:hidden;" type="text" name="oldTitle" id="oldTitle" onclick="this.focus();this.select()" readonly="readonly" value="<?php echo $form->title; ?>"></td>
<label for="title">Título:</label><br>
<input type="text" name="title" id="title" value="<?php echo $form->title; ?>"><br>
<label for="description"> Descrição:</label><br>
<textarea id="description" name="description" cols=16 rows=3><?php echo $form->description ?></textarea><br><br>
<label for="timed">Temporizador:</label>
<input type="checkbox" id="timed" name="timed" id="timed" <?php if ($form->timed) {
echo 'checked';
} ?>><br>
<input type="radio" id="temp_type1" name="temp_type" class="temp" value="upUntil" <?php if ($form->hour != null && $form->date != null) {
echo ' checked';
} ?>>
<label for="temp_type1" class="temp">Até às</label><br>
<input type="radio" id="temp_type2" name="temp_type" class="temp" value="current" <?php if ($form->hour != null && $form->date == null) {
echo ' checked';
} ?>>
<label for="temp_type2" class="temp">Durante</label><br>
<label for="hour">Hora:</label><br>
<input type="time" name="hour" id="hour" class="temp time" value="<?php echo $form->hour; ?>"><br>
<label for="date">Data:</label><br>
<input type="date" name="date" id="date" class="temp time" value="<?php echo $form->date; ?>"><br>
<button id="createF" type="submit" class="rect obtn main-btn right">Salvar</button>
</form>
</div>
</div>
<!--
<div id="modal3" class="modal">
<div id="page-config" class="modal-content animatezoom">
<form id="newform" action="changePageConf.php" method="get">
<label for="question" value="">Questão:</label><br>
<input type="text" name="question" id="question"><br>
<label for="timed">Temporizador:</label>
<input type="checkbox" id="timed" name="timed" id="timed"><br>
<input type="radio" id="temp_type1" name="temp_type" class="temp" value="upUntil" checked="checked">
<label for="temp_type1" class="temp">Até às</label><br>
<input type="radio" id="temp_type2" name="temp_type" class="temp" value="current">
<label for="temp_type2" class="temp">Durante</label><br>
<label for="hour">Hora:</label><br>
<input type="time" name="hour" id="hour" class="temp time"><br><br><br>
<label for="date">Data:</label><br>
<input type="date" name="date" id="date" class="temp time"><br>
<button id="createF" type="submit" class="rect obtn main-btn right">Criar</button>
</form>
</div>
</div>
<div id="modal4" class="modal">
<div id="new-page" class="modal-content animatezoom">
<form id="newform" action="addPage.php" method="get">
<label for="question">Questão:</label><br>
<input type="text" name="question" id="question"><br>
<label for="timed">Temporizador:</label>
<input type="checkbox" id="timed" name="timed" id="timed"><br>
<input type="radio" id="temp_type1" name="temp_type" class="temp" value="upUntil" checked="checked">
<label for="temp_type1" class="temp">Até às</label><br>
<input type="radio" id="temp_type2" name="temp_type" class="temp" value="current">
<label for="temp_type2" class="temp">Durante</label><br>
<label for="hour">Hora:</label><br>
<input type="time" name="hour" id="hour" class="temp time"><br>
<label for="date">Data:</label><br>
<input type="date" name="date" id="date" class="temp time"><br>
<button id="createF" type="submit" class="rect obtn main-btn right">Criar</button>
</form>
</div>
</div>
-->
<footer></footer>
<script type="text/javascript" src="form.js"></script>
<script>
$(document).ready(function() {
let spaceSize = $(document).height() - $('#form').height() - 700;
let spaceSizeTxt = String(spaceSize) + 'px';
$('footer').css('margin-top', spaceSize);
<?php
foreach ($form->pages[0]->blocks as $key => $block) {
$html = $form->print(0, $key);
echo "$('section').append('" . $html . "');";
}
?>
$('.new').click(function() {
$('#modal1').css('display', 'block');
});
$('#formConfig-btn').click(function() {
$('#modal2').css('display', 'block');
});
/*$('#pageConfig-btn').click(function() {
$('#modal3').css('display', 'block');
});
$('#newPage-btn').click(function() {
$('#modal4').css('display', 'block');
});*/
$('.modal').click(function(target) {
if (!$(event.target).closest(".modal-content").length) {
$('.modal').css('display', 'none');
}
});
if ($('#timed').prop("checked")) {
$('.temp').prop('disabled', false);
}
$('#timed').on('change', function() {
$('.temp').prop('disabled', !($(this).prop("checked")));
});
$('#date').prop('disabled', true);
function adj_temp(){
if ($('#temp_type2').is(':checked')) {
return true;
} else {
return false;
}
}
$('#date').prop('disabled', adj_temp());
$('.temp').on('change', function() {
$('#date').prop('disabled', adj_temp());
});
$('#date').prop('min', new Date().toJSON.split('T')[0]);
});
</script>
</body>
<div id="cookie"></div>
</html>