Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first #1

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
49 changes: 26 additions & 23 deletions 00-intro/10-sum/index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<form id="form">
<p>
<label for="num-a">A:</label>
<input id="num-a" name="num-a" type="number" />
</p>
<p>
<label for="num-b">B:</label> <input id="num-b" name="num-b" type="number" />
</p>
<p>
<label>
A + B =
</label>
<output name="result"></output>
</p>
</form>
<script type="module" src="./script.js"></script>
</body>
</html>

<head>
<meta charset="UTF-8" />
<title>First</title>
</head>

<body>
<form id="form">
<p>
<label for="num-a">A:</label>
<input id="num-a" name="num-a" type="number" />
</p>
<p>
<label for="num-b">B:</label> <input id="num-b" name="num-b" type="number" />
</p>
<p>
<label>
A + B =
</label>
<output name="result"></output>
</p>
</form>
<script type="module" src="./script.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion 00-intro/10-sum/sum.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
* @return {number} сумма чисел a и b
*/
export function sum(a, b) {
// Решение
return a+b;
}
18 changes: 18 additions & 0 deletions 01-basics/10-create-app/script.js
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
import { defineComponent, createApp } from 'vue'

const App = defineComponent({
name: 'app',

setup() {

var day = new Date();

return {
today: day.toLocaleDateString('en-US', { dateStyle: 'long' })
ShGKme marked this conversation as resolved.
Show resolved Hide resolved
}
},

template: `
<div>Сегодня {{ today }}</div>`
});

createApp(App).mount('#app');
124 changes: 79 additions & 45 deletions 01-basics/20-weather/WeatherApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,83 @@ import { getWeatherData, WeatherConditionIcons } from './weather.service.ts'

export default defineComponent({
name: 'WeatherApp',
setup() {
const weatherData = getWeatherData();

template: `
<div>
<h1 class="title">Погода в Средиземье</h1>

<ul class="weather-list unstyled-list">
<li class="weather-card weather-card--night">
<div class="weather-alert">
<span class="weather-alert__icon">⚠️</span>
<span class="weather-alert__description">Королевская метеослужба короля Арагорна II: Предвещается наступление сильного шторма.</span>
</div>
<div>
<h2 class="weather-card__name">
Гондор
</h2>
<div class="weather-card__time">
07:17
</div>
</div>
<div class="weather-conditions">
<div class="weather-conditions__icon" title="thunderstorm with heavy rain">⛈️</div>
<div class="weather-conditions__temp">15.0 °C</div>
</div>
<div class="weather-details">
<div class="weather-details__item">
<div class="weather-details__item-label">Давление, мм рт. ст.</div>
<div class="weather-details__item-value">754</div>
</div>
<div class="weather-details__item">
<div class="weather-details__item-label">Влажность, %</div>
<div class="weather-details__item-value">90</div>
</div>
<div class="weather-details__item">
<div class="weather-details__item-label">Облачность, %</div>
<div class="weather-details__item-value">100</div>
</div>
<div class="weather-details__item">
<div class="weather-details__item-label">Ветер, м/с</div>
<div class="weather-details__item-value">10.5</div>
</div>
</div>
</li>
</ul>
</div>
`,
})
function convertToCelsius(k) {
return (parseFloat(k - 273.15)).toFixed(1) ;
}

function formatPressure(hPa){
return parseInt(Math.round(hPa*0.75));
}

function isNight(currentHourText, sunriseArrayText, sunsetArrayText) {

var currentHourArray = currentHourText.split(":");
var sunriseArray = sunriseArrayText.split(":")
var sunsetArray = sunsetArrayText.split(":")

const currentHour = currentHourArray[0]*60+currentHourArray[1]
const sunrise = sunriseArray[0]*60+sunriseArray[1]
const sunset = sunsetArray[0]*60+sunsetArray[1]

return currentHour < sunrise && currentHour > sunset;
}
ShGKme marked this conversation as resolved.
Show resolved Hide resolved


return {
weatherData,
WeatherConditionIcons,
formatPressure,
isNight,
convertToCelsius,
};
},

template: `
<div>
<h1 class="title">Погода в Средиземье</h1>

<ul class="weather-list unstyled-list">
<li v-for="data in weatherData" v-bind:class="{ 'weather-card': true, 'weather-card--night': isNight(data.current.dt, data.current.sunrise, data.current.sunset) }">
ShGKme marked this conversation as resolved.
Show resolved Hide resolved
<div class="weather-alert" v-if="data.alert != null">
<span class="weather-alert__icon">⚠️</span>
<span class="weather-alert__description">{{data.alert.sender_name}}:{{data.alert.description}}</span>
</div>
<div>
<h2 class="weather-card__name">
{{data.geographic_name}}
ShGKme marked this conversation as resolved.
Show resolved Hide resolved
</h2>
<div class="weather-card__time">
{{data.current.dt}}
</div>
</div>
<div class="weather-conditions">
<div class="weather-conditions__icon" :title = data.current.weather.description>{{WeatherConditionIcons[data.current.weather.id]}}</div>
<div class="weather-conditions__temp">{{convertToCelsius( data.current.temp )}} °C</div>
</div>
<div class="weather-details">
<div class="weather-details__item">
<div class="weather-details__item-label">Давление, мм рт. ст.</div>

<div class="weather-details__item-value">{{ formatPressure(data.current.pressure) }}</div>
</div>
<div class="weather-details__item">
<div class="weather-details__item-label">Влажность, %</div>
<div class="weather-details__item-value">{{data.current.humidity}}</div>
</div>
<div class="weather-details__item">
<div class="weather-details__item-label">Облачность, %</div>
<div class="weather-details__item-value">{{data.current.clouds}}</div>
</div>
<div class="weather-details__item">
<div class="weather-details__item-label">Ветер, м/с</div>
<div class="weather-details__item-value">{{data.current.wind_speed}}</div>
</div>
</div>
</li>
</ul>
</div>
`,
});
2 changes: 2 additions & 0 deletions 01-basics/20-weather/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
<script type="module" src="./main.js"></script>
</body>
</html>


Loading