Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
app-todo
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
Geovanny E. Vera Pazmino
app-todo
Commits
cb4438d3
Commit
cb4438d3
authored
Mar 31, 2020
by
Milan Iliev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial Commit
parents
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
0 deletions
+108
-0
index.html
index.html
+58
-0
main.js
main.js
+50
-0
No files found.
index.html
0 → 100644
View file @
cb4438d3
<!doctype html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf8"
/>
<style>
body
{
display
:
grid
;
grid-template
:
"summary detail"
1
fr
"controls controls"
40px
/
1
fr
1
fr
;
}
task-list
{
grid-area
:
summary
;
display
:
grid
;
}
task-summary
:hover
{
background-color
:
#eee
;
cursor
:
pointer
;
}
task-summary
:active
{
background-color
:
#ddd
;
}
task-detail
{
grid-area
:
detail
;
background-color
:
#eee
;
}
</style>
</head>
<body>
<task-list>
</task-list>
<task-detail>
<input
type=
"checkbox"
name=
"done"
/>
<input
type=
"text"
name=
"description"
/>
<input
type=
"date"
name=
"due_date"
/>
<button>
Delete
</button>
</task-detail>
<button>
Add Task
</button>
<script
src=
"main.js"
></script>
</body>
</html>
\ No newline at end of file
main.js
0 → 100644
View file @
cb4438d3
let
tasks
=
[
{
done
:
true
,
description
:
"Do Laundry"
},
{
done
:
false
,
description
:
"Do Homework"
},
{
done
:
false
,
description
:
"Do Chores"
},
]
class
TaskView
{
static
template
=
`
<input type="checkbox" name="done"/>
<task-description> -- </task-description>
`
constructor
(
task
){
this
.
task
=
task
this
.
element
=
document
.
createElement
(
"task-summary"
)
this
.
element
.
innerHTML
=
this
.
constructor
.
template
this
.
update
()
}
update
()
{
this
.
element
.
querySelector
(
"[name=done]"
).
checked
=
this
.
task
.
done
this
.
element
.
querySelector
(
"task-description"
).
innerText
=
this
.
task
.
description
}
}
class
DetailTaskView
{
constructor
(
element
){
this
.
element
=
element
}
update
(
task
)
{
this
.
element
.
querySelector
(
"[name=done]"
).
checked
=
task
.
done
this
.
element
.
querySelector
(
"[name=description]"
).
value
=
task
.
description
}
}
let
detail_view
=
new
DetailTaskView
(
document
.
querySelector
(
"task-detail"
))
let
list
=
document
.
querySelector
(
"task-list"
)
for
(
let
task
of
tasks
){
let
view
=
new
TaskView
(
task
)
view
.
element
.
addEventListener
(
"click"
,
()
=>
detail_view
.
update
(
task
)
)
list
.
appendChild
(
view
.
element
)
}
\ No newline at end of file
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