-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
147 lines (128 loc) · 4.77 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
// ---
const hamMenuBtn = document.querySelector('.header__main-ham-menu-cont')
const smallMenu = document.querySelector('.header__sm-menu')
const headerHamMenuBtn = document.querySelector('.header__main-ham-menu')
const headerHamMenuCloseBtn = document.querySelector(
'.header__main-ham-menu-close'
)
const headerSmallMenuLinks = document.querySelectorAll('.header__sm-menu-link')
hamMenuBtn.addEventListener('click', () => {
if (smallMenu.classList.contains('header__sm-menu--active')) {
smallMenu.classList.remove('header__sm-menu--active')
} else {
smallMenu.classList.add('header__sm-menu--active')
}
if (headerHamMenuBtn.classList.contains('d-none')) {
headerHamMenuBtn.classList.remove('d-none')
headerHamMenuCloseBtn.classList.add('d-none')
} else {
headerHamMenuBtn.classList.add('d-none')
headerHamMenuCloseBtn.classList.remove('d-none')
}
})
for (let i = 0; i < headerSmallMenuLinks.length; i++) {
headerSmallMenuLinks[i].addEventListener('click', () => {
smallMenu.classList.remove('header__sm-menu--active')
headerHamMenuBtn.classList.remove('d-none')
headerHamMenuCloseBtn.classList.add('d-none')
})
}
// ---
const headerLogoConatiner = document.querySelector('.header__logo-container')
headerLogoConatiner.addEventListener('click', () => {
location.href = 'index.html'
})
//my js script
function calcirisl22(radius) {
return 2 * Math.PI * radius;
}
function calcirisl() {
let inputElement = document.getElementById("calcirisl");
let resultElement = document.getElementById("atoz");
let radius = parseFloat(inputElement.value);
if (!isNaN(radius)) {
let circumference = calcirisl22(radius);
resultElement.textContent = circumference.toFixed(2);
} else {
resultElement.textContent = "กรุณากรอกค่าที่ถูกต้อง";
}
}
printAlphabets();
function clicktochange() {
document.getElementById("clicktochange").innerHTML = "Now you don't<br><img src='assets/gif/apex-mirage.gif'>";
}
function myFunction2() {
// Get the value of the input field with id="numb"
let x = document.getElementById("numb").value;
// If x is Not a Number or less than one or greater than 10
let text;
if (isNaN(x) || x < 1 || x > 10) {
text = "Input not valid";
} else {
text = "Input OK";
}
document.getElementById("demo3").innerHTML = text;
}
function randomnumberr(){
document.getElementById("showrannumber").innerHTML = "สุ่มตัวเลข: " + Math.floor(Math.random() * 11);
}
function bigtextt(){
var str = prompt("Enter name ");
var res = str.slice(0,1).toUpperCase()+str.slice(1);
document.getElementById("showbigtext").innerHTML = "ตัวอักษรตัวแรกใหญ่เสมอ: " + res;
alert(res);
}
var typed = new Typed('#element', {
strings: ['programming.','play minecraft.', 'cat.'],
typeSpeed: 60,
backDelay: 4000,
smartBackspace: true,
showCursor: true,
cursorChar: '<b><font color="#FFFFFFFF">|</font></b>',
autoInsertCss: true,
loop: true
});
//getRandomQuote
function getRandomQuote() {
const apiUrl = 'https://animechan.xyz/api/random';
fetch(apiUrl).then(response => {
if (!response.ok) {
throw new Error(`Network response was not ok: ${response.status}`);
}
return response.json();
})
.then(dataText => {
console.log(dataText);
const imageAPI = `https://api.jikan.moe/v4/characters?q=${dataText.character}`
fetch(imageAPI).then(responseImage =>{
if(!responseImage.ok){
throw new Error(`Network response was not ok: ${responseImage.status}`);
}
return responseImage.json();
}).then(image => {
// console.log(image);
console.log(image.data[0].images.webp.image_url);
const animeimage = document.getElementById('animeimage');
animeimage.src = image.data[0].images.webp.image_url;
})
document.getElementById("catcat").innerHTML = dataText.quote + "<br>- " + dataText.character +" ("+dataText.anime+")";
})
.catch(error => {
console.error('Fetch error:', error);
});
}
async function getAnimePoster(){
const parameterValue = document.getElementById('posterfinder').value;
const posterAPI = `https://api.jikan.moe/v4/anime?q=${parameterValue}&sfw`;
fetch(posterAPI).then(responsePoster =>{
if(!responsePoster.ok){
throw new Error(`Network response was not ok: ${responseImage.status}`);
}
return responsePoster.json();
}).then(poster =>{
console.log(poster.data[0].images.webp.image_url);
const PosterImage = document.getElementById('PosterImage');
PosterImage.src = poster.data[0].images.webp.image_url;
})
}
//