-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
148 lines (110 loc) · 4.39 KB
/
index.js
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
var Create_Button = document.getElementById('New_Listing_Button');
Create_Button.addEventListener('click', function() {unhideModal();});
var Create_Button1 = document.getElementById('New_buy_Button');
Create_Button1.addEventListener('click', function() {unhideModal();});
var Create_Button2 = document.getElementById('New_sell_Button');
Create_Button2.addEventListener('click', function() {unhideModal();});
function unhideModal(){
document.getElementById("Popup_Background").style.display ="block";
document.getElementById("Dialog_Window").style.display = "block";
}
var Close_Button = document.getElementsByClassName('Close_Button')[0];
Close_Button.addEventListener('click', function() {closeModal();});
var Close_Button = document.getElementsByClassName('Window_Cancel_Button')[0];
Close_Button.addEventListener('click', function() {closeModal();});
var Accept_Button = document.getElementsByClassName('Window_Accept_Button')[0];
Accept_Button.addEventListener('click', function() {acceptButton();});
function closeModal(){
document.getElementById("Popup_Background").style.display ="none";
document.getElementById("Dialog_Window").style.display = "none";
document.getElementById("text_input").value = "";
document.getElementById("Date_Input").value = "";
}
function acceptButton(){
if (document.getElementById("text_input").value === "" && document.getElementById("Date_Input").value === "")
{
alert("You did not enter any text for either field")
return 0;
}
else if (document.getElementById("text_input").value === "")
{
alert("You did not enter any text")
return 0;
}
else if(document.getElementById("Date_Input").value === "")
{
alert("You did not enter any text for a Attribution")
return 0;
}
else
{
var main = document.createElement("main");
var div0 = document.createElement("div");
var article = document.createElement("article");
console.log(article);
var div1 = document.createElement("div");
var i = document.createElement("I");
var div2 = document.createElement("div");
var p = document.createElement("P");
var p2 = document.createElement("P");
var a = document.createElement("A");
var img = document.createElement("img");
div0.appendChild(article);
article.appendChild(div1);
div1.appendChild(i);
article.appendChild(div2);
div2.appendChild(p);
img.appendChild(p);
div2.appendChild(p2);
p2.appendChild(a);
div0.className = "Post";
article.className = "Listing_Box";
div1.className = "Description_Field";
i.className = "fa fa-flag";
div2.className = "Description_Field";
p.className = "Text_On_Screen";
img.className = "Thumbnail";
img.src = document.getElementById("Img_URL").value;
p2.className = "Sale_Date_Time";
a.className = "#";
var new_text = document.createTextNode(document.getElementById("text_input").value);
var New_date = document.createTextNode(document.getElementById("Date_Input").value);
var New_URL = document.createTextNode(document.getElementById("Img_URL").value);
new_text.classname = "Text_On_Screen";
New_date.classname = "Sale_Date_Time";
New_URL.classname = "Img_URL";
p.appendChild(new_text);
p2.appendChild(New_date);
p2.appendChild(img);
div1.appendChild(p);
div1.appendChild(p2);
var container = document.getElementsByClassName("Post");
container[0].appendChild(article);
document.getElementById("Popup_Background").style.display ="none";
document.getElementById("Dialog_Window").style.display = "none";
document.getElementById("text_input").value = "";
document.getElementById("Date_Input").value = "";
document.getElementById("Img_URL").value = "";
}
};
/***********************SEARCH FUNCTION************************************/
var navbarSearchbutton = document.getElementById('Search_Button');
navbarSearchbutton.addEventListener('click', function() {
searchFunction();
});
document.getElementById("Menu_Bar_Search_Input").addEventListener("keyup", searchFunction);
function searchFunction() {
var input, filter, ul, li, a, i, foo;
foo = document.getElementsByClassName("Listing_Box");
foo2 = document.getElementsByClassName("Sale_Box");
input = document.getElementById("Menu_Bar_Search_Input");
filter = input.value.toUpperCase();
for (i = 0; i < foo.length; i++) {
ul = foo[i];
if (ul.textContent.toUpperCase().indexOf(filter) > -1) {
ul.style.display = "";
} else {
ul.style.display = "none";
}
}
}