Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
task_31_restCountries
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Гульняшкин Евгений
task_31_restCountries
Commits
5528e836
Commit
5528e836
authored
Sep 26, 2023
by
Гульняшкин Евгений
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Данные выводятся в виде списка
parent
8ae258bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
17 deletions
+51
-17
index.html
task_1/index.html
+0
-8
script.js
task_1/script.js
+51
-9
No files found.
task_1/index.html
View file @
5528e836
...
@@ -14,15 +14,7 @@
...
@@ -14,15 +14,7 @@
<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>
<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>
</div>
<div
class=
"show"
>
<div
class=
"show"
>
<p><b>
Name:
</b><span
id=
"name"
></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>
Flag:
</b><span
id=
"flag"
>
</span></p>
</div>
</div>
<input
id=
"country_name"
type=
"text"
>
<input
id=
"country_name"
type=
"text"
>
...
...
task_1/script.js
View file @
5528e836
...
@@ -23,7 +23,7 @@ const request = (config) => {
...
@@ -23,7 +23,7 @@ const request = (config) => {
else
{
else
{
error
(
'bad response'
);
error
(
'bad response'
);
}
}
return
;
return
;
}
}
else
if
(
xml
.
status
===
'404'
)
{
else
if
(
xml
.
status
===
'404'
)
{
...
@@ -44,14 +44,9 @@ const request = (config) => {
...
@@ -44,14 +44,9 @@ const request = (config) => {
}
}
const
processResult
=
(
result
)
=>
{
const
processResult
=
(
result
)
=>
{
countryName
.
innerText
=
result
[
0
].
name
const
flagImg
=
document
.
createElement
(
'img'
);
const
items
=
createTree
(
result
[
0
])
flagImg
.
setAttribute
(
'src'
,
`
${
result
[
0
].
flag
}
`
);
infoToshow
.
append
(
items
)
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'
loader
.
style
.
display
=
'none'
}
}
...
@@ -61,9 +56,56 @@ const errorHandler = (msg) => {
...
@@ -61,9 +56,56 @@ const errorHandler = (msg) => {
}
}
const
createTree
=
(
data
)
=>
{
console
.
log
(
data
);
const
ul
=
document
.
createElement
(
'ul'
)
for
(
item
in
data
)
{
const
li
=
document
.
createElement
(
'li'
)
if
(
Array
.
isArray
(
data
))
{
if
(
typeof
data
[
item
]
===
'object'
)
{
const
innerUl
=
createTree
(
data
[
item
])
li
.
append
(
innerUl
)
}
else
{
li
.
append
(
`
${
data
[
item
]}
`
)
}
}
else
{
if
(
Array
.
isArray
(
data
[
item
]))
{
li
.
innerHTML
=
`<b>
${
item
}
:</b> \n`
const
innerUl
=
createTree
(
data
[
item
])
li
.
append
(
innerUl
)
}
else
{
if
((
typeof
data
[
item
]
===
'object'
))
{
li
.
innerHTML
=
`<b>
${
item
}
:</b> \n`
const
innerUl
=
createTree
(
data
[
item
])
li
.
append
(
innerUl
)
}
else
{
li
.
innerHTML
=
`<b>
${
item
}
:</b>
${
data
[
item
]}
`
}
}
}
ul
.
append
(
li
)
}
return
ul
}
const
createTreefromObject
=
(
data
)
=>
{
const
ul
=
document
.
createElement
(
'ul'
)
for
(
item
in
data
)
{
const
li
=
document
.
createElement
(
'li'
)
if
(
Array
.
isArray
(
data
[
item
]))
{
li
.
append
(
`
${
item
}
: `
)
const
innerUl
=
createTree
(
data
[
item
])
li
.
append
(
innerUl
)
}
else
{
li
.
append
(
`
${
item
}
:
${
data
[
item
]}
`
)
}
ul
.
append
(
li
)
}
return
ul
}
const
showInfo
=
()
=>
{
const
showInfo
=
()
=>
{
if
(
userInput
.
value
)
{
if
(
userInput
.
value
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment