SHOW:
|
|
- or go back to the newest paste.
1 | var currencies = { | |
2 | "EUR": ["€", "EUR", "EURO", "EUROS"], | |
3 | "USD": ["$", "USD", "USDOLLAR", "USDOLLARS"], | |
4 | "DEM": ["DM", "Deutsche Mark"] | |
5 | }; | |
6 | var rates = { | |
7 | "EUR": { USD: 1.2613 }, | |
8 | "USD": { EUR: 0.792832792 }, | |
9 | "DEM": { DEM: 2.466888379 } | |
10 | }; | |
11 | Knotenliste=document.selectNodes('//div'); | |
12 | for (var Zaehler=Knotenliste.length-1; Zaehler>=0; Zaehler--) | |
13 | { | |
14 | var inhalt = Knotenliste[Zaehler].innerHTML; | |
15 | inhalt = replaceCurrencies(inhalt, "DEM"); | |
16 | - | if(Knotenliste[Zaehler].innerHTML.indexOf("€") != -1) |
16 | + | if(inhalt.indexOf("€") != -1) |
17 | { | |
18 | - | //alert(inhalt); |
18 | + | alert("Still there"); |
19 | } | |
20 | Knotenliste[Zaehler].innerHTML = inhalt; | |
21 | } | |
22 | ||
23 | ||
24 | function replaceCurrencies(text, targetCurrency, currencyFormatIndex, currencySeparator) { | |
25 | var regex = /(\d+)\s*(€|EURO?S?)/gi; | |
26 | return text.replace(regex, function(m, number, currency) { | |
27 | var c, i; | |
28 | for (c in currencies) { | |
29 | if (currencies.hasOwnProperty(c)) { | |
30 | for (i = 0; i < currencies[c].length; i++) { | |
31 | if (currencies[c][i] === currency) { | |
32 | return [Math.round(rates[c][targetCurrency] * number, 2), currencies[targetCurrency][currencyFormatIndex || 0]].join(currencySeparator || ""); | |
33 | } | |
34 | } | |
35 | } | |
36 | } | |
37 | return m; | |
38 | }); | |
39 | } |