JSFiddle - React, Tailwind, and code Playground
HTML
jQuery(document).ready(function() {
realtime_fb_likes();
setInterval("realtime_fb_likes()", 30000);
});
function realtime_fb_likes() {
$.getJSON('https://www.facebook.com/Save-Our-Bangka-Island-471831706215579/timeline/?ref=hl',
function(data) {
var fb_likes = addCommas(data.likes);
$('.fb-likes-count').text(fb_likes);
});
}
function addCommas(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + '.' + '$2');
}
return x1 + x2;
}
CSS
body {
background:#edeff4
}
#fblike-wrap {
width:325px;
height:108px;
background:white url(http://4.bp.blogspot.com/-eX2OP3lHCng/UpjQ3ow0aFI/AAAAAAAAGJY/hCKrbQ1tc3Y/s130/fb2.png) no-repeat left center;
border-radius:10px;
margin:30px auto;
border:1px solid #bdc7d8;
}
.fb-wrapper {
width:190px;
margin-left:130px;
text-align:center;
color:#a3bfd2;
padding-top:20px;
}
.fb-likes-count {
color:#87acc5;
font:normal 42px Arial;
text-align:center;
letter-spacing:-2px;
}
.fb-like-text {
font:normal 18px Arial;
}
.center {
text-align:center;
margin-left:100px;
margin-top:-15px;
}
JavaScript
jQuery(document).ready(function() {
realtime_fb_likes();
setInterval("realtime_fb_likes()", 30000);
});
function realtime_fb_likes() {
$.getJSON('http://graph.facebook.com/kangismet.net/',
function(data) {
var fb_likes = addCommas(data.likes);
$('.fb-likes-count').text(fb_likes);
});
}
function addCommas(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + '.' + '$2');
}
return x1 + x2;
}