buildroot.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. var text = document.createTextNode(data);
  21. link.appendChild(text);
  22. link.title = entry.title;
  23. link.href = entry.link
  24. div.appendChild(link);
  25. container.appendChild(div);
  26. }
  27. var empty = nb_display - loaded;
  28. for (var i = 0; i < empty; i++) {
  29. container.appendChild(document.createElement("p"));
  30. }
  31. console.log(loaded);
  32. }
  33. });
  34. }
  35. function initialize() {
  36. load_activity("http://rss.gmane.org/topics/excerpts/gmane.comp.lib.uclibc.buildroot", "mailing-list-activity");
  37. load_activity("http://git.buildroot.org/buildroot/atom/?h=master", "commit-activity");
  38. }
  39. function google_analytics() {
  40. var _gaq = _gaq || [];
  41. _gaq.push(['_setAccount', 'UA-21761074-1']);
  42. _gaq.push(['_setDomainName', 'none']);
  43. _gaq.push(['_setAllowLinker', true]);
  44. _gaq.push(['_trackPageview']);
  45. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  46. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  47. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  48. }
  49. google.load("feeds", "1");
  50. google.setOnLoadCallback(initialize);
  51. google_analytics();
  52. jQuery(document).ready(function($){
  53. var url = window.location.href;
  54. // Get the basename of the URL
  55. url = url.split(/[\\/]/).pop()
  56. $('.nav a[href="/'+url+'"]').parent().addClass('active');
  57. });