Skip to content

Instantly share code, notes, and snippets.

@jefffriesen
Created October 31, 2013 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jefffriesen/7251608 to your computer and use it in GitHub Desktop.
Save jefffriesen/7251608 to your computer and use it in GitHub Desktop.
Strange code example
{"description":"Strange code example","endpoint":"","display":"div","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/xQXa82Y.png"}
function SimpleWidget(spec) {
var instance = {};
var headline, description;
instance.render = function() {
var div = d3.select('#display').append("div");
div.append("h3").text(headline);
div.attr("class", "box")
.attr("style", "color:" + spec.color)
.append('p')
.text(description);
return instance;
};
instance.headline = function(h) {
if (!arguments.length) h;
headline = h;
return instance;
};
instance.description = function(d) {
if (!arguments.length) d;
description = d;
return instance;
};
return instance;
}
var widget = SimpleWidget({color: "#ED64DD"})
.headline("SimpleWidget")
.description("This is a simplee widget demo'ing functional JS.");
widget.render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment