Skip to content

Commit

Permalink
Merge pull request #35 from shankari/release_v_8
Browse files Browse the repository at this point in the history
Bump up version to v8
  • Loading branch information
shankari committed Apr 27, 2016
2 parents e769f91 + 24be406 commit f41eaed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
6 changes: 3 additions & 3 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="edu.berkeley.eecs.emission"
version="0.0.7"
android-versionCode="7"
ios-CFBundleVersion="7"
version="0.0.8"
android-versionCode="8"
ios-CFBundleVersion="8"
xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>emission</name>
<description>
Expand Down
24 changes: 21 additions & 3 deletions www/js/diary/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,17 @@ angular.module('emission.main.diary.services', ['emission.services'])

}
dh.getLongerOrShorter = function(trip, id) {
var noChangeReturn = [0, ''];
var ctrip = CommonGraph.findCommon(id);
if (!angular.isUndefined(ctrip)) {
var cDuration = ctrip.durations[0];
var cDuration = dh.average(ctrip.durations);
if (cDuration == null) {
return noChangeReturn;
}
var thisDuration = trip.properties.end_ts - trip.properties.start_ts;
var diff = thisDuration - cDuration;
if (diff < 60 && diff > -60) {
return [0, ''];
return noChangeReturn;
} else {
if (diff > 0) {
return [1, dh.getFormattedDuration(diff)];
Expand All @@ -158,9 +162,23 @@ angular.module('emission.main.diary.services', ['emission.services'])

}
} else {
return [0, ''];
return noChangeReturn;
}
}
dh.average = function(array) {
if (array.length == 0) {
// We want to special case the handling of the array length because
// otherwise we will get a divide by zero error and the dreaded nan
return null;
}
// check out cool use of reduce and arrow functions!
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
// Hm, arrow functions don't work, but reduce does!
var sum = array.reduce(function(previousValue, currentValue, currentIndex, array) {
return previousValue + currentValue;
});
return sum/array.length
}
dh.arrowColor = function(pn) {
if (pn == 0) {
return 'transparent';
Expand Down

0 comments on commit f41eaed

Please sign in to comment.