Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 1 file changed
  • 0 comments
  • 1 contributor

Showing 1 changed file with 41 additions and 11 deletions. Show diff stats Hide diff stats

  1. 52  js/soundtrack-of-you.js
52  js/soundtrack-of-you.js
@@ -146,12 +146,8 @@ function convertMonth(month) {
146 146
     }
147 147
 
148 148
     monthnumber = i + 1 ;
149  
-
150  
-    if (monthnumber < 10) {
151  
-	    monthnumber = '0' + monthnumber;
152  
-    }
153 149
 	
154  
-	return monthnumber + '';
  150
+	return monthnumber;
155 151
 }
156 152
 
157 153
 function convertDay(day) {
@@ -175,6 +171,39 @@ function fadeOut(success) {
175 171
 	fade();
176 172
 }
177 173
 
  174
+// takes the date submitted by the user and winds it back by 9 months (ish)
  175
+function windbackclock(day, month, year) {
  176
+    var wildnight = {};
  177
+
  178
+
  179
+    // month - 9
  180
+    wildnight.month = parseInt(month) - 9;
  181
+
  182
+console.log('month',month - 9);
  183
+
  184
+    wildnight.day = day;
  185
+
  186
+    // if it's less than 1 then set year back by 1
  187
+    if (wildnight.month < 1) {
  188
+	   wildnight.year = year - 1;
  189
+	   wildnight.month = 12 + wildnight.month;
  190
+    } else {
  191
+	   wildnight.year = year;
  192
+    }
  193
+
  194
+    wildnight.day = convertDay(wildnight.day);
  195
+    wildnight.month = wildnight.month;
  196
+
  197
+    if (wildnight.month < 10) {
  198
+	    wildnight.month = '0' + wildnight.month;
  199
+    }
  200
+
  201
+    console.log(wildnight);
  202
+	
  203
+    return wildnight;	
  204
+	
  205
+}
  206
+
178 207
 
179 208
 $(document).ready(function() {
180 209
 	
@@ -192,13 +221,14 @@ $(document).ready(function() {
192 221
 	    ev.preventDefault();
193 222
 	    var dateto = {}, datefrom = {};
194 223
 	
195  
-	    dateto.day = convertDay($('#day').val());
196  
-	    dateto.month = convertMonth($('#month').val());
197  
-	    dateto.year = $('#year').val() - 1;
198 224
 	
199  
-	    datefrom.day = convertDay($('#day').val());
200  
-	    datefrom.month = convertMonth($('#month').val());
201  
-	    datefrom.year = $('#year').val() - 2;
  225
+	    dateto = windbackclock($('#day').val(), convertMonth($('#month').val()), $('#year').val());
  226
+	
  227
+	    console.log(dateto);
  228
+	
  229
+	    datefrom.day = dateto.day;
  230
+	    datefrom.month = dateto.month;
  231
+	    datefrom.year = dateto.year - 1;
202 232
 		
203 233
 		getTunesOfYou(datefrom, dateto, function () {		
204 234
 		    $('body').removeClass('loading').addClass("zoom").addClass("reveal");

No commit comments for this range

Something went wrong with that request. Please try again.