Created
June 28, 2017 16:11
-
-
Save wate/2f3792fab1071ca7804516164d14282b to your computer and use it in GitHub Desktop.
EC2インスタンス料金月額日本円化(改)
This file contains 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
/* | |
* 元ネタ | |
* | |
* EC2インスタンス料金月額日本円化 | |
* http://qiita.com/yuroyoro/items/08cded7662cf494d53f2 | |
* | |
* YQLを使ってYahoo! Financeから為替レートを取得する | |
* http://qiita.com/masato/items/6f81bdc89f81a7b6cc3a | |
*/ | |
$.getJSON("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22USDJPY%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys", function(yqlResult){ | |
var currentRate = yqlResult.query.results.rate.Rate; | |
$("td.rate").each(function(i,e){ | |
var s=$(e).text(); | |
var v=s.match(/\$([0-9\.]+)/)[1]*24*30*currentRate; | |
$(e).text(s+" | 月額 "+v.toFixed(0).toString().replace(/(\d)(?=(\d{3})+$)/g , '$1,')+"円"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment