Skip to content

Commit c48fbec

Browse files
Separate HTML from JS.
1 parent 880e24d commit c48fbec

File tree

2 files changed

+64
-60
lines changed

2 files changed

+64
-60
lines changed

_includes/footer_custom.html

+1-60
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,4 @@
1+
<script src="/assets/js/ad.js"></script>
12
<script>
2-
const ads = [
3-
{
4-
img: 'patreon.png',
5-
href: 'https://patreon.com/structurizr',
6-
expiry: new Date('2025-12-31')
7-
},
8-
{
9-
img: 'j-on-the-beach.png',
10-
href: 'https://www.jonthebeach.com/workshops/visualising-software-architecture-with-the-C4-model/',
11-
expiry: new Date('2025-05-13')
12-
},
13-
{
14-
img: 'trifork-nl.png',
15-
href: 'https://trifork.nl/academy/our-courses/software-architecture-for-developers/',
16-
expiry: new Date('2025-05-20')
17-
},
18-
{
19-
img: 'ddd-europe.png',
20-
href: 'https://ddd.academy/visualising-software-architecture/',
21-
expiry: new Date('2025-06-02')
22-
},
23-
{
24-
img: 'yow-melbourne.png',
25-
href: 'https://yowcon.com/melbourne-2025/masterclasses/541/visualising-software-architecture-with-the-c4-model',
26-
expiry: new Date('2025-12-02')
27-
},
28-
{
29-
img: 'yow-sydney.png',
30-
href: 'https://yowcon.com/sydney-2025/masterclasses/542/visualising-software-architecture-with-the-c4-model',
31-
expiry: new Date('2025-12-09')
32-
}
33-
];
34-
35-
function showAd(id) {
36-
try {
37-
var ad;
38-
while (ad === undefined || ad.expiry < new Date()) {
39-
const randomNumber = Math.floor(Math.random() * ads.length);
40-
ad = ads[randomNumber];
41-
}
42-
43-
const img = document.createElement('img');
44-
img.src = '/assets/ads/' + ad.img;
45-
img.style.width = '728px';
46-
img.style.height = '90px';
47-
img.style.borderRadius = '5px';
48-
img.style.border = 'solid 1px black';
49-
50-
const a = document.createElement('a');
51-
a.href = ad.href;
52-
a.target = '_blank';
53-
a.append(img);
54-
55-
const mainContentElement = document.getElementById(id);
56-
mainContentElement.insertBefore(a, mainContentElement.firstChild);
57-
} catch (e) {
58-
log.warn(e);
59-
}
60-
}
61-
623
showAd('main-content');
634
</script>

assets/js/ad.js

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
const ads = [
2+
{
3+
img: 'patreon.png',
4+
href: 'https://patreon.com/structurizr',
5+
expiry: new Date('2025-12-31')
6+
},
7+
{
8+
img: 'j-on-the-beach.png',
9+
href: 'https://www.jonthebeach.com/workshops/visualising-software-architecture-with-the-C4-model/',
10+
expiry: new Date('2025-05-13')
11+
},
12+
{
13+
img: 'trifork-nl.png',
14+
href: 'https://trifork.nl/academy/our-courses/software-architecture-for-developers/',
15+
expiry: new Date('2025-05-20')
16+
},
17+
{
18+
img: 'ddd-europe.png',
19+
href: 'https://ddd.academy/visualising-software-architecture/',
20+
expiry: new Date('2025-06-02')
21+
},
22+
{
23+
img: 'yow-melbourne.png',
24+
href: 'https://yowcon.com/melbourne-2025/masterclasses/541/visualising-software-architecture-with-the-c4-model',
25+
expiry: new Date('2025-12-02')
26+
},
27+
{
28+
img: 'yow-sydney.png',
29+
href: 'https://yowcon.com/sydney-2025/masterclasses/542/visualising-software-architecture-with-the-c4-model',
30+
expiry: new Date('2025-12-09')
31+
}
32+
];
33+
34+
function showAd(id, baseUrl) {
35+
try {
36+
if (baseUrl === undefined) {
37+
baseUrl = '';
38+
}
39+
40+
var ad;
41+
while (ad === undefined || ad.expiry < new Date()) {
42+
const randomNumber = Math.floor(Math.random() * ads.length);
43+
ad = ads[randomNumber];
44+
}
45+
46+
const img = document.createElement('img');
47+
img.src = baseUrl + '/assets/ads/' + ad.img;
48+
img.style.width = '728px';
49+
img.style.height = '90px';
50+
img.style.borderRadius = '5px';
51+
img.style.border = 'solid 1px black';
52+
53+
const a = document.createElement('a');
54+
a.href = ad.href;
55+
a.target = '_blank';
56+
a.append(img);
57+
58+
const mainContentElement = document.getElementById(id);
59+
mainContentElement.insertBefore(a, mainContentElement.firstChild);
60+
} catch (e) {
61+
log.warn(e);
62+
}
63+
}

0 commit comments

Comments
 (0)