fix for new name (probably)

master
Drake 12 months ago
parent 8853f7b7c0
commit c6de2901ac

2
Cargo.lock generated

@ -3,7 +3,7 @@
version = 3
[[package]]
name = "matcha_weather"
name = "maccha_weather"
version = "0.1.0"
dependencies = [
"mexprp",

@ -1,5 +1,5 @@
[package]
name = "matcha_weather"
name = "maccha_weather"
version = "0.1.0"
edition = "2021"

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Svelte + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

@ -1,29 +1,34 @@
<script lang="ts">
function encodeRFC3986URIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
}
import { http } from "@tauri-apps/api";
function encodeRFC3986URIComponent(str) {
return encodeURIComponent(str).replace(
/[!'()*]/g,
(c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`
);
}
import { http } from "@tauri-apps/api";
let place = "Unknown, Unknown";
let temp_c = "";
let temp_f = "";
let place = "Unknown, Unknown";
let temp_c = "";
let temp_f = "";
window.addEventListener("matcha-submit", async (event: CustomEventInit) => {
const query = `https://wttr.in/${encodeRFC3986URIComponent(event.detail.substring(4).trim())}?format=j1`;
console.log(query);
const res = await http.fetch(query);
window.addEventListener("maccha-submit", async (event: CustomEventInit) => {
const query = `https://wttr.in/${encodeRFC3986URIComponent(
event.detail.substring(4).trim()
)}?format=j1`;
console.log(query);
const res = await http.fetch(query);
const data = res.data as { [k: string]: any };
const data = res.data as { [k: string]: any };
console.log(data);
console.log(data);
place = `${data.nearest_area[0].areaName[0].value}, ${data.nearest_area[0].country[0].value}`;
temp_c = data.current_condition[0].temp_C;
temp_f = data.current_condition[0].temp_F;
});
place = `${data.nearest_area[0].areaName[0].value}, ${data.nearest_area[0].country[0].value}`;
temp_c = data.current_condition[0].temp_C;
temp_f = data.current_condition[0].temp_F;
});
</script>
<div class="matcha-weather">
<h1 class="weather-header">{place}</h1>
<h2 class="temperature-header">{temp_c}°C / {temp_f}°F</h2>
<div class="maccha-weather">
<h1 class="weather-header">{place}</h1>
<h2 class="temperature-header">{temp_c}°C / {temp_f}°F</h2>
</div>

@ -1,5 +1,5 @@
.matcha-weather {
display: flex;
flex-direction: column;
align-items: center;
.maccha-weather {
display: flex;
flex-direction: column;
align-items: center;
}

Loading…
Cancel
Save