-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
test.html
102 lines (82 loc) · 2.83 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html lang="en">
<head>
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
#previews {
display: flex;
flex-wrap: wrap;
justify-content: center;
flex-direction: row;
}
#previews > div {
padding: 1rem;
border: 1px solid #000;
max-width: 400px;
margin: auto;
}
#previews > div.horizontal {
max-width: 550px;
}
</style>
</head>
<body>
<div id="previews"></div>
<script>
let config_matrix = [
{ k: 'direction', v: ['horizontal', 'vertical'] },
{ k: 'bubbles', v: [true, false] },
{ k: 'announcements', v: [true, false] },
{ k: 'highlights', v: [true, false] },
{ k: 'badges', v: [true, false] },
//{ k: 'badges_on_left', v: [true, false] },
//{ k: 'timestamp', v: [true, false] },
]
function permutate_matrix(matrix) {
if (matrix.length === 0) return [[]]
let [current, ...rest] = matrix
let combinations = permutate_matrix(rest)
return current.v.reduce((a, string) =>
[...a, ...combinations.map(c => [string, ...c])], [])
}
let config_permutations = permutate_matrix(config_matrix);
console.log(config_permutations);
let previews = document.getElementById('previews');
let elements = [];
for (let i = 0; i < config_permutations.length; i++) {
let config = config_permutations[i].map((v, k) => {
return [config_matrix[k]['k'], v];
});
let h1 = document.createElement('h1');
h1.innerText = config.map((v, k) => {
return v[0] + ': ' + v[1];
}).join(', ');
// Enable debug message generation
// Disable this to use messages from the websocket
config.push(['debug', true]);
// Disable update check (to prevent getting rate limited by GitHub)
config.push(['version_check', false]);
config.push(['version_alert', false]);
let div = document.createElement('div');
let iframe = document.createElement('iframe');
iframe.src = './chat.html?' + new URLSearchParams(config).toString();
iframe.width = '300';
iframe.height = '250';
if (config[0][1] == 'horizontal') {
iframe.width = '500';
iframe.height = '80';
div.classList.add('horizontal');
}
div.appendChild(h1);
div.appendChild(iframe);
elements.push(div);
}
for (let i = 0; i < elements.length; i++) {
previews.appendChild(elements[i]);
}
</script>
</html>