/
index.php
49 lines (44 loc) · 1.39 KB
/
index.php
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
<?php
session_start();
require_once(__DIR__ . '/config.php');
require_once(__DIR__ . '/functions.php');
require_once(__DIR__ . '/Todo.php');
// get todos
$todoApp = new \MyApp\Todo();
$todos = $todoApp->getAll();
// var_dump($todos);
// exit;
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>My Todos</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="container">
<h1>Todos</h1>
<form action="" id="new_todo_form">
<input type="text" id="new_todo" placeholder="What needs to be done?">
</form>
<ul id="todos">
<?php foreach ($todos as $todo) : ?>
<li id="todo_<?= h($todo->id); ?>" data-id="<?= h($todo->id); ?>">
<input type="checkbox" class="update_todo" <?php if ($todo->state === '1') { echo 'checked'; } ?>>
<span class="todo_title <?php if ($todo->state === '1') { echo 'done'; } ?>"><?= h($todo->title); ?></span>
<div class="delete_todo">x</div>
</li>
<?php endforeach; ?>
<li id="todo_template" data-id="">
<input type="checkbox" class="update_todo">
<span class="todo_title"></span>
<div class="delete_todo">x</div>
</li>
</ul>
</div>
<input type="hidden" id="token" value="<?= h($_SESSION['token']); ?>">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="todo.js"></script>
</body>
</html>