Skip to content
This repository was archived by the owner on Mar 25, 2018. It is now read-only.

Commit b0c9941

Browse files
robertkowalskitjfontaine
authored andcommitted
Remove duplicated inline code
- Remove code duplication for easier maintenance - Remove inline scripts, which e.g. allows minifying in a later step
1 parent 3b1a352 commit b0c9941

10 files changed

+57
-230
lines changed

Diff for: Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ $(blog_dirs):
5959
out/doc/%.html: doc/%.html
6060
cat $< | sed -e 's|__VERSION__|'$(VERSION)'|g' > $@
6161

62+
out/doc/main.js: doc/main.js
63+
cat $< | sed -e 's|__VERSION__|'$(VERSION)'|g' > $@
64+
6265
out/doc/%: doc/%
6366
cp -r $< $@
6467

Diff for: doc/about.html

+2-42
Original file line numberDiff line numberDiff line change
@@ -99,48 +99,8 @@
9999
}
100100
});
101101
});
102-
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
103-
(function(d, t) {
104-
var g = d.createElement(t),
105-
s = d.getElementsByTagName(t)[0];
106-
g.src = '//www.google-analytics.com/ga.js';
107-
s.parentNode.insertBefore(g, s);
108-
}(document, 'script'));
109-
;(function(d,n) {
110-
var os = n.platform.match(/(Win|Mac|Linux)/);
111-
var x = n.userAgent.match(/x86_64|Win64|WOW64/) ||
112-
n.cpuClass === 'x64' ? 'x64' : 'x86';
113-
var base = 'http://nodejs.org/dist/__VERSION__/';
114-
var href = 'node-__VERSION__.tar.gz';
115-
var db = d.getElementById('downloadbutton');
116-
var d2;
117-
switch (os && os[1]) {
118-
case 'Mac':
119-
href = 'node-__VERSION__.pkg';
120-
break;
121-
case 'Win':
122-
href = 'node-__VERSION__-' + x + '.msi';
123-
if (x === 'x64') href = 'x64/' + href;
124-
break;
125-
126-
// TODO uncomment when we have these
127-
// case 'Linux':
128-
// // two buttons: .deb and .rpm
129-
// href = 'node-__VERSION__-' + x + '.rpm';
130-
// var d2 = document.createElement('a');
131-
// d2.href = base + 'node-__VERSION__-' + x + '.deb';
132-
// d2.className = 'button downloadbutton';
133-
// d2.innerHTML = 'INSTALL .deb';
134-
// db.innerHTML = 'INSTALL .rpm';
135-
// db.parentNode.insertBefore(d2, db);
136-
// break;
137-
}
138-
139-
db.href = base + href;
140-
// if there's one download option, then download it at #download
141-
if (location.hash === '#download' && !d2)
142-
location.replace(b.href);
143-
})(document,navigator);
144102
</script>
103+
<script src="/tracking.js"></script>
104+
<script src="/main.js"></script>
145105
</body>
146106
</html>

Diff for: doc/blog.html

+1-9
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,6 @@ <h1><a href="<%=
178178
<script src="/sh_main.js"></script>
179179
<script src="/sh_javascript.min.js"></script>
180180
<script>highlight(undefined, undefined, 'pre');</script>
181-
<script>
182-
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
183-
(function(d, t) {
184-
var g = d.createElement(t),
185-
s = d.getElementsByTagName(t)[0];
186-
g.src = '//www.google-analytics.com/ga.js';
187-
s.parentNode.insertBefore(g, s);
188-
}(document, 'script'));
189-
</script>
181+
<script src="/tracking.js"></script>
190182
</body>
191183
</html>

Diff for: doc/contributing.html

+2-42
Original file line numberDiff line numberDiff line change
@@ -98,48 +98,8 @@
9898
$(this).parent().closest('div').addClass(blockclass);
9999
});
100100
});
101-
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
102-
(function(d, t) {
103-
var g = d.createElement(t),
104-
s = d.getElementsByTagName(t)[0];
105-
g.src = '//www.google-analytics.com/ga.js';
106-
s.parentNode.insertBefore(g, s);
107-
}(document, 'script'));
108-
;(function(d,n) {
109-
var os = n.platform.match(/(Win|Mac|Linux)/);
110-
var x = n.userAgent.match(/x86_64|Win64|WOW64/) ||
111-
n.cpuClass === 'x64' ? 'x64' : 'x86';
112-
var base = 'http://nodejs.org/dist/__VERSION__/';
113-
var href = 'node-__VERSION__.tar.gz';
114-
var db = d.getElementById('downloadbutton');
115-
var d2;
116-
switch (os && os[1]) {
117-
case 'Mac':
118-
href = 'node-__VERSION__.pkg';
119-
break;
120-
case 'Win':
121-
href = 'node-__VERSION__-' + x + '.msi';
122-
if (x === 'x64') href = 'x64/' + href;
123-
break;
124-
125-
// TODO uncomment when we have these
126-
// case 'Linux':
127-
// // two buttons: .deb and .rpm
128-
// href = 'node-__VERSION__-' + x + '.rpm';
129-
// var d2 = document.createElement('a');
130-
// d2.href = base + 'node-__VERSION__-' + x + '.deb';
131-
// d2.className = 'button downloadbutton';
132-
// d2.innerHTML = 'INSTALL .deb';
133-
// db.innerHTML = 'INSTALL .rpm';
134-
// db.parentNode.insertBefore(d2, db);
135-
// break;
136-
}
137-
138-
db.href = base + href;
139-
// if there's one download option, then download it at #download
140-
if (location.hash === '#download' && !d2)
141-
location.replace(b.href);
142-
})(document,navigator);
143101
</script>
102+
<script src="/tracking.js"></script>
103+
<script src="/main.js"></script>
144104
</body>
145105
</html>

Diff for: doc/docs.html

+2-42
Original file line numberDiff line numberDiff line change
@@ -100,48 +100,8 @@
100100
}
101101
});
102102
});
103-
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
104-
(function(d, t) {
105-
var g = d.createElement(t),
106-
s = d.getElementsByTagName(t)[0];
107-
g.src = '//www.google-analytics.com/ga.js';
108-
s.parentNode.insertBefore(g, s);
109-
}(document, 'script'));
110-
;(function(d,n) {
111-
var os = n.platform.match(/(Win|Mac|Linux)/);
112-
var x = n.userAgent.match(/x86_64|Win64|WOW64/) ||
113-
n.cpuClass === 'x64' ? 'x64' : 'x86';
114-
var base = 'http://nodejs.org/dist/__VERSION__/';
115-
var href = 'node-__VERSION__.tar.gz';
116-
var db = d.getElementById('downloadbutton');
117-
var d2;
118-
switch (os && os[1]) {
119-
case 'Mac':
120-
href = 'node-__VERSION__.pkg';
121-
break;
122-
case 'Win':
123-
href = 'node-__VERSION__-' + x + '.msi';
124-
if (x === 'x64') href = 'x64/' + href;
125-
break;
126-
127-
// TODO uncomment when we have these
128-
// case 'Linux':
129-
// // two buttons: .deb and .rpm
130-
// href = 'node-__VERSION__-' + x + '.rpm';
131-
// var d2 = document.createElement('a');
132-
// d2.href = base + 'node-__VERSION__-' + x + '.deb';
133-
// d2.className = 'button downloadbutton';
134-
// d2.innerHTML = 'INSTALL .deb';
135-
// db.innerHTML = 'INSTALL .rpm';
136-
// db.parentNode.insertBefore(d2, db);
137-
// break;
138-
}
139-
140-
db.href = base + href;
141-
// if there's one download option, then download it at #download
142-
if (location.hash === '#download' && !d2)
143-
location.replace(b.href);
144-
})(document,navigator);
145103
</script>
104+
<script src="/tracking.js"></script>
105+
<script src="/main.js"></script>
146106
</body>
147107
</html>

Diff for: doc/index.html

+2-44
Original file line numberDiff line numberDiff line change
@@ -135,49 +135,7 @@ <h3>Node.js at Walmart</h3>
135135
<script src="sh_javascript.min.js"></script>
136136
<script>highlight(undefined, undefined, 'pre');</script>
137137

138-
<script>
139-
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
140-
(function(d, t) {
141-
var g = d.createElement(t),
142-
s = d.getElementsByTagName(t)[0];
143-
g.src = '//www.google-analytics.com/ga.js';
144-
s.parentNode.insertBefore(g, s);
145-
}(document, 'script'));
146-
;(function(d,n) {
147-
var os = n.platform.match(/(Win|Mac|Linux)/);
148-
var x = n.userAgent.match(/x86_64|Win64|WOW64/) ||
149-
n.cpuClass === 'x64' ? 'x64' : 'x86';
150-
var base = 'http://nodejs.org/dist/__VERSION__/';
151-
var href = 'node-__VERSION__.tar.gz';
152-
var db = d.getElementById('downloadbutton');
153-
var d2;
154-
switch (os && os[1]) {
155-
case 'Mac':
156-
href = 'node-__VERSION__.pkg';
157-
break;
158-
case 'Win':
159-
href = 'node-__VERSION__-' + x + '.msi';
160-
if (x === 'x64') href = 'x64/' + href;
161-
break;
162-
163-
// TODO uncomment when we have these
164-
// case 'Linux':
165-
// // two buttons: .deb and .rpm
166-
// href = 'node-__VERSION__-' + x + '.rpm';
167-
// var d2 = document.createElement('a');
168-
// d2.href = base + 'node-__VERSION__-' + x + '.deb';
169-
// d2.className = 'button downloadbutton';
170-
// d2.innerHTML = 'INSTALL .deb';
171-
// db.innerHTML = 'INSTALL .rpm';
172-
// db.parentNode.insertBefore(d2, db);
173-
// break;
174-
}
175-
176-
db.href = base + href;
177-
// if there's one download option, then download it at #download
178-
if (location.hash === '#download' && !d2)
179-
location.replace(b.href);
180-
})(document,navigator);
181-
</script>
138+
<script src="tracking.js"></script>
139+
<script src="main.js"></script>
182140
</body>
183141
</html>

Diff for: doc/main.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
;(function(d,n) {
2+
var os = n.platform.match(/(Win|Mac|Linux)/);
3+
var x = n.userAgent.match(/x86_64|Win64|WOW64/) ||
4+
n.cpuClass === 'x64' ? 'x64' : 'x86';
5+
var base = 'http://nodejs.org/dist/__VERSION__/';
6+
var href = 'node-__VERSION__.tar.gz';
7+
var db = d.getElementById('downloadbutton');
8+
var d2;
9+
switch (os && os[1]) {
10+
case 'Mac':
11+
href = 'node-__VERSION__.pkg';
12+
break;
13+
case 'Win':
14+
href = 'node-__VERSION__-' + x + '.msi';
15+
if (x === 'x64') href = 'x64/' + href;
16+
break;
17+
18+
// TODO uncomment when we have these
19+
// case 'Linux':
20+
// // two buttons: .deb and .rpm
21+
// href = 'node-__VERSION__-' + x + '.rpm';
22+
// var d2 = document.createElement('a');
23+
// d2.href = base + 'node-__VERSION__-' + x + '.deb';
24+
// d2.className = 'button downloadbutton';
25+
// d2.innerHTML = 'INSTALL .deb';
26+
// db.innerHTML = 'INSTALL .rpm';
27+
// db.parentNode.insertBefore(d2, db);
28+
// break;
29+
}
30+
31+
db.href = base + href;
32+
// if there's one download option, then download it at #download
33+
if (location.hash === '#download' && !d2)
34+
location.replace(b.href);
35+
})(document,navigator);

Diff for: doc/template.html

+1-9
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,6 @@ <h2>Table of Contents</h2>
7373
<script src="../sh_main.js"></script>
7474
<script src="../sh_javascript.min.js"></script>
7575
<script>highlight(undefined, undefined, 'pre');</script>
76-
<script>
77-
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
78-
(function(d, t) {
79-
var g = d.createElement(t),
80-
s = d.getElementsByTagName(t)[0];
81-
g.src = '//www.google-analytics.com/ga.js';
82-
s.parentNode.insertBefore(g, s);
83-
}(document, 'script'));
84-
</script>
76+
<script src="/tracking.js"></script>
8577
</body>
8678
</html>

Diff for: doc/tracking.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
2+
(function(d, t) {
3+
var g = d.createElement(t),
4+
s = d.getElementsByTagName(t)[0];
5+
g.src = '//www.google-analytics.com/ga.js';
6+
s.parentNode.insertBefore(g, s);
7+
}(document, 'script'));

Diff for: doc/website.html

+2-42
Original file line numberDiff line numberDiff line change
@@ -95,48 +95,8 @@
9595
$(this).parent().closest('div').addClass(blockclass);
9696
});
9797
});
98-
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
99-
(function(d, t) {
100-
var g = d.createElement(t),
101-
s = d.getElementsByTagName(t)[0];
102-
g.src = '//www.google-analytics.com/ga.js';
103-
s.parentNode.insertBefore(g, s);
104-
}(document, 'script'));
105-
;(function(d,n) {
106-
var os = n.platform.match(/(Win|Mac|Linux)/);
107-
var x = n.userAgent.match(/x86_64|Win64|WOW64/) ||
108-
n.cpuClass === 'x64' ? 'x64' : 'x86';
109-
var base = 'http://nodejs.org/dist/__VERSION__/';
110-
var href = 'node-__VERSION__.tar.gz';
111-
var db = d.getElementById('downloadbutton');
112-
var d2;
113-
switch (os && os[1]) {
114-
case 'Mac':
115-
href = 'node-__VERSION__.pkg';
116-
break;
117-
case 'Win':
118-
href = 'node-__VERSION__-' + x + '.msi';
119-
if (x === 'x64') href = 'x64/' + href;
120-
break;
121-
122-
// TODO uncomment when we have these
123-
// case 'Linux':
124-
// // two buttons: .deb and .rpm
125-
// href = 'node-__VERSION__-' + x + '.rpm';
126-
// var d2 = document.createElement('a');
127-
// d2.href = base + 'node-__VERSION__-' + x + '.deb';
128-
// d2.className = 'button downloadbutton';
129-
// d2.innerHTML = 'INSTALL .deb';
130-
// db.innerHTML = 'INSTALL .rpm';
131-
// db.parentNode.insertBefore(d2, db);
132-
// break;
133-
}
134-
135-
db.href = base + href;
136-
// if there's one download option, then download it at #download
137-
if (location.hash === '#download' && !d2)
138-
location.replace(b.href);
139-
})(document,navigator);
14098
</script>
99+
<script src="/tracking.js"></script>
100+
<script src="/main.js"></script>
141101
</body>
142102
</html>

0 commit comments

Comments
 (0)