docs/website/js/buildroot.js: switch var to let
PATCH v2 1/3 docs/website/js/buildroot.js: switch var to let
From: Adam Duskett <[email protected]>
In javascript, let is preferred for local, var is preferred for global. Change any local variables from "var" to "let"
---
Changes v1 -> v2:
- Updated to apply to latest master commit.
docs/website/js/buildroot.js | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-)
docs/website/js/buildroot.js +20 -20
@@ -1,51 +1,51 @@ function load_activity(feedurl, divid) { - var container = document.getElementById(divid); + let 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; + let x2js = new X2JS(); + let result = x2js.xml_str2json(data); + let loaded = 0; + let nb_display = 8; if (result==null) return; - for (var i = 0; i < result.feed.entry.length; i++) { - var entry = result.feed.entry[i]; + for (let i = 0; i < result.feed.entry.length; i++) { + let 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); + let div = document.createElement("p"); + let link = document.createElement("a"); + let d = new Date(entry.published); + let data = '[' + d.toLocaleDateString() + '] ' + entry.title + let 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++) { + let empty = nb_display - loaded; + for (let i = 0; i < empty; i++) { container.appendChild(document.createElement("p")); } }); } function google_analytics() { - var _gaq = _gaq || []; + let _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-21761074-1']); _gaq.push(['_setDomainName', 'none']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); - var ga = document.createElement('script'); + let 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]; + let s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); }
@@ -54,7 +54,7 @@ function showTooltip(elem, msg) { elem.setAttribute('aria-label', msg); } -var clipboard = new Clipboard('.btn'); +let clipboard = new Clipboard('.btn'); $(function () { $('[data-toggle="tooltip"]').tooltip()
@@ -68,7 +68,7 @@ clipboard.on('success', function(e) { $(function() { $('a[href*=\\#]:not([href=\\#])').click(function() { 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) +']'); if (target.length) { $('html,body').animate({
@@ -81,7 +81,7 @@ $(function() { }); jQuery(document).ready(function($) { - var url = window.location.href; + let url = window.location.href; // Get the basename of the URL url = url.split(/[\\/]/).pop() $('.nav a[href="/' + url + '"]').parent().addClass('active');
Signature · 1 line
2.17.2 (Apple Git-113)
PATCH v2 2/3 docs/website/js/buildroot.js: Fix possible type coercion
From: Adam Duskett <[email protected]>
With javascript, when comparing variables, using === instead of == is preferred.
---
Changes v1 -> v2:
- Updated to apply to latest master commit.
docs/website/js/buildroot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
docs/website/js/buildroot.js +3 -3
@@ -11,7 +11,7 @@ function load_activity(feedurl, divid) { if (result==null) return; for (let i = 0; i < result.feed.entry.length; i++) { let entry = result.feed.entry[i]; - if (entry.title.indexOf("git commit") != -1) + if (entry.title.indexOf("git commit") !== -1) continue; loaded += 1; if (loaded > nb_display)
@@ -44,7 +44,7 @@ function google_analytics() { let 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'; + ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; let s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); }
@@ -67,7 +67,7 @@ clipboard.on('success', function(e) { $(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) { let target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) {
Signature · 1 line
2.17.2 (Apple Git-113)
PATCH v2 2/3 docs/website/js/buildroot.js: Fix possible type coercion
Quoted 7 lines · On Mon, Feb 4, 2019 at 3:27 PM <[email protected]> wrote:
From: Adam Duskett <[email protected]>
With javascript, when comparing variables, using === instead of == is preferred.
Signed-off-by Adam Duskett <[email protected]>
Quoted 45 lines
---
Changes v1 -> v2:
- Updated to apply to latest master commit.docs/website/js/buildroot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)docs/website/js/buildroot.js +3
-4@@ -11,7 +11,7 @@ function load_activity(feedurl, divid) { if (result==null) return; for (let i = 0; i < result.feed.entry.length; i++) { let entry = result.feed.entry[i]; - if (entry.title.indexOf("git commit") != -1) + if (entry.title.indexOf("git commit") !== -1) continue; loaded += 1; if (loaded > nb_display)@@ -44,7 +44,7 @@ function google_analytics() { let 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'; + ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; let s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); }@@ -67,7 +67,7 @@ clipboard.on('success', function(e) { $(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) { let target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { --2.17.2 (Apple Git-113)
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH v2 3/3 docs/website/js/buildroot.js: Fix unterminated statements
In reply to aduskett at gmail.comFrom: Adam Duskett <[email protected]>
Some statements are missing their semicolons.
---
Changes v1 -> v2:
- Updated to apply to latest master commit.
docs/website/js/buildroot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
docs/website/js/buildroot.js +3 -3
@@ -19,7 +19,7 @@ function load_activity(feedurl, divid) { let div = document.createElement("p"); let link = document.createElement("a"); let d = new Date(entry.published); - let data = '[' + d.toLocaleDateString() + '] ' + entry.title + let data = '[' + d.toLocaleDateString() + '] ' + entry.title; let text = document.createTextNode(data); link.appendChild(text); link.title = entry.title;
@@ -58,7 +58,7 @@ let clipboard = new Clipboard('.btn'); $(function () { $('[data-toggle="tooltip"]').tooltip() -}) +}); clipboard.on('success', function(e) { e.clearSelection();
@@ -83,7 +83,7 @@ $(function() { jQuery(document).ready(function($) { let url = window.location.href; // Get the basename of the URL - url = url.split(/[\\/]/).pop() + 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");
Signature · 1 line
2.17.2 (Apple Git-113)
PATCH v2 3/3 docs/website/js/buildroot.js: Fix unterminated statements
Quoted 6 lines · On Mon, Feb 4, 2019 at 3:27 PM <[email protected]> wrote:
From: Adam Duskett <[email protected]>
Some statements are missing their semicolons.
Signed-off-by Adam Duskett <[email protected]>
Quoted 45 lines
---
Changes v1 -> v2:
- Updated to apply to latest master commit.docs/website/js/buildroot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)docs/website/js/buildroot.js +3
-4@@ -19,7 +19,7 @@ function load_activity(feedurl, divid) { let div = document.createElement("p"); let link = document.createElement("a"); let d = new Date(entry.published); - let data = '[' + d.toLocaleDateString() + '] ' + entry.title + let data = '[' + d.toLocaleDateString() + '] ' + entry.title; let text = document.createTextNode(data); link.appendChild(text); link.title = entry.title;@@ -58,7 +58,7 @@ let clipboard = new Clipboard('.btn'); $(function () { $('[data-toggle="tooltip"]').tooltip() -}) +}); clipboard.on('success', function(e) { e.clearSelection();@@ -83,7 +83,7 @@ $(function() { jQuery(document).ready(function($) { let url = window.location.href; // Get the basename of the URL - url = url.split(/[\\/]/).pop() + 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"); --2.17.2 (Apple Git-113)
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH v2 1/3 docs/website/js/buildroot.js: switch var to let
In reply to aduskett at gmail.comQuoted 7 lines · On Mon, Feb 4, 2019 at 3:27 PM <[email protected]> wrote:
From: Adam Duskett <[email protected]>
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 <[email protected]>
Quoted 114 lines
---
Changes v1 -> v2:
- Updated to apply to latest master commit.docs/website/js/buildroot.js | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-)docs/website/js/buildroot.js +20
-21@@ -1,51 +1,51 @@ function load_activity(feedurl, divid) { - var container = document.getElementById(divid); + let 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; + let x2js = new X2JS(); + let result = x2js.xml_str2json(data); + let loaded = 0; + let nb_display = 8; if (result==null) return; - for (var i = 0; i < result.feed.entry.length; i++) { - var entry = result.feed.entry[i]; + for (let i = 0; i < result.feed.entry.length; i++) { + let 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); + let div = document.createElement("p"); + let link = document.createElement("a"); + let d = new Date(entry.published); + let data = '[' + d.toLocaleDateString() + '] ' + entry.title + let 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++) { + let empty = nb_display - loaded; + for (let i = 0; i < empty; i++) { container.appendChild(document.createElement("p")); } }); } function google_analytics() { - var _gaq = _gaq || []; + let _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-21761074-1']); _gaq.push(['_setDomainName', 'none']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); - var ga = document.createElement('script'); + let 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]; + let s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); }@@ -54,7 +54,7 @@ function showTooltip(elem, msg) { elem.setAttribute('aria-label', msg); } -var clipboard = new Clipboard('.btn'); +let clipboard = new Clipboard('.btn'); $(function () { $('[data-toggle="tooltip"]').tooltip()@@ -68,7 +68,7 @@ clipboard.on('success', function(e) { $(function() { $('a[href*=\\#]:not([href=\\#])').click(function() { 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) +']'); if (target.length) { $('html,body').animate({@@ -81,7 +81,7 @@ $(function() { }); jQuery(document).ready(function($) { - var url = window.location.href; + let url = window.location.href; // Get the basename of the URL url = url.split(/[\\/]/).pop() $('.nav a[href="/' + url + '"]').parent().addClass('active'); --2.17.2 (Apple Git-113)
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH v2 1/3 docs/website/js/buildroot.js: switch var to let
In reply to aduskett at gmail.comQuoted 9 lines · On Mon, 4 Feb 2019 15:27:29 +0100 aduskett at gmail.com wrote:
From: Adam Duskett <[email protected]>
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 <[email protected]>---
Changes v1 -> v2:
- Updated to apply to latest master commit.
Series applied to master, thanks! Thanks also to Angelo for the review/testing.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com