Created
August 20, 2013 14:24
-
-
Save paulbjensen/6282063 to your computer and use it in GitHub Desktop.
The world map and tweet list widgets from the Dashku demo
This file contains hidden or 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
| module.exports = | |
| css: "ul {\n list-style-type: none;\n margin-left: 0px;\n margin-top: 10px;\n}\n\nli {\n padding: 5px;\n background: rgba(255,255,255,0.03);\n margin: 5px;\n border-radius: 5px;\n color:#f1f1f1;\n cursor: pointer;\n}\n\n* content ul {\n overflow: clip; \n}" | |
| height: 608 | |
| html: "<ul id=\"tweets\">\n <li></li>\n</ul>" | |
| json: "{\n \"text\": \"I just finished a 8.02 mi run with Nike+ Running. #nikeplus\",\n \"location\": {\n \"latitude\": \"51\",\n \"longitude\": \"0\"\n },\n \"sentiment\": 1,\n \"tweet_id\": \"24324324234\",\n \"screen_name\": \"jeese\",\n \"_id\": \"4fe772d77c249dc40e0004d7\",\n \"apiKey\": \"c19cabb2-85d6-4be0-b1d6-d85a19b8245e\"\n}" | |
| name: "on Twitter" | |
| script: "// You can use 3rd-party libraries with your widget. For more information, \n// check out the Docs section titled 'Using 3rd-party JS libraries'.\n\n// The widget's html as a jQuery object\nvar widget = this.widget;\n\n// This runs when the widget is loaded\nthis.on('load', function(data){\n tweet = jQuery(widget.find('li')[0]).clone()\n});\n// This runs when the widget receives a transmission\nthis.on('transmission', function(data){\n console.log(data);\n var t = tweet.clone()\n var url = 'http://twitter.com/'+data.screen_name+'/status/'+data.tweet_id\n jQuery(t).text(data.text).attr('url', url)\n jQuery(t).click(function(){\n window.open(jQuery(this).attr('url'),'_blank')\n });\n widget.find(\"ul\").prepend((t).hide().fadeIn());\n if (widget.find('li').length > 8) {\n widget.find(\"li:last\").remove(); \n }\n \n});\n});" | |
| scriptType: "javascript" | |
| width: 200 |
This file contains hidden or 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
| module.exports = | |
| css: "#holder {\n margin-top: 40px; \n}" | |
| height: 501 | |
| html: "<div id=\"holder\"></div>" | |
| json: "{\n \"text\": \"I just finished a 8.02 mi run with Nike+ Running. #nikeplus\",\n \"location\": {\n \"latitude\": \"51\",\n \"longitude\": \"0\"\n },\n \"sentiment\": 1,\n \"tweet_id\": \"24324324234\",\n \"screen_name\": \"jeese\",\n \"_id\": \"4fe772d77c249dc40e0004d7\",\n \"apiKey\": \"c19cabb2-85d6-4be0-b1d6-d85a19b8245e\"\n}" | |
| name: "Global sentiment tracker" | |
| script: "@on 'load', (data) =>\n head.js '/javascripts/raphael/world.js', '/javascripts/raphael-min.js'\n head.ready =>\n w = 1000\n h = 400\n window.paper = paper = Raphael \"holder\", w, h\n paper.rect(0, 0, w, h, 10).attr\n stroke: \"none\"\n fill: \"none\"\n paper.setStart()\n for country, path of worldmap.shapes\n paper.path(path).attr\n stroke: \"black\"\n fill: \"rgba(255,255,255,0.5)\"\n \"stroke-opacity\": 0.2\n world = paper.setFinish()\n \n@on 'transmission', (data) =>\n bad = \"#FF3636\"\n neutral = \"#FDEA8C\"\n good = \"#7EFF33\"\n \n colour = neutral\n colour = good if data.sentiment > 0\n colour = bad if data.sentiment < 0 \n \n window.getXY = (lat, lon) ->\n cx: lon * 2.6938 + 465.4,\n cy: lat * -2.6938 + 227.066\n \n if data.location? and data.location.latitude?\n coords = getXY(data.location.latitude, data.location.longitude)\n circle = window.paper.circle() \n circle.attr({stroke: \"none\", fill: colour, r: 2, opacity: 1,title: data.text})\n .attr(coords)\n .hover(\n -> @stop().animate({r: 5},250)\n ,\n -> @stop().animate({r: 2},500)\n )\n .click ->\n url = \"http://twitter.com/\#{data.screen_name}/status/\#{data.tweet_id}\"\n window.open(url, \"_blank\")\n" | |
| scriptType: "coffeescript" | |
| width: 1019 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment