-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.js
More file actions
99 lines (71 loc) · 2.7 KB
/
app.js
File metadata and controls
99 lines (71 loc) · 2.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
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
import { Github } from './github.js';
import { UI } from './ui.js';
// class'ın örneğini oluşturma
const github = new Github();
const ui = new UI();
//! Html'den gelenler
const searchInput = document.querySelector('#search-input');
const searchButton = document.querySelector('#search-btn');
const alert = document.querySelector('.alert');
//! olay izleyicileri
searchButton.addEventListener('click', getInput);
//! methodlar
function getInput() {
// arama terimi dolu ise çalışır
if (searchInput.value) {
// api 'isteği atar
github
.fetchUserData(searchInput.value)
.then((res) => {
// eğer kullanıcı bulunamadıysa
if (res.data.message === 'Not Found') {
showAlert2('Kullanıcı Bulunamadı!');
// arama terimi boş ise çalışır
function showAlert2(message2) {
alertDiv.textContent = message2;
alertDiv.style.display = 'block'; // Uyarı kutusunu görünür hale getir
alertDiv.style.border = '2px solid #FFF3CD';
alertDiv.style.marginTop = '20px';
alertDiv.style.backgroundColor = '#FFF3CD';
alertDiv.style.color = 'red';
// Uyarı kutusunu görünür hale getir
setTimeout(() => {
alertDiv.style.display = 'none'; // Uyarı kutusunu gizle
}, 3000);
}
} else {
// kullanıcı bulunduysa
ui.renderProfile(res.data);
ui.renderProjects(res.repos);
}
})
.catch((err) => console.log(err));
return;
}
showAlert('Lütfen bir kullanıcı adı girin!');
// arama terimi boş ise çalışır
function showAlert(message) {
alertDiv.textContent = message;
alertDiv.style.display = 'block'; // Uyarı kutusunu görünür hale getir
alertDiv.style.border = '2px solid #FFF3CD';
alertDiv.style.marginTop = '20px';
alertDiv.style.backgroundColor = '#FFF3CD';
alertDiv.style.color = 'red';
// Uyarı kutusunu görünür hale getir
setTimeout(() => {
alertDiv.style.display = 'none'; // Uyarı kutusunu gizle
}, 3000);
}
}
const modeToggleBtn = document.getElementById('mode-toggle-btn');
const lightModeStylesheet = document.getElementById('light-mode-stylesheet');
// Function to toggle between dark and light modes
function toggleMode() {
// Toggle the "disabled" attribute to enable or disable the light mode stylesheet
lightModeStylesheet.disabled = !lightModeStylesheet.disabled;
// Update the button text based on the current mode
const currentMode = lightModeStylesheet.disabled ? 'Koyu Mod' : 'Aydınlık Mod';
modeToggleBtn.innerText = currentMode;
}
// Add event listener to the mode toggle button
modeToggleBtn.addEventListener('click', toggleMode);