-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
638 lines (566 loc) · 22.5 KB
/
Copy pathindex.html
File metadata and controls
638 lines (566 loc) · 22.5 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<meta name="application-name" content="JS Number To Word Processor" />
<meta name="theme-color" content="#4285f4" />
<meta
name="description"
content="The Goal Of JSnumberToWordProcessor Is A Well Formatted Human Readable Number, With It's Corresponding Words."
/>
<meta name="robots" content="index,follow" />
<meta name="generator" content="program" />
<meta
name="subject"
content="Process Numbers In To Human Readable Numbers And Words"
/>
<meta name="rating" content="General" />
<meta property="og:site_name" content="sidodus" />
<meta property="og:title" content="Saheed Odulaja" />
<meta property="og:url" content="https://github.com/Sidodus/" />
<meta
property="og:description"
content="The Goal Of JSnumberToWordProcessor Is A Well Formatted Human Readable Number, With It's Corresponding Words."
/>
<meta name="twitter:card" content="Saheed Odulaja" />
<meta name="twitter:site" content="@SaheedOdulaja" />
<meta name="twitter:creator" content="@SaheedOdulaja" />
<meta name="twitter:title" content="Saheed Odulaja" />
<meta
name="twitter:description"
content="The Goal Of JSnumberToWordProcessor Is A Well Formatted Human Readable Number, With It's Corresponding Words."
/>
<link rel="me" href="https://github.com/Sidodus/" type="text/html" />
<link rel="me" href="https://www.npmjs.com/~sidodus/" type="text/html" />
<link rel="me" href="https://twitter.com/SaheedOdulaja" type="text/html" />
<link rel="me" href="https://facebook.com/sidodus" type="text/html" />
<link
rel="me"
href="https://www.linkedin.com/in/saheed-odulaja-75111337"
type="text/html"
/>
<link type="text/css" rel="stylesheet" href="bootstrap.min.css" />
<link
type="text/css"
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
/>
<link rel="icon" href="./SidoByMe.PNG" />
<title>JSnumberToWordProcessor</title>
</head>
<style>
.BoxShadow {
width: 100%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2),
0 6px 20px 0 rgba(0, 0, 0, 0.19);
padding: 15px 25px 15px 55px;
}
.BoxShadow0 {
width: 100%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
/* 0 6px 20px 0 rgba(0, 0, 0, 0.19); */
/* padding: 15px 25px 15px 55px; */
}
.BoxShadowHover:hover {
cursor: pointer;
transform: scale(1.03);
transition: transform 0.2s cubic-bezier(0.25, 0.45, 0.45, 0.95);
}
.BoxShadowFooter {
width: 100%;
box-shadow: 0 4px 8px 0 rgb(46, 46, 46), 0 6px 20px 0 rgb(100, 100, 100);
padding: 15px 25px 15px 55px;
}
.BoxShadowFooterHover:hover {
cursor: pointer;
transform: scale(1.5);
transition: transform 0.5s cubic-bezier(0.25, 0.45, 0.45, 0.95);
}
.tooltip {
background-color: rgb(54, 53, 53);
color: white;
position: absolute;
left: 55%;
z-index: 1;
padding: 7px;
border: 1px solid white;
border-radius: 15px;
opacity: 1;
text-align: center;
font-weight: bold;
transform: translateY(-8%);
}
</style>
<body class="container-fluid bg-light">
<div
class="row BoxShadow0 mx-auto"
style="
background-color: rgb(247, 240, 240);
color: gray;
padding: 15px 15px 5px 15px;
text-align: center;
font-size: 18px;
font-weight: bold;
"
>
<div style="font-style: italic" class="BoxShadow mb-2">
JS Number To Word Processor <small>v3.0.4</small> <br />
Is A JavaScript Plugin That Can Process Standard Dictionary Numbers Up
To (<span id="Decillinillion" style="color: rgb(231, 167, 48)"
>10<sup>33003</sup></span
>),
<div
style="width: 10%; display: none"
id="Decillinillion-title"
class="tooltip"
>
Decillinillion
</div>
Into Human Readable Numbers & Words <br />
Based On
<a
href="https://www.mrob.com/pub/math/largenum.html"
target="_blank"
class="text-info"
style="font-style: italic"
>Conway-Wechsler Numbering System</a
>
<hr class="row col-sm-6 ml-auto" />
<hr class="row col-sm-6" />
</div>
<form
id="formDecimalPoint"
class="mx-auto"
style="margin-top: -7px; margin-bottom: -16px"
>
<p>
<small
><b>Change Decimal Length (default is 2 decimal place)</b></small
>
</p>
<div class="input-group input-group-sm mb-3" style="margin-top: -18px">
<div class="input-group-append">
<span id="decimalPointValue" class="input-group-text"></span>
</div>
<input
id="decimalPlaceInput"
type="number"
class="form-control"
placeholder="Decimal Place"
/>
<div class="input-group-append">
<button
id="changeDecimalPointBTN"
class="btn btn-info"
type="submit"
>
Change...
</button>
</div>
</div>
<div
id="changeDecimalPointBTN-title"
style="width: 29%; display: none"
class="tooltip"
>
Number Would Only Be Called On Decimal Numbers. <br />If Number Is
Greater Than The Decimal Point Length, <br />
OR <br />
Number Falls Outside (Range Numbering) Limit, <br />
The Default 2 Decimal Point Would Be Used.
</div>
</form>
</div>
<br />
<div class="row">
<div class="col-sm-6">
<form>
<div class="form-group">
<label for="num-input" style="font-weight: bold; font-style: italic"
>Input A Number</label
>
<div>
<small
id="notify"
style="color: red; font-weight: bolder"
></small>
</div>
<input
type="number"
id="num-input"
style="height: 86px; background-color: lightgray"
class="form-control"
step="any"
placeholder="Enter A Number eg. 9, -98, 98.7, -98.765 etc."
/>
<br />
<button
type="button"
id="num-button"
class="btn btn-info form-control"
>
Process A Number ✨
</button>
</div>
</form>
</div>
<div class="col-sm-6">
<label for="num-input-arr" style="font-weight: bold; font-style: italic"
>Input An Array Of Numbers</label
>
<div>
<small
id="notify_arr"
style="color: red; font-weight: bolder"
></small>
</div>
<textarea
id="num-input-arr"
class="form-control"
rows="3"
style="background-color: lightgray"
placeholder="INPUT NUMBERS SEPARATED BY A COMMA eg. 1, -12, 12.3, -12.345 etc.
Note: All Non-Numbers Would Be Discarded Before Processing..."
></textarea>
<br />
<button
type="button"
id="num-button-arr"
class="btn btn-info form-control"
>
Process An Array Of Numbers 💥
</button>
</div>
</div>
<br /><br />
<div class="row">
<div class="col-sm-12">
<h6 id="note"></h6>
<ul
id="ul"
style="
font-weight: bold;
font-size: 1.3em;
font-style: oblique;
display: none;
"
class="BoxShadow"
></ul>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<small style="font-style: italic">
<footer
style="
color: rgb(75, 74, 74);
text-align: center;
margin-top: 58px;
padding: 5px 0;
background-color: rgb(193, 201, 202);
"
class="BoxShadowFooter mb-2"
>
<div class="BoxShadowFooterHover">
Install From
<a
href="https://www.npmjs.com/package/js-number-to-word-processor"
target="_blank"
>NPM</a
>
</div>
<div class="BoxShadowFooterHover">
Get Source Code From
<a
href="https://github.com/Sidodus/JavaScript-Number-To-Word-Processor"
target="_blank"
>GitHub</a
>
</div>
<div class="BoxShadowFooterHover">
Live Site: @
<a
href="https://sidodus.github.io/JavaScript-Number-To-Word-Processor/"
target="_blank"
>JSnumberToWordProcessor</a
>
</div>
<div class="BoxShadowFooterHover">
<a
href="https://sidodus.github.io/Sidodus-proforma-invoice-calculator/"
target="_blank"
>Proforma Invoice Calculator</a
>
Is Another Application Using #JSnumberToWordProcessor
<a
href="https://github.com/Sidodus/Sidodus-proforma-invoice-calculator/"
target="_blank"
>
Plugin / Code</a
>
</div>
<br />
Copyright (c) <span id="copyRightYear"></span>
<a
href="https://www.linkedin.com/in/saheed-odulaja-75111337"
target="_blank"
>
Saheed Odulaja
</a>
</footer>
</small>
</div>
</div>
<script src="curStrLengthFunc_2.min.js"></script>
<script src="JSnumberToWordProcessor.js"></script>
<script>
// (((((((((((((((((((((((((((((((((((((((((((((( Init START ))))))))))))))))))))))))))))))))))))))))))))))
// Set Footer Year
const thisYear = new Date("2019").getFullYear();
let presentYear = new Date().getFullYear();
let fullYear;
thisYear === presentYear
? (fullYear = thisYear)
: thisYear < presentYear
? (fullYear = thisYear + "-" + presentYear)
: null;
document.getElementById("copyRightYear").textContent = fullYear;
/* Create decimalPlaceLength If It Doesn't Exist In SS & Put The Value In decimalPointValue
** Else Just Pull the Value From decimalPlaceLength Into decimalPointValue */
let numInput;
let numSplit;
let newNumInput;
let process;
let li;
sessionStorage.getItem("decimalPlaceLength") === null
? (sessionStorage.setItem("decimalPlaceLength", "2"),
(document.getElementById(
"decimalPointValue"
).innerHTML = `<b> ${sessionStorage.getItem(
"decimalPlaceLength"
)} </b>`))
: (document.getElementById(
"decimalPointValue"
).innerHTML = `<b>${sessionStorage.getItem(
"decimalPlaceLength"
)}</b>`);
// Pull display2Document To Document If Available In SS
let previousSession = JSON.parse(
sessionStorage.getItem("display2Document")
);
let isPreviousSessionArr = JSON.parse(sessionStorage.getItem("arrOfNum"));
previousSession
? display2Document(previousSession, isPreviousSessionArr)
: null;
// (((((((((((((((((((((((((((((((((((((((((((((( Init END ))))))))))))))))))))))))))))))))))))))))))))))
// ****************************************** TOOLTIP START **************************************************
document
.querySelector("#Decillinillion")
.addEventListener("mouseover", function () {
document.querySelector("#Decillinillion-title").style.display =
"block";
});
document
.querySelector("#Decillinillion")
.addEventListener("mouseout", function () {
document.querySelector("#Decillinillion-title").style.display =
"none";
});
document
.querySelector("#changeDecimalPointBTN")
.addEventListener("mouseover", function () {
document.querySelector("#changeDecimalPointBTN-title").style.display =
"block";
});
document
.querySelector("#changeDecimalPointBTN")
.addEventListener("mouseout", function () {
document.querySelector("#changeDecimalPointBTN-title").style.display =
"none";
});
// ****************************************** TOOLTIP END **************************************************
// ++++++++++++++++++++++++++++++ START MANAGE NUMBER / WORD STYLES +++++++++++++++++++++++++++
function manageNumWordStyle(processed) {
let negativeIntSign;
let decimalPointWord;
let negativeIntWord;
let unit;
if (processed.negativeInt === true) {
negativeIntSign = `<span style="color: red">-</span>`;
negativeIntWord = `<span style="color: tomato">(negative) </span>`;
} else {
negativeIntSign = "";
negativeIntWord = "";
}
if (
processed.decimalPoint === true &&
processed.displayDecimalNum !== ".00"
) {
decimalPointWord = `<span style="color: tomato"> (dot) </span>`;
unit = `<span style="color: gray"> ${processed.decimalPlaceWord}</span>`;
} else {
decimalPointWord = "";
unit = "";
}
let numOutput = `${negativeIntSign}${processed.displayWholeNum}<small><b>${processed.displayDecimalNum}</b></small>`;
let wordOutput = `${negativeIntWord}${processed.displayWholeWord}${decimalPointWord}${processed.displayDecimalWord}${unit}`;
let numMaxErrorOutput = `${negativeIntSign}${processed.displayWholeNum}${processed.displayDecimalNum}`;
return {
numOutput,
wordOutput,
numMaxErrorOutput,
};
}
// ++++++++++++++++++++++++++++++ END MANAGE NUMBER / WORD STYLES +++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++ DISPLAY TO DOCUMENT +++++++++++++++++++++++++++
function display2Document(process, description) {
let hr;
description
? ((description =
"This Is An Array Of Number(s) Converted To Word Using JSnumberToWordProcessor"),
(hr = "<hr />"))
: ((description =
"This Is A Number Converted To Word Using JSnumberToWordProcessor"),
(hr = ""));
// Split The Variable Array
process.forEach(function (processed) {
let processStyle = manageNumWordStyle(processed);
let note = `<div style="color: gray; text-align: center; font-size: 18px">${description}</div><hr />`;
let li = `<div class="BoxShadow BoxShadowHover"><li class="li"><span style="color: gray">${processStyle.numOutput} </span><span style="color: blue">:-</span> ${processStyle.wordOutput}. </li></div>${hr}`;
let liMaxError = `<div class='BoxShadow BoxShadowHover'><li class="li"><span style="color: gray">${processStyle.numMaxErrorOutput}</span><span style="color: blue">:-</span><span style="color: red"> ${processed.displayWholeWord}. </span> </li></div>${hr}`;
document.getElementById("note").innerHTML = note;
document.getElementById("ul").style.display = "block";
// Display Word As Red Id decimal Number Is Exceeded
processed.displayWord.includes("SORRY")
? (document.getElementById("ul").innerHTML += liMaxError)
: (document.getElementById("ul").innerHTML += li);
});
}
// ++++++++++++++++++++++++++++++ END DISPLAY TO DOCUMENT +++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++ NOTYFY +++++++++++++++++++++++++++
// Manage Notification On Input Keypress
document
.querySelector("#num-input")
.addEventListener("keypress", function () {
document.querySelector("#num-input").value.length === 0
? ((document.getElementById("notify").innerText =
"Number-Length Greater Than 308 Should Be Handled In The 2nd Box"),
(document.getElementById("notify_arr").innerText = ""))
: ((document.getElementById("notify").innerText = ""),
(document.getElementById("notify_arr").innerText = ""));
});
document
.querySelector("#num-input-arr")
.addEventListener("keypress", function () {
document.querySelector("#notify").innerText !== ""
? ((document.getElementById("notify").innerText = ""),
(document.getElementById("notify_arr").innerText = ""))
: (document.getElementById("notify_arr").innerText = "");
});
// ++++++++++++++++++++++++++++++++++++++++ END NOTIFY +++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++ EVENTS +++++++++++++++++++++++++++
// Event Listener For Decimal Place BTN
document
.getElementById("changeDecimalPointBTN")
.addEventListener("click", function (e) {
e.preventDefault();
let decimalPlaceInputValue = document.getElementById(
"decimalPlaceInput"
).value;
decimalPlaceInputValue === ""
? (decimalPlaceInputValue = document.getElementById(
"decimalPointValue"
).innerText)
: (document.getElementById(
"decimalPointValue"
).innerHTML = `<b>${decimalPlaceInputValue}</b>`),
(document.getElementById("decimalPlaceInput").value = "");
sessionStorage.setItem("decimalPlaceLength", decimalPlaceInputValue);
});
// Event Listener For Single Number Input
document
.querySelector("#num-button")
.addEventListener("click", function () {
// Manage Notification On BTN Click
document.querySelector("#num-input").value.length === 0
? (document.getElementById("notify").innerText =
"Number-Length Greater Than 308 Should Be Handled In The 2nd Box")
: (document.getElementById("notify").innerHTML = "");
if (document.querySelector("#num-input").value !== "") {
// Clear ul
document.getElementById("ul").innerHTML = "";
// Put User Input Value Into A Variable As A String
numInput = document.querySelector("#num-input").value;
// Remove Numbers With Letters But Retain "0"
if (Number(numInput) || Number(numInput) === 0) {
// Maintain Perfect Number By removing Any Starting "0s"
// Clear Input
document.querySelector("#num-input").value = "";
document.querySelector("#num-input-arr").value = "";
// Manage Decimal Place
let toDecimalPlace = Number(
document.getElementById("decimalPointValue").innerText
);
process = JSnumberToWordProcessor(numInput, toDecimalPlace);
// Display Output To Document
display2Document(process, false);
// Save To SS
sessionStorage.setItem(
"display2Document",
JSON.stringify(process)
);
sessionStorage.setItem("arrOfNum", JSON.stringify(false));
}
}
});
// Event Listener For Array Input
document
.querySelector("#num-button-arr")
.addEventListener("click", function () {
// Manage Notification On BTN Click
document.getElementById("notify").innerHTML = "";
document.getElementById("notify_arr").innerText = "";
if (document.querySelector("#num-input-arr").value !== "") {
// Clear ul
document.getElementById("ul").innerHTML = "";
numInput = document.querySelector("#num-input-arr").value;
// Clear Input
document.querySelector("#num-input-arr").value = "";
document.querySelector("#num-input").value = "";
// Split Input by (',')
numSplit = numInput.split(",");
newNumInputStr = [];
newNumInput = [];
// Separate Spliced Input Array And Push A New Number Array To NewNumInput
numSplit.forEach(function (splitedNum) {
// Remove Negative Numbers & Fractions From The New Array
// Remove Numbers With Letters But Retain "0"
if (Number(splitedNum) || Number(splitedNum) === 0) {
// Maintain Perfect Number By removing Any Starting "0s"
newNumInputStr.push(splitedNum);
}
});
// Convert Number String To BigInt. This Is To Handle (+) eg. +234,345 etc If Not They Would Be Rejected
// Now Convert The Whole Numbers Back To Strings
newNumInputStr.forEach(function (value) {
newNumInput.push(value);
});
// Manage Decimal Place
let toDecimalPlace = Number(
document.getElementById("decimalPointValue").innerText
);
// Input The Details Of Number To Word Processor Into A Variable
process = JSnumberToWordProcessor(newNumInput, toDecimalPlace);
// Display Output To Document
display2Document(process, true);
// Save To SS
sessionStorage.setItem("display2Document", JSON.stringify(process));
sessionStorage.setItem("arrOfNum", JSON.stringify(true));
}
});
// ++++++++++++++++++++++++++++++++++++++++ END EVENTS +++++++++++++++++++++++++++
</script>
</body>
</html>