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