-
-
Notifications
You must be signed in to change notification settings - Fork 414
/
Copy pathindex.ejs
100 lines (100 loc) · 4.18 KB
/
index.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Express • TodoMVC</title>
<link rel="stylesheet" href="/css/base.css">
<link rel="stylesheet" href="/css/index.css">
<link rel="stylesheet" href="/css/app.css">
</head>
<body>
<section class="todoapp">
<nav class="nav">
<ul>
<li class="user"><%= user.username %></li>
<li>
<form action="/logout" method="post">
<button class="logout" type="submit">Sign out</button>
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
</form>
</li>
</ul>
</nav>
<header class="header">
<h1>todos</h1>
<form action="/" method="post">
<input class="new-todo" name="title" placeholder="What needs to be done?" autofocus>
<% if (filter) { %>
<input type="hidden" name="filter" value="<%= filter %>"/>
<% } %>
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
</form>
</header>
<% if (activeCount + completedCount > 0) { %>
<section class="main">
<form action="/toggle-all" method="post">
<input id="toggle-all" class="toggle-all" type="checkbox" name="completed" <%- activeCount == 0 ? 'checked' : '' %> onchange="this.form.submit();">
<label for="toggle-all">Mark all as complete</label>
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
</form>
<ul class="todo-list">
<% todos.forEach(function(todo) { %>
<li <%- todo.completed ? 'class="completed"' : '' %>>
<form action="<%= todo.url %>" method="post">
<div class="view">
<input class="toggle" type="checkbox" name="completed" <%- todo.completed ? 'checked' : '' %> onchange="this.form.submit();">
<label ondblclick="this.closest('li').className = this.closest('li').className + ' editing'; this.closest('li').querySelector('input.edit').focus(); this.closest('li').querySelector('input.edit').value = ''; this.closest('li').querySelector('input.edit').value = '<%= todo.title %>';"><%= todo.title %></label>
<button class="destroy" form="delete-<%= todo.id %>"></button>
</div>
<input class="edit" name="title" value="<%= todo.title %>" onkeyup="if (event.keyCode == 27) { this.setAttribute('data-esc', ''); this.closest('li').className = this.closest('li').className.replace('editing', ''); }" onblur="if (this.getAttribute('data-esc') !== null) { return this.removeAttribute('data-esc'); } this.form.submit();">
<% if (filter) { %>
<input type="hidden" name="filter" value="<%= filter %>"/>
<% } %>
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
</form>
<form id="delete-<%= todo.id %>" action="<%= todo.url %>/delete" method="post">
<% if (filter) { %>
<input type="hidden" name="filter" value="<%= filter %>"/>
<% } %>
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
</form>
</li>
<% }); %>
</ul>
</section>
<% } %>
<% if (activeCount + completedCount > 0) { %>
<footer class="footer">
<span class="todo-count"><strong><%= activeCount %></strong> <%= pluralize('item', activeCount) %> left</span>
<ul class="filters">
<li>
<a <%- !filter ? 'class="selected"' : '' %> href="/">All</a>
</li>
<li>
<a <%- filter == 'active' ? 'class="selected"' : '' %> href="/active">Active</a>
</li>
<li>
<a <%- filter == 'completed' ? 'class="selected"' : '' %> href="/completed">Completed</a>
</li>
</ul>
<% if (completedCount > 0) { %>
<form action="/clear-completed" method="post">
<button class="clear-completed">Clear completed</button>
<% if (filter) { %>
<input type="hidden" name="filter" value="<%= filter %>"/>
<% } %>
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
</form>
<% } %>
</footer>
<% } %>
</section>
<footer class="info">
<p>Double-click to edit a todo</p>
<p>Created by <a href="https://www.jaredhanson.me">Jared Hanson</a></p>
<p>Part of <a href="https://todomvc.com">TodoMVC</a></p>
<p>Authentication powered by <a href="https://www.passportjs.org">Passport</a></p>
</footer>
</body>
</html>