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 | <?php // ... other routes $app->get('/add-task/:tid', 'authenticate', function ($tid) use ($app) { $app->render('add-task.php', array('id' => $tid)); }); $app->post('/add-task', 'authenticate', function () use ($app) { if (isset($_POST['submit'])) { $title = trim(htmlentities($_POST['title'])); $due = trim(htmlentities($_POST['due'])); $id = trim(htmlentities($_POST['id'])); if (empty($title)) { $title = 'Untitled Task'; } if (empty($due)) { $due = 'tomorrow'; } $task = new Google_Task(); $task->setTitle($title); $task->setDue(date(DATE_RFC3339, strtotime($due))); $result = $app->tasksService->tasks->insert($id, $task); $app->redirect('/index'); } }); $app->get('/delete-task/:lid/:tid', 'authenticate', function ($lid, $tid) use ($app) { $app->tasksService->tasks->delete($lid, $tid); $app->redirect('/index'); }); |
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 | <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/ jquery.mobile-1.3.2.min.css" /> <link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/ datebox/latest/jqm-datebox.min.css" /> <script src="//code.jquery.com/jquery-1.9.1.min.js"></script> <script src="//code.jquery.com/mobile/1.3.2/ jquery.mobile-1.3.2.min.js"></script> <script src="//dev.jtsage.com/cdn/datebox/latest/ jqm-datebox.core.min.js"></script> <script src="//dev.jtsage.com/cdn/datebox/latest/ jqm-datebox.mode.calbox.min.js"></script> <script src="//dev.jtsage.com/cdn/datebox/i18n /jquery.mobile.datebox.i18n.en_US.utf8.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> Add Task </div> <div data-role="content"> <div data-role="collapsible-set"> <form method="post" action="/add-task"> <input name="id" type="hidden" value="<?php echo $id; ?>" /> <label for="title">Title:</label> <input name="title" id="title" data-clear-btn="true" type="text"/> <label for="due">Due:</label> <input name="due" id="due" type="date" data-role="datebox" data-options='{"mode": "calbox", "useFocus": true, "themeDateToday": "e"}' /> <input name="submit" value="Save" type="submit" data-icon="check" data-inline="true" data-theme="a" /> <a href="/index" data-role="button" data-inline="true" data-icon="back" data-theme="a">Back</a> </form> </div> </div> </body> </html> |
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 | <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/ jquery.mobile-1.3.2.min.css" /> <link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.min.css" /> <script src="//code.jquery.com/jquery-1.9.1.min.js"></script> <script src="//code.jquery.com/mobile/1.3.2/ jquery.mobile-1.3.2.min.js"></script> <script src="//dev.jtsage.com/cdn/datebox/latest/ jqm-datebox.core.min.js"></script> <script src="//dev.jtsage.com/cdn/datebox/latest/ jqm-datebox.mode.calbox.min.js"></script> <script src="//dev.jtsage.com/cdn/datebox/i18n/ jquery.mobile.datebox.i18n.en_US.utf8.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> Tasks </div> <div data-role="content"> <div data-role="collapsible-set" data-inset="false"> <?php foreach ($lists['items'] as $list): ?> <?php $id = $list['id']; ?> <div data-role="collapsible"> <h2><?php echo $list['title']; ?></h2> <ul data-role="listview"> <?php if (isset($tasks[$id]['items'])): ?> <?php foreach ($tasks[$id]['items'] as $task): ?> <li> <div class="ui-grid-b"> <div class="ui-block-a"> <?php if ($task['status'] == 'needsAction'): ?> <h3><?php echo $task['title']; ?></h3> <?php else: ?> <h3 style="text-decoration:line-through"> <?php echo $task['title']; ?></h3> <?php endif; ?> <?php if (isset($task['due']) && ($task['status'] == 'needsAction')): ?> <p>Due on <?php echo date('d M Y', strtotime($task['due'])); ?></p> <?php endif; ?> <?php if (isset($task['completed']) && ($task['status'] == 'completed')): ?> <p>Completed on <?php echo date('d M Y', strtotime($task['completed'])); ?></p> <?php endif; ?> </div> <div class="ui-block-b"></div> <div class="ui-block-c"> <?php if ($task['status'] == 'needsAction'): ?> <a href="/update-task/<?php echo $id; ?>/ <?php echo $task['id']; ?>" data-inline="true" data-role="button" data-icon="check" data-theme="a">Done!</a> <?php endif; ?> <a href="/delete-task/ <?php echo $id; ?>/<?php echo $task['id']; ?>" data-inline="true" data-role="button" data-icon="delete" data-theme="a">Remove task</a> </div> </div> </li> <?php endforeach; ?> <?php endif; ?> </ul> <br/> <a href="/add-task/<?php echo $id; ?>" data-inline="true" data-role="button" data-icon="plus" data-theme="a">Add new task</a> <a href="/delete-list/<?php echo $id; ?>" data-inline="true" data-role="button" data-icon="delete" data-theme="a">Remove list</a> </div> <?php endforeach; ?> </div> <a href="/add-list" data-inline="true" data-role="button" data-icon="plus" data-theme="b">Add new list</a> </div> </div> </body> </html> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |