forked from practicalparticipation/IATI-Data-Explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exhibit-helpers.js
42 lines (36 loc) · 974 Bytes
/
exhibit-helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
Helper functions to IATI Exhibit. Compiled by [email protected]; February 2011.
**/
/**
Currency formatting taken from http://www.mail-archive.com/[email protected]/msg03590.html
**/
Exhibit.Formatter._CurrencyFormatter.prototype.formatText =
function(value) {
var number;
if (this._decimalDigits == -1) {
number = value.toString();
}
else {
number = new Number(value).toFixed(this._decimalDigits);
}
number = addCommas(number);
return number;
};
function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
function filterBy(prop, a) {
var value = a.innerHTML;
alert(value);
Exhibit.getComponent("textSearch-facet").applyRestrictions({
selection: [ value ], selectMissing: false});;
}