Skip to content

Instantly share code, notes, and snippets.

@larsemil
Created October 10, 2012 11:24
Show Gist options
  • Save larsemil/3864915 to your computer and use it in GitHub Desktop.
Save larsemil/3864915 to your computer and use it in GitHub Desktop.
ddeventz frontend
var theFeed = 0;
var pointer = -1;
$(document).ready(function()
{
$.getJSON('http://events.daladevelop.se/index.php?callback=?&eventId=1', function(data) {
theFeed = data;
interval = window.setInterval("swapFeed()", 4000);
});
});
function swapFeed()
{
if(typeof theFeed[pointer + 1] != 'undefined')
{
pointer = pointer + 1;
}
else
pointer = 0;
$('div#content').hide("slow",function(){
content = getContent(theFeed[pointer]);
$('div#content').html(content);
$('div#content').show("slow");
});
console.log(content);
}
function getContent(feedItem)
{
console.log(feedItem);
var content = '';
if(feedItem.metadata.service == 'instagram')
{
content ='<h1>'+feedItem.content.text+'</h1>';
content+='<img src="'+feedItem.content.media[0].hires_url+'"/>';
}
else if(feedItem.metadata.service == 'twitter')
{
content = '<img src="http://twitter.com/api/users/profile_image/'+feedItem.metadata.handle+'" class="avatar"/>';
content+= feedItem.content.text;
console.log(feedItem.metadata.handle);
}
else if(feedItem.metadata.service == 'RSS')
{
content = "<h1>RSS</h1>"
content += feedItem.content;
}
return content;
}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>DDEVENT</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="ddevent.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<div id="content">
</div>
</div>
</body>
</html>
body{background-color: #F6F4F2; }
div#wrapper{
background-color: #fff;
padding: 30px;
width: 1024px;
margin: 100px auto;
height: 700px;
}
div#wrapper div#content
{
text-align: center;
}
div#wrapper div#content h1
{
margin-top: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment