2
1

buildroot.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. function display_activity(result, activity) {
  2. let loaded = 0;
  3. let nb_display = 8;
  4. let container;
  5. if (result==null) return;
  6. for (let i = 0; i < result.feed.entry.length; i++) {
  7. let entry = result.feed.entry[i];
  8. if (activity==="commit" && entry.title.toString().indexOf("git commit") !== -1) {
  9. container = document.getElementById("commit-activity");
  10. } else if (activity==="mailing-list" && entry.title.toString().indexOf("git commit") === -1) {
  11. container = document.getElementById("mailing-list-activity");
  12. } else {
  13. continue;
  14. }
  15. loaded += 1
  16. if (loaded > nb_display)
  17. break;
  18. let div = document.createElement("p");
  19. let link = document.createElement("a");
  20. let d = new Date(entry.updated);
  21. let data = '[' + d.toLocaleDateString() + '] ' + entry.title;
  22. data = data.replace("Re: ","");
  23. data = data.replace("[Buildroot] ","");
  24. let text = document.createTextNode(data);
  25. link.appendChild(text);
  26. link.title = entry.title;
  27. link.href = entry.link._href;
  28. div.appendChild(link);
  29. container.appendChild(div);
  30. }
  31. for (let i = 0; i < (nb_display - loaded); i++) {
  32. container.appendChild(document.createElement("p"));
  33. }
  34. }
  35. function load_activity(feedurl) {
  36. $.ajax({
  37. url: feedurl
  38. })
  39. .done(function(data){
  40. let x2js = new X2JS();
  41. let result = x2js.xml_str2json(data.documentElement.outerHTML);
  42. display_activity(result, "commit");
  43. display_activity(result, "mailing-list");
  44. });
  45. }
  46. function google_analytics() {
  47. let _gaq = _gaq || [];
  48. _gaq.push(['_setAccount', 'UA-21761074-1']);
  49. _gaq.push(['_setDomainName', 'none']);
  50. _gaq.push(['_setAllowLinker', true]);
  51. _gaq.push(['_trackPageview']);
  52. let ga = document.createElement('script');
  53. ga.type = 'text/javascript';
  54. ga.async = true;
  55. ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  56. let s = document.getElementsByTagName('script')[0];
  57. s.parentNode.insertBefore(ga, s);
  58. }
  59. function showTooltip(elem, msg) {
  60. elem.setAttribute('class', 'btn tooltipped tooltipped-s');
  61. elem.setAttribute('aria-label', msg);
  62. }
  63. let clipboard = new Clipboard('.btn');
  64. $(function () {
  65. $('[data-toggle="tooltip"]').tooltip()
  66. });
  67. clipboard.on('success', function(e) {
  68. e.clearSelection();
  69. $(e.trigger).tooltip('show');
  70. });
  71. $(function() {
  72. $('a[href*=\\#]:not([href=\\#])').click(function() {
  73. if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
  74. let target = $(this.hash);
  75. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  76. if (target.length) {
  77. $('html,body').animate({
  78. scrollTop: target.offset().top
  79. }, 1000);
  80. return false;
  81. }
  82. }
  83. });
  84. });
  85. jQuery(document).ready(function($) {
  86. let url = window.location.href;
  87. // Get the basename of the URL
  88. url = url.split(/[\\/]/).pop();
  89. $('.nav a[href="/' + url + '"]').parent().addClass('active');
  90. load_activity("/new.atom");
  91. $('#slides').html('<iframe src="https://docs.google.com/gview?url=http://bootlin.com/doc/training/buildroot/buildroot-slides.pdf&embedded=true" style="position:absolute; width:100%; height:100%; top:0; left:0;" frameborder="0"></iframe>')
  92. });