diff --git a/habit.php b/habit.php
index 4d0d022..671e6a8 100644
--- a/habit.php
+++ b/habit.php
@@ -772,11 +772,12 @@
$jsonArray['align'] = "bad";
$jsonArray['calCol'] = "#e81b1b";
$jsonArray['title1'] = "Streak";
- $jsonArray['title2'] = "Top";
- $jsonArray['title3'] = "Total (Year)";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+
$jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
- $jsonArray['result2'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
- $jsonArray['result3'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
}
$todayCheck = habit_check_daily($section['Activity'], $moodlog);
if ($todayCheck) {
@@ -805,6 +806,8 @@
if( $weekCount < $multiplier )
if($todayCheck)
$jsonArray['buttonText'] = $weekCount;
+ if($weekCount >= $multiplier)
+ $jsonArray['buttonClass'] = 'button-done';
if( $todayCheck ) {
$jsonArray['buttonClass'] = 'button-neut';
if($weekCount >= $multiplier)
@@ -819,6 +822,87 @@
return false;
}
+function habit_get_json_all($moodlog, $habitlog) {
+ $fileContent = file_get_contents($habitlog);
+ $resultArray = habit_parse_file($fileContent);
+
+ $jsonWordsArray = array();
+
+ foreach ($resultArray as $section) {
+ $jsonArray = array();
+ $jsonArray['activity'] = $section['Activity'];
+ $jsonArray['align'] = "";
+ $jsonArray['buttonClass'] = "";
+ $jsonArray['buttonText'] = "";
+
+ if ($section['Category'][0] == "d") {
+ $jsonArray['freq'] = "d";
+
+ if ($section['Category'][1] == "+") {
+ $jsonArray['align'] = "good";
+ $jsonArray['calCol'] = "#58e81b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top($section['Activity'], $moodlog);
+ } elseif ($section['Category'][1] == "-") {
+ $jsonArray['align'] = "bad";
+ $jsonArray['calCol'] = "#e81b1b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
+ }
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-' . $jsonArray['align'];
+ }
+ } elseif ($section['Category'][0] == "w") {
+ $jsonArray['freq'] = "w";
+
+ $multiplier = $section['Category'][1];
+ $jsonArray['align'] = "good";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_week($section['Activity'], $multiplier, $moodlog);
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+ $weekCount = habit_count_weekly($section['Activity'], $moodlog);
+ $jsonArray['weekSoFar'] = $weekCount;
+ $jsonArray['weekGoal'] = $multiplier;
+
+ if ($weekCount < $multiplier && $todayCheck) {
+ $jsonArray['buttonText'] = $weekCount;
+ }
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-done';
+ }
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-neut';
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-good';
+ }
+ }
+ }
+
+ $jsonWordsArray[] = $jsonArray;
+ }
+
+ return json_encode($jsonWordsArray);
+}
+
/***
* creating calendar stuff
*/
diff --git a/habit.php b/habit.php
index 4d0d022..671e6a8 100644
--- a/habit.php
+++ b/habit.php
@@ -772,11 +772,12 @@
$jsonArray['align'] = "bad";
$jsonArray['calCol'] = "#e81b1b";
$jsonArray['title1'] = "Streak";
- $jsonArray['title2'] = "Top";
- $jsonArray['title3'] = "Total (Year)";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+
$jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
- $jsonArray['result2'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
- $jsonArray['result3'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
}
$todayCheck = habit_check_daily($section['Activity'], $moodlog);
if ($todayCheck) {
@@ -805,6 +806,8 @@
if( $weekCount < $multiplier )
if($todayCheck)
$jsonArray['buttonText'] = $weekCount;
+ if($weekCount >= $multiplier)
+ $jsonArray['buttonClass'] = 'button-done';
if( $todayCheck ) {
$jsonArray['buttonClass'] = 'button-neut';
if($weekCount >= $multiplier)
@@ -819,6 +822,87 @@
return false;
}
+function habit_get_json_all($moodlog, $habitlog) {
+ $fileContent = file_get_contents($habitlog);
+ $resultArray = habit_parse_file($fileContent);
+
+ $jsonWordsArray = array();
+
+ foreach ($resultArray as $section) {
+ $jsonArray = array();
+ $jsonArray['activity'] = $section['Activity'];
+ $jsonArray['align'] = "";
+ $jsonArray['buttonClass'] = "";
+ $jsonArray['buttonText'] = "";
+
+ if ($section['Category'][0] == "d") {
+ $jsonArray['freq'] = "d";
+
+ if ($section['Category'][1] == "+") {
+ $jsonArray['align'] = "good";
+ $jsonArray['calCol'] = "#58e81b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top($section['Activity'], $moodlog);
+ } elseif ($section['Category'][1] == "-") {
+ $jsonArray['align'] = "bad";
+ $jsonArray['calCol'] = "#e81b1b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
+ }
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-' . $jsonArray['align'];
+ }
+ } elseif ($section['Category'][0] == "w") {
+ $jsonArray['freq'] = "w";
+
+ $multiplier = $section['Category'][1];
+ $jsonArray['align'] = "good";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_week($section['Activity'], $multiplier, $moodlog);
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+ $weekCount = habit_count_weekly($section['Activity'], $moodlog);
+ $jsonArray['weekSoFar'] = $weekCount;
+ $jsonArray['weekGoal'] = $multiplier;
+
+ if ($weekCount < $multiplier && $todayCheck) {
+ $jsonArray['buttonText'] = $weekCount;
+ }
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-done';
+ }
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-neut';
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-good';
+ }
+ }
+ }
+
+ $jsonWordsArray[] = $jsonArray;
+ }
+
+ return json_encode($jsonWordsArray);
+}
+
/***
* creating calendar stuff
*/
diff --git a/habit_ui.php b/habit_ui.php
index 31ecafb..585cfd4 100644
--- a/habit_ui.php
+++ b/habit_ui.php
@@ -45,7 +45,7 @@
-
+
@@ -119,6 +119,8 @@
if( $weekCount < $section['Category'][1] )
if($todayCheck)
$buttText = $weekCount;
+ if($weekCount >= $multiplier)
+ $buttonClass = 'button-done';
if( $todayCheck ) {
$buttonClass = 'button-neut';
if($weekCount >= $multiplier)
diff --git a/habit.php b/habit.php
index 4d0d022..671e6a8 100644
--- a/habit.php
+++ b/habit.php
@@ -772,11 +772,12 @@
$jsonArray['align'] = "bad";
$jsonArray['calCol'] = "#e81b1b";
$jsonArray['title1'] = "Streak";
- $jsonArray['title2'] = "Top";
- $jsonArray['title3'] = "Total (Year)";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+
$jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
- $jsonArray['result2'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
- $jsonArray['result3'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
}
$todayCheck = habit_check_daily($section['Activity'], $moodlog);
if ($todayCheck) {
@@ -805,6 +806,8 @@
if( $weekCount < $multiplier )
if($todayCheck)
$jsonArray['buttonText'] = $weekCount;
+ if($weekCount >= $multiplier)
+ $jsonArray['buttonClass'] = 'button-done';
if( $todayCheck ) {
$jsonArray['buttonClass'] = 'button-neut';
if($weekCount >= $multiplier)
@@ -819,6 +822,87 @@
return false;
}
+function habit_get_json_all($moodlog, $habitlog) {
+ $fileContent = file_get_contents($habitlog);
+ $resultArray = habit_parse_file($fileContent);
+
+ $jsonWordsArray = array();
+
+ foreach ($resultArray as $section) {
+ $jsonArray = array();
+ $jsonArray['activity'] = $section['Activity'];
+ $jsonArray['align'] = "";
+ $jsonArray['buttonClass'] = "";
+ $jsonArray['buttonText'] = "";
+
+ if ($section['Category'][0] == "d") {
+ $jsonArray['freq'] = "d";
+
+ if ($section['Category'][1] == "+") {
+ $jsonArray['align'] = "good";
+ $jsonArray['calCol'] = "#58e81b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top($section['Activity'], $moodlog);
+ } elseif ($section['Category'][1] == "-") {
+ $jsonArray['align'] = "bad";
+ $jsonArray['calCol'] = "#e81b1b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
+ }
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-' . $jsonArray['align'];
+ }
+ } elseif ($section['Category'][0] == "w") {
+ $jsonArray['freq'] = "w";
+
+ $multiplier = $section['Category'][1];
+ $jsonArray['align'] = "good";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_week($section['Activity'], $multiplier, $moodlog);
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+ $weekCount = habit_count_weekly($section['Activity'], $moodlog);
+ $jsonArray['weekSoFar'] = $weekCount;
+ $jsonArray['weekGoal'] = $multiplier;
+
+ if ($weekCount < $multiplier && $todayCheck) {
+ $jsonArray['buttonText'] = $weekCount;
+ }
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-done';
+ }
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-neut';
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-good';
+ }
+ }
+ }
+
+ $jsonWordsArray[] = $jsonArray;
+ }
+
+ return json_encode($jsonWordsArray);
+}
+
/***
* creating calendar stuff
*/
diff --git a/habit_ui.php b/habit_ui.php
index 31ecafb..585cfd4 100644
--- a/habit_ui.php
+++ b/habit_ui.php
@@ -45,7 +45,7 @@
-
+
@@ -119,6 +119,8 @@
if( $weekCount < $section['Category'][1] )
if($todayCheck)
$buttText = $weekCount;
+ if($weekCount >= $multiplier)
+ $buttonClass = 'button-done';
if( $todayCheck ) {
$buttonClass = 'button-neut';
if($weekCount >= $multiplier)
diff --git a/habit_ui_style.css b/habit_ui_style.css
index 94089ba..4f4d096 100644
--- a/habit_ui_style.css
+++ b/habit_ui_style.css
@@ -67,6 +67,7 @@
font-weight:700;
}
+.button-done{ background-color: #399113; color:#000; }
.button-good{ background-color: #58e81b; color:#000; }
.button-bad{ background-color: #e81b1b; color:#000; }
.button-neut{ background-color: #efe23e; color:#000; }
diff --git a/habit.php b/habit.php
index 4d0d022..671e6a8 100644
--- a/habit.php
+++ b/habit.php
@@ -772,11 +772,12 @@
$jsonArray['align'] = "bad";
$jsonArray['calCol'] = "#e81b1b";
$jsonArray['title1'] = "Streak";
- $jsonArray['title2'] = "Top";
- $jsonArray['title3'] = "Total (Year)";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+
$jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
- $jsonArray['result2'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
- $jsonArray['result3'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
}
$todayCheck = habit_check_daily($section['Activity'], $moodlog);
if ($todayCheck) {
@@ -805,6 +806,8 @@
if( $weekCount < $multiplier )
if($todayCheck)
$jsonArray['buttonText'] = $weekCount;
+ if($weekCount >= $multiplier)
+ $jsonArray['buttonClass'] = 'button-done';
if( $todayCheck ) {
$jsonArray['buttonClass'] = 'button-neut';
if($weekCount >= $multiplier)
@@ -819,6 +822,87 @@
return false;
}
+function habit_get_json_all($moodlog, $habitlog) {
+ $fileContent = file_get_contents($habitlog);
+ $resultArray = habit_parse_file($fileContent);
+
+ $jsonWordsArray = array();
+
+ foreach ($resultArray as $section) {
+ $jsonArray = array();
+ $jsonArray['activity'] = $section['Activity'];
+ $jsonArray['align'] = "";
+ $jsonArray['buttonClass'] = "";
+ $jsonArray['buttonText'] = "";
+
+ if ($section['Category'][0] == "d") {
+ $jsonArray['freq'] = "d";
+
+ if ($section['Category'][1] == "+") {
+ $jsonArray['align'] = "good";
+ $jsonArray['calCol'] = "#58e81b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top($section['Activity'], $moodlog);
+ } elseif ($section['Category'][1] == "-") {
+ $jsonArray['align'] = "bad";
+ $jsonArray['calCol'] = "#e81b1b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
+ }
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-' . $jsonArray['align'];
+ }
+ } elseif ($section['Category'][0] == "w") {
+ $jsonArray['freq'] = "w";
+
+ $multiplier = $section['Category'][1];
+ $jsonArray['align'] = "good";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_week($section['Activity'], $multiplier, $moodlog);
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+ $weekCount = habit_count_weekly($section['Activity'], $moodlog);
+ $jsonArray['weekSoFar'] = $weekCount;
+ $jsonArray['weekGoal'] = $multiplier;
+
+ if ($weekCount < $multiplier && $todayCheck) {
+ $jsonArray['buttonText'] = $weekCount;
+ }
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-done';
+ }
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-neut';
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-good';
+ }
+ }
+ }
+
+ $jsonWordsArray[] = $jsonArray;
+ }
+
+ return json_encode($jsonWordsArray);
+}
+
/***
* creating calendar stuff
*/
diff --git a/habit_ui.php b/habit_ui.php
index 31ecafb..585cfd4 100644
--- a/habit_ui.php
+++ b/habit_ui.php
@@ -45,7 +45,7 @@
-
+
@@ -119,6 +119,8 @@
if( $weekCount < $section['Category'][1] )
if($todayCheck)
$buttText = $weekCount;
+ if($weekCount >= $multiplier)
+ $buttonClass = 'button-done';
if( $todayCheck ) {
$buttonClass = 'button-neut';
if($weekCount >= $multiplier)
diff --git a/habit_ui_style.css b/habit_ui_style.css
index 94089ba..4f4d096 100644
--- a/habit_ui_style.css
+++ b/habit_ui_style.css
@@ -67,6 +67,7 @@
font-weight:700;
}
+.button-done{ background-color: #399113; color:#000; }
.button-good{ background-color: #58e81b; color:#000; }
.button-bad{ background-color: #e81b1b; color:#000; }
.button-neut{ background-color: #efe23e; color:#000; }
diff --git a/index.php b/index.php
index 0140716..b262e73 100755
--- a/index.php
+++ b/index.php
@@ -111,6 +111,13 @@
echo "0";
}
break;
+ case 'habit_all_stats': // get unfiltered main cal averages - output JSON
+ header('Content-Type: application/json');
+
+ $result = habit_get_json_all( $moodlog, $habitlog );
+ echo $result;
+
+ break;
default:
# code...
break;
@@ -728,6 +735,8 @@
if( $weekCount < $section['Category'][1] )
if($todayCheck)
$buttText = $weekCount;
+ if($weekCount >= $multiplier)
+ $buttonClass = 'button-done';
if( $todayCheck ) {
$buttonClass = 'button-neut';
if($weekCount >= $multiplier)
diff --git a/habit.php b/habit.php
index 4d0d022..671e6a8 100644
--- a/habit.php
+++ b/habit.php
@@ -772,11 +772,12 @@
$jsonArray['align'] = "bad";
$jsonArray['calCol'] = "#e81b1b";
$jsonArray['title1'] = "Streak";
- $jsonArray['title2'] = "Top";
- $jsonArray['title3'] = "Total (Year)";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+
$jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
- $jsonArray['result2'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
- $jsonArray['result3'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
}
$todayCheck = habit_check_daily($section['Activity'], $moodlog);
if ($todayCheck) {
@@ -805,6 +806,8 @@
if( $weekCount < $multiplier )
if($todayCheck)
$jsonArray['buttonText'] = $weekCount;
+ if($weekCount >= $multiplier)
+ $jsonArray['buttonClass'] = 'button-done';
if( $todayCheck ) {
$jsonArray['buttonClass'] = 'button-neut';
if($weekCount >= $multiplier)
@@ -819,6 +822,87 @@
return false;
}
+function habit_get_json_all($moodlog, $habitlog) {
+ $fileContent = file_get_contents($habitlog);
+ $resultArray = habit_parse_file($fileContent);
+
+ $jsonWordsArray = array();
+
+ foreach ($resultArray as $section) {
+ $jsonArray = array();
+ $jsonArray['activity'] = $section['Activity'];
+ $jsonArray['align'] = "";
+ $jsonArray['buttonClass'] = "";
+ $jsonArray['buttonText'] = "";
+
+ if ($section['Category'][0] == "d") {
+ $jsonArray['freq'] = "d";
+
+ if ($section['Category'][1] == "+") {
+ $jsonArray['align'] = "good";
+ $jsonArray['calCol'] = "#58e81b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top($section['Activity'], $moodlog);
+ } elseif ($section['Category'][1] == "-") {
+ $jsonArray['align'] = "bad";
+ $jsonArray['calCol'] = "#e81b1b";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Total (Year)";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog);
+ $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog);
+ }
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-' . $jsonArray['align'];
+ }
+ } elseif ($section['Category'][0] == "w") {
+ $jsonArray['freq'] = "w";
+
+ $multiplier = $section['Category'][1];
+ $jsonArray['align'] = "good";
+ $jsonArray['title1'] = "Streak";
+ $jsonArray['title2'] = "Missed";
+ $jsonArray['title3'] = "Top";
+ $jsonArray['result1'] = habit_get_stat_streak_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result2'] = habit_get_stat_missed_week($section['Activity'], $multiplier, $moodlog);
+ $jsonArray['result3'] = habit_get_stat_top_week($section['Activity'], $multiplier, $moodlog);
+
+ $todayCheck = habit_check_daily($section['Activity'], $moodlog);
+ $weekCount = habit_count_weekly($section['Activity'], $moodlog);
+ $jsonArray['weekSoFar'] = $weekCount;
+ $jsonArray['weekGoal'] = $multiplier;
+
+ if ($weekCount < $multiplier && $todayCheck) {
+ $jsonArray['buttonText'] = $weekCount;
+ }
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-done';
+ }
+
+ if ($todayCheck) {
+ $jsonArray['buttonClass'] = 'button-neut';
+
+ if ($weekCount >= $multiplier) {
+ $jsonArray['buttonClass'] = 'button-good';
+ }
+ }
+ }
+
+ $jsonWordsArray[] = $jsonArray;
+ }
+
+ return json_encode($jsonWordsArray);
+}
+
/***
* creating calendar stuff
*/
diff --git a/habit_ui.php b/habit_ui.php
index 31ecafb..585cfd4 100644
--- a/habit_ui.php
+++ b/habit_ui.php
@@ -45,7 +45,7 @@
-
+
@@ -119,6 +119,8 @@
if( $weekCount < $section['Category'][1] )
if($todayCheck)
$buttText = $weekCount;
+ if($weekCount >= $multiplier)
+ $buttonClass = 'button-done';
if( $todayCheck ) {
$buttonClass = 'button-neut';
if($weekCount >= $multiplier)
diff --git a/habit_ui_style.css b/habit_ui_style.css
index 94089ba..4f4d096 100644
--- a/habit_ui_style.css
+++ b/habit_ui_style.css
@@ -67,6 +67,7 @@
font-weight:700;
}
+.button-done{ background-color: #399113; color:#000; }
.button-good{ background-color: #58e81b; color:#000; }
.button-bad{ background-color: #e81b1b; color:#000; }
.button-neut{ background-color: #efe23e; color:#000; }
diff --git a/index.php b/index.php
index 0140716..b262e73 100755
--- a/index.php
+++ b/index.php
@@ -111,6 +111,13 @@
echo "0";
}
break;
+ case 'habit_all_stats': // get unfiltered main cal averages - output JSON
+ header('Content-Type: application/json');
+
+ $result = habit_get_json_all( $moodlog, $habitlog );
+ echo $result;
+
+ break;
default:
# code...
break;
@@ -728,6 +735,8 @@
if( $weekCount < $section['Category'][1] )
if($todayCheck)
$buttText = $weekCount;
+ if($weekCount >= $multiplier)
+ $buttonClass = 'button-done';
if( $todayCheck ) {
$buttonClass = 'button-neut';
if($weekCount >= $multiplier)
diff --git a/style.css b/style.css
index 42fe39a..60be515 100755
--- a/style.css
+++ b/style.css
@@ -193,6 +193,7 @@
font-weight:700;
}
+.button-done{ background-color: #399113; color:#000; }
.button-good{ background-color: #58e81b; color:#000; }
.button-bad{ background-color: #e81b1b; color:#000; }
.button-neut{ background-color: #efe23e; color:#000; }