buildroot.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. let text = document.createTextNode(data);
  23. link.appendChild(text);
  24. link.title = entry.title;
  25. link.href = entry.link._href;
  26. div.appendChild(link);
  27. container.appendChild(div);
  28. }
  29. for (let i = 0; i < (nb_display - loaded); i++) {
  30. container.appendChild(document.createElement("p"));
  31. }
  32. }
  33. function load_activity(feedurl) {
  34. $.ajax({
  35. url: feedurl
  36. })
  37. .done(function(data){
  38. let x2js = new X2JS();
  39. let result = x2js.xml_str2json(data.documentElement.outerHTML);
  40. display_activity(result, "commit");
  41. display_activity(result, "mailing-list");
  42. });
  43. }
  44. function google_analytics() {
  45. let _gaq = _gaq || [];
  46. _gaq.push(['_setAccount', 'UA-21761074-1']);
  47. _gaq.push(['_setDomainName', 'none']);
  48. _gaq.push(['_setAllowLinker', true]);
  49. _gaq.push(['_trackPageview']);
  50. let ga = document.createElement('script');
  51. ga.type = 'text/javascript';
  52. ga.async = true;
  53. ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  54. let s = document.getElementsByTagName('script')[0];
  55. s.parentNode.insertBefore(ga, s);
  56. }
  57. function showTooltip(elem, msg) {
  58. elem.setAttribute('class', 'btn tooltipped tooltipped-s');
  59. elem.setAttribute('aria-label', msg);
  60. }
  61. let clipboard = new Clipboard('.btn');
  62. $(function () {
  63. $('[data-toggle="tooltip"]').tooltip()
  64. });
  65. clipboard.on('success', function(e) {
  66. e.clearSelection();
  67. $(e.trigger).tooltip('show');
  68. });
  69. $(function() {
  70. $('a[href*=\\#]:not([href=\\#])').click(function() {
  71. if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
  72. let target = $(this.hash);
  73. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  74. if (target.length) {
  75. $('html,body').animate({
  76. scrollTop: target.offset().top
  77. }, 1000);
  78. return false;
  79. }
  80. }
  81. });
  82. });
  83. jQuery(document).ready(function($) {
  84. let url = window.location.href;
  85. // Get the basename of the URL
  86. url = url.split(/[\\/]/).pop();
  87. $('.nav a[href="/' + url + '"]').parent().addClass('active');
  88. load_activity("/new.atom");
  89. $('#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>')
  90. });