diff --git a/app/app.js b/app/app.js index 8fd4d5f..2782b3f 100644 --- a/app/app.js +++ b/app/app.js @@ -38,6 +38,7 @@ require('app/models/sources/time_source'); require('app/models/sources/rss_source'); require('app/models/sources/twitter_timeline_source'); require('app/models/sources/stock_source'); +require('app/models/sources/worldCup_source'); require('app/views/gridster_view'); require('app/views/last_updated_view'); diff --git a/app/css/widgets/ticker_widget.css b/app/css/widgets/ticker_widget.css new file mode 100644 index 0000000..cdc49d7 --- /dev/null +++ b/app/css/widgets/ticker_widget.css @@ -0,0 +1,36 @@ +.widget-ticker { + background-color: #373737; + padding: 0px 0px 0px 0px; +} + +/* Make it a marquee */ +.marquee { + overflow: hidden; + white-space: nowrap; + margin:0 auto; + max-width:1314px; +} + +.marquee span { + display: inline-block; + padding-left: 100%; + -webkit-animation: marquee 40s linear infinite; + -moz-animation: marquee 40s linear infinite; + letter-spacing: 0.1em; + text-transform: uppercase; +} + +@keyframes marquee { + 0% { -webkit-transform: translate(0, 0); } + 100% { -webkit-transform: translate(-100%, 0); } +} + +@-webkit-keyframes marquee { + 0% { -webkit-transform: translate(0, 0); } + 100% { -webkit-transform: translate(-100%, 0); } +} + +@-moz-keyframes marquee { + 0% { -moz-transform: translate(0, 0); } + 100% { -moz-transform: translate(-100%, 0); } +} \ No newline at end of file diff --git a/app/models/sources/worldCup_source.js b/app/models/sources/worldCup_source.js new file mode 100644 index 0000000..d9e2aab --- /dev/null +++ b/app/models/sources/worldCup_source.js @@ -0,0 +1,24 @@ +/** + * Provides bitcoin ticker data from Bitstamp. + * + * The data is provided to widgets as single floating point values. + */ +Dashboard.WorldCupSource = Dashboard.PeriodicSource.extend({ + + inGame: false, + + period: function() { + return this.get('inGame') ? 30000 : 5 * 60000; + }.property(), + + dataUpdate: function(callback) { + $.get("http://worldcup.sfg.io/matches/today", function(data) { + callback(data.map(function(match) { + + return match.home_team.code + " " + match.home_team.goals + "-" + + match.away_team.goals + " " + match.away_team.code; + + })); + }); + } +}); diff --git a/app/models/widgets/ticker_widget.js b/app/models/widgets/ticker_widget.js new file mode 100644 index 0000000..db6a6ba --- /dev/null +++ b/app/models/widgets/ticker_widget.js @@ -0,0 +1,40 @@ +/* +// +// +*/ +Dashboard.TickerWidget = Dashboard.Widget.extend({ + sourceData: "", + + showLastUpdated: true, + templateName: 'ticker_widget', + classNames: ['widget', 'widget-ticker'], + + formatSourceData: function(){ + if( typeof this.get('content') == 'string' ){ + return this.get('content'); + }else{ + return this.get('content').join(' '); + }); + } + }.property('content'), + + widgetView: function() { + return this._super().reopen({ + didInsertElement: function() { + var span = this.$(); + var that = this; + + var setScale = function() { + var scaleFactor = 0.5; + var scaleSource = span.height(); + + var fontSize = scaleSource * scaleFactor; + + that.$().css('font-size', fontSize + 'px'); + } + + setScale(); + } + }); + }.property() +}); diff --git a/app/templates/ticker_widget.hbs b/app/templates/ticker_widget.hbs new file mode 100644 index 0000000..c359eae --- /dev/null +++ b/app/templates/ticker_widget.hbs @@ -0,0 +1,3 @@ +{{#if content}} +
{{formateSourceData}}
+{{/if}}