Created
September 20, 2010 07:09
-
-
Save koduki/587523 to your computer and use it in GitHub Desktop.
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 get_items = function(){ | |
var parse_day = function(x){ | |
var xs = x.replace('購入','').replace('日', '').replace('年', '月').split('月').map(function(x) parseInt(x)) | |
return new Date(xs[0], xs[1] - 1, xs[2]) | |
} | |
var parse_value = function(x){ | |
return parseInt(x.replace('円','').replace(',','')) | |
} | |
var xs = $('.itemBlock').map( | |
function(){ | |
return { | |
day:parse_day($(this).find('.day').text()), | |
name:$(this).find('.itemName').text(), | |
value:parse_value($(this).find('.itemDetail dd').eq(0).text()), | |
shop:$(this).find('.itemDetail dd').eq(1).text(), | |
} | |
}) | |
var items = [] | |
for(var i=0;i<xs.size();i++) items.push(xs[i]) | |
return items | |
} | |
Array.prototype.uniq = function(){ | |
var xs = [] | |
this.sort().forEach(function(x){ | |
if(xs[xs.length-1] != x) xs.push(x) | |
}) | |
return xs | |
} | |
var items = get_items(); | |
var values = items.reduce(function(r, x) r + x.value, 0) | |
var shops = items.map(function(x) x.shop).uniq() | |
var days = items.map(function(x) x.day) | |
status = { | |
hp:items.reduce(function(r, x) r + x.value, 0), | |
atk:items.map(function(x) x.value), | |
dex:shop.length, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment