Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Style Guide 2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Weby
Style Guide 2
Commits
a17e7ee1
Commit
a17e7ee1
authored
2 months ago
by
Alexa Valentová
Browse files
Options
Downloads
Patches
Plain Diff
finish nakopneme calc page
parent
406a476c
No related branches found
No related tags found
No related merge requests found
Pipeline
#21207
passed
2 months ago
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
majak_uistyleguide/templates/patterns/templates/nakopneme/calculator/calculator.html
+38
-10
38 additions, 10 deletions
...s/patterns/templates/nakopneme/calculator/calculator.html
with
38 additions
and
10 deletions
majak_uistyleguide/templates/patterns/templates/nakopneme/calculator/calculator.html
+
38
−
10
View file @
a17e7ee1
...
...
@@ -28,15 +28,17 @@
<h2
class=
"text-center head-9xl mb-4"
>
Sečteno a rozkradeno
</h2>
<div
class=
"flex justify-center"
>
<div
class=
"bg-pirati-yellow p-5 head-8xl font-alt justify-center flex min-w-64"
id=
"total"
data-value=
"0"
>
0 Kč
</div>
<div
class=
"bg-pirati-yellow p-5 head-8xl font-alt justify-center flex min-w-96"
>
<div
id=
"total"
data-value=
"0"
>
0 Kč
</div>
</div>
</div>
<div
class=
"mt-8 text-3xl lg:text-4xl max-w-3xl mx-auto hidden"
id=
"buyable-things-wrapper"
>
<div
class=
"mt-8 text-3xl lg:text-4xl max-w-3xl mx-auto hidden
min-h-40
"
id=
"buyable-things-wrapper"
>
<span>
Za to jsme mohli pořídit
</span>
<span
id=
"buyable-things"
class=
"font-bold"
></span><span>
.
</span>
</div>
<div
class=
"prose prose-black mt-8 [&_p]:text-lg"
>
<div
class=
"prose prose-black mt-8 [&_p]:text-lg
mx-auto
"
>
<p>
{{ after_calc_text }}
</p>
...
...
@@ -55,11 +57,14 @@
{
%
endfor
%
}
};
const
buyWrapper
=
document
.
getElementById
(
"
buyable-things-wrapper
"
);
const
total
=
document
.
getElementById
(
"
total
"
);
for
(
const
element
of
document
.
getElementsByClassName
(
"
_calculator_item
"
))
{
element
.
addEventListener
(
"
change
"
,
(
event
)
=>
{
let
currentValue
=
Number
(
document
.
getElementById
(
"
total
"
)
.
dataset
.
value
);
let
currentValue
=
Number
(
total
.
dataset
.
value
);
let
targetValue
=
Number
(
event
.
currentTarget
.
dataset
.
monetaryValue
);
let
finalValue
=
0
;
...
...
@@ -69,33 +74,56 @@
finalValue
=
currentValue
-
targetValue
;
}
document
.
getElementById
(
"
total
"
).
dataset
.
value
=
finalValue
;
document
.
getElementById
(
"
total
"
).
innerHTML
=
`
${
finalValue
.
toLocaleString
()}
Kč`
total
.
dataset
.
value
=
finalValue
;
let
buyableThingsText
=
""
;
let
position
=
0
;
const
thingPricesLength
=
Object
.
keys
(
thingPrices
).
length
;
document
.
getElementById
(
"
buyable-things-wrapper
"
).
classList
.
remove
(
"
hidden
"
)
let
foundAnything
=
false
;
for
(
let
[
key
,
value
]
of
Object
.
entries
(
thingPrices
))
{
if
(
finalValue
/
value
>
1
)
{
const
actualCount
=
Math
.
floor
(
finalValue
/
value
);
if
(
position
+
1
==
thingPricesLength
)
{
buyableThingsText
+=
"
a
"
;
buyableThingsText
+=
"
, nebo
"
;
}
else
if
(
position
!=
0
)
{
buyableThingsText
+=
"
,
"
;
buyableThingsText
+=
"
,
nebo
"
;
}
buyableThingsText
+=
`
${
actualCount
}
${
key
}
`
;
foundAnything
=
true
;
}
position
++
;
}
if
(
!
foundAnything
)
{
document
.
getElementById
(
"
buyable-things-wrapper
"
).
classList
.
add
(
"
hidden
"
);
total
.
innerHTML
=
`
${
finalValue
.
toLocaleString
()}
Kč`
;
return
;
}
if
(
document
.
getElementById
(
"
buyable-things-wrapper
"
).
classList
.
contains
(
"
hidden
"
))
{
document
.
getElementById
(
"
buyable-things
"
).
innerHTML
=
buyableThingsText
;
document
.
getElementById
(
"
buyable-things-wrapper
"
).
classList
.
remove
(
"
hidden
"
);
}
else
{
buyWrapper
.
animate
([
{
opacity
:
[
0
]
}
],
{
duration
:
250
});
setTimeout
(()
=>
{
document
.
getElementById
(
"
buyable-things
"
).
innerHTML
=
buyableThingsText
;
buyWrapper
.
animate
([
{
opacity
:
[
1
]
}
],
{
duration
:
250
});
},
250
);
}
total
.
animate
([
{
opacity
:
[
0
]
}
],
{
duration
:
250
});
setTimeout
(()
=>
{
total
.
animate
([
{
opacity
:
[
1
]
}
],
{
duration
:
250
});
total
.
innerHTML
=
`
${
finalValue
.
toLocaleString
()}
Kč`
;
});
}
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment