-
Notifications
You must be signed in to change notification settings - Fork 0
/
o.js
158 lines (141 loc) · 5.05 KB
/
o.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
149
150
151
152
153
154
155
156
157
158
setInterval(() => {
var date = new Date();
var min = date.getMinutes();
var hour = date.getHours();
var sec = date.getSeconds();
var noon;
document.querySelector("#sec").style.transform = "rotateZ(" + (sec * 6) + "deg)";
document.querySelector("#min").style.transform = "rotateZ(" + (min * 6) + "deg)";
document.querySelector("#hour").style.transform = "rotateZ(" + (hour * 30.4) + "deg)";
if (hour > 12) {
hour = hour - 12;
noon = " PM";
} else {
noon = " AM";
}
if (min.toString().length < 2) {
min = "0" + min;
}
if (sec.toString().length < 2) {
sec = "0" + sec;
}
document.querySelector("#home").innerHTML = hour + ":" + min + ":" + sec + noon;
}, 100);
$("document").ready(function() {
$("#set").click(function() {
var mins = $("#mino").val();
var secs = $("#seco").val();
var mil = $("#mili").val();
if ((mins < 0) || (secs < 0) || (mil < 0)) {
alert("abey saale");
} else {
var t = setInterval(() => {
mil--;
if (mil < 0) {
mil = 59;
secs--;
}
if (secs < 0) {
secs = 59;
mins--;
}
if (mins == 0 && secs == 0 && mil == 0) {
alert("hey its compvare");
clearInterval(t);
$("#mili").val(0);
$("#seco").val(0);
$("#mino").val(0);
}
if (mil.toString().length < 2) {
mil = "0" + mil;
}
if (secs.toString().length < 2) {
secs = "0" + secs;
}
if (mins.toString().length < 2) {
mins = "0" + mins;
}
$('#newT').html(mins + ":" + secs + ":" + mil + "")
}, 1000)
}
})
var newAlarm = new Array();
var date = new Date();
$("#setTime").click(() => {
var time = $("#time").val();
if (time != "") {
newAlarm.push(time);
newAlarm.sort();
}
})
var k = setInterval(() => {
for (let i = 0; i < newAlarm.length; i++) {
let well = newAlarm[i].toString();
console.log(newAlarm[0])
console.log((date.getHours() + ":" + date.getMinutes()))
console.log(well == (date.getMinutes() + ":" + date.getSeconds()).toString())
if (newAlarm[i].toString() == (date.getMinutes() + ":" + date.getSeconds())) {
alert("hello");
break;
clearInterval(k);
}
}
}, 1000)
var count = 0;
$("#add").click(() => {
var val = $("#text").val();
if (val == "") {
alert("first add something")
} else {
count++;
var newL = document.createElement("li");
newL.innerHTML = val;
var radio = document.createElement("input");
radio.type = 'radio';
document.querySelector("#list").appendChild(newL);
document.querySelector("#list li:nth-child(" + count + ")").appendChild(radio);
$("#text").val('');
}
})
})
function getWeather() {
var temperature = document.querySelector("#temperature");
var description = document.querySelector("#description");
var location = document.querySelector("#location");
var api = "https://api.openweathermap.org/data/2.5/weather";
var apiKey = "f146799a557e8ab658304c1b30cc3cfd";
navigator.geolocation.getCurrentPosition(success, error);
function success(position) {
console.log("hey success");
latitude = position.coords.latitude;
longitude = position.coords.longitude;
var url =
api +
"?lat=" +
latitude +
"&lon=" +
longitude +
"&appid=" +
apiKey +
"&units=imperial";
fetch(url)
.then(response => response.json())
.then(data => {
console.log(data);
const temp = data.main.temp;
const cel = parseInt((temp - 32) * 5 / 9);
if (cel > 30) {
document.querySelector("#weather").style.background = "url(https://cdn.pixabay.com/photo/2016/01/19/21/41/painting-1150525_960_720.jpg)"
}
console.log(parseInt(cel));
document.querySelector("#temp").innerHTML = cel + "°C";
console.log(
data.name + " (" + latitude + "°, " + longitude + "°)");
document.querySelector("#map").innerHTML = data.weather[0].main;
});
}
function error() {
location.innerHTML = "Unable to retrieve your location";
}
}
getWeather();