Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Navigate up and down the URL tree

Known bugs:
- When you bottom out, you start over. Inception!
- Sites that use hashtags *cough*Twitter*cough* only have a root
  • Loading branch information...
commit f81999df4c6f77c1dc78bfa8847ca937b2eaea9b 1 parent 078dfba
@kristjan authored
Showing with 23 additions and 9 deletions.
  1. +2 −1  index.html
  2. +21 −8 js/histomine.js
View
3  index.html
@@ -10,7 +10,8 @@
</head>
<body>
- <canvas id="cloud" width=800 height=600></canvas>
+ <a href='#' id="up">Up</a>
+ <canvas id="cloud" width=600 height=400></canvas>
<div id="urls">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
View
29 js/histomine.js
@@ -2,9 +2,17 @@ HistoMine = (function() {
var BATCH_SIZE = 500;
var FETCH_URL = '/push/chromehistory-history/getCurrent';
var urls = {};
+ var stack = [];
function init() {
$.getJSON(FETCH_URL, {limit: BATCH_SIZE}, addBatch);
+ $('#up').click(up);
+ }
+
+ function up(evt) {
+ evt.preventDefault();
+ var item = stack.pop();
+ if (item) draw(item);
}
function addBatch(history) {
@@ -34,7 +42,8 @@ HistoMine = (function() {
tree[first] = {
name: first,
count: 1,
- tree: {}
+ tree: {},
+ parent: tree
};
} else {
tree[first].count++;
@@ -43,29 +52,33 @@ HistoMine = (function() {
addPieces(tree[first].tree, rest);
}
- var MIN_FONT = 10;
- var MAX_FONT = 80;
+ var MIN_FONT = 16;
+ var MAX_FONT = 60;
var FONT_RANGE = MAX_FONT - MIN_FONT;
function draw(tree) {
var range = countRange(urls);
var min = range[0];
var max = range[1];
range = max - min;
- var list = $('#urls');
+ var list = $('#urls').html('');
$.each(tree, function(i, node) {
var percent = (node.count - min) / range;
var size = MIN_FONT + Math.floor(FONT_RANGE * percent);
list.append(
- $('<a>', {
- href: '#'
- }).
+ $('<a>').
attr('data-size', size).
- text(node.name)
+ text(node.name).
+ click(function(evt) {
+ evt.preventDefault();
+ stack.push(tree);
+ draw(node.tree);
+ })
);
});
$('#cloud').tagcanvas({
frontSelect: true,
reverse: true,
+ textColour: '#666',
weight: true,
weightFrom: 'data-size'
}, 'urls');
Please sign in to comment.
Something went wrong with that request. Please try again.