-
Notifications
You must be signed in to change notification settings - Fork 0
/
writeupdate.html
391 lines (346 loc) · 15.3 KB
/
writeupdate.html
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<!DOCTYPE html>
<html lang="en">
<head>
<!-- basic page need -->
<title>Create Content</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- meta tag -->
<meta name="description" content="Blog Sinlge">
<!-- custom css -->
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/theme.css">
<link rel="stylesheet" href="assets/css/responsive.css">
<link rel="stylesheet" href="assets/css/single.css">
<!-- libs -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap.min.css"
integrity="sha512-SbiR/eusphKoMVVXysTKG/7VseWii+Y3FdHrt0EpKgpToZeemhqHeZeLWLhJutz/2ut2Vw1uQEj2MbRF+TVBUA=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.css"
integrity="sha512-+ouAqATs1y4kpPMCHfKHVJwf308zo+tC9dlEYK9rKe7kiP35NiP+Oi35rCFnc16zdvk9aBkDUtEO3tIPl0xN5w=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Dosis&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/write.css">
<link rel="stylesheet" href="assets/libs/toastr/toastr.min.css">
<link rel="stylesheet" href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css" />
<link rel="stylesheet" href="assets/css/editor.css">
<link rel="stylesheet" href="assets/css/hamburgermenu.css">
</head>
<body class="light">
<header class="mx-lg-4 mx-3">
<div class="nav-area container-fluid px-3 px-lg-5">
<div id="nav-logo">
<a href="/index.html">
<img src="assets/images/ekrem gunes-logos.jpeg" width="45rem" style="border-radius: 50%;"
alt="LOGO">
</a>
</div>
<div id="nav-links">
<ul>
<a href="/write.html">
<li><i class="fa-sharp fa-solid fa-feather"></i>Write</li>
</a>
<a href="#">
<li><i class="fa-regular fa-bell"></i></li>
</a>
<a href="#">
<!-- needs modal or another thing-->
<li><i class="fa-solid fa-gear"></i></li>
</a>
<li class="switch-parent">
<label class="switch">
<input id="switch-input" type="checkbox">
<span class="slider round"></span>
</label>
</li>
</ul>
</div>
<div id="hamburgerDiv" class="open">
<span class="cls"></span>
<span>
<ul class="sub-menu ">
<li>
<a href="write.html" title="about">Write</a>
</li>
<li>
<a href="userSettings.html" title="skills">Settings</a>
</li>
<li>
<!-- modal or another solution needs here -->
<a href="notifcati.html" title="jobs">Notification</a>
</li>
<li class="switch-parent">
<a href="javascript:void(0)" id="mobileDarkSwitch">Dark Mode</a>
</li>
</ul>
</span>
<span class="cls"></span>
</div>
</div>
</header>
<main id="main" class="row px-2 px-lg-3 mx-1 mx-md-3 mx-lg-4">
<section id="middle-forum-section" class="col-lg-9 col-12 ">
<div class="post-area ">
<div class="editorArea">
<div>
<input type="hidden" id="post-id" value="1">
<div id="editor">
<h3>Step 1</h3>
<hr>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Provident expedita totam
nesciunt! Voluptatibus similique quos alias ad! Vel quia fugiat in amet quis facilis
aliquid, accusantium quos, hic cupiditate rem.</p>
<br>
<h3>Step 2</h3>
<hr>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Provident expedita totam
nesciunt! Voluptatibus similique quos alias ad! Vel quia fugiat in amet quis facilis
aliquid, accusantium quos, hic cupiditate rem.</p>
<br>
</div>
<div>
<label class="form-label" for="">Title</label>
<input value="How you can learn programming" id="form-title" type="text"
class="form-control">
<br>
</div>
<div>
<label class="form-label" for="">Category</label>
<select class="form-select" id="form-category">
<option value="1" selected>software</option>
<!-- other options -->
<option value="2">Tech</option>
<option value="3">Sport</option>
<option value="4">Art</option>
</select>
<br>
</div>
<!-- <label class="form-label" for="">Tags</label>
<div class="keyHandler">
<button type="button" id="addKey">+</button>
<input class="form-control" type="text" placeholder="Keyword + Enter" id="keysInput">
</div>
<div id="form-tags" class="addedKeysHolder"></div>
<input type="hidden" id="lkey" name="tags"> -->
<div class="col-12">
<button class="write-btn" type="button" onclick="UpdateContent(this)"
id="write-btn">Update</button>
</div>
</div>
</div>
</div>
</section>
<section id="right-forum-section" class="col-12 col-lg-3">
<div class="user-info">
<a href="/user.html"><img src="assets/images/ekrem gunes-logos.jpeg" alt=""></a>
<h4>Ekrem</h4>
<h6>Developer</h6>
<h6>343 Followers</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Delectus earum aliquam quidem facilis odio
illum </p>
<p>You posted <b style="margin: 0 0.15rem;">8</b> time</p>
<p>You're liked <b style="margin: 0 0.15rem;">12.310</b> time</p>
</div>
<!-- <div id="footer">
<div id="footer-social-links">
<ul>
<li><a href="#"><i class="fa-brands fa-instagram"></i>Instagram</a></li>
<li><a href="https://www.linkedin.com/in/ekremgunes/"><i
class="fa-brands fa-linkedin"></i>Linkedin</a></li>
<li><a href="#"><i class="fa-brands fa-github"></i>Github</a></li>
<li><a href="#"><i class="fa-brands fa-facebook"></i>Facebook</a></li>
</ul>
</div>
</div>-->
</section>
</main>
<div class="text-center small footer-links mb-2 col-12"> • <a href="">About</a> •<a
href="privacy">Privacy-Policy</a> • Copyright <i><a style="color: #c79005;margin: .2rem;"
href="http://gunesekrem.com">gunesekremcom</a></i>
<script>var date = new Date(); document.write(date.getFullYear()); </script> ©
</div>
<!-- back to top -->
<a onclick="javascript:void(0);" class="back-to-top"><i class="fa-solid fa-arrow-up"></i></a>
<!-- loading -->
<div class="wrapper">
<div class="loader" id="loader">
<div class="dot dot1"></div>
<div class="dot dot2"></div>
<div class="dot dot3"></div>
</div>
</div>
<!-- scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.js"
integrity="sha512-6DC1eE3AWg1bgitkoaRM1lhY98PxbMIbhgYCGV107aZlyzzvaWCW1nJW2vDuYQm06hXrW0As6OGKcIaAVWnHJw=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="assets/libs/toastr/toastr.min.js"></script>
<script src="assets/js/hamburgermenu.js"></script>
<script src="https://uicdn.toast.com/editor/latest/toastui-editor-all.min.js"></script>
<script>
//call addKey() by pressing Enter
$(window).keydown(function (event) {
if (event.keyCode == 13) {
event.preventDefault();
addKey();
return false;
}
});
//call addKey() by pressing button
$('#addKey').click(function (e) {
addKey();
});
//Add key function
function addKey() {
let key = $('#keysInput').val()
if (key != '') {
let tag = document.createElement('span')
$(tag).append(key)
$(tag).attr('onclick', `$(this).remove();removeKey("${key}");`)
$('.addedKeysHolder').append(tag)
$('#keysInput').val('')
resetKey()
}
}
function removeKey() {
resetKey()
}
//Reset all keys
function resetKey() {
$('#lkey').val('')
for (let i = 1; i <= $('.addedKeysHolder span').length; i++) {
let theKey = $(`.addedKeysHolder span:nth-child(${i})`).text()
let prevVal = $('#lkey').val() + ','
$('#lkey').val(prevVal + theKey)
}
$('#lkey').val($('#lkey').val());
$('#keysInput').focus();
}
const { Editor } = toastui;
const editor = new Editor({
el: document.querySelector('#editor'),
previewStyle: 'vertical',
initialEditType: 'wysiwyg',
height: '400px'
});
editor.focus()
const ResetEditor = () => {
editor.reset()
}
function checkEditor(html) {
var hasImgTag = /<img\s[^>]*>/i.test(html);
var hasImgSrc = /<img\s[^>]*src=["'][^"']*["'][^>]*>/i.test(html);
var isImgSrcEmpty = /<img\s[^>]*src=["'][\s]*["'][^>]*>/i.test(html);
if (hasImgTag && hasImgSrc && !isImgSrcEmpty) {
return true
} else {
var prevLength;
do {
prevLength = html.length;
html = html
.replace(/<\/?[A-Za-z]+\/?>/g, '') // boş etiketleri kaldır
.replace(/<\/?[\s\S]*?>/g, '') // diğer boş etiketleri kaldır
.replace(/^\s*\n/gm, '') // boş satırları kaldır
.replace(/ | /gi, ' ') // özel karakterleri boşlukla değiştir
.replace(/<\/?(\w+)[^>]*>/g, function (match, p1) {
// table tag'larını düzenle
if (p1.toLowerCase() === 'table') {
return match.replace(/[\r\n]+/g, '').replace(/>\s+</g, '><');
}
return match;
});
} while (html.length !== prevLength);
if (html.replace(/\s/g, '').length > 10) {
return true
} else {
return false
}
}
}
const SendContent = (e) => {
var tags = [];
$("#form-tags span").each(function () {
tags.push($(this).text());
});
var category = $("#form-category").val()
var title = $("#form-title").val()
if (title.length < 10) {
toastr.warning("Title is too short")
$("#form-title").focus()
return
}
if (category == null) {
toastr.warning("Category is empty")
$("#form-category").focus()
return
}
var html = editor.getHTML()
var editorController = checkEditor(html)
if (editorController) {
if (html.toString().length > 4000000) {
toastr.error("Too much content images and texts greater than ~4mb :(")
return
}
toastr.info("Post sending")
var data = {
title: title,
content: html,
category: category,
tags: tags
}
console.log(JSON.stringify(data))
// akax - fetch
} else {
toastr.warning("Post can't be empty")
}
}
const UpdateContent = (e) => {
var tags = [];
$("#form-tags span").each(function () {
tags.push($(this).text());
});
var category = $("#form-category").val()
var title = $("#form-title").val()
var id = $("#post-id").val()
if (id <= 0 || id == null || id == "") {
toastr.warning("Id can't found")
return
}
if (title.length < 10) {
toastr.warning("Title is too short")
$("#form-title").focus()
return
}
if (category == null) {
toastr.warning("Category is empty")
$("#form-category").focus()
return
}
var html = editor.getHTML()
var editorController = checkEditor(html)
if (editorController) {
if (html.toString().length > 5000000) {
toastr.error("Too much content; images and texts greater than ~5mb :(")
return
}
toastr.info("Post sending")
var data = {
title: title,
content: html,
category: category,
tags: tags,
id: id
}
console.log(JSON.stringify(data))
// ajax - fetch
} else {
toastr.warning("Post can't be empty")
}
}
</script>
<script src="assets/js/app.js"></script>
<script src="assets/js/theme.js"></script>
</body>
</html>