[ Launch: Strange code example ] 7251608 by jefffriesen
-
-
Save jefffriesen/7251608 to your computer and use it in GitHub Desktop.
Strange code example
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":"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"} |
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
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