-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const $ = document.querySelector.bind(document); | ||
|
||
export const $$ = document.querySelectorAll.bind(document); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { TARGET } from "./dustUtil.js"; | ||
|
||
export function getCurrentLocation() { | ||
navigator.geolocation.getCurrentPosition((position) => { | ||
getStationData(position.coords.latitude, position.coords.longitude); | ||
}); | ||
} | ||
|
||
async function getStationData(latitude, longitude) { | ||
const options = { | ||
method: 'GET' | ||
}; | ||
const response = await fetch(`http://15.165.113.21:8080/location?coordinateWGS84=${longitude},${latitude}`, options); | ||
const result = await response.json(); | ||
const stationName = result.responseMessage[0].stationName; | ||
getDustData(stationName); | ||
} | ||
|
||
async function getDustData(stationName) { | ||
const options = { | ||
method: 'GET' | ||
}; | ||
const response = await fetch(`http://15.165.113.21:8080/dust-status?stationName=${stationName}`, options); | ||
const result = await response.json(); | ||
render(stationName, result.responseMessage); | ||
} | ||
|
||
function render(stationName, dustData) { | ||
renderStation(stationName); | ||
} | ||
|
||
function renderStation(stationName) { | ||
TARGET.location.innerText = stationName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { $ } from "../common/util.js"; | ||
|
||
export const TARGET = { | ||
location: $('.dust-location') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { getCurrentLocation } from "./dust/dust.js"; | ||
|
||
window.addEventListener('DOMContentLoaded', () => { | ||
getCurrentLocation(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
@charset 'utf-8'; | ||
|
||
body, html { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
body, button, dd, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, input, legend, li, ol, p, select, table, td, textarea, th, ul { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body, button, input, select, table, textarea { | ||
font-family: Dotum, "돋움", Helvetica, sans-serif; | ||
font-size: 12px; | ||
-webkit-text-size-adjust: none; | ||
} | ||
|
||
button, input, select, textarea { | ||
border: 0; | ||
border-radius: 0; | ||
-webkit-appearance: none; | ||
-moz-appearance: none; | ||
appearance: none; | ||
} | ||
|
||
button { | ||
cursor: pointer; | ||
background-color: transparent; | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
} | ||
|
||
html { | ||
-ms-overflow-style: none; | ||
scrollbar-width: none; | ||
} | ||
|
||
html::-webkit-scrollbar { | ||
display: none; | ||
} | ||
|
||
/* Phone Device */ | ||
@media all and (min-width:375px) { | ||
|
||
body { | ||
text-align: center; | ||
max-width: 100%; | ||
} | ||
|
||
.dust-nav { | ||
width: 100%; | ||
height: 45px; | ||
display: flex; | ||
} | ||
|
||
.dust-nav-box { | ||
width: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: 1rem; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters