Commit dd1dd8a28578b057b6ff2183b7e6a82320e9aef2

  • avatar
  • p4bl0 <pablo.rauzy @gm…l.com>
  • Thu Jun 25 15:57:11 GMT 2009
added the possibility to delete the currently used cookie
index.html
(4 / 1)
  
1010 <body id="twotwodo">
1111
1212 <div id="header">
13 <span id="cookieName">default</span>
1413 <span id="soap">by <a href="http://soap.coders.fm/">soap</a></span>
1514 <h1>TwoTwoDo!</h1>
15 <div id="cookies">
16 <span id="current-cookie">default</span>
17 <span id="delete-cookie">delete?</span>
18 </div>
1619 </div>
1720
1821 <table cellspacing="16">
twotwodo.css
(10 / 2)
  
3333#soap a {
3434 color: #eee;
3535}
36#cookieName {
36#cookies {
3737 color: #fc6;
3838 position: absolute;
3939 top: 0.5em;
4040 left: 0.5em;
41 font-size: small;
41}
42#current-cookie {
4243 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;
4351}
4452
4553table {
twotwodo.js
(33 / 1)
  
2424 document.cookie = TwoTwoDo.data.cookie+'='+escape(tasks)+';expires='+expires.toGMTString();
2525};
2626
27TwoTwoDo.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
2756TwoTwoDo.utils.txt2html = function (txt) {
2857 var html = txt.replace(/\n/g, '<br />');
2958 html = html.replace(/#([a-zA-Z0-9_-]*)/g,
280280 var url = document.location.toString();
281281 if (url.indexOf('?') != -1) {
282282 var cookieName = url.substr(url.indexOf('?')+1);
283 $('#cookieName').html(cookieName);
283 $('#current-cookie').html(cookieName);
284284 TwoTwoDo.data.cookie = 'TwoTwoDo-'+cookieName;
285285 }
286286 var data = TwoTwoDo.utils.readCookie();
317317 $('.state').live('click', function(){
318318 TwoTwoDo.task.switchState($(this).attr('id'));
319319 });
320 $('#delete-cookie').click(function(){
321 TwoTwoDo.utils.deleteCookie('ask');
322 });
320323};
321324
322325$(document).ready(function(){

Comments

Add a new comment:

Login or create an account to post a comment

Add your comment