/
index.php
304 lines (252 loc) · 10.6 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
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<?php
include "includes/header.php";
$lines=$code="";
$formgroup = $words = array();
$code = '
title h4 "Customer Registration Form" --***
text cusname [p:Name-Surname] [l:Name of the Customer] 1/2***
radio [l:Gender] [o:"Female" "Male"] [v:"f" "m"] @@ 1/2***
select [p:Please Select] [l:Registered Branch] [o:"Berlin" "Paris" "Istanbul!!"] [v:"1" "2" "3"] 1/2***
number cusage [l:Number of Renewals] [v:5] [min:4] 1/2***
checkbox [o:"Update Main Server"]***
textarea notes [l:Notes] [p:Your personal notes about customer]***
button submit "Update" [success] bb 1/3***
button reset "Reset" [secondary] bb 1/3
';
if(isset($_POST['submit'])){
$start = 1;
$code = $_POST['code'];
$lines = explode("\n", $code);
$item=0;
foreach ($lines as $line) {
if ($line!="") {
if ($line=="[row]") {
} elseif ($line=="[col]") {
} else {
$item++;
$formitems [] = form_item($line, $item);
}
}
}
} else {
$lines = explode("***", $code);
$item=0;
foreach ($lines as $line) {
if ($line!="") {
if ($line=="[row]") {
} elseif ($line=="[col]") {
} else {
$item++;
$formitems [] = form_item($line, $item);
}
}
}
}
?>
<div class="container-fluid">
<div class="row mt-1 ml-1 mr-1">
</div>
<div class="row m-4">
<div class="col-sm-5">
<div class="border border-secondary p-4 bg-light">
<form action ="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<h4 class="mb-4" >Your Short Codes</h4>
<textarea id="code" name="code" style="height:400px; width:100%; font-size:80%;" class="takenote"><?php echo str_replace("***", "", $code);?></textarea>
<br></br><button class="btn btn-block btn-warning" type="submit" name="submit">Preview >></button>
</form>
<br>
<h5 class="mb-4" >Add Sample Codes:</h5>
<button class="btn btn-sm mb-1" id="addtitle">+ Title</button>
<button class="btn btn-sm mb-1" id="addtext">+ Text</button>
<button class="btn btn-sm mb-1" id="addnumber">+ Number</button>
<button class="btn btn-sm mb-1" id="addtime">+ Time</button>
<button class="btn btn-sm mb-1" id="adddate">+ Date </button>
<button class="btn btn-sm mb-1" id="addpassword">+ Password </button>
<button class="btn btn-sm mb-1" id="addtextarea">+ Textarea</button>
<button class="btn btn-sm mb-1" id="addselect">+ Select</button>
<button class="btn btn-sm mb-1" id="addcheck">+ Check</button>
<button class="btn btn-sm mb-1" id="addradio">+ Radio</button>
<button class="btn btn-sm mb-1" id="addbutton">+ Button</button>
<?php //include "helpfile.php";?>
<div id="helpdiv" class="mt-4"></div>
</div>
</div>
<div class="col-sm-7">
<div class="border border-primary p-4 bg-light">
<h4 class="mb-4" >Preview</h4>
<div class="bg-white p-4 border border-warning">
<?php
preview ($formitems);
?>
</div>
<div class="col-sm-12 mt-4 border border-danger">
<h4 class="mb-4 mt-4" >HTML Codes <small><a id="copybutton" href="">[Copy]</a></small></h4>
<?php
printcode ($formitems);
?>
</div>
</div>
</div>
</div>
</div>
<div style="display:none;">
<div id="titlehelp">
<h4>Title</h4>
<small><p class="border border-secondary bg-warning p-1">title <i>class</i> "title text" [attributes]</p></small>
<p><b>Classes:</b> <small>h1, h2 ... h6</small>
</br><b>Attributes:</b> <small>--: Border-bottom</p></small>
<small><p class="border border-secondary bg-white p-1">title h3 "Registration Form" --
</br>title h5 "Name of Company"
</p></small>
</br>
</div>
<div id="texthelp">
<h4>Text Inputs</h4>
<p>For <b>input</b> style of <i>text, date, number, password</i>:</p>
<small><p class="border border-secondary bg-warning p-1"><i>type</i> name [parameters] [attributes] <i>column-size</i></p></small>
<p><b>Types:</b> <small>text, date, time, number, password</small>
</br><b>Parameters:</b> <small>p: placeholder, l: label, v: value, h: help-text, min: minimum (for date, time, number), max: (for date, time, number)</small>
</br><b>Attributes:</b> <small>**: required, ##: disabled</p></small>
<small><p class="border border-secondary bg-white p-1">text customername [l:Name of Customer] [p:Name - Surname] ** 1/2
</br>date regdate [l:Date of Registration] ** 1/2
</br>number customerage [l:Age of Customer] [v:30] [min:18] ## 1/3
</br>time time-entrance [l:Time of Entrance] [min:09:00] [max:23:00] ## 1/3
</p></small>
</br>
</div>
<div id="checkhelp">
<h4>Radios and Checks</h4>
<p>For <b>input</b> style of <i>checkbox, radio</i>:</p>
<small><p class="border border-secondary bg-warning p-1"><i>type</i> name [parameters] [attributes] <i>column-size</i></p></small>
<p><b>Types:</b> <small>checkbox, radio</small>
</br><b>Parameters:</b> <small>l: label, o: options, v: values, h: help-text</small>
</br><b>Attributes:</b> <small>**: required, ##: disabled, @@: inline, </p></small>
<small><p class="border border-secondary bg-white p-1">radio country [l:Country of Birth] [o:"UK" "USA"] **
</br>radio city [l:Destination] [o:"Ankara" "Sofia"] [v:"1" "2"] [h:Please Select Destination] @@ 1/2
</br>checkbox customerage [l:Age of Customer] [o:18+] [v:1] [h:Currently not open for people older than 18] ## 1/3
</p></small>
</br>
</div>
<div id="selecthelp">
<h4>Select Box (Dropdown)</h4>
<p>For <b>input</b> style of <i>selectbox</i>:</p>
<small><p class="border border-secondary bg-warning p-1">select name [parameters] [attributes] <i>column-size</i></p></small>
<p><b>Parameters:</b> <small>l: label, o: options, v: values, h: help-text</small>
</br><b>Attributes:</b> <small>**: required, ##: disabled, $$:selected (in option quotation marks), !!:disabled (in option quotation marks)</p></small>
<small><p class="border border-secondary bg-white p-1">select country [l:Country of Birth] [o:"UK!!" "USA"] **
</br>select [l:Destination] [o:"Ankara$$" "Berlin" "Paris" "Rome!!" "Sofia!!"] [v:"1" "2" "3" "4" "5"] [h:Please Select Destination] ** 1/2
</br>checkbox customerage [l:Age of Customer] [o:18+] [v:1] [h:Currently not open for people older than 18] ## 1/3
</p></small>
</br>
</div>
<div id="textareahelp">
<h4>Textarea</h4>
<p>For <b>input</b> style of <i>textarea</i>:</p>
<small><p class="border border-secondary bg-warning p-1">select name [parameters] [attributes] <i>column-size</i></p></small>
<p><b>Parameters:</b> <small>p: placeholder, l: label, v: values, h: help-text</small>
</br><b>Attributes:</b> <small>**: required, ##: disabled</p></small>
<small><p class="border border-secondary bg-white p-1">textarea notes [l:Quick Notes] [p:Write your note here]
</p></small>
</br>
</div>
<div id="buttonhelp">
<h4>Button</h4>
<small><p class="border border-secondary bg-warning p-1">button name "button text" [bootstrap-class] [attributes] <i>column-size</i></p></small>
<p><b>Bootstrap Class:</b> <small>primary, secondary, success, info, dark, light, warning, danger... Get more info about <a href="https://getbootstrap.com/docs/4.1/utilities/colors/">Bootstrap Colors</a>.</small>
</br><b>Attributes:</b> <small>bb: block-size button</p></small>
<small><p class="border border-secondary bg-white p-1">button submit "Send" [primary] bb
</br>button reset "Reset" [secondary] 1/3
</p></small>
</br>
</div>
</div>
<script>
function copyFunction() {
const copyText = document.getElementById("htmlcode").textContent;
const textArea = document.createElement('textarea');
textArea.textContent = copyText;
document.body.append(textArea);
textArea.select();
document.execCommand("copy");
alert('Copied to the Clipboard.');
}
function exportHTML() {
const copyText = document.getElementById("htmlcode").textContent;
const textArea = document.createElement('textarea');
textArea.textContent = copyText;
document.body.append(textArea);
textArea.select();
document.execCommand("copy");
}
document.getElementById('copybutton').addEventListener('click', copyFunction);
$(document).ready(function(){
$("#addtext").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + "text txtname [p:Placeholder Text] [l:Label Text] [h:Help Text] 1/1 \n");
var help = $('#texthelp').html();
$('#helpdiv').html(help);
});
$("#addtime").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + "time timename [l:Label Text] [h:Help Text] [min:00:01] [max:23:59] [v:23:00] 1/1 \n");
var help = $('#texthelp').html();
$('#helpdiv').html(help);
});
$("#adddate").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + "date datename [l:Label Text] [min:2018-01-01] 1/1 \n");
var help = $('#texthelp').html();
$('#helpdiv').html(help);
});
$("#addpassword").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + "password pwname [l:Label Text] 1/1 \n");
var help = $('#texthelp').html();
$('#helpdiv').html(help);
});
$("#addnumber").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + "number numname [l:Label Text] [max:99] 1/1 \n");
var help = $('#texthelp').html();
$('#helpdiv').html(help);
});
$("#addtitle").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + 'title h3 "Title Here" -- \n');
var help = $('#titlehelp').html();
$('#helpdiv').html(help);
});
$("#addtextarea").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + 'textarea txtname [p:Placeholder Text] [l:Label Text] [h:Help Text] 1/1 \n');
var help = $('#textareahelp').html();
$('#helpdiv').html(help);
});
$("#addcheck").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + 'check [l:Label Text] [o:"Option Text"] [v:"1"] 1/1 \n');
var help = $('#checkhelp').html();
$('#helpdiv').html(help);
});
$("#addradio").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + 'radio [l:Label Text] [o:"Option1 Text", "Option2 Text", "Option3 Text"] [v:"1", "2", "3"] @@ 1/1 \n');
var help = $('#checkhelp').html();
$('#helpdiv').html(help);
});
$("#addselect").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + 'select [p:Select...] [l:Label Text] [o:"Select1 Text", "Select2 Text", "Disabled Text!!"] [v:"1", "2", "3"] @@ 1/1 \n');
var help = $('#selecthelp').html();
$('#helpdiv').html(help);
});
$("#addbutton").click(function(){
var txt = $("textarea#code");
txt.val( txt.val() + 'button submit "Button Text" [info] bb 1/3 \n');
var help = $('#buttonhelp').html();
$('#helpdiv').html(help);
});
});
</script>
</body>
</html>