This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 19th, 2012  |  syntax: JavaScript  |  size: 1.27 KB  |  views: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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(inhalt.indexOf("€") != -1)
  17.         {
  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. }
clone this paste RAW Paste Data