]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - docs/website/js/buildroot.js
2fd3b7811b5903d0de02765c51f116bd655520b5
[coffee/buildroot.git] / docs / website / js / buildroot.js
1 function load_activity(feedurl, divid) {
2     var feed = new google.feeds.Feed(feedurl);
3     var container = document.getElementById(divid);
4     var loaded = 0;
5     var nb_display = 8;
6     feed.setNumEntries(30);
7     feed.load(function(result) {
8         if (result.error) {
9                 return;
10         }
11         for (var i = 0; i < result.feed.entries.length; i++) {
12             var entry = result.feed.entries[i];
13             if (entry.title.indexOf("git commit") != -1)
14                 continue;
15             loaded += 1;
16             if (loaded > nb_display)
17                 break;
18             var div = document.createElement("p");
19             var link = document.createElement("a");
20             var d = new Date(entry.publishedDate);
21             var data = '[' + d.toLocaleDateString() + '] ' + entry.title
22             var text = document.createTextNode(data);
23             link.appendChild(text);
24             link.title = entry.title;
25             link.href = entry.link
26             div.appendChild(link);
27             container.appendChild(div);
28         }
29         var empty = nb_display - loaded;
30         for (var i = 0; i < empty; i++) {
31             container.appendChild(document.createElement("p"));
32         }
33     });
34 }
35
36 function initialize() {
37     load_activity("http://rss.gmane.org/topics/excerpts/gmane.comp.lib.uclibc.buildroot", "mailing-list-activity");
38     load_activity("http://git.buildroot.org/buildroot/atom/?h=master", "commit-activity");
39 }
40
41 function google_analytics() {
42     var _gaq = _gaq || [];
43     _gaq.push(['_setAccount', 'UA-21761074-1']);
44     _gaq.push(['_setDomainName', 'none']);
45     _gaq.push(['_setAllowLinker', true]);
46     _gaq.push(['_trackPageview']);
47
48     var ga = document.createElement('script');
49     ga.type = 'text/javascript';
50     ga.async = true;
51     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
52     var s = document.getElementsByTagName('script')[0];
53     s.parentNode.insertBefore(ga, s);
54 }
55
56 $(function() {
57   $('a[href*=#]:not([href=#])').click(function() {
58     if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
59       var target = $(this.hash);
60       target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
61       if (target.length) {
62         $('html,body').animate({
63           scrollTop: target.offset().top
64         }, 1000);
65         return false;
66       }
67     }
68   });
69 });
70
71 google.load("feeds", "1");
72 google.setOnLoadCallback(initialize);
73 google_analytics();
74
75 jQuery(document).ready(function($) {
76     var 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
81     $('#slides').html('<iframe src="http://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>')
82 });
83
84 function showTooltip(elem, msg) {
85     elem.setAttribute('class', 'btn tooltipped tooltipped-s');
86     elem.setAttribute('aria-label', msg);
87 }
88
89 var clipboard = new Clipboard('.btn');
90
91 $(function () {
92   $('[data-toggle="tooltip"]').tooltip()
93 })
94
95 clipboard.on('success', function(e) {
96     e.clearSelection();
97     $(e.trigger).tooltip('show');
98 });
99
100 $(function() {
101   $('a[href*=#]:not([href=#])').click(function() {
102     if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
103       var target = $(this.hash);
104       target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
105       if (target.length) {
106         $('html,body').animate({
107           scrollTop: target.offset().top
108         }, 1000);
109         return false;
110       }
111     }
112   });
113 });