-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagesPrev.html
560 lines (470 loc) · 19.8 KB
/
pagesPrev.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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
<!DOCTYPE html>
<HTML>
<title>CreateATX
</title>
<head>
<link rel="stylesheet" href="createatxstyles.css">
</head>
<body onload="loadDropdowns()">
<style>
#headerImage{
flex: 1;
overflow: hidden;
margin-right: 1rem;
margin-left: 1rem;
height: 400px;
object-fit: cover;
border-radius: 25px;
}
#imgBox {
display: flex;
flex-direction: row;
width: 100%;
align-items: center;
justify-content: center;
}
#buyBox {
display: flex;
width: 800px;
margin: 0px auto;
flex-direction: row;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
#purchaseImage {
flex: 1;
border-radius: 25px;
}
#buyButton {
flex: 0;
flex-basis: auto;
background-color: crimson;
border-radius: 10px;
color: white;
padding: 15 px 32 px;
text-align: center;
display: inline-block;
font-size: 16px;
width: 100px;
}
body {
margin: 0;
overflow: hidden;
}
#buyTitle {
flex: 1;
}
#buyText {
flex: 1;
}
.break {
flex-basis: 100%;
height: 0;
}
.modal {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
opacity: 0;
visibility: hidden;
transform: scale(1.1);
transition: visibility 0s linear 0.25s, opacity 0.25s 0s, transform 0.25s;
overflow-y: scroll;
align-items: flex-start;
}
.modal-content {
position: absolute;
/*margin-top: 100px;
margin-bottom: 100px; */
margin: auto;
margin-top: 200px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white;
padding: 1rem 1.5rem;
width: 65%;
border-radius: 0.5rem;
max-width: 830px;
overflow-y: scroll;
min-height: min-content;
}
.close-button {
float: right;
width: 1.5rem;
line-height: 1.5rem;
text-align: center;
cursor: pointer;
border-radius: 0.25rem;
background-color: lightgray;
}
.close-button:hover {
background-color: darkgray;
}
.show-modal {
opacity: 1;
visibility: visible;
transform: scale(1.0);
transition: visibility 0s linear 0s, opacity 0.25s 0s, transform 0.25s;
}
body{
overflow-y: scroll;
}
#replace{
overflow-y: scroll;
}
.modal{
overflow-y: scroll;
}
#clickMe2{
border-radius: 12px;
border: 3px solid rgb(0, 167, 167);
font-size: 20px;
background-color: rgb(157, 252, 128);
transition-duration: 0.4s;
}
#clickMe2:hover{
background-color: rgb(101, 252, 154);
}
table{
margin-left: auto;
margin-right: auto;
border-collapse: separate;
border-spacing: 50px;
}
img{
border-radius: 10px;
}
</style>
<nav class="navbar">
<div class="logo">CreateATX</div>
<ul class="nav-links">
<div class="menu">
<li><a href="/">Home</a></li>
<li class="services">Articles
<ul class="dropdown">
<li><a href="/createArticle.html">Create an Article</a></li>
<li><a href="/pagesPrev.html">View Articles</a></li>
</ul></li>
<li><a href="/colorGen.html">Color Palettes</a></li>
<li><a href="/mapPage.html">Art in Austin</a></li>
</div>
</ul>
</nav>
<br>
<input style = "width: 500px; height: 100px;", id="clickMe2" type="button" value="Filter by Article Type" text-align = center onclick="TestsFunction()" />
<input style = "width: 500px; height: 100px;", id="clickMe2" type="button" value="Remove Filters" text-align = center onclick="updateListings([]);" />
<fieldset id="Tests" style="display:none">
<div>
<input type="checkbox" id="medium" name="check" value="medium">
<label for="medium">Mediums</label>
</div>
<div>
<input type="checkbox" id="techniques" name="check" value="techniques">
<label for="techniques">Techniques</label>
</div>
<div>
<input type="checkbox" id="styles" name="check" value="styles">
<label for="styles">Styles</label>
</div>
<button type="button" onclick="applyFilters()">Filter</button>
</fieldset>
<br><br>
<div id = "replace"></div>
<br>
<br>
<!-- <select name="Article" id="Article">
<option value="test1">test1</option>
<option value="test2">test2</option>
</select>
<div id="button-group">
<p id="new-test">Test test</p>
<div>
<button id="button-1">Button 1</button>
</div>
<button id="button-2">Button 2</button>
<button id="button-3">Button 3</button>
<button id="button-4">Button 4</button>
<button id="button-5">Button 5</button>
</div> -->
<!-- <button class="trigger">Click here to trigger page preview!</button> -->
<div class="modal">
<div class="modal-content">
<span class="close-button">×</span>
<h1 id="myTitle">
<!-- title -->
</h1>
<h2 id="myAuthor">
<!---Article by: {{ author }} ✓-->
</h2>
<h3 id="date"><!--Date Posted: {{ date }}--></h3>
<div id = "imgBox">
<img src="" id="headerImage" > <br>
</div>
<br>
<br>
<div id="articletext">
<p id="myTexts">
</p>
</div>
<br><br>
</div>
</div>
</body>
<script>
window.onload = loadDropdowns();
//insert text
//document.getElementById("myTexts").innerHTML = "<embed src = '" + "filename" + "'>";
function changeModal(elementID){
var eID = elementID;
console.log(eID);
let url = "";
url = "http://165.22.183.12/articleData";
//var info = {
// "albumName": "Abbey Road"}
var info = '{ "employees" : [' +
'{ "firstName":"John" , "lastName":"Doe" },' +
'{ "firstName":"Anna" , "lastName":"Smith" },' +
'{ "firstName":"Peter" , "lastName":"Jones" } ]}';
const params = {
headers: {
"content-type": "application/json; charset=UTF-8",
},
body: info,
method: "POST",
};
fetch(url, params)
.then((data) => {
return data.json();
})
.then((result) => {
//console.log(result);
loginResponse = result.data;
console.log(loginResponse);
// below here should work...
var localName2 = "";
var localName3 = "";
var articleTitle ="";
var articleURL = "";
var articleAuthor = "";
var articleText = "";
var articleDate = "";
var article = "";
var articleVeri = "";
articleTitle = loginResponse[eID][1];
articleURL = loginResponse[eID][8];
articleAuthor = "Article by: " + loginResponse[eID][2];
articleText = loginResponse[eID][7];
articleDate = loginResponse[eID][4];
articleVeri = loginResponse[eID][3];
if(articleVeri == "on"){
articleAuthor += " ✓"
}
var articleIMGURL = '<img src=' + '"' + articleURL +'"' + "id='headerImage'>" ;
// Get the element with id="myDIV" (a div), then get all elements inside div with class="example"
//var x = document.getElementById("elementID").querySelectorAll("#title");
//var file = document.getElementById("Article");
//value of option selection
//var fileVal = file.options[file.selectedIndex].value;
var title = "My Title";
var author = "Article by: " + "author";
var imageLink = '<img src=' + '"' + "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Flower_poster_2.jpg/660px-Flower_poster_2.jpg" +'"' + "id='headerImage'>" ;
document.getElementById("myTitle").innerHTML = articleTitle;
document.getElementById("myAuthor").innerHTML = articleAuthor;
document.getElementById("imgBox").innerHTML = articleIMGURL;
document.getElementById("myTexts").innerHTML = articleText;
document.getElementById("date").innerHTML = articleDate;
modal.classList.toggle("show-modal");
})
.catch((error) => console.log(error));
}
const modal = document.querySelector(".modal");
const trigger = document.querySelector(".trigger");
const closeButton = document.querySelector(".close-button");
const replace = document.querySelector("#replace");
//const replace = document.querySelector("#replace");
//const imgClicks = document.querySelector
//takes in event id of img
function toggleModal(e){
var elementID = e.target.className;
console.log(elementID);
//elementID = parseInt(elementID);
var elIDNew = elementID.slice(1, -1);
//elementID = parseInt(elementID.replace(/^"|"$/g, ""), 10);
console.log(elIDNew);
elementIDN = parseInt(elIDNew);
console.log(elementIDN);
//document.getElementById("test").innerHTML = elementID;
changeModal(elementIDN);
}
//for window click - takes in event
function toggleModalE(e){
modal.classList.toggle("show-modal");
}
function windowOnClick(event){
if(event.target === modal){
toggleModalE(event);
}
}
//add event listener to each image instance
//document.querySelectorAll("img").forEach(occurence =>{
//occurence.addEventListener('click', (e) => {
//var elementId = e.target.className;
//var elementInt = parseInt(elementId);
// toggleModal(elementInt);
// })
// })
//const imageNodes = document.getElementsByTagName('img');
//const imgPressed = e => {
// console.log(e.target.className);
//}
//for(let img of imageNodes){
// img.addEventListener("click", buttonPressed);
//}
//for (var i=0; i<imageNodes.length; i++){
// imageNodes[i].addEventListener('click', e => {
// var elementId = e.target.className;
// var elementInt = parseInt(elementId);
// toggleModal(elementInt);
// })
// }
replace.addEventListener("click", toggleModal);
//trigger.addEventListener("click", toggleModal);
//trigger.addEventListener("click", () => { changeModal(file)})
closeButton.addEventListener("click", toggleModal);
window.addEventListener("click", windowOnClick);
//const replaceArea =
function updateListings(theArray) {
myArray = theArray;
let url = "";
url = "http://165.22.183.12/articleData";
//var info = {
// "albumName": "Abbey Road"}
var info = '{ "employees" : [' +
'{ "firstName":"John" , "lastName":"Doe" },' +
'{ "firstName":"Anna" , "lastName":"Smith" },' +
'{ "firstName":"Peter" , "lastName":"Jones" } ]}';
const params = {
headers: {
"content-type": "application/json; charset=UTF-8",
},
body: info,
method: "POST",
};
fetch(url, params)
.then((data) => {
return data.json();
})
.then((result) => {
//console.log(result);
loginResponse = result.data.reverse();
console.log("login Response");
console.log(loginResponse);
var v1 = document.getElementById("medium");
var v2 = document.getElementById("techniques");
var v3 = document.getElementById("styles");
console.log("myArray")
console.log(myArray);
if(myArray.length > 0){
const filteredData = [];
for(let i=0; i<loginResponse.length; i++){
if(theArray.includes(loginResponse[i][6]) == true){
filteredData.push(loginResponse[i]);
}
}
console.log("filtered Data");
console.log(filteredData);
loginResponse = filteredData;
}
// below here should work...
var localName2 = "";
var localName3 = "";
var articleTitle ="";
var articleURL = "";
var articleAuthor = "";
var articleText = "";
var article = "";
for (let i = 0; i < loginResponse.length; i++) {
articleTitle = loginResponse[i][1];
articleURL = loginResponse[i][8];
articleAuthor = loginResponse[i][2];
articleText = loginResponse[i][7];
articleID = loginResponse[i][0] -1;
//if it's first index
//start with <table> <tr> <td id = articleID > <div id = image + articleID> </div> <span id=title> articleTitle </span> <span id="author">By: articleAuthor </span> </td>
//'<section id = "' + articleID + '">' + '<div id = "image' + articleID + '">' + "</div>" + '<span id = "title">' + articleTitle + '</span>' + "<br>" + '<span id = "author">' + "By: " + articleAuthor + "</span>" + "</section>";
if(i==0){
article = article + '<table><tr><td id="' + articleID + '">' + '<div id = "image' + articleID + '">' + "</div>" + '<span id="title">' + articleTitle + '</span><br><span id="author">By: ' + articleAuthor + "</span></td>" ;
}
//last index
//end in </td></tr></table>
else if(i== loginResponse.length -1){
article = article + '<td id="' + articleID + '">' + '<div id = "image' + articleID + '">' + "</div>" + '<span id="title">' + articleTitle + '</span><br><span id="author">By: ' + articleAuthor + "</span></td></tr></table>" ;
}
//end of row
//end row start new row
//end in </td></tr><tr>
else if((i+1)%4==0){
article = article + '<td id="' + articleID + '">' + '<div id = "image' + articleID + '">' + "</div>" + '<span id="title">' + articleTitle + '</span><br><span id="author">By: ' + articleAuthor + "</span></td></tr><tr>" ;
}
//if it's normal situation
//start <td> end <td>
else{
article = article + '<td id="' + articleID + '">' + '<div id = "image' + articleID + '">' + "</div>" + '<span id="title">' + articleTitle + '</span><br><span id="author">By: ' + articleAuthor + "</span></td>" ;
}
//localName2 = localName2 + "<br>"+ '<div id = "image' + i + '">' + "</div>" + '<div id = "record' + i + '">' + loginResponse[i][2] + " by " + loginResponse[i][1] + " - $" + loginResponse[i][7] + "</div>";
//localName3 = localName3 + "<br>"+ '<div id = "image' + i + '">' + "</div>";
//article= article + "<br>" + '<section id = "' + articleID + '">' + '<div id = "image' + articleID + '">' + "</div>" + '<span id = "title">' + articleTitle + '</span>' + "<br>" + '<span id = "author">' + "By: " + articleAuthor + "</span>" + "</section>";
}
//self, article_title, author_username, author_verification, article_text_path, article_type, article_texts, article_img
var x = article;
console.log("article");
console.log(x);
document.getElementById("replace").innerHTML = x;
for (let i = 0; i < loginResponse.length; i++) {
var img = document.createElement('img');
img.src =loginResponse[i][8];
articlesID = loginResponse[i][0] -1 ;
img.classList.add("'" + articlesID + "'");
document.getElementById("image" + articlesID).appendChild(img);
img.style.width = '200px';
img.style.height = '200px';
}
})
.catch((error) => console.log(error));
}
function loadDropdowns(){
updateListings([]);
}
function applyFilters() {
var items = document.getElementsByName("check");
var selectedItems = "";
for (var i = 0; i < items.length; i++) {
if (items[i].type == "checkbox" && items[i].checked == true) selectedItems += items[i].value + ",";
}
selectedItems = selectedItems.replace(/,\s*$/, "");
console.log("selectedItemsCheck");
console.log(selectedItems);
var array = selectedItems.split(',');
console.log("array check");
console.log(array);
updateListings(array)
}
var switcher = 0;
function TestsFunction() {
var T = document.getElementById("Tests");
if(switcher ==0){
T.style.display = "block"; // <-- Set it to block
switcher = 1
}
else if(switcher == 1){
T.style.display = "none"; // <-- Set it to block
switcher = 0
}
}
</script>
</HTML>