]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - docs/website/js/buildroot.js
docs/website: Speedup javascript query
[coffee/buildroot.git] / docs / website / js / buildroot.js
1 function load_activity(feedurl, divid) {
2     var yqlURL = "https://query.yahooapis.com/v1/public/yql";
3     var yqlQS = "?q=select%20entry%20from%20xml%20where%20url%20%3D%20'";
4     var yqlOPTS = "'%20limit%2010&format=json&callback=";
5     var container = document.getElementById(divid);
6     var url = yqlURL + yqlQS + encodeURIComponent(feedurl) + yqlOPTS;
7
8     $.getJSON(url, function(data){
9         var result = data.query.results;
10         var loaded = 0;
11         var nb_display = 8;
12         if (result==null) return;
13         for (var i = 0; i < result.feed.length; i++) {
14             var entry = result.feed[i].entry;
15             if (entry.title.indexOf("git commit") != -1)
16                 continue;
17             loaded += 1;
18             if (loaded > nb_display)
19                 break;
20             var div = document.createElement("p");
21             var link = document.createElement("a");
22             var d = new Date(entry.published);
23             var data = '[' + d.toLocaleDateString() + '] ' + entry.title
24             var 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         var empty = nb_display - loaded;
32         for (var i = 0; i < empty; i++) {
33             container.appendChild(document.createElement("p"));
34         }
35     });
36 }
37
38 function google_analytics() {
39     var _gaq = _gaq || [];
40     _gaq.push(['_setAccount', 'UA-21761074-1']);
41     _gaq.push(['_setDomainName', 'none']);
42     _gaq.push(['_setAllowLinker', true]);
43     _gaq.push(['_trackPageview']);
44
45     var ga = document.createElement('script');
46     ga.type = 'text/javascript';
47     ga.async = true;
48     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
49     var s = document.getElementsByTagName('script')[0];
50     s.parentNode.insertBefore(ga, s);
51 }
52
53 function showTooltip(elem, msg) {
54     elem.setAttribute('class', 'btn tooltipped tooltipped-s');
55     elem.setAttribute('aria-label', msg);
56 }
57
58 var clipboard = new Clipboard('.btn');
59
60 $(function () {
61   $('[data-toggle="tooltip"]').tooltip()
62 })
63
64 clipboard.on('success', function(e) {
65     e.clearSelection();
66     $(e.trigger).tooltip('show');
67 });
68
69 $(function() {
70   $('a[href*=\\#]:not([href=\\#])').click(function() {
71     if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
72       var 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
84 jQuery(document).ready(function($) {
85     var url = window.location.href;
86     // Get the basename of the URL
87     url = url.split(/[\\/]/).pop()
88     $('.nav a[href="/' + url + '"]').parent().addClass('active');
89
90     load_activity("http://buildroot-busybox.2317881.n4.nabble.com/Buildroot-busybox-ft2.xml", "mailing-list-activity");
91     load_activity("http://git.buildroot.org/buildroot/atom/?h=master", "commit-activity");
92
93     $('#slides').html('<iframe src="https://docs.google.com/gview?url=http://free-electrons.com/doc/training/buildroot/buildroot-slides.pdf&embedded=true" style="position:absolute; width:100%; height:100%; top:0; left:0;" frameborder="0"></iframe>')
94 });