-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
187 lines (170 loc) · 6.56 KB
/
index.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Magic Circles and Runes</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/viewerjs/1.11.2/viewer.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/viewerjs/1.11.2/viewer.min.css">
<link href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300..800;1,300..800&display=swap" rel="stylesheet">
<style>
body {
margin: 0;
padding: 20px;
font-family: 'Public Sans', Arial, sans-serif;
background-color: #222;
color: #f8f8f8;
overflow-x: hidden;
display: grid;
grid-template-rows: auto 1fr;
height: min-content;
}
.section {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
}
.section-title {
font-size: 24px;
margin-bottom: 10px;
}
.images-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 0;
width: 100%;
box-sizing: border-box;
overflow: auto;
}
.images-container img {
cursor: pointer;
outline: 1px solid black;
transition: none;
width: 150px;
height: 150px;
object-fit: cover;
margin: 5px;
}
.images-container img:hover {
filter: brightness(1.1);
outline: 2px solid #299abd;
}
.viewer-title {
color: white;
background-color: rgba(100, 100, 100, 0.8);
padding: 0.5em 1em;
backdrop-filter: blur(5px);
opacity: 1 !important;
}
.viewer-close {
color: white;
}
.input-container {
display: flex;
justify-content: center;
margin-bottom: 20px;
flex-direction: column;
align-items: center;
}
.input-container textarea {
margin-right: 10px;
padding: 8px;
border: 1px solid #444;
border-radius: 4px;
font-size: 16px;
width: 80vw;
background-color: #333;
color: #f8f8f8;
resize: none;
box-sizing: border-box;
height: 200px;
overflow-y: auto;
margin-bottom: 10px;
}
.input-container button {
padding: 8px 20px;
background-color: #4a7af0;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
.input-container button:hover {
background-color: #3c66c0;
}
</style>
</head>
<body>
<div class="section">
<h2 class="section-title">Magic Circles</h2>
<div class="input-container">
<textarea id="circlesInput" placeholder="Paste JSON or 'MAGIC_CIRCLES = []' format"></textarea>
<button id="loadCircles">Load Circles</button>
</div>
<div id="circles" class="images-container"></div>
</div>
<div class="section">
<h2 class="section-title">Magic Runes</h2>
<div class="input-container">
<textarea id="runesInput" placeholder="Paste JSON or 'MAGIC_RUNES = []' format"></textarea>
<button id="loadRunes">Load Runes</button>
</div>
<div id="runes" class="images-container"></div>
</div>
<script>
const displayImages = (type, imageUrls) => {
const container = document.getElementById(type);
container.innerHTML = "";
if (type === 'circles') {
imageUrls.forEach((url, index) => {
const img = document.createElement("img");
img.src = url;
img.alt = `Circle ${index}`;
container.appendChild(img);
});
} else if (type === 'runes') {
imageUrls.forEach((url, index) => {
const img = document.createElement("img");
img.style.backgroundImage = `url(${url})`;
img.style.height = '50px';
img.style.width = '100%';
img.style.contentVisibility = 'hidden';
img.style.backgroundRepeat = 'repeat-x';
img.style.backgroundSize = 'auto 50px';
img.alt = `Rune ${index}`;
container.appendChild(img);
});
}
new Viewer(container, {
zoomRatio: 0.3,
transition: false,
url: img => img.src || img.style.backgroundImage.replace(/url\(['"](.+)['"]\)/, '$1'),
});
};
const extractImageUrls = (inputText) => {
const regex = /(?<=(MAGIC_CIRCLES|MAGIC_RUNES)\s*=\s*)\[.*?\]/gs;
const matches = inputText.match(regex);
if (!matches) return [];
const jsonArray = JSON.parse(matches[0].replace(/'/g, "\""));
return jsonArray;
};
const loadImages = (type) => {
const inputText = document.getElementById(`${type}Input`).value;
const imageUrls = extractImageUrls(inputText);
displayImages(type, imageUrls);
};
window.onload = async () => {
document.getElementById("circlesInput").value = await (await fetch("https://gist.githubusercontent.com/stepsword/37e6bbd96c0c912cf6d75862050fbf96/raw/5fd38406a6a93a54e7d28814d7b60f774eed61ee/magic_circles.txt")).text()
document.getElementById("runesInput").value = await (await fetch("https://gist.githubusercontent.com/stepsword/37e6bbd96c0c912cf6d75862050fbf96/raw/5fd38406a6a93a54e7d28814d7b60f774eed61ee/magic_runes.txt")).text()
loadImages('circles');
loadImages('runes');
};
document.getElementById("loadCircles").addEventListener("click", () => loadImages('circles'));
document.getElementById("loadRunes").addEventListener("click", () => loadImages('runes'));
</script>
</body>
</html>