Skip to content

Commit

Permalink
Fixed minor bug on clean startup
Browse files Browse the repository at this point in the history
I was previously always loading from html5 WebStorage but this messed
stuff up if there was no stored data. Wrapped it in an if statement
  • Loading branch information
nuclearpidgeon committed Jun 17, 2014
1 parent 9a890d4 commit d829ec9
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,25 +223,13 @@ $(function() {
$(this).toggleClass('disabled');
});

// TODO - this will be data loading when it works
var assessmentdata = [];

var localAssessments = JSON.parse(localStorage.getItem('SubjectMarksAssessments'));
var mappedAssessments = $.map(localAssessments, function(ass) { return new Assessment(ass.assName, ass.score, ass.total, ass.weighting, ass.graded); });
subject.assessments(mappedAssessments);

// prepare document
// if ( typeof assessmentdata == 'undefined' ) {
// // no data
// loadNoAssessments();
// } else if ( assessmentdata.length === 0 ) {
// // blank list
// loadNoAssessments();
// } else if ( assessmentdata.length > 0 ) {
// //there is data
// } else {
// //some error
// }
var assessmentdata = localStorage.getItem('SubjectMarksAssessments');

if (assessmentdata !== null) {
var localAssessments = JSON.parse();
var mappedAssessments = $.map(localAssessments, function(ass) { return new Assessment(ass.assName, ass.score, ass.total, ass.weighting, ass.graded); });
subject.assessments(mappedAssessments);
}

ko.applyBindings(subject);
subject.weightingOverview.subscribe(function(newValue){plotChart(newValue);});
Expand Down

0 comments on commit d829ec9

Please sign in to comment.