diff options
author | Sem <sembrestels@riseup.net> | 2013-11-09 16:16:08 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2013-11-09 16:16:08 +0100 |
commit | e58937426578eac71d1447c38ae3f93cbc331bf1 (patch) | |
tree | 3bac3ed5c025f05250d7c07b14f8b83135e07233 /mod/identica/views/default/identica/js.php | |
parent | 293fe873dcbedf45571807b722ce859e00a5a3a5 (diff) | |
parent | d2494d74da2f015465bb340292c049d9c63756cd (diff) | |
download | elgg-e58937426578eac71d1447c38ae3f93cbc331bf1.tar.gz elgg-e58937426578eac71d1447c38ae3f93cbc331bf1.tar.bz2 |
Add 'mod/identica/' from commit 'd2494d74da2f015465bb340292c049d9c63756cd'
git-subtree-dir: mod/identica
git-subtree-mainline: 293fe873dcbedf45571807b722ce859e00a5a3a5
git-subtree-split: d2494d74da2f015465bb340292c049d9c63756cd
Diffstat (limited to 'mod/identica/views/default/identica/js.php')
-rw-r--r-- | mod/identica/views/default/identica/js.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mod/identica/views/default/identica/js.php b/mod/identica/views/default/identica/js.php new file mode 100644 index 000000000..1dd560836 --- /dev/null +++ b/mod/identica/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<identicas.length; i++){ + var username = identicas[i].user.screen_name; + var status = identicas[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) { + return '<a href="'+url+'">'+url+'</a>'; + }).replace(/\B@([_a-z0-9]+)/ig, function(reply) { + return reply.charAt(0)+'<a href="http://identi.ca/'+reply.substring(1)+'">'+reply.substring(1)+'</a>'; + }).replace(/\B#([-_a-z0-9]+)/ig, function(tag) { + return tag.charAt(0)+'<a href="http://identi.ca/tag/'+tag.substring(1).replace(/[^a-z0-9]+/ig, '')+'">'+tag.substring(1)+'</a>'; + }).replace(/\B!([_a-z0-9]+)/ig, function(group) { + return group.charAt(0)+'<a href="http://identi.ca/group/'+group.substring(1)+'">'+group.substring(1)+'</a>'; + }); + statusHTML.push('<li><span>'+status+'</span> <a style="font-size:85%" href="http://identi.ca/notice/'+identicas[i].id+'">'+elgg.get_friendly_time(identicas[i].created_at)+'</a></li>'); + } + 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); |