buildroot.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. function load_activity(feedurl, divid) {
  2. var feed = new google.feeds.Feed(feedurl);
  3. feed.setNumEntries(30);
  4. feed.load(function(result) {
  5. if (!result.error) {
  6. var container = document.getElementById(divid);
  7. var loaded = 0;
  8. var nb_display = 8;
  9. for (var i = 0; i < result.feed.entries.length; i++) {
  10. var entry = result.feed.entries[i];
  11. if (entry.title.indexOf("git commit") != -1)
  12. continue;
  13. loaded += 1;
  14. if (loaded >= nb_display)
  15. break;
  16. var div = document.createElement("p");
  17. var link = document.createElement("a");
  18. var d = new Date(entry.publishedDate);
  19. var data = '[' + d.toLocaleDateString() + '] ' + entry.title
  20. // Ensure all titles are the same length
  21. if (data.length > 60) {
  22. data = data.substr(0, 57)
  23. data += '...'
  24. }
  25. var text = document.createTextNode(data);
  26. link.appendChild(text);
  27. link.title = entry.title;
  28. link.href = entry.link
  29. div.appendChild(link);
  30. container.appendChild(div);
  31. }
  32. console.log(loaded);
  33. }
  34. });
  35. }
  36. function initialize() {
  37. load_activity("http://rss.gmane.org/topics/excerpts/gmane.comp.lib.uclibc.buildroot", "mailing-list-activity");
  38. load_activity("http://git.buildroot.org/buildroot/atom/?h=master", "commit-activity");
  39. }
  40. function google_analytics() {
  41. var _gaq = _gaq || [];
  42. _gaq.push(['_setAccount', 'UA-21761074-1']);
  43. _gaq.push(['_setDomainName', 'none']);
  44. _gaq.push(['_setAllowLinker', true]);
  45. _gaq.push(['_trackPageview']);
  46. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  47. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  48. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  49. }
  50. google.load("feeds", "1");
  51. google.setOnLoadCallback(initialize);
  52. google_analytics();
  53. jQuery(document).ready(function($){
  54. var url = window.location.href;
  55. // Get the basename of the URL
  56. url = url.split(/[\\/]/).pop()
  57. $('.nav a[href="/'+url+'"]').parent().addClass('active');
  58. });