buildroot.js 3.3 KB

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