-
-
Save Teino1978-Corp/6415565da101656f3de0 to your computer and use it in GitHub Desktop.
Cordova 5 / iOS 9 Security Blog - index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = { | |
initialize: function() { | |
document.addEventListener('deviceready', this.updateEuroValue, false); | |
}, | |
updateEuroValue: function() { | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function() { | |
var euroPrice, | |
displayText = '', | |
resultsElement; | |
if (xhr.readyState === XMLHttpRequest.DONE) { | |
if (xhr.status === 200) { | |
euroPrice = JSON.parse(xhr.responseText); | |
displayText = 'US $1 = €' + parseFloat(euroPrice.rates.EUR); | |
} else { | |
displayText = 'Error Connecting to API.' | |
} | |
resultsElement = document.getElementById('results'); | |
resultsElement.innerHTML = displayText; | |
document.getElementById('initializing').setAttribute('style', 'display:none;'); | |
resultsElement.setAttribute('style', 'display:block;'); | |
} | |
}; | |
xhr.open('GET', 'http://api.fixer.io/latest?base=USD&symbols=EUR' , true); | |
xhr.send(); | |
} | |
}; | |
app.initialize(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment