xonecas.io
49
Do

dotter / commit 2c5606a

Added some sort of ui and explanation of what this is, finally.

xonecas2011-05-11 2c5606a6b976ada3f8d582def9eebf980fe7f44a parent 2a237c9

5 files changed

README.md+7−0
@@ -0,0 +1,7 @@
1+The Dotter Experiment
2+=====================
3+
4+This is an experiment using the Twitter API.
5+Every dot is a tweet with geographic coordinates. I used a canvas element layout as a latitude/longitude grid.
6+
7+*Sit back and let the world draw itself one tweet at a time :-)*
css/style.css+50−5
@@ -89,8 +89,8 @@ html { overflow-y: scroll; }
8989 /* accessible focus treatment: people.opera.com/patrickl/experiments/keyboard/test */
9090 a:hover, a:active { outline: none; }
9191
92-a, a:active, a:visited { color: #607890; }
93-a:hover { color: #036; }
92+a, a:active, a:visited { color: #3366ff; }
93+a:hover { color: #2255cc; }
9494
9595
9696 ul, ol { margin-left: 2em; }
@@ -162,10 +162,55 @@ button { width: auto; overflow: visible; }
162162 */
163163
164164 html, body {
165- background-color: #222;
165+ background-color: #444;
166+}
167+h1 {
168+ margin: 5px 10px; font-size: 26px; font-family: 'Carter One', arial, serif;
169+ text-shadow: 0px 1px 1px #000; color: #eee;
170+}
171+p { margin-bottom: 1em;}
172+em {font-style: italic;}
173+#container {position: relative;}
174+#about {
175+ width: 250px;
176+ display:none; position: absolute; top: 5px; right: 10px;z-index: 2;
177+ background-color: #333; padding: 10px;
178+ -moz-border-radius: 12px;
179+ -webkit-border-radius: 12px;
180+ border-radius: 12px;
181+ -moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box;
182+ -moz-box-shadow: 0px 0px 4px #000;
183+ -webkit-box-shadow: 0px 0px 4px #000;
184+ box-shadow: 0px 0px 4px #000;
185+}
186+.handle {float: right;margin: 5px 15px 0 0;}
187+.button {
188+ padding: 2px 10px; cursor: pointer;
189+ -moz-border-radius: 20px;
190+ -webkit-border-radius: 20px;
191+ border-radius: 20px;
192+ -moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box;
193+ color: #fff !important; text-decoration: none !important;
194+ background-color: #3366ff;
195+ background-image: -webkit-gradient(linear, left top, left bottom, from(#3366ff), to(#335599));
196+ background-image: -webkit-linear-gradient(top, #3366ff, #335599);
197+ background-image: -moz-linear-gradient(top, #3366ff, #335599);
198+ background-image: -ms-linear-gradient(top, #3366ff, #335599);
199+ background-image: -o-linear-gradient(top, #3366ff, #335599);
200+ background-image: linear-gradient(top, #3366ff, #335599);
201+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#3366ff', EndColorStr='#335599');
202+}
203+.button:hover {
204+ background-color: #335599;
205+ background-image: -webkit-gradient(linear, left top, left bottom, from(#335599), to(#3366ff));
206+ background-image: -webkit-linear-gradient(top, #335599, #3366ff);
207+ background-image: -moz-linear-gradient(top, #335599, #3366ff);
208+ background-image: -ms-linear-gradient(top, #335599, #3366ff);
209+ background-image: -o-linear-gradient(top, #335599, #3366ff);
210+ background-image: linear-gradient(top, #335599, #3366ff);
211+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#335599', EndColorStr='#3366ff');
212+
166213 }
167-
168-
169214
170215
171216
index.html+19−6
@@ -18,29 +18,42 @@
1818
1919
2020 <link rel="stylesheet" href="css/style.css?v=2">
21+ <link href='http://fonts.googleapis.com/css?family=Carter+One' rel='stylesheet' type='text/css'>
22+
2123
22- <!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects -->
2324 <script src="js/libs/modernizr-1.6.min.js"></script>
2425 </head>
2526
2627 <body lang="en" >
2728
28- <div id="container">
29- </div> <!--! end of #container -->
29+ <div id="container">
30+ <div id="about">
31+ <p>This is an experiment using the <em>Twitter API</em>.<br />
32+ Every dot is a tweet with geographic coordinates.
33+ I used a canvas element layout as a latitude/longitude
34+ grid.<br /><em>Sit back and let the world draw itself one tweet at a time :-)
35+ </em></p>
36+
37+ <a class="button" href="//github.com/xonecas/dotter">View the source</a>
38+ <a href="#" class="handle" data-target="about">Close</a>
39+ </div>
40+ <header>
41+ <strong class="button handle" data-target="about">About</strong>
42+ <h1>The Dotter Experience</h1>
43+ </header>
44+ </div> <!--! end of #container -->
3045
3146
3247 <!-- JavaScript at the bottom for fast page loading -->
3348
34- <!-- Grab Google CDN's jQuery. fall back to local if necessary -->
3549 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.js"></script>
3650 <script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.5.0.js"%3E%3C/script%3E'))</script>
3751
3852
39- <!-- scripts concatenated and minified via ant build script-->
4053 <script>!Modernizr.canvas && document.write(unescape('%3Cscript src="js/libs/excanvas.js"%3E%3C/script%3E'))</script>
4154 <script src="/socket.io/socket.io.js"></script>
55+ <script src="js/plugins.js"></script>
4256 <script src="js/script.js"></script>
43- <!-- end concatenated and minified scripts-->
4457
4558 </body>
4659 </html>
js/plugins.js+96−0
@@ -10,4 +10,100 @@ window.log = function(){
1010
1111
1212 // place any jQuery/helper plugins in here, instead of separate, slower script files.
13+if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
14+
15+var Storage = function (type) {
16+ function createCookie(name, value, days) {
17+ var date, expires;
18+
19+ if (days) {
20+ date = new Date();
21+ date.setTime(date.getTime()+(days*24*60*60*1000));
22+ expires = "; expires="+date.toGMTString();
23+ } else {
24+ expires = "";
25+ }
26+ document.cookie = name+"="+value+expires+"; path=/";
27+ }
28+
29+ function readCookie(name) {
30+ var nameEQ = name + "=",
31+ ca = document.cookie.split(';'),
32+ i, c;
33+
34+ for (i=0; i < ca.length; i++) {
35+ c = ca[i];
36+ while (c.charAt(0)==' ') {
37+ c = c.substring(1,c.length);
38+ }
39+
40+ if (c.indexOf(nameEQ) == 0) {
41+ return c.substring(nameEQ.length,c.length);
42+ }
43+ }
44+ return null;
45+ }
46+
47+ function setData(data) {
48+ data = JSON.stringify(data);
49+ if (type == 'session') {
50+ window.name = data;
51+ } else {
52+ createCookie('localStorage', data, 365);
53+ }
54+ }
55+
56+ function clearData() {
57+ if (type == 'session') {
58+ window.name = '';
59+ } else {
60+ createCookie('localStorage', '', 365);
61+ }
62+ }
63+
64+ function getData() {
65+ var data = type == 'session' ? window.name : readCookie('localStorage');
66+ return data ? JSON.parse(data) : {};
67+ }
68+
69+
70+ // initialise if there's already data
71+ var data = getData();
72+
73+ return {
74+ length: 0,
75+ clear: function () {
76+ data = {};
77+ this.length = 0;
78+ clearData();
79+ },
80+ getItem: function (key) {
81+ return data[key] === undefined ? null : data[key];
82+ },
83+ key: function (i) {
84+ // not perfect, but works
85+ var ctr = 0;
86+ for (var k in data) {
87+ if (ctr == i) return k;
88+ else ctr++;
89+ }
90+ return null;
91+ },
92+ removeItem: function (key) {
93+ delete data[key];
94+ this.length--;
95+ setData(data);
96+ },
97+ setItem: function (key, value) {
98+ data[key] = value+''; // forces the value to a string
99+ this.length++;
100+ setData(data);
101+ }
102+ };
103+};
104+
105+if (typeof window.localStorage == 'undefined') window.localStorage = new Storage('local');
106+if (typeof window.sessionStorage == 'undefined') window.sessionStorage = new Storage('session');
107+
108+})();
13109
js/script.js+7−3
@@ -25,10 +25,14 @@
2525 ctx.fillRect(x-4,y-4,8,8);
2626 }
2727
28- window.onload = function () {
28+ $(window).ready(function () {
29+ $(".handle").click(function (ev) {
30+ var target = '#'+$(this).data('target');
31+ $(target).slideToggle('slow');
32+ });
2933
3034 var canvas = document.createElement('canvas');
31- if (!Modernizr.canvas)
35+ if (!Modernizr.canvas && G_vmlCanvasManager)
3236 G_vmlCanvasManager.initElement(canvas);
3337
3438 var ctx = canvas.getContext('2d');
@@ -66,6 +70,6 @@
6670 draw(ctx, lat, lng);
6771
6872 });
69- }
73+ });
7074 }) (window);