1 if(!dojo._hasResource["dojox.dtl.filter.misc"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.dtl.filter.misc"] = true;
3 dojo.provide("dojox.dtl.filter.misc");
5 dojo.mixin(dojox.dtl.filter.misc, {
6 filesizeformat: function(value){
7 // summary: Format the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB, 102bytes, etc).
8 value = parseFloat(value);
10 return (value == 1) ? value + " byte" : value + " bytes";
11 }else if(value < 1024 * 1024){
12 return (value / 1024).toFixed(1) + " KB";
13 }else if(value < 1024 * 1024 * 1024){
14 return (value / 1024 / 1024).toFixed(1) + " MB";
16 return (value / 1024 / 1024 / 1024).toFixed(1) + " GB";
18 pluralize: function(value, arg){
20 // Returns a plural suffix if the value is not 1, for '1 vote' vs. '2 votes'
22 // By default, 's' is used as a suffix; if an argument is provided, that string
23 // is used instead. If the provided argument contains a comma, the text before
24 // the comma is used for the singular case.
26 if(arg.indexOf(",") == -1){
29 var parts = arg.split(",");
33 var singular = parts[0];
34 var plural = parts[1];
36 if(parseInt(value) != 1){
41 _phone2numeric: { a: 2, b: 2, c: 2, d: 3, e: 3, f: 3, g: 4, h: 4, i: 4, j: 5, k: 5, l: 5, m: 6, n: 6, o: 6, p: 7, r: 7, s: 7, t: 8, u: 8, v: 8, w: 9, x: 9, y: 9 },
42 phone2numeric: function(value){
43 // summary: Takes a phone number and converts it in to its numerical equivalent
44 var dm = dojox.dtl.filter.misc;
47 for(var i = 0; i < value.length; i++){
48 var chr = value.charAt(i).toLowerCase();
49 (dm._phone2numeric[chr]) ? output += dm._phone2numeric[chr] : output += value.charAt(i);
53 pprint: function(value){
54 // summary: A wrapper around toJson unless something better comes along
55 return dojo.toJson(value);