[Bast-commits] r8871 - in DBIC-Web: . components pages/resources
pages/resources/js
david at dev.catalyst.perl.org
david at dev.catalyst.perl.org
Thu Mar 4 14:42:29 GMT 2010
Author: david
Date: 2010-03-04 14:42:29 +0000 (Thu, 04 Mar 2010)
New Revision: 8871
Added:
DBIC-Web/pages/resources/js/
DBIC-Web/pages/resources/js/twitter.js
Modified:
DBIC-Web/
DBIC-Web/components/twitter.tt
DBIC-Web/components/wrapper.tt
Log:
r20 at drax: david | 2010-03-02 17:32:30 +0000
Copy blogger js to local (1 few DNS lookups) and fix so it doesn't require invalid HTML
Property changes on: DBIC-Web
___________________________________________________________________
Modified: svk:merge
- 8f56f3f5-0ce6-439a-8bf6-7ff32a8a3359:/local/DBIC-Web:19
+ 8f56f3f5-0ce6-439a-8bf6-7ff32a8a3359:/local/DBIC-Web:20
Modified: DBIC-Web/components/twitter.tt
===================================================================
--- DBIC-Web/components/twitter.tt 2010-03-04 14:42:25 UTC (rev 8870)
+++ DBIC-Web/components/twitter.tt 2010-03-04 14:42:29 UTC (rev 8871)
@@ -4,10 +4,7 @@
<h2 class="sidebar-title">
Latest information
</h2>
- <ul id="twitter_update_list"></ul>
- <script type="text/javascript"
- src="http://twitter.com/statuses/user_timeline/dbix_class.json?callback=twitterCallback2&count=10">
- </script>
+ <div id="twitter_update_list"></div>
<div>
<a href="http://twitter.com/dbix_class" id="twitter-link" style="display:block;text-align:right;">
follow us on Twitter
Modified: DBIC-Web/components/wrapper.tt
===================================================================
--- DBIC-Web/components/wrapper.tt 2010-03-04 14:42:25 UTC (rev 8870)
+++ DBIC-Web/components/wrapper.tt 2010-03-04 14:42:29 UTC (rev 8871)
@@ -17,7 +17,7 @@
</div>
</div>
-<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
+<script type="text/javascript" src="/resources/js/twitter.js"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/dbix_class.json?callback=twitterCallback2&count=10"></script>
</body>
Added: DBIC-Web/pages/resources/js/twitter.js
===================================================================
--- DBIC-Web/pages/resources/js/twitter.js (rev 0)
+++ DBIC-Web/pages/resources/js/twitter.js 2010-03-04 14:42:29 UTC (rev 8871)
@@ -0,0 +1,38 @@
+function twitterCallback2(twitters) {
+ var statusHTML = [];
+ for (var i=0; i<twitters.length; i++){
+ var username = twitters[i].user.screen_name;
+ var status = twitters[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://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
+ });
+ statusHTML.push('<li><span>'+status+'</span> <a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id+'">'+relative_time(twitters[i].created_at)+'</a></li>');
+ }
+ document.getElementById('twitter_update_list').innerHTML = "<ul>" + statusHTML.join('') + "</ul>";
+}
+
+function relative_time(time_value) {
+ var values = time_value.split(" ");
+ time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
+ var parsed_date = Date.parse(time_value);
+ var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
+ var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
+ delta = delta + (relative_to.getTimezoneOffset() * 60);
+
+ if (delta < 60) {
+ return 'less than a minute ago';
+ } else if(delta < 120) {
+ return 'about a minute ago';
+ } else if(delta < (60*60)) {
+ return (parseInt(delta / 60)).toString() + ' minutes ago';
+ } else if(delta < (120*60)) {
+ return 'about an hour ago';
+ } else if(delta < (24*60*60)) {
+ return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
+ } else if(delta < (48*60*60)) {
+ return '1 day ago';
+ } else {
+ return (parseInt(delta / 86400)).toString() + ' days ago';
+ }
+}
More information about the Bast-commits
mailing list