ui improvements
1 parent 2cb493a commit 5277f86151e267f15858be515b521c56471434f5
0xRoM authored on 6 Jan 2024
Showing 5 changed files
View
93
habit.php
if($section['Category'][1] == "-"){
$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) {
$jsonArray['buttonClass'] = 'button-'.$jsonArray['align'];
 
if( $weekCount < $multiplier )
if($todayCheck)
$jsonArray['buttonText'] = $weekCount;
if($weekCount >= $multiplier)
$jsonArray['buttonClass'] = 'button-done';
if( $todayCheck ) {
$jsonArray['buttonClass'] = 'button-neut';
if($weekCount >= $multiplier)
$jsonArray['buttonClass'] = 'button-good';
 
if($found)
return json_encode($jsonArray);
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
View
4
habit_ui.php
<link rel="stylesheet" href="/deps/jquery-ui.css">
<link rel="stylesheet" href="/deps/fa.css">
<script src="/deps/jquery-1.12.4.js"></script>
<script src="/deps/jquery-ui.js"></script>
<link rel="stylesheet" href="habit_ui_style.css?id=2" >
<link rel="stylesheet" href="habit_ui_style.css" >
 
<script src="habit_ui_script.js"></script>
</head>
<body>
 
if( $weekCount < $section['Category'][1] )
if($todayCheck)
$buttText = $weekCount;
if($weekCount >= $multiplier)
$buttonClass = 'button-done';
if( $todayCheck ) {
$buttonClass = 'button-neut';
if($weekCount >= $multiplier)
$buttonClass = 'button-good';
View
1
■■■■
habit_ui_style.css
font-family: 'Source Code Pro', monospace;
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; }
 
View
9
index.php
echo $result;
}else{
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;
 
if( $weekCount < $section['Category'][1] )
if($todayCheck)
$buttText = $weekCount;
if($weekCount >= $multiplier)
$buttonClass = 'button-done';
if( $todayCheck ) {
$buttonClass = 'button-neut';
if($weekCount >= $multiplier)
$buttonClass = 'button-good';
View
1
■■■■
style.css
font-family: 'Source Code Pro', monospace;
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; }
 
Buy Me A Coffee