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