git ssb

0+

Angelica / ang-blev



Tree: a0de5cbce90b8fa61981e40f1bcb1da2ddb5e5dc

Files: a0de5cbce90b8fa61981e40f1bcb1da2ddb5e5dc / script.js

1167 bytesRaw
1// Learn more about using JavaScript to interact with webpages:
2// https://developer.mozilla.org/en-US/docs/Web/javascript
3
4const COLORS = [
5 'rebeccapurple',
6 'magenta',
7 'lime',
8 'violet',
9 'red',
10 'cyan',
11 'yellow',
12 'springgreen',
13 'aqua',
14 'orange',
15 'crimson',
16 'coral',
17 'deeppink',
18 'dodgerblue',
19 'gold'
20]
21const button = document.getElementById('change-background-color')
22
23button.addEventListener('click', changeBackgroundColor)
24
25document.addEventListener('DOMContentLoaded', function () {
26 document.getElementById('url').innerText = window.location
27 document.getElementById('library-url').href = `beaker://library/${window.location}`
28
29 // is this a Dat-supported website? If so, use a dat:// URL for the beakerbrowser.com link
30 const beakerLink = document.getElementById('beaker-url')
31 if (window.DatArchive) {
32 beakerLink.href = 'dat://beakerbrowser.com'
33 } else {
34 beakerLink.href = 'https://beakerbrowser.com'
35 }
36})
37
38function changeBackgroundColor () {
39 const maxIdx = COLORS.length - 1
40 const idx = Math.floor(Math.random() * Math.floor(maxIdx))
41 const newColor = COLORS[idx]
42
43 document.body.style.background = newColor
44}

Built with git-ssb-web