Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Full Stack harjoitustyö
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AA2875
Full Stack harjoitustyö
Commits
03280588
Commit
03280588
authored
2 years ago
by
AA2875
Browse files
Options
Downloads
Patches
Plain Diff
suunitelmia
parent
6a4e4a1a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
V2/page/code.js
+11
-10
11 additions, 10 deletions
V2/page/code.js
with
11 additions
and
10 deletions
V2/page/code.js
+
11
−
10
View file @
03280588
...
...
@@ -11,13 +11,13 @@ async function loadJumps() {
showJumps
(
jumps
)
}
function
createJumpListItem
(
jump
)
{
function
createJumpListItem
(
jump
)
{
// Tähän sisennys hommat
let
li
=
document
.
createElement
(
'
li
'
)
let
li_attr
=
document
.
createAttribute
(
'
id
'
)
li_attr
.
value
=
jump
.
_id
li_attr
.
value
=
jump
.
_id
li
.
setAttributeNode
(
li_attr
)
let
text
=
document
.
createTextNode
(
jump
.
te
xt
)
li
.
appendChild
(
text
)
let
jumpSpecs
=
document
.
createTextNode
(
jump
.
number
+
"
"
+
jump
.
da
te
)
li
.
appendChild
(
jumpSpecs
)
// spanit
let
edit_span
=
document
.
createElement
(
'
span
'
)
let
edit_span_attr
=
document
.
createAttribute
(
'
class
'
)
...
...
@@ -45,7 +45,7 @@ function showJumps(jumps) {
let
infoText
=
document
.
getElementById
(
'
infoText
'
)
// no jumps
if
(
jumps
.
length
===
0
)
{
infoText
.
innerHTML
=
'
Ei
tehtävi
ä
'
infoText
.
innerHTML
=
'
Ei
hyppyj
ä
'
}
else
{
jumps
.
forEach
(
jump
=>
{
let
li
=
createJumpListItem
(
jump
)
...
...
@@ -76,21 +76,22 @@ async function addJump() {
let
infoText
=
document
.
getElementById
(
'
infoText
'
)
infoText
.
innerHTML
=
''
newJump
.
value
=
''
newJumpNumber
.
value
=
''
newJumpDate
.
value
=
''
}
function
editJump
(
id
){
let
li
=
document
.
getElementById
(
id
)
let
input
=
document
.
getElementById
(
"
newJump
"
)
let
number
=
document
.
getElementById
(
"
newJump
Number
"
)
let
jump_content
=
li
.
innerHTML
.
slice
(
0
,
-
63
)
input
.
value
=
jump_content
let
button
=
document
.
getElementById
(
"
b
tn
"
)
number
.
value
=
jump_content
let
button
=
document
.
getElementById
(
"
addJumpB
tn
"
)
button
.
style
.
backgroundColor
=
"
yellow
"
button
.
innerHTML
=
"
Tallenna
"
button
.
onclick
=
function
()
{
saveJump
(
id
)
}
}
async
function
saveJump
(
id
){
async
function
saveJump
(
id
){
// Erheitä esim text newJump.value
let
newJump
=
document
.
getElementById
(
'
newJump
'
)
const
data
=
{
'
text
'
:
newJump
.
value
}
const
response
=
await
fetch
(
'
http://localhost:3000/jumps/
'
+
id
,
{
...
...
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