Created
October 1, 2012 10:08
-
-
Save mizoR/3810682 to your computer and use it in GitHub Desktop.
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
var targetUsername = 'ccc'; | |
var jsons = $("#downloaded").val().split("\n"); | |
jsons = $.map(jsons, function (json, i) { | |
json = JSON.parse(json); | |
if (json.username === targetUsername) { | |
return {"key": json.username, "count": 1, "like": json.like} | |
} else { | |
return null; | |
} | |
}); | |
(function (values) { | |
var result = {"count": 0, "like": 0}; | |
for (var i in values) { | |
result.count += values[i].count; | |
result.like += values[i].like; | |
} | |
$('#output').val("targetUsername: " + targetUsername + "\ncount: " + result.count + "\nlike:" + result.like); | |
})(jsons); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment