-
Notifications
You must be signed in to change notification settings - Fork 0
/
main copy.html
316 lines (300 loc) · 12.6 KB
/
main copy.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
<!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>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous" />
<link rel="stylesheet" href="style.css">
<style>
.mainheading {
font-size: 2em;
font-weight: bolder;
text-align: center;
}
.mainheading:hover #button1 {
display: inline-block;
}
.subheading {
font-size: 1.5em;
font-weight: bold;
}
.subheading:hover #button1 {
display: inline-block;
}
.paragraph {
font-size: 1em;
padding-top: 5px;
}
.paragraph:hover #button1 {
display: inline-block;
}
#button1 {
background-color: transparent;
border: none;
display: none;
}
i {
font-size: 20px;
}
img {
width: 100%;
}
</style>
</head>
<body>
<div class="page-wrapper">
<div class="nav-wrapper">
<div class="grad-bar"></div>
<nav class="navbar">
<h1 class="img font-weight-bold d-none d-sm-none d-md-none d-lg-block">Foxiton Blog Generator</h1>
<h1 class="img font-weight-bold d-block d-sm-block d-md-block d-lg-none">Foxiton</h1>
<div class="menu-toggle" id="mobile-menu">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</div>
<ul class="nav no-search">
<li class="nav-item"><a href="#">Home</a></li>
<li class="nav-item"><a href="#">About</a></li>
<li class="nav-item"><a href="#">Work</a></li>
<li class="nav-item"><a href="#">Careers</a></li>
<li class="nav-item"><a href="#">Contact Us</a></li>
<i class="fas fa-search" id="search-icon"></i>
<input class="search-input" type="text" placeholder="Search..">
</ul>
</nav>
</div>
</div>
<div>
<div id='mainform' class="container border-left border-right col-lg-8 my-5">
</div>
<button onclick="generate()" class="btn" id='generator'>Generate</button>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
function fetchlink() {
link = document.getElementById('data').value
quotation_index=link.indexOf('?')
if(quotation_index!=-1){
link=link.slice(0,quotation_index)
console.log(link)
}
var imagePane = document.getElementById('imagePane');
imagePane.setAttribute('src', link)
}
function toggleUploadButton() {
console.log('toggling')
selectiontag = document.getElementById('tagtype')
if (selectiontag.value == 'image') {
document.getElementById('imageUpload').style.display = 'block'
document.getElementById('imagePane').style.display = 'block'
document.getElementById('imageProgressBar').style.display = 'block'
document.getElementById('data').setAttribute('placeholder', 'Please paste link of Image')
document.getElementById('data').setAttribute('onchange', 'fetchlink()')
}
else {
document.getElementById('imageUpload').style.display = 'none'
document.getElementById('imageProgressBar').style.display = 'none'
document.getElementById('imagePane').style.display = 'none'
document.getElementById('data').setAttribute('placeholder', '')
document.getElementById('data').setAttribute('onchange', '')
//var output = document.getElementById('imagePane');
//output.src = ''
}
}
function showimage() {
var output = document.getElementById('imagePane');
output.setAttribute('src', URL.createObjectURL(event.target.files[0]));
}
options_dict={
'Main heading':'mainheading',
'Sub heading':'subheading',
'Paragraph':'paragraph',
'Image':'image'
}
function scaleImage(){
var imagePane= document.getElementById('imagePane');
imageProgressBar=document.getElementById('imageProgressBar')
imagePane.setAttribute('style','width:'+imageProgressBar.value+'%')
}
function getmaindiv(clsname, innerText, eleid) {
maindiv = document.createElement('div')
selecttag = document.createElement('select')
maindiv.setAttribute('id', 'maindiv')
selecttag.classList.add("btn", "bg-light", "my-3")
selecttag.setAttribute('id', 'tagtype')
selecttag.setAttribute('onchange', 'toggleUploadButton()')
options=Object.keys(options_dict)
for (i = 0; i < options.length; i++) {
option = document.createElement('option')
option.setAttribute('value', options_dict[options[i]])
if (options_dict[options[i]] == clsname) {
option.setAttribute('selected', "")
}
option.innerHTML = options[i]
selecttag.append(option)
}
maindiv.append(selecttag)
inputtag = document.createElement('textarea')
inputtag.setAttribute('value', innerText)
inputtag.classList.add("form-control", "mb-3")
inputtag.setAttribute('id', 'data')
imagePane = document.createElement('img')
imagePane.setAttribute('id', 'imagePane')
if (clsname == 'image') {
imagePane.setAttribute('src', innerText)
}
else {
inputtag.innerHTML = innerText
}
maindiv.append(imagePane)
imageupload = document.createElement('input')
imageupload.innerHTML = 'Upload Image'
imageupload.setAttribute('id','imageUpload')
imageupload.setAttribute('type','file')
imageupload.setAttribute('accept','image/*')
imageupload.setAttribute('onchange','showimage(event)')
imageProgressBar=document.createElement('input')
imageProgressBar.setAttribute('type','range')
imageProgressBar.setAttribute('min','0')
imageProgressBar.setAttribute('max','100')
imageProgressBar.setAttribute('value','100')
imageProgressBar.setAttribute('id','imageProgressBar')
imageProgressBar.setAttribute('onchange','scaleImage()')
imageupload.style.display = 'none'
button = document.createElement('button')
button.classList.add("btn", "bg-light", "mb-3")
button.innerHTML = 'Submit'
button.setAttribute('id', 'submit')
button.setAttribute('onclick', 'submit("' + eleid + '")')
maindiv.append(inputtag)
maindiv.append(imageProgressBar)
maindiv.append(imageupload)
maindiv.append(button)
return maindiv
}
count = 1
editstate = false
function generate() {
document.getElementById('data').remove()
document.getElementById('tagtype').remove()
document.getElementById('generator').remove()
document.getElementById('submit').remove()
}
function deleteElement(eleid) {
document.getElementById(eleid).remove()
//document.getElementById('maindiv').style.display="block"
}
function editElement(eleid) {
if (editstate == false) {
editstate = true
}
else {
alert('Can only edit 1 element at a time')
return
}
document.getElementById('maindiv').style.display = "none"
outsidediv = document.getElementById(eleid)
insidediv = outsidediv.getElementsByTagName('div')[0]
clsname = insidediv.className
if (clsname == 'image') {
imagePane=document.getElementById('imagePane')
innerText = imagePane.src
}
else {
innercontent = insidediv.innerHTML
innercontent_index = innercontent.indexOf('<')
innerText = innercontent.slice(0, innercontent_index)
}
insidediv.remove()
maindiv = getmaindiv(clsname, innerText, eleid)
document.getElementById('mainform').append(maindiv)
outsidediv.append(maindiv)
toggleUploadButton()
}
//generate button
//next line
//
function submit(eid) {
editstate = false
document.getElementById('maindiv').style.display = "block"
tagtype = document.getElementById('tagtype').value
data = document.getElementById('data').value
outsidediv = document.createElement('div')
outsidediv.setAttribute('id', 'element' + count)
div = document.createElement('div')
div.setAttribute('class', tagtype)
console.log(tagtype)
if (tagtype == 'image') {
imagepane = document.getElementById('imagePane')
imagepane.setAttribute('id','imagePane-submitted')
div.append(imagepane)
}
else {
div.innerHTML = data
}
editbutton = document.createElement('button')
editbutton.setAttribute('id', 'button1')
editbutton.classList.add("text-success")
delbutton = document.createElement('button')
delbutton.setAttribute('id', 'button1')
delbutton.classList.add("text-danger")
editbutton.innerHTML = '<i class="fad fa-edit px-2"></i>'
delbutton.innerHTML = '<i class="fad fa-trash-alt px-2"></i>'
if (eid == "None") {
editbutton.setAttribute('onclick', "editElement('element" + count + "')")
div.append(editbutton)
delbutton.setAttribute('onclick', "deleteElement('element" + count + "')")
div.append(delbutton)
}
else {
editbutton.setAttribute('onclick', "editElement('" + eid + "')")
div.append(editbutton)
delbutton.setAttribute('onclick', "deleteElement('" + eid + "')")
div.append(delbutton)
}
outsidediv.append(div)
if (eid != 'None') {
console.log(eid)
document.getElementById(eid).innerHTML = ""
document.getElementById(eid).append(div)
}
else {
document.getElementById('data').remove()
document.getElementById('tagtype').remove()
document.getElementById('submit').remove()
document.getElementById('maindiv').remove()
try {
document.getElementById('imageUpload').remove()
}
catch (e) {
}
document.getElementById('mainform').append(outsidediv)
count = count + 1
createnewmain(tagtype)
}
document.getElementById('maindiv').style.display = "block"
}
function createnewmain(classname) {
maindiv = getmaindiv(classname, "", "None")
document.getElementById('mainform').append(maindiv)
toggleUploadButton()
}
createnewmain()
$("#search-icon").click(function () {
$(".nav").toggleClass("search");
$(".nav").toggleClass("no-search");
$(".search-input").toggleClass("search-active");
});
$('.menu-toggle').click(function () {
$(".nav").toggleClass("mobile-nav");
$(this).toggleClass("is-active");
});
</script>
</body>
</html>