Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var currencies = {
- "EUR": ["€", "EUR", "EURO", "EUROS"],
- "USD": ["$", "USD", "USDOLLAR", "USDOLLARS"],
- "DEM": ["DM", "Deutsche Mark"]
- };
- var rates = {
- "EUR": { USD: 1.2613 },
- "USD": { EUR: 0.792832792 },
- "DEM": { DEM: 2.466888379 }
- };
- Knotenliste=document.selectNodes('//div');
- for (var Zaehler=Knotenliste.length-1; Zaehler>=0; Zaehler--)
- {
- var inhalt = Knotenliste[Zaehler].innerHTML;
- inhalt = replaceCurrencies(inhalt, "DEM");
- if(inhalt.indexOf("€") != -1)
- {
- alert("Still there");
- }
- Knotenliste[Zaehler].innerHTML = inhalt;
- }
- function replaceCurrencies(text, targetCurrency, currencyFormatIndex, currencySeparator) {
- var regex = /(\d+)\s*(€|EURO?S?)/gi;
- return text.replace(regex, function(m, number, currency) {
- var c, i;
- for (c in currencies) {
- if (currencies.hasOwnProperty(c)) {
- for (i = 0; i < currencies[c].length; i++) {
- if (currencies[c][i] === currency) {
- return [Math.round(rates[c][targetCurrency] * number, 2), currencies[targetCurrency][currencyFormatIndex || 0]].join(currencySeparator || "");
- }
- }
- }
- }
- return m;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement