-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
67 lines (51 loc) · 1.7 KB
/
Copy pathindex.js
File metadata and controls
67 lines (51 loc) · 1.7 KB
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
const searchBox = document.getElementById('search-box');
const searchBtn = document.getElementById('search-btn');
const usernameh1 = document.getElementById('usernameh1');
searchBtn.addEventListener("click", getDetails);
searchBox.onfocus = () => {
setInterval(() => {
let username = searchBox.value;
if (username.length > 2) {
console.log("active button");
searchBtn.disabled = false;
}
else {
console.log("disable button");
searchBtn.disabled = true;
}
}, 1000);
};
function getDetails()
{
const githubUsername = searchBox.value;
console.log(githubUsername);
window.location.replace(`/github-wrapper-javascript/profile.html?${githubUsername}`);
// window.location.replace(`/profile.html?${githubUsername}`);
}
searchBox.addEventListener("keypress", function(event) {
if (event.key === "Enter") {
// Cancel the default action, if needed
// event.preventDefault();
// Trigger the button element with a click
searchBtn.click();
}
});
// function myFunction(x)
// {
// if (x.matches)
// { // If media query matches
// var element = document.getElementById("left-side");
// element.classList.remove("w-75");
// element.classList.add("w-100");
// var element = document.getElementById("right-side");
// element.classList.remove("w-25");
// element.classList.add("w-100");
// }
// else
// {
// document.body.style.backgroundColor = "pink";
// }
// }
// var x = window.matchMedia("(max-width: 700px)")
// myFunction(x) // Call listener function at run time
// x.addEventListener(myFunction)