diff --git a/inc/myco.js b/inc/myco.js index 5e1a33d..5526acb 100644 --- a/inc/myco.js +++ b/inc/myco.js @@ -67,6 +67,57 @@ navbar_collapse_hide=function() { } } +/**************** + * Parts + ****************/ + +view_part=function(part) { + $('.part').each(function(idx,div) { + $(div).css('display','none'); + }); + $(part).css('display','block'); +} + +view_home=function() { + if (user) { + $('#view-home #title').html('Bonjour '+user.name); + } + else { + $('#view-home #title').html('Bonjour'); + } + if (groups.count()>0) { + tbody=$('#view-home #mybalances tbody'); + tbody.html(''); + balances=groups.balances(); + var sum=0; + for (g in balances) { + if (jQuery.type(balances[g]['balance'][user.name])!='undefined') { + if (balances[g]['balance'][user.name]['diff']<0) { + sum+=balances[g]['balance'][user.name]['diff']; + diff=''+balances[g]['balance'][user.name]['diff'].toFixed(2)+''; + } + else { + value=balances[g]['balance'][user.name]['total']-balances[g]['min']; + sum+=value; + diff='+'+value.toFixed(2)+' €'; + } + tbody.html(tbody.html()+''+g+''+diff+''); + } + } + if (sum<0) { + $('#view-home #mybalances #total-value').html(''+sum.toFixed(2)+' €'); + } + else { + $('#view-home #mybalances #total-value').html(''+(sum==0?'':'+')+sum.toFixed(2)+' €'); + } + $('#view-home #mybalances').css('display','block'); + } + else { + $('#view-home #mybalances').css('display','none'); + } + view_part('#view-home'); +} + /**************** * View group ****************/ @@ -75,7 +126,7 @@ view_group=function(group) { $('#view-group #group_name')[0].value=group.name; set_contributors(group); on_contributor_change(); - $('#view-group').css('display','block'); + view_part('#view-group'); } set_contributors=function(group) { @@ -535,4 +586,5 @@ $( document ).ready( function() { $("#display_balance_btn").bind('click',on_display_balance_btn_click); $('#remove_group_btn').bind('click',on_remove_group_btn_click); + view_home(); } ); diff --git a/index.html b/index.html index da777ef..f485f6c 100644 --- a/index.html +++ b/index.html @@ -37,11 +37,15 @@ body{ font-weight: bold; } -.late { +.positive { + color: green; +} + +.negative { color: red; } -.hidden-part { +.part { display: none; } @@ -84,7 +88,26 @@ body{
-
+
+

+ + + + + + + + + + + + + + +
GroupeBalance
Total :
+
+ +

Noël