mirror of
https://github.com/benbusby/whoogle-search
synced 2024-11-04 18:00:25 +00:00
7bea6349a0
This implements a method for converting between various currencies. When a user searches "<currency A> to <currency B>" (including when prefixed by a specific amount), they are now presented with a table for quickly converting between the two. This makes use of the currency ratio returned as the first "card" in currency related searches, and the table is inserted into this same card.
10 lines
394 B
JavaScript
10 lines
394 B
JavaScript
const convert = (n1, n2, conversionFactor) => {
|
|
// id's for currency input boxes
|
|
let id1 = "cb" + n1;
|
|
let id2 = "cb" + n2;
|
|
// getting the value of the input box that just got filled
|
|
let inputBox = document.getElementById(id1).value;
|
|
// updating the other input box after conversion
|
|
document.getElementById(id2).value = ((inputBox * conversionFactor).toFixed(2));
|
|
}
|