Last active
December 19, 2015 02:38
-
-
Save meza/5883976 to your computer and use it in GitHub Desktop.
A talk box for blogs
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
[ | |
{ | |
"title":"Agile Testing & BDD Exchange NYC", | |
"city":"New York", | |
"url":"http://skillsmatter.com/event/agile-testing/agile-testing-bdd-exchange-nyc-2013", | |
"date":"2013/09/20 13:15" | |
}, | |
{ | |
"title":"London Testers Gathering Workshops 2013", | |
"city":"London", | |
"url":"http://skillsmatter.com/event/agile-scrum/ltg-workshops", | |
"date":"2013/10/18 09:00" | |
} | |
] |
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
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script> | |
<script> | |
var Talks = angular.module('Talks', []).filter('future', function () { | |
return function (talks) { | |
var filteredResult = [] | |
var today = Date.now(); | |
for (var i in talks) { | |
var talkDate = Date.parse(talks[i]["date"]) | |
if (talkDate > today) { | |
filteredResult.push(talks[i]) | |
} | |
} | |
return filteredResult | |
} | |
}) | |
Talks.controller("TalksController", function ($scope, $http) { | |
$http.jsonp('http://bebop.meza.hu/talks.json?callback=JSON_CALLBACK') | |
.success(function (data) { | |
$scope.talks = data; | |
}); | |
}) | |
</script> | |
<div ng-app="Talks" id="talks"> | |
<div ng-controller="TalksController" id="talksContainer"> | |
<div ng-repeat="talk in filteredTalks = (talks | future:'talks' | orderBy:'date')" class="talk"> | |
<h3 class="talkTitle"><a href="{{talk.url}}" target="_blank">{{talk.title}}</a></h3> | |
<div class="talkDate">{{talk.date | date:'yyyy-MM-dd HH:mm'}} - {{talk.city}}</div> | |
</div> | |
<div ng-show="!filteredTalks.length">There are no upcoming talks at the moment.</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment