docs/website/js/buildroot.js: switch var to let

In javascript, let is preferred for local, var is preferred for global.
Change any local variables from "var" to "let"

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
Acked-by: <angelo@amarulasolutions.com>
Tested-by: <angelo@amarulasolutions.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Adam Duskett 2019-02-04 15:27:29 +01:00 committed by Thomas Petazzoni
parent 37a1c59c4c
commit 385e08d54f

View File

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