|
| 1 | +<!doctype html> |
| 2 | +<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> |
| 3 | +<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> |
| 4 | +<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> |
| 5 | +<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> |
| 6 | +<head> |
| 7 | + <meta charset="utf-8"> |
| 8 | + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 9 | + |
| 10 | + <title></title> |
| 11 | + <meta name="description" content=""> |
| 12 | + <meta name="author" content=""> |
| 13 | + |
| 14 | + <meta name="viewport" content="width=device-width"> |
| 15 | + |
| 16 | + <!-- Use SimpLESS (Win/Linux/Mac) or LESS.app (Mac) to compile your .less files |
| 17 | + <link rel="stylesheet/less" href="less/style.less"> |
| 18 | + <script src="js/libs/less-1.3.0.min.js"></script> |
| 19 | + |
| 20 | + to style.css, and replace the 2 lines above by this one: |
| 21 | +
|
| 22 | + --> |
| 23 | + <link rel="stylesheet" href="less/style.css"> |
| 24 | + |
| 25 | + <script src="js/libs/modernizr-2.5.3-respond-1.1.0.min.js"></script> |
| 26 | +</head> |
| 27 | +<body> |
| 28 | +<!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]--> |
| 29 | + |
| 30 | + |
| 31 | + <div class="container"> |
| 32 | + <!--h1>TODO today/week/month</h1--> |
| 33 | + <h2 id="day"><span>Sunday</span><a href="#clear" class="clear" rel="d">clear</a></h2> |
| 34 | + <div> |
| 35 | + <input type="text" id="d1" /> |
| 36 | + <input type="text" id="d2" /> |
| 37 | + <input type="text" id="d3" /> |
| 38 | + </div> |
| 39 | + |
| 40 | + |
| 41 | + <hr> |
| 42 | + <div class="row"> |
| 43 | + <div class="span6"> |
| 44 | + <h2>Week<a href="#clear" class="clear" rel="w">clear</a></h2> |
| 45 | + <div> |
| 46 | + <input type="text" id="w1"/> |
| 47 | + <input type="text" id="w2" /> |
| 48 | + <input type="text" id="w3" /> |
| 49 | + </div> |
| 50 | + </div> |
| 51 | + <div class="span6"> |
| 52 | + <h2 id="month"><span>April</span><a href="#clear" class="clear" rel="m">clear</a></h2> |
| 53 | + <div> |
| 54 | + <input type="text" id="m1" /> |
| 55 | + <input type="text" id="m2" /> |
| 56 | + <input type="text" id="m3" /> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + </div> |
| 60 | + |
| 61 | + <footer> |
| 62 | + <p>© Oren Roth 2012</p> |
| 63 | + </footer> |
| 64 | + |
| 65 | + </div> <!-- /container --> |
| 66 | +<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> |
| 67 | +<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script> |
| 68 | + |
| 69 | +<script src="js/libs/bootstrap/bootstrap.min.js"></script> |
| 70 | + |
| 71 | +<!--script src="js/script.js"></script--> |
| 72 | +<script> |
| 73 | + var date = new Date(), |
| 74 | + month = date.getMonth(), |
| 75 | + weekday = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"), |
| 76 | + monthname = new Array("January","February","March","April","May","June","July","August","September","October","November","December"), |
| 77 | + day = date.getDay(), |
| 78 | + ctrlDown = false; |
| 79 | + $("#month span").text(monthname[month]); |
| 80 | + $("#day span").text(weekday[day]); |
| 81 | + |
| 82 | + $('input').each(function(){ |
| 83 | + var $this = $(this), |
| 84 | + id = $(this).attr('id'), |
| 85 | + val = localStorage.getItem(id), |
| 86 | + dir = localStorage.getItem(id + 'dir'); |
| 87 | + |
| 88 | + $this.keydown(function(event) { |
| 89 | + |
| 90 | + var $note = $(this), |
| 91 | + id = $note.attr('id'); |
| 92 | + //===================switch text direction========================= |
| 93 | + |
| 94 | + if (event.which == 17) { |
| 95 | + ctrlDown = true; |
| 96 | + } |
| 97 | + if (event.which == 16) { |
| 98 | + if(ctrlDown){ |
| 99 | + setTimeout ( function(){saveNote(id + 'dir',$note.css('direction'));},200 ); |
| 100 | + $note.css('direction',$(this).css('direction')=="ltr" ? "rtl" : "ltr"); |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + //event.preventDefault(); |
| 107 | + //save here |
| 108 | + setTimeout ( function(){saveNote(id,$note.val());},10 ); |
| 109 | + }) |
| 110 | + .keyup(function(event) { |
| 111 | + if (event.which == 17) { |
| 112 | + ctrlDown = false; |
| 113 | + } |
| 114 | + |
| 115 | + }) |
| 116 | + .val(val) |
| 117 | + .wrap('<div class="inputCon' + (localStorage.getItem( id + "complete") ? " complete" : "") + '" />'); |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + if(dir){ |
| 122 | + $this.css('direction',dir); |
| 123 | + } |
| 124 | + |
| 125 | + |
| 126 | + }); |
| 127 | + |
| 128 | + function saveNote(noteId,msg){ |
| 129 | + |
| 130 | + if(msg === '') |
| 131 | + localStorage.removeItem(noteId); |
| 132 | + else |
| 133 | + localStorage.setItem(noteId,msg); |
| 134 | + } |
| 135 | + |
| 136 | + function clearInput(el){ |
| 137 | + var id = el.attr('id'); |
| 138 | + el.parent().removeClass('complete'); |
| 139 | + localStorage.removeItem( id + "complete") |
| 140 | + el.val(''); |
| 141 | + saveNote(id,el.val()); |
| 142 | + } |
| 143 | + |
| 144 | + //set the body height to window height minus the padding |
| 145 | + document.body.style.height = (document.height-100) +"px"; |
| 146 | + |
| 147 | + $(".clear").on('click',function(){ |
| 148 | + |
| 149 | + var elStart = $(this).attr('rel'); |
| 150 | + |
| 151 | + $("input[id^=" + elStart + "]").val('').each(function(){ |
| 152 | + clearInput($(this)); |
| 153 | + }); |
| 154 | + }); |
| 155 | + |
| 156 | + //=================== clear & done ========================= |
| 157 | + $(".inputCon").append('<span class="done">v</span><span class="clearOne">x</span>'); |
| 158 | + $(".done").on('click',function(){ |
| 159 | + var $this = $(this), |
| 160 | + $parent = $this.parent(); |
| 161 | + |
| 162 | + $parent.toggleClass('complete'); |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | + var id = $this.siblings('input').attr('id'); |
| 167 | + if($parent.hasClass('complete')) |
| 168 | + saveNote(id + "complete",true); |
| 169 | + else |
| 170 | + localStorage.removeItem( id + "complete"); |
| 171 | + |
| 172 | + }); |
| 173 | + $(".clearOne").on('click',function(){ |
| 174 | + var $this = $(this); |
| 175 | + |
| 176 | + clearInput($this.siblings('input')); |
| 177 | + |
| 178 | + }); |
| 179 | +</script> |
| 180 | +</body> |
| 181 | +</html> |
0 commit comments