Skip to content
Snippets Groups Projects
Commit ee6dd52d authored by Milan's avatar Milan
Browse files

fix goals.sh

parent 36921d80
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
set -e
avg_past3=$(echo "scale=2; (($month1_spent + $month2_spent + $month3_spent) / 3) * -1" | bc -l )
goal1_percentage=$(bc -l <<< "scale=2; (${month0_donated} * 100) / (${avg_past3})")
goal1_reached=$(bc -l <<< "$month0_donated >= $avg_past3")
goal2_target=$(bc -l <<< "scale=2; $avg_past3 + $spending_buffer")
goal2_percentage=$(bc -l <<< "scale=2; ((${month0_donated} - $avg_past3) * 100) / ($goal2_target - $avg_past3)")
goal2_reached=$(bc -l <<< "$month0_donated >= $goal2_target")
goal3_target=$(echo "scale=2; ((($month1_th + $month2_th + $month3_th) / 3) * 60) + $goal2_target" | bc -l )
goal3_percentage=$(bc -l <<< "scale=2; ((${month0_donated} - $goal2_target) * 100) / ($goal3_target - $goal2_target)")
goal3_reached=$(bc -l <<< "$month0_donated >= $goal3_target")
goals=(1 2 3)
for i in ${goals[@]}; do
percentage=goal${i}_percentage
reached=goal${i}_reached
if (( "${!reached}" == 1 )); then
declare goal${i}_lenght=100
declare goal${i}_bar="linear-gradient(90deg, #0093f0 0%, #0093f0 100%)"
declare goal${i}_success="background: #0093f0;"
declare goal${i}_noflash="animation: none;"
else
declare goal${i}_lenght=${!percentage}
lenght=goal${i}_lenght
declare goal${i}_bar="linear-gradient(90deg, #0093f0 0%, #0093f0 ${!lenght}%, rgba(0,0,0,0) ${!lenght}%)"
fi
done
# little bit dirty – to avoid all hr's to get filled at the same time
if [ $goal1_lenght != 100 ]; then
goal2_bar=none
goal3_bar=none
elif [ $goal2_lenght != 100 ]; then
goal3_bar=none
fi
generated=$(date +'%A, %d.%m.%Y – %H:%M%P %Z')
echo " span.donate-goals-current>span {
display: none;
}
span.donate-goals-current::after {
content: \"${month0_donated}\";
visibility: visible;
display: inline-block;
}
.donate-goals > .target .icon.progress-goal1 {
background-image: $goal1_bar;
background-color: #a1b3c4;
}
.donate-goals hr.progress-goal2 {
background-image: $goal2_bar;
}
.donate-goals hr.progress-goal3 {
background-image: $goal3_bar;
}
span.goal1::before {
content: \"$avg_past3\";
}
span.goal2::before {
content: \"$goal2_target\";
}
span.goal3::before {
content: \"$goal3_target\";
}
.donate-goals > .target .icon.progress-goal1,
.progress-goal1+.tooltip+.target>.icon {
$goal1_success
$goal1_noflash
}
.progress-goal2+.target .icon,
.progress-goal2+.tooltip+.target>.icon {
$goal2_success
$goal2_noflash
}
.progress-goal3+.target .icon,
.progress-goal3+.tooltip+.target>.icon {
$goal3_success
$goal3_noflash
}
.donate-goals-generated::before {
content: \"${generated}\";
} ">$outpath/donate-goals.css
echo "✅ goals css written."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment