Commit dd1dd8a28578b057b6ff2183b7e6a82320e9aef2
- Diff rendering mode:
- inline
- side by side
index.html
(4 / 1)
|   | |||
| 10 | 10 | <body id="twotwodo"> | |
| 11 | 11 | ||
| 12 | 12 | <div id="header"> | |
| 13 | <span id="cookieName">default</span> | ||
| 14 | 13 | <span id="soap">by <a href="http://soap.coders.fm/">soap</a></span> | |
| 15 | 14 | <h1>TwoTwoDo!</h1> | |
| 15 | <div id="cookies"> | ||
| 16 | <span id="current-cookie">default</span> | ||
| 17 | <span id="delete-cookie">delete?</span> | ||
| 18 | </div> | ||
| 16 | 19 | </div> | |
| 17 | 20 | ||
| 18 | 21 | <table cellspacing="16"> |
twotwodo.css
(10 / 2)
|   | |||
| 33 | 33 | #soap a { | |
| 34 | 34 | color: #eee; | |
| 35 | 35 | } | |
| 36 | #cookieName { | ||
| 36 | #cookies { | ||
| 37 | 37 | color: #fc6; | |
| 38 | 38 | position: absolute; | |
| 39 | 39 | top: 0.5em; | |
| 40 | 40 | left: 0.5em; | |
| 41 | font-size: small; | ||
| 41 | } | ||
| 42 | #current-cookie { | ||
| 42 | 43 | font-style: italic; | |
| 44 | font-weight: bold; | ||
| 45 | } | ||
| 46 | #delete-cookie { | ||
| 47 | font-size: small; | ||
| 48 | } | ||
| 49 | #delete-cookie .delete-cookie-answer { | ||
| 50 | cursor: pointer; | ||
| 43 | 51 | } | |
| 44 | 52 | ||
| 45 | 53 | table { |
twotwodo.js
(33 / 1)
|   | |||
| 24 | 24 | document.cookie = TwoTwoDo.data.cookie+'='+escape(tasks)+';expires='+expires.toGMTString(); | |
| 25 | 25 | }; | |
| 26 | 26 | ||
| 27 | TwoTwoDo.utils.deleteCookie = function (step) { | ||
| 28 | if (step == 'ask') { | ||
| 29 | $('#delete-cookie').unbind('click').html('delete: <span class="delete-cookie-answer">confirm</span> or <span class="delete-cookie-answer">cancel</span>'); | ||
| 30 | $('#delete-cookie .delete-cookie-answer').click(function(){ | ||
| 31 | TwoTwoDo.utils.deleteCookie($(this).html()); | ||
| 32 | }); | ||
| 33 | } | ||
| 34 | else if (step == 'cancel') { | ||
| 35 | $('#delete-cookie').html('delete?'); | ||
| 36 | $('#delete-cookie').click(function(){ | ||
| 37 | TwoTwoDo.utils.deleteCookie('reset'); | ||
| 38 | }); | ||
| 39 | } | ||
| 40 | else if (step == 'confirm') { | ||
| 41 | var expires = new Date(); | ||
| 42 | document.cookie = TwoTwoDo.data.cookie+'=0;expires='+expires.toGMTString(); | ||
| 43 | var url = document.location.toString(); | ||
| 44 | if (url.indexOf('?') != -1) { | ||
| 45 | url = url.substring(0, url.indexOf('?')); | ||
| 46 | } | ||
| 47 | document.location = url; | ||
| 48 | } | ||
| 49 | else if (step == 'reset') { | ||
| 50 | $('#delete-cookie').click(function(){ | ||
| 51 | TwoTwoDo.utils.deleteCookie('ask'); | ||
| 52 | }); | ||
| 53 | } | ||
| 54 | }; | ||
| 55 | |||
| 27 | 56 | TwoTwoDo.utils.txt2html = function (txt) { | |
| 28 | 57 | var html = txt.replace(/\n/g, '<br />'); | |
| 29 | 58 | html = html.replace(/#([a-zA-Z0-9_-]*)/g, | |
| … | … | ||
| 280 | 280 | var url = document.location.toString(); | |
| 281 | 281 | if (url.indexOf('?') != -1) { | |
| 282 | 282 | var cookieName = url.substr(url.indexOf('?')+1); | |
| 283 | $('#cookieName').html(cookieName); | ||
| 283 | $('#current-cookie').html(cookieName); | ||
| 284 | 284 | TwoTwoDo.data.cookie = 'TwoTwoDo-'+cookieName; | |
| 285 | 285 | } | |
| 286 | 286 | var data = TwoTwoDo.utils.readCookie(); | |
| … | … | ||
| 317 | 317 | $('.state').live('click', function(){ | |
| 318 | 318 | TwoTwoDo.task.switchState($(this).attr('id')); | |
| 319 | 319 | }); | |
| 320 | $('#delete-cookie').click(function(){ | ||
| 321 | TwoTwoDo.utils.deleteCookie('ask'); | ||
| 322 | }); | ||
| 320 | 323 | }; | |
| 321 | 324 | ||
| 322 | 325 | $(document).ready(function(){ |
Comments
Add a new comment:
Login or create an account to post a comment
Add your comment
Please log in to comment

