Widget:PledgeTracker: Difference between revisions
Jump to navigation
Jump to search
zero indexed |
we're indexing everything from zero now |
||
Line 9: | Line 9: | ||
=== Parameters === | === Parameters === | ||
;tableIndex | ;tableIndex | ||
:The index of the table on the page containing the pledges ( | :The index of the table on the page containing the pledges (0 = the first table). Default: <code>0</code> | ||
;pledgeGoal | ;pledgeGoal | ||
Line 15: | Line 15: | ||
;pledgeAmountColumn | ;pledgeAmountColumn | ||
:The index of the column within the pledges table which contains the pledge amount ( | :The index of the column within the pledges table which contains the pledge amount (0 = the first column). Default: <code>1</code> | ||
;pledgePaidColumn | ;pledgePaidColumn | ||
:The index of the column within the table which indicates if the pledge amount has been paid (1 = 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: <code> | :The index of the column within the table which indicates if the pledge amount has been paid (1 = 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: <code>2</code> | ||
== Example == | == Example == | ||
Line 49: | Line 49: | ||
var amountPledged = 0; | var amountPledged = 0; | ||
var amountCollected = 0; | var amountCollected = 0; | ||
$('.wikitable:eq(<!--{$tableIndex|validate:int|default:0}--> | $('.wikitable:eq(<!--{$tableIndex|validate:int|default:0}-->) tr:gt(0)').each( | ||
function(index, value) { | function(index, value) { | ||
var cols = $(value).children(); | var cols = $(value).children(); | ||
var pledgeAmountCol = cols.eq(<!--{$pledgeAmountColumn|validate:int|default:2}--> | var pledgeAmountCol = cols.eq(<!--{$pledgeAmountColumn|validate:int|default:2}-->); | ||
var pledgeAmountValue = parseFloat(pledgeAmountCol.text().substring(2)) || 0; | var pledgeAmountValue = parseFloat(pledgeAmountCol.text().substring(2)) || 0; | ||
var pledgePaidCol = cols.eq(<!--{$pledgePaidColumn|validate:int|default:3}--> | var pledgePaidCol = cols.eq(<!--{$pledgePaidColumn|validate:int|default:3}-->); | ||
var pledgePaidValue = pledgePaidCol.text().trim().toLowerCase(); | var pledgePaidValue = pledgePaidCol.text().trim().toLowerCase(); | ||
Revision as of 00:18, 12 June 2014
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=1|pledgeGoal=100|pledgeAmountColumn=2|pledgePaidColumn=3}}
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 (1 = 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
Who | Amount | Paid? | Method Paid |
---|---|---|---|
Bob | £30 | Yes | BACS |
Alice | £50 | Yes | CASH |
Carol | £25 | No | BACS |