個人用
by
amachang
2010-10-14 [2010/10/14 22:20:27]
個人用
@@ -51,4 +51,4 @@
labelList.push('other ' + otherCount / totalCount * 100 + '%');
dataList.push(otherCount / totalCount);
-location.href = 'http://chart.apis.google.com/chart?cht=p3&chd=t:' + dataList.join(',') + '&chs=800x300&chl=' + labeleList.join('|')
+location.href = 'http://chart.apis.google.com/chart?cht=p3&chd=t:' + dataList.join(',') + '&chs=800x300&chl=' + labelList.join('|')
/*
* @title クリック数をグラフで見る
* @description クリック数をグラフで見る
* @include http://*
* @license MIT License
* @require
*/
var parentEl = document.getElementById('bookmarked_user');
var nodes = parentEl.childNodes;
var ElementInfo = function(el, count, username) {
this.el = el;
this.count = count;
this.username = username;
};
var totalCount = 0;
var elList = [];
for (var i = 0, l = nodes.length; i < l; i++) {
var el = nodes[i];
if (el.nodeType === 1) {
var usernameEl = Ten.DOM.getElementsByClassName('username', el)[0];
var countEl = Ten.DOM.getElementsByClassName('click-count', el)[0];
if (countEl) {
var username = usernameEl.innerText || usernameEl.textContent;
var count = countEl.innerText || countEl.textContent;
var m = count.match(/\d+/);
count = +m[0];
elList.push(new ElementInfo(el, count, username));
totalCount += count;
}
}
}
elList = elList.sort(function(a, b) { return a.count - b.count });
var otherCount = 0;
var labelList = [];
var dataList = [];
for (var i = 0; i < elList.length; i++) {
if (elList[i].count / totalCount < 0.1) {
otherCount += elList[i].count;
}
else {
labelList.push(elList[i].username + ' ' + elList[i].count / totalCount * 100 + '%');
dataList.push(elList[i].count / totalCount);
}
}
labelList.push('other ' + otherCount / totalCount * 100 + '%');
dataList.push(otherCount / totalCount);
location.href = 'http://chart.apis.google.com/chart?cht=p3&chd=t:' + dataList.join(',') + '&chs=800x300&chl=' + labelList.join('|')
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。