buildroot.js 2.3 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. 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. }
  32. });
  33. }
  34. function initialize() {
  35. load_activity("http://rss.gmane.org/topics/excerpts/gmane.comp.lib.uclibc.buildroot", "mailing-list-activity");
  36. load_activity("http://git.buildroot.org/buildroot/atom/?h=master", "commit-activity");
  37. }
  38. function google_analytics() {
  39. var _gaq = _gaq || [];
  40. _gaq.push(['_setAccount', 'UA-21761074-1']);
  41. _gaq.push(['_setDomainName', 'none']);
  42. _gaq.push(['_setAllowLinker', true]);
  43. _gaq.push(['_trackPageview']);
  44. var ga = document.createElement('script');
  45. ga.type = 'text/javascript';
  46. 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];
  49. s.parentNode.insertBefore(ga, s);
  50. }
  51. google.load("feeds", "1");
  52. google.setOnLoadCallback(initialize);
  53. google_analytics();
  54. jQuery(document).ready(function($) {
  55. var url = window.location.href;
  56. // Get the basename of the URL
  57. url = url.split(/[\\/]/).pop()
  58. $('.nav a[href="/' + url + '"]').parent().addClass('active');
  59. });