buildroot.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. function load_activity(feedurl, divid) {
  2. var feed = new google.feeds.Feed(feedurl);
  3. var container = document.getElementById(divid);
  4. var loaded = 0;
  5. var nb_display = 8;
  6. feed.setNumEntries(30);
  7. feed.load(function(result) {
  8. if (result.error) {
  9. return;
  10. }
  11. for (var i = 0; i < result.feed.entries.length; i++) {
  12. var entry = result.feed.entries[i];
  13. if (entry.title.indexOf("git commit") != -1)
  14. continue;
  15. loaded += 1;
  16. if (loaded > nb_display)
  17. break;
  18. var div = document.createElement("p");
  19. var link = document.createElement("a");
  20. var d = new Date(entry.publishedDate);
  21. var data = '[' + d.toLocaleDateString() + '] ' + entry.title
  22. var text = document.createTextNode(data);
  23. link.appendChild(text);
  24. link.title = entry.title;
  25. link.href = entry.link
  26. div.appendChild(link);
  27. container.appendChild(div);
  28. }
  29. var empty = nb_display - loaded;
  30. for (var i = 0; i < empty; i++) {
  31. container.appendChild(document.createElement("p"));
  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');
  46. ga.type = 'text/javascript';
  47. ga.async = true;
  48. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  49. var s = document.getElementsByTagName('script')[0];
  50. s.parentNode.insertBefore(ga, s);
  51. }
  52. $(function() {
  53. $('a[href*=#]:not([href=#])').click(function() {
  54. if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
  55. var target = $(this.hash);
  56. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  57. if (target.length) {
  58. $('html,body').animate({
  59. scrollTop: target.offset().top
  60. }, 1000);
  61. return false;
  62. }
  63. }
  64. });
  65. });
  66. google.load("feeds", "1");
  67. google.setOnLoadCallback(initialize);
  68. google_analytics();
  69. jQuery(document).ready(function($) {
  70. var url = window.location.href;
  71. // Get the basename of the URL
  72. url = url.split(/[\\/]/).pop()
  73. $('.nav a[href="/' + url + '"]').parent().addClass('active');
  74. $('#slides').html('<iframe src="https://docs.google.com/gview?url=http://free-electrons.com/doc/training/buildroot/buildroot-slides.pdf&embedded=true" style="position:absolute; width:100%; height:100%; top:0; left:0;" frameborder="0"></iframe>')
  75. });
  76. function showTooltip(elem, msg) {
  77. elem.setAttribute('class', 'btn tooltipped tooltipped-s');
  78. elem.setAttribute('aria-label', msg);
  79. }
  80. var clipboard = new Clipboard('.btn');
  81. $(function () {
  82. $('[data-toggle="tooltip"]').tooltip()
  83. })
  84. clipboard.on('success', function(e) {
  85. e.clearSelection();
  86. $(e.trigger).tooltip('show');
  87. });
  88. $(function() {
  89. $('a[href*=#]:not([href=#])').click(function() {
  90. if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
  91. var target = $(this.hash);
  92. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  93. if (target.length) {
  94. $('html,body').animate({
  95. scrollTop: target.offset().top
  96. }, 1000);
  97. return false;
  98. }
  99. }
  100. });
  101. });