-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
145 lines (142 loc) · 3.84 KB
/
index.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<title>numericText Example</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="build/numericText.min.js"></script>
</head>
<body>
<h2>Static Examples</h2>
<table border="1">
<thead>
<tr>
<th>Type</th>
<th>Input</th>
<th>Output</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>Input</td>
<td><input type="text" name="sample" value="79234856789"/></td>
<td><input type="text" class="input" name="sample" value="79234856789"/></td>
<td>works on input</td>
</tr>
<tr>
<td>Span</td>
<td><span>123456789</span></td>
<td><span class="span">123456789</span></td>
<td>works on span</td>
</tr>
<tr>
<td>Label</td>
<td><label>123456</label></td>
<td><label class="label">123456</label></td>
<td>works on label</td>
</tr>
<tr>
<td>Div</td>
<td>
<div>53245</div>
</td>
<td>
<div class="div">53245</div>
</td>
<td>works on div</td>
</tr>
</tbody>
<table>
<hr/>
<h2>Dynamic Example</h2>
<p>Input any number in text box and tab out to see the changed format.</p>
Type : <select id="type">
<option value="indian">Indian</option>
<option value="international">International</option>
</select>
Name : <select id="name">
<option value="s">Short Name</option>
<option value="f">Full Name</option>
</select>
Minimum digits : <select id="minimum">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
Decimal digits : <select id="decimal">
<option value="0">0</option>
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
Number : <input id="num" type="number"/><label id="numInText"></label>
<hr/>
<div>
<h2>numericText</h2>
<p>Converts Number to Textual value.</p>
<h3>Examples :</h3>
<ul>
<li>100000 -> 1.00 Lakh (Indian) or 100.00 Thousand (International)</li>
<li>3453232 -> 34.53 Lakh (Indian) or 3.45 Million (International)</li>
</ul>
<h3>Options :</h3>
<table border="1">
<thead>
<tr>
<th>Option</th>
<th>Default</th>
<th>Possible values</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td>'indian'</td>
<td>'indian', 'international'</td>
<td>Type of texual currency.</td>
</tr>
<tr>
<td>shortHand</td>
<td>true</td>
<td>true, false</td>
<td>Whether full currency text is required or short form.</td>
</tr>
<tr>
<td>minimum</td>
<td>2</td>
<td>Integer value greater than 2</td>
<td>Minimum number of digits after which number should be converted to text.</td>
</tr>
<tr>
<td>decimal</td>
<td>2</td>
<td>Integer value (>=0)</td>
<td>Number of digits after decimal point.</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
$(function(){
//pulggin supports global settings
$.fn.numericText.defaults.type="indian";
//can be applied on various element types
$(".input, .span, .label, .div").numericText();
//can have custom settings, options
$("#num, #type, #name, #minimum, #decimal").change(function(){
$("#numInText").text($("#num").val()).numericText({
type : $("#type").val(),
shortHand:$("#name").val()==="s",
minimum:parseInt($("#minimum").val()),
decimal:parseInt($("#decimal").val())
});
});
});
</script>
</body>
</html>