-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchComponent.js
143 lines (128 loc) · 4.65 KB
/
searchComponent.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
import "./css/home.css";
import twitchIcon from "./images/twitch-icon-5.png";
import instagramIconImg from "./images/instagram.png";
import searchIcon from "./images/search-icon.png";
import youtubeIcon from "./images/white-youtube.png";
// prettier-ignore
document.querySelector(".search_engine").innerHTML =//html
`
<div class="container_search_engine inputSelect">
<div class="input_search inputSelect">
<input
id="input_searchId" class=" inputSelect" title="search"
placeholder="COSITA HERMOZA! ,COSITA BIEN HECHA!!!"
type="search" data-search
>
</div>
<div class="object1"></div>
<div class="icon_search">
<img src="${searchIcon}" alt="icon-search" />
</div>
<br>
<div class="social_networks">
<div id="twitch_icon" class="icons_social_networks">
<img src="${twitchIcon}" alt="twitch-icon-5" />
</div>
<div id="youtube_icon" class="icons_social_networks">
<img src="${youtubeIcon}" alt="white-youtube" />
</div>
<div id="instagram_icon" class="icons_social_networks">
<img src="${instagramIconImg}" alt="instagram" />
</div>
</div>
</div>
`;
// here start the config of cards
const userCardTemplate = document.querySelector("[data-template-users]");
const userCardContainer = document.querySelector("[data-card-container]");
const searchInputCard = document.querySelector("[data-search]");
let users = [];
searchInputCard.addEventListener("input", (e) => {
const value = e.target.value.toLowerCase();
users.forEach((user) => {
const isVisible =
user.name.toLowerCase().includes(value) ||
user.email.toLowerCase().includes(value);
user.element.classList.toggle("hide", !isVisible);
});
// console.log(users)
});
fetch("http://jsonplaceholder.typicode.com/users")
.then((res) => res.json())
.then((data) => {
users = data.map((user) => {
const card = userCardTemplate.content.cloneNode(true).children[0];
const header = card.querySelector("[data-header-card]");
const bodyCard = card.querySelector("[data-body-card]");
header.textContent = user.name;
bodyCard.textContent = user.email;
userCardContainer.append(card);
// console.log(user);
return { name: user.name, email: user.email, element: card };
});
});
// Get the modal
var modal = document.getElementById("myModal");
// Get the button that opens the modal
const btn = document.querySelector("#input_searchId");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
let elementsArray = document.querySelectorAll(".inputSelect");
var inputSearch = document.querySelector(".input_search");
btn.oninput = function () {
if (btn.value !== 0) {
modal.style.display = "block";
document.querySelector(".modal").style.paddingTop = "360px";
}
btn.innerHTML = btn.value;
// console.log( btn.innerHTML)-----
/* do something that appear x in right position
*this x delete text content insite input
*/
};
btn.onclick =
/**
* Description placeholder
* @date 2/26/2024 - 6:16:27 PM
*/
function () {
document.querySelector(".modal").style.paddingTop = "350px";
modal.style.display = "block";
// console.log(elementsArray);
console.log(document.querySelector(".modal").style.paddingTop);
// console.log(document.getElementsByClassName("input_search"));
};
// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
};
// When the user clicks anywhere outside of the modal, close it
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
};
// CONFIGS AND EFFECTS OF SOCIALS
const windowOfSearchs = document.getElementById("input_search");
const object1 = document.querySelector(".object1");
const instagramIcon = document.getElementById("instagram_icon");
// console.log(windowOfSearchs);
function modify() {
if (object1.style.display === "none") {
object1.style.display = "block";
} else {
object1.style.display = "none";
}
}
function linkConEspera() {
// crear un cronómetro de 3seg pra avisar cuando me llevo a mi ig
document.createElement("div");
alert("en 3seg te llevo a mi ig...");
setInterval(console.log("en 3seg te llevo a mi ig..."), 0);
setTimeout(() => window.open("https://www.instagram.com/victorcode_/"), 2500);
}
instagramIcon.addEventListener("click", linkConEspera, false);
// windowOfSearchs.addEventListener("click",modify,false)
// alert('searching data...')
// const object1=document.createElement('div')