Widget:PledgeTracker: Difference between revisions
Jump to navigation
Jump to search
trying to fix rounding errors... |
|||
(11 intermediate revisions by one other user not shown) | |||
Line 39: | Line 39: | ||
{{#widget:PledgeTracker|pledgeGoal=100}} | {{#widget:PledgeTracker|pledgeGoal=100}} | ||
[[Category:Widget]] | |||
</noinclude> | </noinclude> | ||
<includeonly> | <includeonly> | ||
Line 67: | Line 67: | ||
var pledgePaidCol = cols.eq(<!--{$pledgePaidColumn|validate:int|default:2}-->); | var pledgePaidCol = cols.eq(<!--{$pledgePaidColumn|validate:int|default:2}-->); | ||
var pledgePaidValue = pledgePaidCol.text().trim().toLowerCase(); | var pledgePaidValue = pledgePaidCol.text().trim().toLowerCase(); | ||
amountPledged += pledgeAmountValue; | amountPledged += pledgeAmountValue; | ||
Line 76: | Line 74: | ||
} | } | ||
) | ) | ||
jQuery("<p><b>Pledges Raised:</b> £" + amountPledged + <!--{if $pledgeGoal>0}-->" / £" + pledgeGoalAmount + " (" + ((amountPledged / pledgeGoalAmount) * 100).toFixed(2) + "%)" + <!--{/if}-->"</p>").appendTo('#pledgeTracker<!--{$pledgeTrackerDivId|escape:'html'}-->'); | jQuery("<p><b>Pledges Raised:</b> £" + amountPledged.toFixed(2) + <!--{if $pledgeGoal>0}-->" / £" + pledgeGoalAmount.toFixed(2) + " (" + ((amountPledged / pledgeGoalAmount) * 100).toFixed(2) + "%)" + <!--{/if}-->"</p>").appendTo('#pledgeTracker<!--{$pledgeTrackerDivId|escape:'html'}-->'); | ||
jQuery("<p><b>Pledges Collected:</b> £" + amountCollected + " / £" + amountPledged + " (" + ((amountCollected / amountPledged) * 100).toFixed(2) + "%)</p>").appendTo('#pledgeTracker<!--{$pledgeTrackerDivId|escape:'html'}-->'); | jQuery("<p><b>Pledges Collected:</b> £" + amountCollected.toFixed(2) + " / £" + amountPledged.toFixed(2) + " (" + ((amountCollected / amountPledged) * 100).toFixed(2) + "%)</p>").appendTo('#pledgeTracker<!--{$pledgeTrackerDivId|escape:'html'}-->'); | ||
//}); | //}); | ||
}); | }); |
Latest revision as of 15:59, 29 March 2019
This widget tracks the current amount pledged and collected for a pledge drive on a wiki page which makes use of table with specific columns.
Using this widget
You can insert a pledge tracker with the following wiki code:
{{#widget:PledgeTracker|tableIndex=0|pledgeGoal=100|pledgeAmountColumn=1|pledgePaidColumn=2}}
Parameters
- tableIndex
- The index of the table on the page containing the pledges (0 = the first table). Default:
0
- pledgeGoal
- The goal amount for the pledge drive. Default:
0
- pledgeAmountColumn
- The index of the column within the pledges table which contains the pledge amount (0 = the first column). Default:
1
- pledgePaidColumn
- The index of the column within the table which indicates if the pledge amount has been paid (0 = the first column). If the column contains 'yes' or 'y' (case insensitive) then the pledge amount is considered to have been paid, any other content is considered as not paid. Default:
2
Example
{{#widget:PledgeTracker|pledgeGoal=100}}
Who | Amount | Paid? | Method Paid |
---|---|---|---|
Alice | £30 | Yes | BACS |
Bob | £50 | Yes | CASH |
Carol | £25 | No |