Skip to content

Commit 8f59c82

Browse files
committed
variables are function-level; don't redeclare them
1 parent a35fe8b commit 8f59c82

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

‎js/solari.js‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,17 @@ function UpdateSolariRow(row, current_row, new_row) {
226226

227227
function SpinChars(rate, selector_prefix, max_boxes, current_text, new_text) {
228228
//populate each box
229+
var num_spins = 0;
229230
for (var box = 0; box < max_boxes; box++) {
230231
// get the to and from character codes for this box
231232
var to_char_code = ToUpper(((new_text.length > box) ? new_text.charCodeAt(box) : 32));
232233
var from_char_code = ToUpper(((current_text.length > box) ? current_text.charCodeAt(box) : 32));
233234
var final_pos = '';
234235
if (from_char_code > to_char_code) {
235-
var num_spins = ((LAST_CHAR_CODE - from_char_code) + (to_char_code - FIRST_CHAR_CODE)) * CHAR_FACTOR;
236+
num_spins = ((LAST_CHAR_CODE - from_char_code) + (to_char_code - FIRST_CHAR_CODE)) * CHAR_FACTOR;
236237
final_pos = ((LETTER_HEIGHT * (to_char_code - FIRST_CHAR_CODE)) * CHAR_FACTOR) * -1;
237238
} else {
238-
var num_spins = (to_char_code - from_char_code) * CHAR_FACTOR;
239+
num_spins = (to_char_code - from_char_code) * CHAR_FACTOR;
239240
}
240241
var selector = selector_prefix + 'box' + box; // add the box part
241242

@@ -245,16 +246,20 @@ function SpinChars(rate, selector_prefix, max_boxes, current_text, new_text) {
245246

246247
function SpinImage(rate, selector, from_pos, to_pos) {
247248
var final_pos = '';
249+
var num_spins = 0;
250+
248251
if (from_pos > to_pos) {
249-
var num_spins = (((LAST_STATUS - from_pos) + to_pos) * IMAGE_FACTOR);
252+
num_spins = (((LAST_STATUS - from_pos) + to_pos) * IMAGE_FACTOR);
250253
final_pos = ((IMAGE_HEIGHT * to_pos) * IMAGE_FACTOR) * -1;
251254
} else {
252-
var num_spins = ((to_pos - from_pos) * IMAGE_FACTOR);
255+
num_spins = ((to_pos - from_pos) * IMAGE_FACTOR);
253256
}
254-
if(from_pos === 4 && to_pos === 0)
257+
258+
if (from_pos === 4 && to_pos === 0) {
255259
num_spins = 8;
260+
}
256261

257-
//unless we're not moving at all, make the image go 'round 8 more times that it needs to, otherwise it finishes too fast.
262+
//unless we're not moving at all, make the image go 'round 8 more times that it needs to, otherwise it finishes too fast.
258263
if (num_spins !== 0) {
259264
$('audio#solari-audio')[0].play();
260265
num_spins +=80;
@@ -265,22 +270,18 @@ function SpinImage(rate, selector, from_pos, to_pos) {
265270
function SpinIt(selector, num_spins, rate, pixel_distance, final_pos) {
266271
for (var ii = 0; ii < num_spins; ii++) {
267272
$(selector).transition(
268-
{backgroundPositionY: '-=' + (pixel_distance * 2)}, {
269-
duration: 1,
270-
easing: "linear"
271-
}
272-
);
273+
{backgroundPositionY: '-=' + (pixel_distance * 2)},
274+
{duration: 1, easing: "linear"}
275+
);
273276
$(selector).transition(
274-
{backgroundPositionY: '+=1'}, {
275-
duration: rate,
276-
easing: "linear"
277-
}
278-
);
277+
{backgroundPositionY: '+=1'},
278+
{duration: rate, easing: "linear"}
279+
);
279280
// on the very last iteration, use a call back to set the background position to the "real" position
280281
var f = function () {};
281282
if ((final_pos !== '') && (ii === (num_spins-1))) {
282283
f = function() {
283-
$(selector).css('backgroundPositionY', final_pos);
284+
$(selector).css('backgroundPositionY', final_pos);
284285
};
285286
}
286287
$(selector).animate({backgroundPositionY: '+=' + (pixel_distance - 1)}, 1, f);
@@ -360,7 +361,7 @@ function updateSolariBoard() {
360361
break;
361362
}
362363
var next_due_row = solariData[i];
363-
var time = next_due_row.sTime;
364+
time = next_due_row.sTime;
364365
var timeDelta = Date.parse(next_due_row.sDate).getTime() - new Date().getTime();
365366
var nOffset = Math.ceil(timeDelta / (1000 * 60 * 60 * 24)); //divide my miliseconds per day
366367
var offset = (nOffset === 0 ? "" : nOffset.toString() + "d"); //hide if next due is today

0 commit comments

Comments
 (0)