Merge lp:~sil/stormcloud/spin-refresh into lp:~cooperjona/stormcloud/quickly_trunk

Proposed by Stuart Langridge
Status: Merged
Merge reported by: consindo
Merged at revision: not available
Proposed branch: lp:~sil/stormcloud/spin-refresh
Merge into: lp:~cooperjona/stormcloud/quickly_trunk
Diff against target: 165 lines (+36/-17)
2 files modified
data/media/script.js (+21/-16)
data/media/style.css (+15/-1)
To merge this branch: bzr merge lp:~sil/stormcloud/spin-refresh
Reviewer Review Type Date Requested Status
consindo Pending
Review via email: mp+129404@code.launchpad.net

Description of the change

Spin the refresh indicator when fetching from the web. Spins for 500ms minimum just because a web refresh on most sane connections is really fast and so you don't see the effect. Useful to show people that there's something going on, and also to see when a refresh is actually happening.

Sorry about the whitespace bits of the diff; my editor removes unnecessary whitespace from empty lines. If that's really annoying, reject. :)

To post a comment you must log in.
Revision history for this message
consindo (cooperjona) wrote :

I'm hosting code at GitHub - it's because I'm going to create Chrome and Android versions and because I also prefer git. I've merged the code anyway.

https://github.com/consindo/stormcloud

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/media/script.js'
2--- data/media/script.js 2012-10-11 11:26:26 +0000
3+++ data/media/script.js 2012-10-12 12:02:28 +0000
4@@ -51,7 +51,7 @@
5 //Temperature
6 weather.temperature = $(data).filterNode('item').children().filterNode("yweather:condition").attr("temp")
7 weather.temperatureUnit = $(data).filterNode('yweather:units').attr("temperature")
8-
9+
10 //Wind
11 weather.windUnit = $(data).filterNode('yweather:units').attr("speed")
12 weather.windSpeed = $(data).filterNode('yweather:wind').attr("speed")
13@@ -85,7 +85,9 @@
14 }
15
16 function render(location) {
17- getWeatherData(location, function(rawdata) {
18+ $('.border .sync').addClass('busy');
19+
20+ getWeatherData(location, function(rawdata) {
21 generateStats(rawdata, function(weather) {
22
23 console.log(weather)
24@@ -98,9 +100,9 @@
25 $("#temperature").text(weather.temperature + " °")
26 document.title = weather.temperature
27 }
28-
29- $("#windSpeed").text(weather.windSpeed)
30- $("#windUnit").text(weather.windUnit)
31+
32+ $("#windSpeed").text(weather.windSpeed)
33+ $("#windUnit").text(weather.windUnit)
34 $("#humidity").text(weather.humidity + " %")
35
36 //Background Color
37@@ -121,6 +123,9 @@
38 $('.border .sync, .border .settings').css("opacity", "0.8")
39 $('#actualWeather').fadeIn(500)
40 $("#locationModal").fadeOut(500)
41+ // spin the thing for 500ms longer than it actually takes, because
42+ // most of the time refreshing is actually instant :)
43+ setTimeout(function() { $('.border .sync').removeClass('busy'); }, 500);
44 })
45 })
46 }
47@@ -132,7 +137,7 @@
48 // Array to RGB
49 if (typeof(i) == 'object') {
50 return 'rgb(' + i.join(', ') + ')';
51-
52+
53 // Hex to array
54 } else if (typeof(i) == 'string') {
55 var output = [];
56@@ -144,12 +149,12 @@
57 return output;
58 }
59 };
60-
61+
62 // Get color at position
63 var blend = function( x ) {
64-
65+
66 x = Number(x);
67-
68+
69 var gradient = [{
70 pos: 0,
71 color: convert('#0081d3')
72@@ -184,7 +189,7 @@
73 pos: 100,
74 color: convert('#e44211')
75 }];
76-
77+
78 var left = {
79 pos: -1,
80 color: false,
81@@ -195,7 +200,7 @@
82 color: false,
83 percent: 0
84 };
85-
86+
87 // Get the 2 closest stops to the specified position
88 for (var i=0, l=gradient.length; i<l; i++) {
89 var stop = gradient[i];
90@@ -225,7 +230,7 @@
91 Math.round((left.color[1] * left.percent) + (right.color[1] * right.percent)),
92 Math.round((left.color[2] * left.percent) + (right.color[2] * right.percent)),
93 ];
94-
95+
96 return convert(blend);
97
98 };
99@@ -345,7 +350,7 @@
100 typingTimer = setTimeout(doneTyping, doneTypingInterval)
101 });
102
103- //on keydown, clear the countdown
104+ //on keydown, clear the countdown
105 locationInput.keydown(function(){
106 clearTimeout(typingTimer)
107 });
108@@ -376,7 +381,7 @@
109
110 /* Other Settings */
111 if (!localStorage.stormcloud_measurement) {
112- localStorage.stormcloud_measurement = "f"
113+ localStorage.stormcloud_measurement = "f"
114 }
115 $('#locationModal .temptype [data-type=' + localStorage.stormcloud_measurement + ']').addClass('selected')
116
117@@ -401,12 +406,12 @@
118 $('body').removeClass('retina')
119 }
120 })
121-
122+
123 /* Error Message Retry Button */
124 $('#errorMessage .btn').click(function() {
125 render(localStorage.stormcloud)
126 })
127-
128+
129 }
130 function show_settings(amount) {
131
132
133=== modified file 'data/media/style.css'
134--- data/media/style.css 2012-10-11 11:26:26 +0000
135+++ data/media/style.css 2012-10-12 12:02:28 +0000
136@@ -22,7 +22,7 @@
137 -moz-user-select: none;
138 -ms-user-select: none;
139 -o-user-select: none;
140- user-select: none;
141+ user-select: none;
142 }
143 p, span, div {
144 cursor: default;
145@@ -35,6 +35,20 @@
146 opacity: 0;
147 -webkit-transition: 500ms ease opacity;
148 }
149+@-webkit-keyframes busy-spinning {
150+ from {
151+ -webkit-transform: rotate(0deg);
152+ -webkit-transform-origin: 8px 8px;
153+ }
154+ to {
155+ -webkit-transform: rotate(360deg);
156+ -webkit-transform-origin: 8px 8px;
157+ }
158+}
159+
160+.border .sync.busy {
161+ -webkit-animation: busy-spinning 0.5s infinite linear;
162+}
163 .border {
164 position: absolute;
165 width: 100%;

Subscribers

People subscribed via source and target branches

to all changes: