1 этап первого задания выполнен.

parent b49f6cc4
.loading{
position: fixed;
background-color: rgba(177, 177, 177, 0.8);
left: 0;
top: 0;
z-index: 1000;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-size: 50px;
}
\ No newline at end of file
......@@ -5,20 +5,24 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<script src="script.js"></script>
<title>Document</title>
</head>
<body>
<p><b>Name: </b><span id="name"></span></p>
<div class="loading" id="loading">
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="64px" height="64px" viewBox="0 0 128 128" xml:space="preserve"><rect x="0" y="0" width="100%" height="100%" fill="#FFFFFF" /><g><circle cx="16" cy="64" r="16" fill="#000000" fill-opacity="1"/><circle cx="16" cy="64" r="14.344" fill="#000000" fill-opacity="1" transform="rotate(45 64 64)"/><circle cx="16" cy="64" r="12.531" fill="#000000" fill-opacity="1" transform="rotate(90 64 64)"/><circle cx="16" cy="64" r="10.75" fill="#000000" fill-opacity="1" transform="rotate(135 64 64)"/><circle cx="16" cy="64" r="10.063" fill="#000000" fill-opacity="1" transform="rotate(180 64 64)"/><circle cx="16" cy="64" r="8.063" fill="#000000" fill-opacity="1" transform="rotate(225 64 64)"/><circle cx="16" cy="64" r="6.438" fill="#000000" fill-opacity="1" transform="rotate(270 64 64)"/><circle cx="16" cy="64" r="5.375" fill="#000000" fill-opacity="1" transform="rotate(315 64 64)"/><animateTransform attributeName="transform" type="rotate" values="0 64 64;315 64 64;270 64 64;225 64 64;180 64 64;135 64 64;90 64 64;45 64 64" calcMode="discrete" dur="720ms" repeatCount="indefinite"></animateTransform></g></svg>
</div>
<p><b>Name: </b><span id="name">sdf</span></p>
<p><b>Region: </b><span id="region"></span></p>
<p><b>Subregion: </b><span id="subregion"></span></p>
<p><b>Capital: </b><span id="capital"></span></p>
<p><b>Capital: </b><span id="capital"> </span></p>
<p><b>Flag: </b><span id="flag"></span></p>
<p><b>Flag: </b><span id="flag"> </span></p>
<script src="script.js"></script>
</body>
</html>
\ No newline at end of file
const loader = document.querySelector('.loading');
const countryName = document.getElementById('name')
const region = document.getElementById('region')
const subregion = document.getElementById('subregion')
const capital = document.getElementById('capital')
const flag = document.getElementById('flag')
const request = (config) => {
const { method, path, success, error } = config;
const xml = new XMLHttpRequest();
xml.addEventListener('load', () => {
if (xml.status < 200 || xml.status > 399) {
error('bad response');
return;
}
const result = JSON.parse(xml.responseText);
success(result)
console.log(result);
});
xml.addEventListener('error', () => {
error('network error');
})
xml.addEventListener('timeout', () => {
error('server response is late')
})
xml.open(method, path);
xml.send();
}
const processResult = (result) => {
console.log(result);
countryName.innerText = result[0].name
const flagImg = document.createElement('img');
flagImg.setAttribute('src', `${result[0].flag}`);
flagImg.style = 'width: 150px'
flag.append(flagImg)
capital.innerText = result[0].capital
region.innerText = result[0].region
subregion.innerText = result[0].subregion
loader.style.display = 'none'
}
const errorHandler = () => {
console.error(msg)
}
const config = {
method: "GET",
path: "https://restcountries.com/v2/name/kz",
success: processResult,
error: errorHandler
}
request(config)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment