From 479e5b1bb819967665bb1933d268e16c16c69b70 Mon Sep 17 00:00:00 2001 From: Sem Date: Fri, 6 Jan 2012 16:07:45 +0100 Subject: Refactored javascripts. Added elgg.get_friendly_time() function. --- views/default/identica/js.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 views/default/identica/js.php (limited to 'views/default/identica/js.php') diff --git a/views/default/identica/js.php b/views/default/identica/js.php new file mode 100644 index 000000000..1dd560836 --- /dev/null +++ b/views/default/identica/js.php @@ -0,0 +1,40 @@ +/** + * Elgg identi.ca widget + * This plugin allows users to pull in their identi.ca feed to display on their profile + * + * @package ElggIdentica + */ + +elgg.identica = {}; + +/** + * Parse the JSON result for show this in HTML + * + * @param JSON string the JSON result of the identi.ca's call + */ +elgg.identica.callback = function(identicas) { + var statusHTML = []; + for (var i=0; i]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) { + return ''+url+''; + }).replace(/\B@([_a-z0-9]+)/ig, function(reply) { + return reply.charAt(0)+''+reply.substring(1)+''; + }).replace(/\B#([-_a-z0-9]+)/ig, function(tag) { + return tag.charAt(0)+''+tag.substring(1)+''; + }).replace(/\B!([_a-z0-9]+)/ig, function(group) { + return group.charAt(0)+''+group.substring(1)+''; + }); + statusHTML.push('
  • '+status+' '+elgg.get_friendly_time(identicas[i].created_at)+'
  • '); + } + document.getElementById('identica_update_list').innerHTML = statusHTML.join(''); +} + +elgg.identica.init = function() { + username = $('#identica_update_list').data('username'); + num = $('#identica_update_list').data('num'); + js = "https://identi.ca/api/statuses/user_timeline/"+username+".json?callback=elgg.identica.callback&count="+num; + $.getScript(js); +}; + +elgg.register_hook_handler('init', 'system', elgg.identica.init); -- cgit v1.2.3