-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
93 lines (80 loc) · 5.67 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<script src="./scripts/index.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.12.0/dist/cdn.min.js"></script>
<title>Partly Cloudy</title>
</head>
<body>
<div x-data="weather" class="container">
<template x-if="error">
<div class="alert mt-3 alert-warning alert-dismissible fade show" role="alert" x-init="setTimeout(() => error = null, 3000)" data-bs-delay="3000">
<div x-text="error"></div>
<button x-on:click="error = null" type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</template>
<div class="card mt-3">
<div class="container py-5 px-5 h-100" x-bind:style="{background: getWeatherColor()}">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-md-12 col-lg-8 col-xl-8" style="background-color: rgba(255, 255, 255, 0);">
<div class="text-center mb-5">
<h3 class="text text-muted text-center mb-0 pb-2 fw-normal">Partly Cloudy with a Chance of Sarcasm</h3>
<p>The Weather App That Tells It Like It Is</p>
</div>
<div class="input-group mb-3">
<input style="background-color: rgba(255, 255, 255, 0.5); font-weight: bold;" x-model="city_search" type="text" class="form-control" placeholder="Enter city" aria-label="Enter city" aria-describedby="button-addon2">
<button x-on:click="getCurrentWeather" class="btn btn-light" type="button" style="background-color: rgba(255, 255, 255, 0.5);">
<span x-show="isLoadingCheck" class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
Check
</button>
<button x-on:click="getAutoWeather" class="btn btn-light" type="button" style="background-color: rgba(255, 255, 255, 0.5);">
<span x-show="isLoadingMyLoc" class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
My Location
</button>
</div>
<div x-show="res !== null && res !== undefined" class="card" style="background-color: rgba(255, 255, 255, 0.5);">
<div class="card-body p-4 text-center">
<p x-text="res !== null ? `${res.location.region}, ${res.location.country}` : ''" class="lead mb-0"></p>
<p x-text="res !== null ? `${getFormattedDate(res.location.localtime)} | ${getlocalTime}` : ''" class="mb-0 d-block mt-1"></p>
<div class="row pb-0 align-items-center">
<div class="col-6 text-end">
<img x-bind:src="res !== null ? res.current.condition.icon : ''" alt="image-alt" style="width: 80px; height: 80px;">
</div>
<div class="col-6 text-start">
<h1 x-text="res !== null ? `${res.current.temp_c}°` : ''" ></h1>
</div>
</div>
<h6 x-text="res !== null ? `${res.current.condition.text}` : ''" class="mb-4"></h6>
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-2">
<template x-if="res">
<template x-for="day in res.forecast.forecastday">
<div class="col">
<div class="card h-100 p-1" style="background-color: rgba(255, 255, 255, 0.3);">
<div class="card-body">
<h6 class="card-title mb-0" x-text="getDayOfWeek(day.date)"></h6>
<hr>
<div class="align-items-center">
<img x-bind:src="day.day.condition.icon" alt="Weather Icon" style="width: auto; height: 60px;">
<div class="h6 font-weight-bold text-right" x-text="`${day.day.maxtemp_c}°C`"></div>
<p class="mt-3 mb-0" x-text="`${day.day.condition.text}`"></p>
</div>
</div>
</div>
</div>
</template>
</template>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>
</body>
</html>