[ Launch: just mine p5 ] 4969799 by roundrobin
[ Launch: just mine p5 ] 4966869 by zeffii
[ Launch: just mine p3 ] 4960296 by zeffii
[ Launch: just mine p2 ] 4959904 by zeffii
[ Launch: just mine ] 4959669 by zeffii
[ Launch: crossfilter racetrack ] 4956157 by zeffii
[ Launch: crossfilter racetrack ] 4624910 by zeffii
[ Launch: Another Inlet ] 4618198 by enjalot
-
-
Save roundrobin/4969799 to your computer and use it in GitHub Desktop.
just mine p5
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
{"description":"just mine p5","endpoint":"","display":"svg","public":true,"require":[{"name":"crossfilter","url":"https://raw.github.com/square/crossfilter/master/crossfilter.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"cars.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"conf.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"tab":"edit","display_percent":0.46399999999999975,"thumbnail":"http://i.imgur.com/pSTfcab.png"} |
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
// maybe extend to user search box, | |
tributary.trace = true; | |
d3.select("body").style("background-color", rgb(40,40,40)) | |
var trib_url = 'http://tributary.io/', | |
users_url = trib_url + 'api/users', | |
created_url = trib_url + 'api/latest/created', | |
trib_inlet = trib_url + 'inlet/'; | |
// standard time info | |
var current_time = new Date().toISOString(), | |
iso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ").parse; | |
// grab the users | |
function getUsers() { | |
d3.json(users_url, function(err, res) { | |
tributary.users = {}; | |
tributary.userList = res; | |
res.forEach(function(u) { | |
tributary.users[u.login] = u; | |
}) | |
}) | |
} | |
if(!tributary.users) { | |
getUsers(); | |
} | |
var svg = d3.select("svg"); | |
var user_inlets = svg.append("g").classed("inlets", true); | |
var solo_group = user_inlets.append("g").classed("solo_group", true); | |
var rect_style = { | |
"fill": "#8FD7FF", | |
"stroke": "#FFFFFF", | |
"stroke-width": 1.37088 + "px" | |
}; | |
var text_style1 = { | |
"fill": "#D8D8D8", | |
"font-size": 0.81254 +"em", | |
"font-face": "sans-serif" | |
}; | |
function draw_content() { | |
// filter inlets by username | |
var username = 'roundrobin'; | |
var single_user_inlets = _.filter(tributary.inlets, function(d){ | |
if (d.user.login === username) return true | |
}); | |
var sg = solo_group.attr("transform", translate(115, 20)) | |
var groups = sg.selectAll("g") | |
.data(single_user_inlets); | |
//groups.exit().remove(); | |
var bp = groups.enter() | |
.append("g") | |
.classed("inlet_", true) | |
.attr({ | |
"transform": function(d, i){ return translate(0, 58+i*27) } | |
}) | |
// for each inlet group make a xlink:href | |
.append("a") | |
.attr({ | |
"xlink:href": function(d){ return trib_inlet + d.gistid }, | |
"xlink:show": "new", | |
"cursor": "pointer" | |
}) | |
// for each inlet group make a rect | |
bp.append("rect") | |
.style(rect_style) | |
.attr({ | |
"height": 20, | |
"width": 20, | |
"id": function(d){ return d.gistid } | |
}) | |
// attach mouse behaviour | |
.each(function(d){ | |
var obj = d3.select(this); | |
obj.on("mouseover", function(d){ | |
obj.style("fill", "#33A9CE") | |
obj.style("stroke-width", 0.8 + "px") | |
}) | |
obj.on("mouseout", function(d){ | |
obj.transition().duration(200).style(rect_style) | |
}) | |
}) | |
// for each inlet group make a text label | |
bp.append("text") | |
.text(function(d){ return d.description.replace(/_/g, " ") }) | |
.classed("inlet_label", true) | |
.style(text_style1) | |
.attr({"x": 28, "y": 16}) | |
// for each inlet group display the time since. | |
bp.append("text") | |
.text(function(d){ return time_since( d.lastSave || d.savedAt ) }) | |
.classed("inlet_time", true) | |
.style(text_style1) | |
.attr({"x": -8, "y": 16, "text-anchor": "end"}) | |
} | |
if(!tributary.inlets) { | |
d3.json(created_url, function(err, res) { | |
tributary.inlets = res; | |
draw_content(); | |
}) | |
} else { | |
draw_content(); | |
} | |
function time_since(posit_time){ | |
var tdelta = iso(current_time) - iso(posit_time) | |
var retval; | |
var _second = 1000, | |
_minute = _second *60, | |
_hour = _minute * 60, | |
_day = _hour * 24, | |
_week = _day * 7, | |
_month = _week * 4, | |
_year = _month * 12; | |
function mf(td){ return d3.round(td,1)} | |
if (tdelta <= _minute) retval = mf(tdelta/_second) + " second(s)" | |
else if (tdelta <= _hour) retval = mf(tdelta/_minute) + " minute(s)" | |
else if (tdelta <= _day) retval = mf(tdelta/_hour) + " hour(s)" | |
else if (tdelta <= _week) retval = mf(tdelta/_day) + " day(s)" | |
else if (tdelta <= _month) retval = mf(tdelta/_week) + " week(s)" | |
else if (tdelta <= _year) retval = mf(tdelta/_month) + " week(s)" | |
else retval = "pretty old" | |
return retval | |
} | |
draw_content(); | |
// ----------- helper functions ---------------- | |
function translate(value_x, value_y){ | |
return "translate(" + [value_x, value_y] + ")" | |
} | |
function rgb(r, g ,b) { | |
return "rgb(" + [r,g,b] + ")" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment