MediaWiki:RobuxUSDConverter.js

/* * RobuxUSDConverter * @description Allows users to see the exchange rate between Robux and USD. * For Robux Converter, Robux and Create. * @author Thundermaker300 * * Current DevEx Rate: 0.0035 USD per Robuk * USD to Robux: n / 0.0035 * Robux to USD: n * 0.0035 * * Current Purchase Rate: 0.0125 USD per Robuk * USD to Robux: n / 0.0125 * Robux to USD: n * 0.0125 */

var recentConversion; var rate = 0.0035;

function changeRate(i) { rate = i;   if(recentConversion) recentConversion; }

function validate { var robuxBox = document.getElementById("robuxBox"); var USDBox = document.getElementById('USDBox'); if(robuxBox.value < 0) { document.getElementById('errorMessage').innerHTML = 'Error: Robux value cannot be less than 0.'; return false; }   if(Math.round(robuxBox.value) != robuxBox.value) { document.getElementById('errorMessage').innerHTML = 'Error: Robux value must be a whole number.'; return false; }   if(USDBox.value < 0) { document.getElementById('errorMessage').innerHTML = 'Error: USD value cannot be less than 0.'; return false; }   document.getElementById('errorMessage').innerHTML = ''; return true; }

function convertRobux { var robuxBox = document.getElementById("robuxBox"); var USDBox = document.getElementById('USDBox'); if(validate) { try { USDBox.value = Math.round(parseFloat(robuxBox.value) * rate * 100) / 100; recentConversion = convertRobux; } catch (e) { USDBox.value = "ERROR"; }   } }

function convertUSD { var robuxBox = document.getElementById("robuxBox"); var USDBox = document.getElementById('USDBox'); if(validate) { try { robuxBox.value = Math.round(USDBox.value / rate); recentConversion = convertUSD; } catch (e) { robuxBox.value = "ERROR"; }   } }

var elem = document.getElementById("RobuxUSDConverter"); if(elem !== null) { elem.innerHTML = ' Robux = $ DevEx Rate Purchase Rate '; }