kumquat-buildroot/docs/website/js/buildroot.js
Angelo Compagnucci 9dcb5c581b docs/website: fixing query.yahooapis.com shutdown
This patch rework the use of query.yahooapis.com to do the conversion
from xml to json required by our script and moves to the use of a js
library. Datas are therefore now converted in json format on the client.

Unfortunately, cause of the CORS restriction on nabble and
buildroot.org, we cannot retrieve directly the xml data from these
servers and we need a CORS proxy to do that.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
[Peter: use sha256 integrity]
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2019-02-04 15:06:20 +01:00

94 lines
3.2 KiB
JavaScript

function load_activity(feedurl, divid) {
var container = document.getElementById(divid);
$.ajax({
url: "https://cors.io/?" + feedurl
})
.done(function(data){
var x2js = new X2JS();
var result = x2js.xml_str2json(data);
var loaded = 0;
var nb_display = 8;
if (result==null) return;
for (var i = 0; i < result.feed.entry.length; i++) {
var entry = result.feed.entry[i];
if (entry.title.indexOf("git commit") != -1)
continue;
loaded += 1;
if (loaded > nb_display)
break;
var div = document.createElement("p");
var link = document.createElement("a");
var d = new Date(entry.published);
var data = '[' + d.toLocaleDateString() + '] ' + entry.title
var text = document.createTextNode(data);
link.appendChild(text);
link.title = entry.title;
link.href = entry.link._href;
div.appendChild(link);
container.appendChild(div);
}
var empty = nb_display - loaded;
for (var i = 0; i < empty; i++) {
container.appendChild(document.createElement("p"));
}
});
}
function google_analytics() {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21761074-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
}
function showTooltip(elem, msg) {
elem.setAttribute('class', 'btn tooltipped tooltipped-s');
elem.setAttribute('aria-label', msg);
}
var clipboard = new Clipboard('.btn');
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
clipboard.on('success', function(e) {
e.clearSelection();
$(e.trigger).tooltip('show');
});
$(function() {
$('a[href*=\\#]:not([href=\\#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
jQuery(document).ready(function($) {
var url = window.location.href;
// Get the basename of the URL
url = url.split(/[\\/]/).pop()
$('.nav a[href="/' + url + '"]').parent().addClass('active');
load_activity("http://buildroot-busybox.2317881.n4.nabble.com/Buildroot-busybox-ft2.xml", "mailing-list-activity");
load_activity("http://git.buildroot.org/buildroot/atom/?h=master", "commit-activity");
$('#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>')
});