drakosfire commited on
Commit
627c8bf
·
2 Parent(s): c11a3c4 cd77173

Merge branch 'feature/docker'

Browse files
.dockerignore ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ignore Python bytecode files
2
+ *.pyc
3
+ __pycache__/
4
+
5
+ # Ignore the Dockerfile and .dockerignore themselves (optional)
6
+ Dockerfile
7
+ .dockerignore
8
+
9
+ # Ignore the environment file
10
+ .env
11
+
12
+ # Ignore test files
13
+ Ebony, the Twisted Fairy_files
14
+ galleries
15
+ output
16
+ app copy.py
17
+ block_builder copy.py
18
+ example_templates.py
19
+ morogors_meaty_inventory.py
20
+ morgors_meaty_marvels.py
21
+ old app.py
22
+ process_text.py
23
+ README.md
24
+ sd_generator copy.py
25
+ sd_generator copy 2.py
26
+ store_json_example.py
27
+ storeUI copy.html
28
+ template.html
29
+ template.py
30
+ utilites.py
.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Python Cache
2
+ __pycache__/
3
+
4
+ # Environment variables
5
+ .env
Dockerfile ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
3
+
4
+ # Set up a new user named "user" with user ID 1000
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Switch to the "user" user
8
+ USER user
9
+
10
+ # Set home to the user's home directory
11
+ ENV HOME=/home/user \
12
+ PATH=/home/user/.local/bin:$PATH
13
+
14
+ # Set the working directory in the container
15
+ WORKDIR $HOME/app
16
+
17
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
18
+ COPY --chown=user . $HOME/app
19
+
20
+ # Install any necessary dependencies specified in requirements.txt
21
+ RUN pip install --no-cache-dir -r requirements.txt
22
+
23
+ # Expose port 5000 for the Flask app
24
+ EXPOSE 7860
25
+
26
+ # Define environment variable to ensure Flask runs the correct application
27
+ ENV FLASK_APP=app.py
28
+ ENV FLASK_ENV=production
29
+
30
+ # Command to run the Flask app
31
+ CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"]
README.md CHANGED
@@ -1,10 +1,28 @@
 
 
 
 
 
 
 
 
 
1
  #Store Generator
2
  ## Another DnD Tool from Drakosfire
3
 
4
  This is a work in progress. I got about 80% of the way to rendering the the Chat GPT 4o generated store into a static html format.
5
  When a friend suggested a different format choice. 3 weeks later I'm writing JavaScript because I've decided what I want is a drag and drop DnD Page formatting tool.
6
  I've got the core functionality built in and am expanding blocks.
7
- Next will be finishing the core block structure based off of The_Mirage_Emporium.html as the static iteration.
 
 
 
 
 
 
 
 
 
8
 
9
  All css in /dependencies comes from the incredible folk at https://github.com/naturalcrit/homebrewery/ as does the original formatting and a whole lot of inspiration.
10
 
 
1
+ ---
2
+ title: Drakosfires Dungeons and Dragons Store Generator
3
+ emoji: 🏪
4
+ colorFrom: yellow
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_port: 7860
8
+ ---
9
+
10
  #Store Generator
11
  ## Another DnD Tool from Drakosfire
12
 
13
  This is a work in progress. I got about 80% of the way to rendering the the Chat GPT 4o generated store into a static html format.
14
  When a friend suggested a different format choice. 3 weeks later I'm writing JavaScript because I've decided what I want is a drag and drop DnD Page formatting tool.
15
  I've got the core functionality built in and am expanding blocks.
16
+ Currently pages are pretty janky and am working to fix.
17
+ Need more user feedback, loading bars.
18
+
19
+ Future additions :
20
+ Gif of talking head for store keeper.
21
+ Use a generated script for rolepplay interaction.
22
+ Voiced output.
23
+ Whisper sync to handle user voice input.
24
+
25
+
26
 
27
  All css in /dependencies comes from the incredible folk at https://github.com/naturalcrit/homebrewery/ as does the original formatting and a whole lot of inspiration.
28
 
__pycache__/store_helper.cpython-310.pyc DELETED
Binary file (7.4 kB)
 
__pycache__/utilities.cpython-310.pyc DELETED
Binary file (3.18 kB)
 
app.py CHANGED
@@ -1,11 +1,9 @@
1
  # this imports the code from files and modules
2
- from flask import Flask, request, jsonify
3
  from flask_cors import CORS
4
- import utilities as u
5
  import os
6
  import ctypes
7
  import store_helper as sh
8
- import process_text
9
  import block_builder
10
  import sd_generator as sd
11
 
@@ -15,14 +13,26 @@ M_MMAP_THRESHOLD = -3
15
 
16
  # Set malloc mmap threshold.
17
  libc.mallopt(M_MMAP_THRESHOLD, 2**20)
18
- # Ensure the directory exists
19
-
20
-
21
 
22
  # Initialize the Flask application
23
  app = Flask(__name__)
24
  os.makedirs('static/images', exist_ok=True)
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  CORS(app)# Route to handle the incoming POST request with user description
27
 
28
  @app.route('/process-description', methods=['POST'])
@@ -57,5 +67,5 @@ def generate_image():
57
  except Exception as e:
58
  return jsonify({'error': str(e)}), 500
59
 
60
- if __name__ == '__main__':
61
- app.run(debug=True)
 
1
  # this imports the code from files and modules
2
+ from flask import Flask, request, jsonify, send_from_directory
3
  from flask_cors import CORS
 
4
  import os
5
  import ctypes
6
  import store_helper as sh
 
7
  import block_builder
8
  import sd_generator as sd
9
 
 
13
 
14
  # Set malloc mmap threshold.
15
  libc.mallopt(M_MMAP_THRESHOLD, 2**20)
 
 
 
16
 
17
  # Initialize the Flask application
18
  app = Flask(__name__)
19
  os.makedirs('static/images', exist_ok=True)
20
 
21
+ # Serve files from the 'dependencies' directory
22
+ @app.route('/dependencies/<path:filename>')
23
+ def custom_static(filename):
24
+ return send_from_directory('dependencies', filename)
25
+
26
+ # Serve HTML files from the main directory
27
+ @app.route('/<path:filename>')
28
+ def serve_html(filename):
29
+ return send_from_directory('.', filename)
30
+
31
+ # Default route for index
32
+ @app.route('/')
33
+ def index():
34
+ return send_from_directory('.', 'storeUI.html') # Make sure this points to your main HTML file
35
+
36
  CORS(app)# Route to handle the incoming POST request with user description
37
 
38
  @app.route('/process-description', methods=['POST'])
 
67
  except Exception as e:
68
  return jsonify({'error': str(e)}), 500
69
 
70
+ if __name__ == "__main__":
71
+ app.run(host="0.0.0.0", port=7860)
block_builder.py CHANGED
@@ -1,8 +1,3 @@
1
- import re, fileinput, sys
2
- import utilities as u
3
- import os
4
- import ast
5
-
6
  # block_id is a global variable that is used to keep track of the current block id
7
  block_id = 0
8
 
 
 
 
 
 
 
1
  # block_id is a global variable that is used to keep track of the current block id
2
  block_id = 0
3
 
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ flask
2
+ flask-cors
3
+ fal_client
4
+ openai
scripts.js ADDED
@@ -0,0 +1,893 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Waits for DOM content to be fully loaded and assigns critical elements to variables.
2
+ let initialPositions = [];
3
+ document.addEventListener("DOMContentLoaded", function() {
4
+ const blockContainer = document.getElementById('blockContainer');
5
+ let blockContainerPage = document.getElementById('block-page');
6
+ const pageContainer = document.getElementById('pages');
7
+ const trashArea = document.getElementById('trashArea');
8
+ const resetButton = document.getElementById('resetButton');
9
+ let currentPage = pageContainer.querySelector('.block.monster.frame.wide');
10
+ const modal = document.getElementById('imageModal');
11
+ const modalImg = document.getElementById('modalImage');
12
+ const captionText = document.getElementById('caption');
13
+ const closeModal = document.getElementsByClassName('close')[0];
14
+ const MAX_COLUMN_HEIGHT = 847;
15
+
16
+ if (!blockContainer || !pageContainer || !trashArea || !currentPage) {
17
+ console.error('Required elements are null');
18
+ return;
19
+ }
20
+ if (!modal) {
21
+ console.error('modal element not found');
22
+ return;
23
+ }
24
+ if (!modalImg) {
25
+ console.error('modalImg element not found');
26
+ return;
27
+ }
28
+ if (!captionText) {
29
+ console.error('captionText element not found');
30
+ return;
31
+ }
32
+ if (!closeModal) {
33
+ console.error('closeModal element not found');
34
+ return;
35
+ }
36
+
37
+ // Event delegation for image clicks
38
+ blockContainer.addEventListener('click', function(event) {
39
+ console.log('Click detected in blockContainer:', event.target);
40
+ if (event.target.tagName === 'IMG' && event.target.id.startsWith('generated-image-')) {
41
+ console.log('Image clicked for modal display. Image ID:', event.target.id);
42
+ modal.style.display = 'block';
43
+ modalImg.src = event.target.src;
44
+ captionText.innerHTML = event.target.alt;
45
+ } else {
46
+ console.log('Clicked element is not an image or does not match ID pattern.');
47
+ }
48
+ });
49
+
50
+ // Function to close the modal
51
+ closeModal.onclick = function() {
52
+ modal.style.display = "none";
53
+ }
54
+
55
+ // Function to close the modal when clicking outside of the modal content
56
+ window.onclick = function(event) {
57
+ if (event.target == modal) {
58
+ modal.style.display = "none";
59
+ }
60
+ }
61
+
62
+ document.getElementById('submitDescription').addEventListener('click', function() {
63
+ const userInput = document.getElementById('user-description').value;
64
+ // Clear the block container before inserting new blocks
65
+ blockContainerPage.innerHTML = '';
66
+ document.getElementById('add-page-button').addEventListener('click', addPage);
67
+ document.getElementById('remove-page-button').addEventListener('click', removePage);
68
+
69
+ fetch('http://127.0.0.1:5000/process-description', {
70
+ method: 'POST',
71
+ headers: {
72
+ 'Content-Type': 'application/json'
73
+ },
74
+ body: JSON.stringify({ user_input: userInput })
75
+ })
76
+ .then(response => response.json())
77
+ .then(data => {
78
+ console.log('Success:', data);
79
+ initialPositions.length = 0; // Clear the initialPositions array
80
+ insertHtmlBlocks(data.html_blocks);
81
+ const blocks = blockContainerPage.querySelectorAll('.block-item');
82
+ blocks.forEach(block => {
83
+ block.setAttribute('data-page-id', 'block-container');
84
+ block.setAttribute('draggable', true);
85
+ block.addEventListener('dragstart', handleDragStart);
86
+ block.addEventListener('dragend', handleDragEnd);
87
+ });
88
+ storeInitialPositions();
89
+ })
90
+ .catch((error) => {
91
+ console.error('Error:', error);
92
+ });
93
+ });
94
+
95
+ window.printPageContainer = function() {
96
+ var pageContainer = document.getElementById('brewRenderer');
97
+ if (pageContainer) {
98
+ var printWindow = window.open('', 'Print Preview', 'height=800,width=600');
99
+
100
+ printWindow.document.write(`
101
+ <!DOCTYPE html>
102
+ <html lang="en">
103
+ <head>
104
+ <meta charset="UTF-8">
105
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
106
+ <link href="./dependencies/all.css" rel="stylesheet">
107
+ <link href="./dependencies/css.css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css">
108
+ <link href="./dependencies/bundle.css" rel="stylesheet">
109
+ <link href="./dependencies/style.css" rel="stylesheet">
110
+ <link href="./dependencies/5ePHBstyle.css" rel="stylesheet">
111
+ <link href="./storeUI.css" rel="stylesheet">
112
+ <title>Print Preview - DnD Stat Block</title>
113
+ <link rel="stylesheet" href="styles.css">
114
+ <style>
115
+ @media print {
116
+
117
+ .page {
118
+ page-break-before: auto;
119
+ page-break-after: avoid;
120
+ page-break-inside: avoid;
121
+
122
+ }
123
+ .columnWrapper {
124
+ overflow: visible;
125
+ }
126
+
127
+ }
128
+ </style>
129
+ </head>
130
+ <body>
131
+ ${pageContainer.innerHTML}
132
+ </body>
133
+ </html>
134
+ `);
135
+
136
+ // Wait for the content to be fully loaded before printing
137
+ printWindow.onload = function() {
138
+ printWindow.print();
139
+ printWindow.close(); // Close the print window after printing
140
+ };
141
+ } else {
142
+ console.error('Element with ID "pages" not found.');
143
+ }
144
+ };
145
+
146
+
147
+ // Store initial positions of the blocks
148
+ function storeInitialPositions() {
149
+ const blocks = blockContainer.querySelectorAll('.block-item');
150
+ blocks.forEach((block, index) => {
151
+ const blockId = block.getAttribute('data-block-id');
152
+ if (!blockId) {
153
+ console.error(`Block at index ${index} is missing data-block-id`);
154
+ }
155
+ initialPositions.push({
156
+ id: blockId,
157
+ index: index
158
+ });
159
+ });
160
+ console.log('Initial positions:', initialPositions);
161
+ }
162
+
163
+ function sortBlocksById() {
164
+ // Select all blocks inside the block-container
165
+ const blocks = Array.from(blockContainerPage.querySelectorAll('.block-item'));
166
+ console.log('Blocks in blockContainerPage:', blocks);
167
+
168
+ // Sort the blocks based on their block-id attribute
169
+ blocks.sort((a, b) => {
170
+ const idA = parseInt(a.getAttribute('data-block-id'), 10);
171
+ const idB = parseInt(b.getAttribute('data-block-id'), 10);
172
+ return idA - idB; // Ascending order
173
+ });
174
+
175
+ // Clear the block-container before re-appending the sorted blocks
176
+ blockContainerPage.innerHTML = '';
177
+
178
+ // Re-append the blocks in the sorted order
179
+ blocks.forEach(block => blockContainerPage.appendChild(block));
180
+
181
+ console.log('Blocks have been sorted and re-appended based on block-id');
182
+ }
183
+
184
+ function reinsertBlock(blockContainerPage, blockId, innerHTML) {
185
+ const originalPosition = initialPositions.find(pos => pos.id === blockId);
186
+ console.log('Original position:', originalPosition);
187
+
188
+ if (originalPosition) {
189
+ const blocks = blockContainerPage.querySelectorAll('.block-item');
190
+ console.log('Blocks in blockContainerPage:', blocks);
191
+
192
+ // Adding debugging output for index details
193
+ console.log(`Attempting to insert block with ID: ${blockId} at original index: ${originalPosition.index}`);
194
+
195
+ const newBlock = document.createElement('div');
196
+ newBlock.classList.add('block-item');
197
+ newBlock.setAttribute('data-block-id', blockId);
198
+ newBlock.setAttribute('data-page-id', 'block-container');
199
+ newBlock.innerHTML = innerHTML;
200
+ newBlock.setAttribute('draggable', true);
201
+ newBlock.addEventListener('dragstart', handleDragStart);
202
+ newBlock.addEventListener('dragend', handleDragEnd);
203
+
204
+ if (originalPosition.index < blocks.length) {
205
+ const referenceNode = blocks[originalPosition.index];
206
+
207
+ // Debugging output to ensure the correct reference node is identified
208
+ console.log(`Reference node index: ${originalPosition.index}, Node:`, referenceNode);
209
+
210
+ if (referenceNode && referenceNode.parentNode === blockContainerPage) {
211
+ console.log(`Inserting before block at index: ${originalPosition.index}`);
212
+ blockContainerPage.insertBefore(newBlock, referenceNode);
213
+ } else {
214
+ console.warn('Reference node does not belong to blockContainerPage, appending to the end');
215
+ blockContainerPage.appendChild(newBlock);
216
+ }
217
+ } else {
218
+ console.log('Original index exceeds current blocks, appending block to the end');
219
+ blockContainerPage.appendChild(newBlock);
220
+ }
221
+ } else {
222
+ console.warn('Original position not found, appending block to the end of blockContainerPage');
223
+ const newBlock = document.createElement('div');
224
+ newBlock.classList.add('block-item');
225
+ newBlock.setAttribute('data-block-id', blockId);
226
+ newBlock.setAttribute('data-page-id', 'block-container');
227
+ newBlock.innerHTML = innerHTML;
228
+ newBlock.setAttribute('draggable', true);
229
+ newBlock.addEventListener('dragstart', handleDragStart);
230
+ newBlock.addEventListener('dragend', handleDragEnd);
231
+
232
+ blockContainerPage.appendChild(newBlock);
233
+ }
234
+
235
+ console.log(`Restored block with ID: ${blockId}`);
236
+ }
237
+
238
+ function insertHtmlBlocks(blocks) {
239
+ console.log('blockContainerPage = ', blockContainerPage)
240
+ console.log('List of blocks:', blocks);
241
+ const parser = new DOMParser();
242
+
243
+ blocks.forEach(blockHtml => {
244
+ console.log('Original blockHtml:', blockHtml);
245
+ // Parse the HTML string
246
+ const doc = parser.parseFromString(blockHtml, 'text/html');
247
+ const block = doc.body.firstChild;
248
+ if (block) {
249
+ blockContainerPage.appendChild(block); // Append the parsed block to the container
250
+ console.log('Appended block:', block);
251
+ }
252
+ });
253
+ // console.log('Final state of blockContainer:', blockContainer.innerHTML);
254
+ initializeTextareaResizing();
255
+ }
256
+
257
+ storeInitialPositions();
258
+
259
+ function adjustTextareaHeight(el) {
260
+ if (el.scrollHeight > 16){
261
+ el.style.height = 'auto';
262
+ el.style.height = (el.scrollHeight) + 'px';
263
+ }
264
+ }
265
+
266
+ function initializeTextareaResizing() {
267
+ const classes = [
268
+ 'description-textarea',
269
+ 'user-description-textarea',
270
+ 'heading-textarea',
271
+ 'properties-textarea',
272
+ 'string-stat-textarea',
273
+ 'string-action-description-textarea',
274
+ ];
275
+
276
+ classes.forEach(className => {
277
+ const textareas = document.querySelectorAll(`.${className}`);
278
+ textareas.forEach(textarea => {
279
+
280
+ // Adjust height on page load
281
+ adjustTextareaHeight(textarea);
282
+ // Adjust height on input
283
+ textarea.addEventListener('input', function() {
284
+ adjustTextareaHeight(textarea);
285
+ console.log('Input event triggered for:', textarea.id); // Debugging line
286
+ });
287
+ });
288
+ });
289
+ }
290
+
291
+ // Initial run on page load
292
+ initializeTextareaResizing();
293
+
294
+ async function extractBlocks() {
295
+ try {
296
+ if (blockContainerPage.children.length > 0) {
297
+ console.log('Blocks already loaded, skipping fetch');
298
+ return;
299
+ }
300
+
301
+ const response = await fetch('template_update.html');
302
+ if (!response.ok) {
303
+ throw new Error('Network response was not ok ' + response.statusText);
304
+ }
305
+
306
+ const text = await response.text();
307
+ const parser = new DOMParser();
308
+ const doc = parser.parseFromString(text, 'text/html');
309
+
310
+ // Selecting all elements with the 'block-item' class
311
+ const blocks = doc.querySelectorAll('.block-item');
312
+
313
+ blocks.forEach((block, index) => {
314
+ const blockContent = block.innerHTML;
315
+ const blockItem = document.createElement('div');
316
+ blockItem.classList.add('block-item');
317
+ blockItem.innerHTML = blockContent;
318
+
319
+ // Assigning unique block ID
320
+ const blockId = `block-${index}`;
321
+ blockItem.setAttribute('data-block-id', blockId);
322
+
323
+ // Setting the page ID and other attributes
324
+ const pageId = 'block-container';
325
+ blockItem.setAttribute('data-page-id', pageId);
326
+ blockItem.setAttribute('draggable', true);
327
+
328
+ // Add event listeners for drag and drop functionality
329
+ blockItem.addEventListener('dragstart', handleDragStart);
330
+ blockItem.addEventListener('dragend', handleDragEnd);
331
+
332
+ console.log(`Loaded block with ID: ${blockId}`);
333
+
334
+ // Append block to the container
335
+ blockContainerPage.appendChild(blockItem);
336
+ });
337
+
338
+ // Store the initial positions of the blocks (if needed for drag and drop)
339
+ storeInitialPositions();
340
+
341
+ } catch (error) {
342
+ console.error('Error fetching and parsing template_update.html:', error);
343
+ }
344
+ }
345
+
346
+
347
+ blockContainer.addEventListener('click', function(event) {
348
+ if (event.target && event.target.classList.contains('generate-image-button')) {
349
+ const blockId = event.target.getAttribute('data-block-id');
350
+ generateImage(blockId);
351
+ }
352
+ });
353
+
354
+ // Function to generate image
355
+ function generateImage(blockId) {
356
+ const sdPromptElement = document.getElementById(`user-storefront-prompt-${blockId}`);
357
+ const imageElement = document.getElementById(`generated-image-${blockId}`);
358
+
359
+ if (!sdPromptElement) {
360
+ console.error('Element with ID user-storefront-prompt not found');
361
+ return;
362
+ }
363
+
364
+ if (!imageElement) {
365
+ console.error('Element with ID generated-image not found');
366
+ return;
367
+ }
368
+
369
+ const sdPrompt = sdPromptElement.value;
370
+
371
+ fetch('/generate-image', {
372
+ method: 'POST',
373
+ headers: {
374
+ 'Content-Type': 'application/json'
375
+ },
376
+ body: JSON.stringify({ sd_prompt: sdPrompt })
377
+ })
378
+ .then(response => response.json())
379
+ .then(data => {
380
+ console.log('Received data:', data);
381
+ imageElement.src = data.image_url;
382
+ imageElement.style.display = 'block';
383
+
384
+ // Log the image element's HTML structure
385
+ console.log('Updated imageElement HTML:', imageElement.outerHTML);
386
+ })
387
+ .catch((error) => {
388
+ console.error('Error:', error);
389
+ });
390
+ }
391
+
392
+ function lockTextareas() {
393
+ const textareas = document.querySelectorAll('textarea');
394
+
395
+ textareas.forEach(textarea => {
396
+ textarea.setAttribute('disabled', true);
397
+ });
398
+
399
+ const descriptionTextareas = document.querySelectorAll('.description-textarea');
400
+
401
+ descriptionTextareas.forEach(descriptionTextarea => {
402
+ descriptionTextarea.removeAttribute('contenteditable');
403
+ });
404
+
405
+ console.log('All textareas have been locked.');
406
+ }
407
+
408
+ function unlockTextareas() {
409
+ const textareas = document.querySelectorAll('textarea');
410
+
411
+ textareas.forEach(textarea => {
412
+ textarea.removeAttribute('disabled');
413
+ });
414
+
415
+ const descriptionTextareas = document.querySelectorAll('.description-textarea');
416
+
417
+ descriptionTextareas.forEach(descriptionTextarea => {
418
+ descriptionTextarea.setAttribute('contenteditable', 'true');
419
+ });
420
+
421
+ console.log('All textareas have been unlocked.');
422
+ }
423
+
424
+ function handleDragStart(e) {
425
+ lockTextareas();
426
+ const target = e.target.closest('.block-item, .block-content');
427
+ if (!target) {
428
+ console.error('Drag started for an element without a valid target');
429
+ return;
430
+ }
431
+ const blockId = target.getAttribute('data-block-id');
432
+ const pageId = target.getAttribute('data-page-id');
433
+ if (!blockId) {
434
+ console.error('Drag started for an element without a data-block-id');
435
+ return;
436
+ }
437
+ if (!pageId) {
438
+ console.error('Drag started for an element without a data-page-id');
439
+ return;
440
+ }
441
+
442
+ // Store the block ID and inner HTML in the data transfer object
443
+ const innerHTML = target.innerHTML;
444
+ e.dataTransfer.setData('block-id', blockId);
445
+ e.dataTransfer.setData('text/plain', innerHTML); // Store inner HTML
446
+ e.dataTransfer.setData('data-page-id', pageId); // Store original page ID
447
+ e.dataTransfer.effectAllowed = 'move';
448
+ target.style.opacity = '0.4';
449
+
450
+ // Create an invisible drag image
451
+ const dragImage = document.createElement('div');
452
+ dragImage.style.width = '1px';
453
+ dragImage.style.height = '1px';
454
+ dragImage.style.opacity = '0';
455
+ document.body.appendChild(dragImage);
456
+ e.dataTransfer.setDragImage(dragImage, 0, 0);
457
+
458
+ console.log(`Drag started for block ID: ${blockId} page ID: ${pageId}`);
459
+ }
460
+
461
+ function handleDragEnd(e) {
462
+ const target = e.target.closest('.block-item, .block-content');
463
+ if (target) {
464
+ target.style.opacity = '1'; // Reset the opacity
465
+ const blockId = target.getAttribute('data-block-id');
466
+ console.log(`Drag ended for block ID: ${blockId}`);
467
+ }
468
+
469
+ // Remove highlight classes from pages and blocks
470
+ document.querySelectorAll('.highlight-page').forEach(el => el.classList.remove('highlight-page'));
471
+ document.querySelectorAll('.highlight-block').forEach(el => el.classList.remove('highlight-block'));
472
+ document.querySelectorAll('.highlight-block-top').forEach(el => el.classList.remove('highlight-block-top'));
473
+ unlockTextareas()
474
+
475
+ }
476
+
477
+ function handleDragOver(e) {
478
+ e.preventDefault();
479
+ // Get the element currently under the cursor
480
+ const elementUnderCursor = document.elementFromPoint(e.clientX, e.clientY);
481
+
482
+ if (elementUnderCursor) {
483
+ // Check if the element is a block or textarea
484
+ if (elementUnderCursor.classList.contains('block-item')) {
485
+ console.log('Dragging over a block-item:', elementUnderCursor);
486
+ console.log('Block ID:', elementUnderCursor.getAttribute('data-block-id'));
487
+ } else if (elementUnderCursor.tagName === 'TEXTAREA') {
488
+ console.log('Dragging over a textarea:', elementUnderCursor);
489
+ } else {
490
+ // Log other elements if needed
491
+ console.log('Dragging over another element:', elementUnderCursor.tagName);
492
+ }
493
+ }
494
+ // Check if the drop target is a TEXTAREA or any other non-droppable area
495
+ if (e.target.tagName === 'TEXTAREA' || e.target.closest('.block-item')) {
496
+ e.dataTransfer.dropEffect = 'none'; // Indicate that drop is not allowed
497
+ return;
498
+ }
499
+ e.dataTransfer.dropEffect = 'move'; // Indicate that drop is allowed
500
+
501
+ const targetPage = e.target.closest('.page');
502
+ if (targetPage) {
503
+ targetPage.classList.add('highlight-page'); // Add highlight class for pages
504
+ }
505
+
506
+ const targetBlock = e.target.closest('.block-item, .block-content');
507
+ if (targetBlock) {
508
+ const bounding = targetBlock.getBoundingClientRect();
509
+ const offset = e.clientY - bounding.top;
510
+ if (offset > bounding.height / 2) {
511
+ targetBlock.classList.add('highlight-block');
512
+ targetBlock.classList.remove('highlight-block-top');
513
+ } else {
514
+ targetBlock.classList.add('highlight-block-top');
515
+ targetBlock.classList.remove('highlight-block');
516
+ }
517
+ }
518
+ }
519
+
520
+ function handleDrop(e) {
521
+ e.preventDefault();
522
+ // Ensure we are not dropping into a textarea or another block
523
+ if (e.target.classList.contains('block-item', 'block-content', 'description-textarea') || e.target.tagName === 'TEXTAREA') {
524
+ console.log('Cannot drop block inside another block or textarea');
525
+ return;
526
+ }
527
+ const blockId = e.dataTransfer.getData('block-id');
528
+ const originalPageId = e.dataTransfer.getData('data-page-id');
529
+ const innerHTML = e.dataTransfer.getData('text/plain');
530
+ console.log(`Drop event for block ID: ${blockId} from page ID: ${originalPageId}`);
531
+
532
+ if (blockId && originalPageId) {
533
+ const originalBlock = document.querySelector(`[data-block-id="${blockId}"]`);
534
+ const newPage = e.target.closest('.page');
535
+ console.log(`Over page ${newPage} from page ID: ${originalPageId}`);
536
+ const newPageId = newPage.getAttribute('data-page-id');
537
+
538
+ // Ensure the original block exists before proceeding
539
+ if (!originalBlock || !newPage) {
540
+ console.error(`Block with ID ${blockId} on page ${originalPageId} not found`);
541
+
542
+ return;
543
+ }
544
+
545
+ const newBlockContent = document.createElement('div');
546
+ newBlockContent.classList.add('block-content');
547
+ newBlockContent.innerHTML = originalBlock.innerHTML; // Transfer inner content only
548
+
549
+ // Add necessary attributes and event listeners
550
+ newBlockContent.setAttribute('data-block-id', blockId);
551
+ newBlockContent.setAttribute('data-page-id', newPageId);
552
+ console.log('newPageID:', newPageId);
553
+ newBlockContent.setAttribute('draggable', true);
554
+ newBlockContent.addEventListener('dragstart', handleDragStart);
555
+ newBlockContent.addEventListener('dragend', handleDragEnd);
556
+
557
+ const target = e.target.closest('.block-item, .block-content');
558
+ let targetColumn = 1;
559
+ if (target) {
560
+ const bounding = target.getBoundingClientRect();
561
+ const offset = e.clientY - bounding.top;
562
+
563
+ console.log('Drop target found:', target);
564
+ console.log('Bounding rectangle:', bounding);
565
+ console.log('Offset from top:', offset);
566
+ console.log('Target height:', bounding.height);
567
+ console.log('Insert before or after decision point (height / 2):', bounding.height / 2);
568
+
569
+ targetColumn = getColumnFromOffset(target, offset);
570
+ if (offset > bounding.height / 2) {
571
+ console.log('Inserting after the target');
572
+ target.parentNode.insertBefore(newBlockContent, target.nextSibling);
573
+
574
+ } else {
575
+ console.log('Inserting before the target');
576
+ target.parentNode.insertBefore(newBlockContent, target);
577
+
578
+ }
579
+
580
+ // Remove highlight borders
581
+ target.style['border-bottom'] = '';
582
+ target.style['border-top'] = '';
583
+ } else {
584
+ console.log('No valid drop target found, appending to the end');
585
+ newPage.querySelector('.block.monster.frame.wide').appendChild(newBlockContent);
586
+
587
+ }
588
+
589
+ // Remove the original block from the original container
590
+ originalBlock.parentNode.removeChild(originalBlock);
591
+
592
+ // Reset opacity of dragged element
593
+ newBlockContent.style.opacity = '1';
594
+ console.log(`Moved existing block with ID: ${blockId} to page ID: ${newPageId}`);
595
+ initializeTextareaResizing();
596
+ // Adjust layouts
597
+ if (originalPageId !== 'block-container') {
598
+ adjustPageLayout(originalPageId);
599
+ }
600
+ adjustPageLayout(newPageId, targetColumn);
601
+ } else {
602
+ console.log('No data transferred');
603
+ }
604
+
605
+ }
606
+
607
+ function getColumnFromOffset(block, offset) {
608
+ const page = block.closest('.page');
609
+ if (!page) return 1;
610
+ const columnWrapper = page.querySelector('.columnWrapper');
611
+ const columnWrapperRect = columnWrapper.getBoundingClientRect();
612
+ const relativeOffset = offset - columnWrapperRect.left; // Calculate the offset relative to the column wrapper
613
+ const columnWidth = columnWrapper.clientWidth / 2; // Assuming two columns
614
+
615
+ // Log details for debugging
616
+ console.log('Block offset:', offset);
617
+ console.log('Relative offset:', relativeOffset);
618
+
619
+ const columnNumber = Math.ceil(relativeOffset / columnWidth);
620
+
621
+ // Ensure the column number is within valid bounds (1 or 2)
622
+ const validColumnNumber = Math.min(Math.max(columnNumber, 1), 2);
623
+
624
+
625
+ return validColumnNumber;
626
+ }
627
+
628
+
629
+ // Function to get the height of a column by index
630
+ function getColumnHeights(pageElement) {
631
+ const columns = [0, 0]; // Assuming two columns for simplicity
632
+ const blocks = pageElement.querySelectorAll('.block-content');
633
+ blocks.forEach(block => {
634
+ const column = getColumnFromOffset(block, block.getBoundingClientRect().left);
635
+ columns[column - 1] += block.offsetHeight;
636
+ });
637
+ return columns;
638
+ }
639
+
640
+ function adjustPageLayout(pageId) {
641
+ const page = document.querySelector(`[data-page-id="${pageId}"]`);
642
+ if (!page) {
643
+ console.error(`Page with ID ${pageId} not found`);
644
+ return;
645
+ }
646
+
647
+ const columnHeights = getColumnHeights(page);
648
+ console.log(`Total height of columns in ${pageId}: ${columnHeights}`);
649
+
650
+ for (let i = 0; i < columnHeights.length; i++) {
651
+ if (columnHeights[i] > MAX_COLUMN_HEIGHT) {
652
+ console.log(`Column ${i + 1} in ${pageId} exceeds max height, total height: ${columnHeights[i]}px`);
653
+ handleColumnOverflow(page, i + 1);
654
+ }
655
+ }
656
+ }
657
+
658
+ let pageCounter = 1;
659
+ // Function to create new page
660
+ function addPage() {
661
+ const newPage = document.createElement('div');
662
+ newPage.classList.add('page');
663
+ newPage.setAttribute('data-page-id', `page-${pageCounter}`);
664
+ newPage.id = `page-${pageCounter}`;
665
+
666
+ const columnWrapper = document.createElement('div');
667
+ columnWrapper.classList.add('columnWrapper');
668
+
669
+ const newMonsterFrame = document.createElement('div');
670
+ newMonsterFrame.classList.add('block', 'monster', 'frame', 'wide');
671
+
672
+ columnWrapper.appendChild(newMonsterFrame);
673
+ newPage.appendChild(columnWrapper);
674
+ pageContainer.appendChild(newPage);
675
+
676
+ currentPage = newMonsterFrame;
677
+ console.log(`Created new page with ID: ${newPage.id}`);
678
+
679
+ // Add event listeners to the new currentPage
680
+ currentPage.addEventListener('dragover', handleDragOver);
681
+ currentPage.addEventListener('drop', handleDrop);
682
+
683
+ pageCounter++;
684
+ return newPage;
685
+ }
686
+
687
+ function removePage() {
688
+ const pages = pageContainer.querySelectorAll('.page');
689
+
690
+ if (pages.length > 1) { // Ensure at least one page remains
691
+ const lastPage = pages[pages.length - 1];
692
+ pageContainer.removeChild(lastPage);
693
+ console.log(`Page removed with ID: ${lastPage.id}`);
694
+ } else {
695
+ console.log('Cannot remove the last page.');
696
+ }
697
+ }
698
+
699
+ function handleColumnOverflow(page, targetColumn) {
700
+ console.log(`Handling overflow for page ID: ${page.getAttribute('data-page-id')} in column ${targetColumn}`);
701
+ const blocks = Array.from(page.querySelectorAll('.block-content'));
702
+ let columnHeights = [0, 0];
703
+ let overflowStartIndex = -1;
704
+
705
+ // Find the start index where overflow begins in the target column
706
+ blocks.forEach((block, index) => {
707
+ const column = getColumnFromOffset(block, block.getBoundingClientRect().left);
708
+ columnHeights[column - 1] += block.offsetHeight;
709
+ if (column === 2 && columnHeights[1] > MAX_COLUMN_HEIGHT && overflowStartIndex === -1) {
710
+ overflowStartIndex = index;
711
+ }
712
+ });
713
+
714
+ // If no overflow, return early
715
+ if (overflowStartIndex === -1) {
716
+ return;
717
+ }
718
+ const overflowBlocks = blocks.slice(overflowStartIndex);
719
+ const overflowHeight = overflowBlocks.reduce((acc, block) => acc + block.offsetHeight, 0);
720
+
721
+ // Get the next page if it exists
722
+ const nextPage = getNextPage(page);
723
+ if (nextPage) {
724
+ const nextPageBlocks = nextPage.querySelectorAll('.block-content, .block-item');
725
+ let nextPageColumnHeights = [0, 0];
726
+
727
+ nextPageBlocks.forEach(block => {
728
+ const column = getColumnFromOffset(block, block.getBoundingClientRect().left);
729
+ nextPageColumnHeights[column - 1] += block.offsetHeight;
730
+ });
731
+
732
+ // Check if there's enough space in the target column of the next page
733
+ if (nextPageColumnHeights[targetColumn - 1] + overflowHeight <= MAX_COLUMN_HEIGHT) {
734
+ const nextPageContainer = nextPage.querySelector('.block.monster.frame.wide');
735
+ overflowBlocks.forEach(block => {
736
+ nextPageContainer.appendChild(block);
737
+ block.setAttribute('data-page-id', nextPage.getAttribute('data-page-id'));
738
+ });
739
+ return;
740
+ }
741
+ }
742
+
743
+ // Otherwise, create a new page and move the overflowing blocks there
744
+ const newPage = addPage();
745
+ if (!newPage) {
746
+ console.error('Failed to create a new page');
747
+ return;
748
+ }
749
+ const newMonsterFrame = newPage.querySelector('.block.monster.frame.wide');
750
+ if (!newMonsterFrame) {
751
+ console.error('New monster frame not found in the new page');
752
+ return;
753
+ }
754
+
755
+ overflowBlocks.forEach(block => {
756
+ newMonsterFrame.appendChild(block);
757
+ block.setAttribute('data-page-id', newPage.getAttribute('data-page-id'));
758
+ });
759
+ console.log(`Moved overflowing blocks to new page with ID: ${newPage.getAttribute('data-page-id')}`);
760
+ }
761
+
762
+ // Utility function to get the next page element
763
+ function getNextPage(currentPage) {
764
+ const nextPageId = parseInt(currentPage.getAttribute('data-page-id').split('-')[1]) + 1;
765
+ return document.querySelector(`[data-page-id="page-${nextPageId}"]`);
766
+ }
767
+
768
+ // Handle the drop event on the trash area
769
+ function handleTrashDrop(e) {
770
+ e.preventDefault();
771
+ const innerHTML = e.dataTransfer.getData('text/plain');
772
+ const blockId = e.dataTransfer.getData('block-id');
773
+ console.log('Trash Drop event:', e);
774
+ console.log('Dragged block ID to trash:', blockId);
775
+
776
+ if (innerHTML && blockId) {
777
+ // Find the dragged element and remove it from the DOM
778
+ let draggedElement = document.querySelector(`[data-block-id="${blockId}"].block-content`);
779
+ if (!draggedElement) {
780
+ draggedElement = document.querySelector(`[data-block-id="${blockId}"].block-item`);
781
+ }
782
+ if (draggedElement && draggedElement.parentElement) {
783
+ draggedElement.parentElement.removeChild(draggedElement);
784
+ console.log(`Removed block with ID: ${blockId} from the page`);
785
+ }
786
+
787
+ // Check if the block already exists in the block-container and remove it if it does
788
+ let existingBlock = blockContainer.querySelector(`[data-block-id="${blockId}"].block-content`);
789
+ if (!existingBlock) {
790
+ existingBlock = blockContainer.querySelector(`[data-block-id="${blockId}"].block-item`);
791
+ }
792
+ if (existingBlock && existingBlock.parentElement) {
793
+ existingBlock.parentElement.removeChild(existingBlock);
794
+ console.log(`Removed duplicate block with ID: ${blockId} from block-container`);
795
+ }
796
+
797
+ // Ensure the block is appended to the page wrapper inside blockContainer
798
+ let blockContainerPage = blockContainer.querySelector('.page');
799
+ if (!blockContainerPage) {
800
+ blockContainerPage = document.createElement('div');
801
+ blockContainerPage.classList.add('page');
802
+ blockContainerPage.setAttribute('data-page-id', 'block-container');
803
+ blockContainer.appendChild(blockContainerPage);
804
+ }
805
+
806
+ // Reinsert the block using the refactored function
807
+ reinsertBlock(blockContainerPage, blockId, innerHTML);
808
+ sortBlocksById();
809
+ } else {
810
+ console.log('No data transferred');
811
+ }
812
+ // Remove the "over" class and reset the background image
813
+ trashArea.classList.remove('over');
814
+ trashArea.style.backgroundImage = "url('./closed-mimic-trashcan.png')";
815
+
816
+ initializeTextareaResizing();
817
+ }
818
+
819
+ function handleTrashOver(e) {
820
+ e.preventDefault();
821
+ e.dataTransfer.dropEffect = 'move';
822
+ trashArea.classList.add('over');
823
+ trashArea.style.backgroundImage = "url('./mimic_trashcan.png')";
824
+ console.log('Trash over event');
825
+ }
826
+
827
+ function handleTrashLeave(e) {
828
+ trashArea.classList.remove('over');
829
+ trashArea.style.backgroundImage = "url('./closed-mimic-trashcan.png')";
830
+ console.log('Trash leave event');
831
+ }
832
+
833
+ function handleReset() {
834
+ console.log('Reset button clicked');
835
+
836
+ // Collect all blocks from all pages
837
+ const allBlocks = [];
838
+ const pages = document.querySelectorAll('.page');
839
+ pages.forEach(page => {
840
+ const blocksOnPage = page.querySelectorAll('[data-block-id]');
841
+ blocksOnPage.forEach(block => {
842
+ const blockId = block.getAttribute('data-block-id');
843
+ allBlocks.push({
844
+ id: blockId,
845
+ innerHTML: block.innerHTML
846
+ });
847
+ block.remove();
848
+ console.log(`Removed block with ID: ${blockId} from page ID: ${page.getAttribute('data-page-id')}`);
849
+ });
850
+ });
851
+
852
+ // Clear all pages
853
+ pages.forEach(page => page.remove());
854
+
855
+ // Clear blockContainer before reinserting blocks
856
+ blockContainer.innerHTML = '';
857
+
858
+ // Reinsert blocks back into the blockContainer in their original order
859
+
860
+ if (!blockContainerPage) {
861
+ blockContainerPage = document.createElement('div');
862
+ blockContainerPage.classList.add('page');
863
+ blockContainerPage.setAttribute('id', 'block-page');
864
+ blockContainer.appendChild(blockContainerPage);
865
+ }
866
+ // Reassign blockContainerPage to the newly created block-page element
867
+ blockContainerPage = document.getElementById('block-page');
868
+
869
+ initialPositions.forEach(pos => {
870
+ const blockData = allBlocks.find(block => block.id === pos.id);
871
+ if (blockData) {
872
+ reinsertBlock(blockContainerPage, blockData.id, blockData.innerHTML);
873
+ sortBlocksById();
874
+ }
875
+ });
876
+ addPage();
877
+
878
+ console.log('Reset complete, all blocks moved back to block-container');
879
+ initializeTextareaResizing();
880
+ }
881
+
882
+
883
+ blockContainer.addEventListener('dragover', handleDragOver);
884
+ blockContainer.addEventListener('drop', handleDrop);
885
+ pageContainer.addEventListener('dragover', handleDragOver);
886
+ pageContainer.addEventListener('drop', handleDrop);
887
+
888
+ trashArea.addEventListener('dragover', handleTrashOver);
889
+ trashArea.addEventListener('dragleave', handleTrashLeave);
890
+ trashArea.addEventListener('drop', handleTrashDrop);
891
+ resetButton.addEventListener('click', handleReset);
892
+ extractBlocks();
893
+ });
storeUI.css ADDED
@@ -0,0 +1,537 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --HB_Color_Background: #EEE5CE;
3
+ --HB_Color_Accent: #E0E5C1;
4
+ --HB_Color_HeaderUnderline: #C0AD6A;
5
+ --HB_Color_HorizontalRule: #9C2B1B;
6
+ --HB_Color_HeaderText: #58180D;
7
+ --HB_Color_MonsterStatBackground: #F2E5B5;
8
+ --HB_Color_CaptionText: #766649;
9
+ --HB_Color_WatercolorStain: #BBAD82;
10
+ --HB_Color_Footnotes: #C9AD6A;
11
+ }
12
+ input[type="text"], textarea {
13
+ width: auto;
14
+ padding: 8px;
15
+ margin: 5px 0;
16
+ border: 1px solid #ccc;
17
+ border-radius: 4px;
18
+ font-size: 14px;
19
+ background-color: #f9f9f9;
20
+ transition: background-color 0.3s ease, border-color 0.3s ease;
21
+ }
22
+ .grid-container {
23
+ display: grid;
24
+ grid-template-columns: 1fr 3fr; /* Two columns with the second column being three times as wide */
25
+ grid-gap: 20px;
26
+ padding: 20px;
27
+ height: 100vh;
28
+ }
29
+ .block-container {
30
+ position: fixed; /* Lock the block-container in place */
31
+ top: 20px; /* Distance from the top of the viewport */
32
+ left: 20px; /* Distance from the left of the viewport */
33
+ width: 450px; /* Set the width of the block-container */
34
+ height: calc(100vh - 40px); /* Full viewport height minus top and bottom padding */
35
+ overflow-y: auto; /* Enable vertical scrolling if needed */
36
+ border-right: 1px solid #ccc; /* Right border for visual separation */
37
+ padding-right: 20px; /* Padding inside the block-container */
38
+ box-sizing: border-box; /* Include padding and border in the element's total width and height */
39
+ background-color: #f9f9f9; /* Background color */
40
+ z-index: 1000; /* Ensure it is on top of other elements */
41
+ }
42
+
43
+ .block-container .page {
44
+ column-count: 1;
45
+ padding: 0;
46
+ width: 425px;
47
+ height: auto; /* Allow the page to expand to fit content */
48
+ overflow: visible; /* Allow content to overflow if necessary */
49
+ page-break-before: auto;
50
+ page-break-after: auto;
51
+
52
+ }
53
+ .page-container {
54
+ margin-left: 450px; /* Offset the page content by the width of block-container plus margin */
55
+ width: 900px;
56
+ padding: 20px;
57
+ overflow: auto; /* Enable scrolling if needed */
58
+ height: 100vh; /* Full viewport height */
59
+ box-sizing: border-box; /* Include padding and border in the element's total width and height */
60
+ }
61
+
62
+ @media print {
63
+
64
+ .page {
65
+ page-break-before: auto;
66
+ page-break-after: avoid;
67
+ page-break-inside: avoid;
68
+
69
+ }
70
+ .columnWrapper {
71
+ overflow: visible;
72
+ }
73
+ .block-content {
74
+ margin-bottom: 0;
75
+ }
76
+ }
77
+
78
+
79
+ .page {
80
+ column-count: 2;
81
+ column-gap: .9cm;
82
+ column-width: 8cm;
83
+ -webkit-column-count: 2;
84
+ -moz-column-count: 2;
85
+ -webkit-column-width: 8cm;
86
+ -moz-column-width: 8cm;
87
+ -webkit-column-gap: .9cm;
88
+ -moz-column-gap: .9cm;
89
+ position: relative;
90
+ z-index: 15;
91
+ box-sizing: border-box;
92
+ width: 215.9mm;
93
+ height: 279.4mm; /* Original height for print layout */
94
+ padding: 1.4cm 1.2cm 1.7cm;
95
+ overflow: hidden;
96
+ font-family: "BookInsanityRemake";
97
+ font-size: .34cm;
98
+ counter-increment: phb-page-numbers;
99
+ background-color: var(--HB_Color_Background);
100
+ background-image: url('./themes/assets/parchmentBackground.jpg');
101
+ text-rendering: optimizeLegibility;
102
+ page-break-before: always;
103
+ page-break-after: always;
104
+ contain: size;
105
+
106
+ }
107
+
108
+ .page .monster hr:last-of-type + * {
109
+ margin-top: .1cm;
110
+ }
111
+ .page * + h3 {
112
+ margin-top: .05cm;
113
+ }
114
+ .page * + h4 {
115
+ margin-top: .1cm;
116
+ }
117
+ .page h4 + * {
118
+ margin-top: .1cm;
119
+ }
120
+ .page dl + * {
121
+ margin-top: .1cm;
122
+ }
123
+ .page p + * {
124
+ margin-top: .1cm;
125
+ }
126
+ .page img {
127
+ width: 100%;
128
+ height: auto;
129
+ cursor: pointer;
130
+ }
131
+ .page .classTable.frame{
132
+ width: 95%;
133
+ margin-right:0.1cm;
134
+ margin-left: 0.1cm;
135
+ }
136
+
137
+ /* Ensure the h1 tag is constrained within its column */
138
+ .block-content h1 {
139
+ column-span: none;
140
+ box-sizing: border-box; /* Include padding and border in the element's total width and height */
141
+ margin: 0 auto; /* Center the h1 within the column */
142
+ overflow: hidden; /* Handle overflow content */
143
+ word-wrap: break-word; /* Break long words to prevent overflow */
144
+ }
145
+ .columnWrapper {
146
+ width: 100%;
147
+ column-gap: inherit;
148
+ max-height: 100%;
149
+ column-span: all;
150
+ columns: inherit;
151
+ height: 100%; /* Ensure it takes full height of the parent */
152
+ box-sizing: border-box; /* Ensures padding and border are included in the element's total width and height */
153
+ }
154
+ /* block-item styling */
155
+ .block-item {
156
+ border: 1px solid #ccc;
157
+ border-radius: 8px;
158
+ background-color: transparent;
159
+ padding: 15px;
160
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
161
+ transition: transform 0.3s;
162
+ }
163
+ .block-item:hover {
164
+ transform: translateY(-5px);
165
+ background-color: rgba(255, 255, 255, 0.5); /* Slightly visible background on hover */
166
+ }
167
+
168
+ .block-item img {
169
+ width: 100%;
170
+ height: auto;
171
+ cursor: pointer;
172
+ }
173
+
174
+ /* Modal styling */
175
+ .modal {
176
+ display: none; /* Hidden by default */
177
+ position: fixed; /* Stay in place */
178
+ z-index: 1001; /* Sit on top */
179
+ left: 0;
180
+ top: 0;
181
+ width: 100%; /* Full width */
182
+ height: 100%; /* Full height */
183
+ overflow: auto; /* Enable scroll if needed */
184
+ background-color: rgb(0,0,0); /* Fallback color */
185
+ background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
186
+ }
187
+
188
+ .modal-content {
189
+ margin: auto;
190
+ display: block;
191
+ width: 80%;
192
+ max-width: 700px;
193
+ }
194
+
195
+ .modal-content, #caption {
196
+ animation-name: zoom;
197
+ animation-duration: 0.6s;
198
+ }
199
+
200
+ @keyframes zoom {
201
+ from {transform: scale(0)}
202
+ to {transform: scale(1)}
203
+ }
204
+
205
+ .close {
206
+ position: absolute;
207
+ top: 15px;
208
+ right: 35px;
209
+ color: #f1f1f1;
210
+ font-size: 40px;
211
+ font-weight: bold;
212
+ transition: 0.3s;
213
+ }
214
+
215
+ .close:hover,
216
+ .close:focus {
217
+ color: #bbb;
218
+ text-decoration: none;
219
+ cursor: pointer;
220
+ }
221
+ input[type="text"]:focus, textarea:focus {
222
+ background-color: #e9e9e9;
223
+ border-color: #aaa;
224
+ outline: none;
225
+ }
226
+
227
+ /* Specific styles for different textboxes */
228
+
229
+ .user-description-textarea {
230
+ width: 400px;
231
+ height: 40px; /* Adjust as needed for 3 lines */
232
+ resize: vertical;
233
+ background: none;
234
+ font-family: "ScalySansRemake";
235
+ font-weight: 800;
236
+
237
+ }
238
+ /* Focus styles for description textbox */
239
+ .user-description-textarea:focus {
240
+ background-color: #e9e9e9;
241
+ border-color: #aaa;
242
+ outline: none;
243
+ }
244
+
245
+ .heading-textarea {
246
+ width: 100%;
247
+ font-size: .458cm; /* Matches the font size of an h4 heading */
248
+ line-height: .7em;
249
+ font-weight: 800;
250
+ border: none;
251
+ background: none;
252
+ margin: 0;
253
+ padding: 0;
254
+ resize: none; /* Prevents the textarea from being resizable */
255
+ overflow: hidden; /* Prevents scrollbars */
256
+ outline: none; /* Removes the focus outline */
257
+ font-family: "MrEavesRemake"; /* Ensures font family is inherited */
258
+ color: var(--HB_Color_HeaderText)
259
+
260
+ }
261
+ .title-textarea{
262
+ height:30px;
263
+ width: 100%;
264
+ margin-bottom: 5px;
265
+ column-span: all;
266
+ font-size: .89cm;
267
+ line-height: 1em;
268
+ font-family: "MrEavesRemake";
269
+ font-weight: 800;
270
+ color: var(--HB_Color_HeaderText);
271
+ border: 0;
272
+ font: inherit;
273
+ background: none;
274
+ padding: 0;
275
+ resize: none; /* Prevents the textarea from being resizable */
276
+ overflow: hidden; /* Prevents scrollbars */
277
+ outline: none; /* Removes the focus outline */
278
+
279
+ }
280
+
281
+ .subtitle-textarea{
282
+ height:20px;
283
+ width: 100%;
284
+ margin-bottom: 5px;
285
+ column-span: all;
286
+ font-size: .89cm;
287
+ line-height: 1em;
288
+ font-family: "MrEavesRemake";
289
+ font-weight: 800;
290
+ color: var(--HB_Color_HeaderText);
291
+ border: 0;
292
+ font: inherit;
293
+ background: none;
294
+ padding: 0;
295
+ resize: none; /* Prevents the textarea from being resizable */
296
+ overflow: hidden; /* Prevents scrollbars */
297
+ outline: none; /* Removes the focus outline */
298
+
299
+ }
300
+
301
+ div[contenteditable="true"]:focus {
302
+ background-color: #e9e9e9;
303
+ border-color: #aaa;
304
+ outline: none;
305
+ }
306
+
307
+ div[contenteditable="true"] p::first-letter {
308
+ float: left;
309
+ padding-bottom: 2px;
310
+ padding-left: 40px;
311
+ margin-top: 0cm;
312
+ margin-bottom: -20px;
313
+ margin-left: -40px;
314
+ font-family: "SolberaImitationRemake";
315
+ font-size: 3.5cm;
316
+ line-height: 1em;
317
+ color: rgba(0, 0, 0, 0);
318
+ background-image: linear-gradient(-45deg, #322814, #998250, #322814);
319
+ -webkit-background-clip: text;
320
+ background-clip: text;
321
+ border: 0;
322
+ }
323
+ .properties-textarea {
324
+ width: 100%;
325
+ font-size: 12px;
326
+ font-weight: 400;
327
+ line-height: .7em;
328
+ margin-bottom: 0;
329
+ font-style: italic;
330
+ box-sizing: border-box;
331
+ border: 0;
332
+ font-family: "ScalySansRemake";
333
+ vertical-align: baseline;
334
+ margin: 0;
335
+ padding: 0;
336
+ overflow-wrap: break-word;
337
+ text-rendering: optimizeLegibility;
338
+ background: none;
339
+ resize: none; /* Prevents the textarea from being resizable */
340
+
341
+ }
342
+
343
+ .description-textarea {
344
+ width: 100%;
345
+ height: auto;
346
+ font-size: .318cm;
347
+ font-weight: 400;
348
+ line-height: .9em;
349
+ margin-bottom: 0;
350
+ font-style: italic;
351
+ box-sizing: border-box;
352
+ border: 0;
353
+ font-family: "ScalySansSmallCapsRemake";
354
+ vertical-align: baseline;
355
+ margin: 0;
356
+ padding: 0;
357
+ overflow-wrap: break-word;
358
+ text-rendering: optimizeLegibility;
359
+ background: none;
360
+ resize: none; /* Prevents the textarea from being manually resizable */
361
+ overflow: hidden; /* Hide scrollbars */
362
+ }
363
+
364
+ .red-integer-stat-textarea {
365
+ width: 20px;
366
+ height:13px;
367
+ font-size: .318cm;
368
+ font-weight: 400;
369
+ line-height: 1.2em;
370
+ margin-bottom: 0;
371
+ font-style: italic;
372
+ box-sizing: border-box;
373
+ border: 0;
374
+ font-family: "ScalySansSmallCapsRemake";
375
+ vertical-align: baseline;
376
+ margin: 0;
377
+ padding: 0;
378
+ overflow-wrap: break-word;
379
+ text-rendering: optimizeLegibility;
380
+ background: none;
381
+ resize: none; /* Prevents the textarea from being manually resizable */
382
+ overflow: hidden; /* Hide scrollbars */
383
+ color: var(--HB_Color_HeaderText);
384
+ white-space: pre-line;
385
+ }
386
+
387
+ .integer-stat-textarea {
388
+ width: 20px;
389
+ height:13px;
390
+ font-size: .318cm;
391
+ font-weight: 400;
392
+ line-height: 1.2em;
393
+ margin-bottom: 0;
394
+ font-style: italic;
395
+ box-sizing: border-box;
396
+ border: 0;
397
+ font-family: "ScalySansRemake";
398
+ vertical-align: baseline;
399
+ margin: 0;
400
+ padding: 0;
401
+ overflow-wrap: break-word;
402
+ text-rendering: optimizeLegibility;
403
+ background: none;
404
+ resize: none; /* Prevents the textarea from being manually resizable */
405
+ overflow: hidden; /* Hide scrollbars */
406
+ white-space: pre-line;
407
+ }
408
+
409
+ .string-stat-textarea {
410
+ width: 200px;
411
+ height:13px;
412
+ font-size: .318cm;
413
+ font-weight: 400;
414
+ line-height: 1.2em;
415
+ margin-bottom: 0;
416
+ font-style: italic;
417
+ box-sizing: border-box;
418
+ border: 0;
419
+ font-family: "ScalySansRemake";
420
+ vertical-align: baseline;
421
+ margin: 0;
422
+ padding: 0;
423
+ overflow-wrap: break-word;
424
+ text-rendering: optimizeLegibility;
425
+ background: none;
426
+ resize: none; /* Prevents the textarea from being manually resizable */
427
+ overflow: hidden; /* Hide scrollbars */
428
+ white-space: pre-wrap;
429
+ }
430
+
431
+ .string-action-name-textarea {
432
+ width: 100%;
433
+ height:13px;
434
+ font-size: .318cm;
435
+ font-style: italic;
436
+ font-weight: bold;
437
+ line-height: 1.2em;
438
+ margin-bottom: 0;
439
+ font-style: italic;
440
+ box-sizing: border-box;
441
+ border: 0;
442
+ font-family: "ScalySansRemake";
443
+ vertical-align: baseline;
444
+ margin: 0;
445
+ padding: 0;
446
+ overflow-wrap: break-word;
447
+ text-rendering: optimizeLegibility;
448
+ background: none;
449
+ resize: none; /* Prevents the textarea from being manually resizable */
450
+ overflow: hidden; /* Hide scrollbars */
451
+
452
+ }
453
+
454
+ .string-action-description-textarea {
455
+ width: 100%;
456
+ height:16px;
457
+ font-size: 14px;
458
+ font-weight: 400;
459
+ line-height: 16px;
460
+ margin-bottom: 0;
461
+ box-sizing: border-box;
462
+ border: 0;
463
+ font-family: "ScalySansRemake";
464
+ vertical-align: baseline;
465
+ margin: 0;
466
+ padding: 0;
467
+ overflow-wrap: break-word;
468
+ text-rendering: optimizeLegibility;
469
+ background: none;
470
+ resize: none; /* Prevents the textarea from being manually resizable */
471
+ overflow: hidden; /* Hide scrollbars */
472
+ }
473
+
474
+ .block.monster.frame.wide {
475
+ column-count: inherit;
476
+ min-height: 100px; /* Set an appropriate minimum height */
477
+ height: 859px; /* Allow height to expand automatically */
478
+ column-fill: auto;
479
+ overflow: hidden; /* Ensure content overflow is visible */
480
+ width: 100%; /* Ensure it takes the full width of the container */
481
+
482
+ }
483
+
484
+ .highlight-page {
485
+ outline: 2px dashed #2196F3; /* Blue dashed border */
486
+ background-color: rgba(33, 150, 243, 0.1); /* Light blue background */
487
+ }
488
+
489
+ .highlight-block {
490
+ border-bottom: 2px solid #2196F3; /* Blue solid border */
491
+ background-color: rgba(33, 150, 243, 0.1); /* Light blue background */
492
+ }
493
+
494
+ .highlight-block-top {
495
+ border-top: 2px solid #2196F3; /* Blue solid border at the top */
496
+ background-color: rgba(33, 150, 243, 0.1); /* Light blue background */
497
+ }
498
+
499
+ .name-textbox {
500
+ width: 50px;
501
+ font-size: 1.5em;
502
+ padding: 10px;
503
+ }
504
+
505
+ .stat-textbox {
506
+ width: 50px;
507
+ text-align: center;
508
+ font-size: 1em;
509
+ padding: 5px;
510
+ }
511
+
512
+ .trash-area {
513
+ position: fixed;
514
+ bottom: 20px;
515
+ right: 20px;
516
+ width: 100px;
517
+ height: 100px;
518
+
519
+ display: flex;
520
+ align-items: center;
521
+ justify-content: center;
522
+
523
+ cursor: pointer;
524
+ background-image: url('./closed-mimic-trashcan.png'); /* Adjust the path to your image file */
525
+ background-size: contain;
526
+ background-repeat: no-repeat;
527
+ background-position: center;
528
+ }
529
+
530
+ .trash-area:hover {
531
+ background-image: url('./mimic_trashcan.png');
532
+ }
533
+ .trash-area.over {
534
+ color: white;
535
+ background-image: url('./mimic_trashcan.png'); /* Example image change */
536
+ }
537
+
storeUI.html CHANGED
@@ -8,532 +8,12 @@
8
  <link href='./dependencies/bundle.css' rel='stylesheet' />
9
  <link href="./dependencies/style.css" rel='stylesheet' />
10
  <link href="./dependencies/5ePHBstyle.css" rel='stylesheet' />
 
11
  <title>DnD Stat Block</title>
12
  <link rel="stylesheet" href="styles.css">
13
  <script src="https://unpkg.com/[email protected]/dist/htmx.min.js"></script>
14
  </head>
15
- <style>
16
- :root {
17
- --HB_Color_Background: #EEE5CE;
18
- --HB_Color_Accent: #E0E5C1;
19
- --HB_Color_HeaderUnderline: #C0AD6A;
20
- --HB_Color_HorizontalRule: #9C2B1B;
21
- --HB_Color_HeaderText: #58180D;
22
- --HB_Color_MonsterStatBackground: #F2E5B5;
23
- --HB_Color_CaptionText: #766649;
24
- --HB_Color_WatercolorStain: #BBAD82;
25
- --HB_Color_Footnotes: #C9AD6A;
26
- }
27
- input[type="text"], textarea {
28
- width: auto;
29
- padding: 8px;
30
- margin: 5px 0;
31
- border: 1px solid #ccc;
32
- border-radius: 4px;
33
- font-size: 14px;
34
- background-color: #f9f9f9;
35
- transition: background-color 0.3s ease, border-color 0.3s ease;
36
- }
37
- .grid-container {
38
- display: grid;
39
- grid-template-columns: 1fr 3fr; /* Two columns with the second column being three times as wide */
40
- grid-gap: 20px;
41
- padding: 20px;
42
- height: 100vh;
43
- }
44
- .block-container {
45
- position: fixed; /* Lock the block-container in place */
46
- top: 20px; /* Distance from the top of the viewport */
47
- left: 20px; /* Distance from the left of the viewport */
48
- width: 450px; /* Set the width of the block-container */
49
- height: calc(100vh - 40px); /* Full viewport height minus top and bottom padding */
50
- overflow-y: auto; /* Enable vertical scrolling if needed */
51
- border-right: 1px solid #ccc; /* Right border for visual separation */
52
- padding-right: 20px; /* Padding inside the block-container */
53
- box-sizing: border-box; /* Include padding and border in the element's total width and height */
54
- background-color: #f9f9f9; /* Background color */
55
- z-index: 1000; /* Ensure it is on top of other elements */
56
- }
57
 
58
- .block-container .page {
59
- column-count: 1;
60
- padding: 0;
61
- width: 425px;
62
- height: auto; /* Allow the page to expand to fit content */
63
- overflow: visible; /* Allow content to overflow if necessary */
64
- page-break-before: auto;
65
- page-break-after: auto;
66
-
67
- }
68
- .page-container {
69
- margin-left: 450px; /* Offset the page content by the width of block-container plus margin */
70
- width: 900px;
71
- padding: 20px;
72
- overflow: auto; /* Enable scrolling if needed */
73
- height: 100vh; /* Full viewport height */
74
- box-sizing: border-box; /* Include padding and border in the element's total width and height */
75
- }
76
-
77
-
78
- .page {
79
- column-count: 2;
80
- column-gap: .9cm;
81
- column-width: 8cm;
82
- -webkit-column-count: 2;
83
- -moz-column-count: 2;
84
- -webkit-column-width: 8cm;
85
- -moz-column-width: 8cm;
86
- -webkit-column-gap: .9cm;
87
- -moz-column-gap: .9cm;
88
- position: relative;
89
- z-index: 15;
90
- box-sizing: border-box;
91
- width: 215.9mm;
92
- height: 279.4mm; /* Original height for print layout */
93
- padding: 1.4cm 1.9cm 1.7cm;
94
- overflow: hidden;
95
- font-family: "BookInsanityRemake";
96
- font-size: .34cm;
97
- counter-increment: phb-page-numbers;
98
- background-color: var(--HB_Color_Background);
99
- background-image: url('./themes/assets/parchmentBackground.jpg');
100
- text-rendering: optimizeLegibility;
101
- page-break-before: always;
102
- page-break-after: always;
103
- contain: size;
104
- }
105
-
106
- .page .monster hr:last-of-type + * {
107
- margin-top: .1cm;
108
- }
109
- .page * + h3 {
110
- margin-top: .05cm;
111
- }
112
- .page * + h4 {
113
- margin-top: .1cm;
114
- }
115
- .page h4 + * {
116
- margin-top: .1cm;
117
- }
118
- .page dl + * {
119
- margin-top: .1cm;
120
- }
121
- .page p + * {
122
- margin-top: .1cm;
123
- }
124
- .page img {
125
- width: 100%;
126
- height: auto;
127
- cursor: pointer;
128
- }
129
- .page .classTable.frame{
130
- margin-right:0.1cm;
131
- margin-left: 0.1cm;
132
- }
133
-
134
- /* Ensure the h1 tag is constrained within its column */
135
- .block-content h1 {
136
- column-span: none;
137
- box-sizing: border-box; /* Include padding and border in the element's total width and height */
138
- margin: 0 auto; /* Center the h1 within the column */
139
- overflow: hidden; /* Handle overflow content */
140
- word-wrap: break-word; /* Break long words to prevent overflow */
141
- }
142
- .columnWrapper {
143
- column-gap: inherit;
144
- max-height: 100%;
145
- column-span: all;
146
- columns: inherit;
147
- height: 100%; /* Ensure it takes full height of the parent */
148
- box-sizing: border-box; /* Ensures padding and border are included in the element's total width and height */
149
- }
150
- /* block-item styling */
151
- .block-item {
152
- border: 1px solid #ccc;
153
- border-radius: 8px;
154
- background-color: transparent;
155
- padding: 15px;
156
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
157
- transition: transform 0.3s;
158
- }
159
- .block-item:hover {
160
- /* transform: translateY(-5px);
161
- background-color: rgba(255, 255, 255, 0.5); /* Slightly visible background on hover */
162
- }
163
-
164
- .block-item img {
165
- width: 100%;
166
- height: auto;
167
- cursor: pointer;
168
- }
169
-
170
- /* Modal styling */
171
- .modal {
172
- display: none; /* Hidden by default */
173
- position: fixed; /* Stay in place */
174
- z-index: 1001; /* Sit on top */
175
- left: 0;
176
- top: 0;
177
- width: 100%; /* Full width */
178
- height: 100%; /* Full height */
179
- overflow: auto; /* Enable scroll if needed */
180
- background-color: rgb(0,0,0); /* Fallback color */
181
- background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
182
- }
183
-
184
- .modal-content {
185
- margin: auto;
186
- display: block;
187
- width: 80%;
188
- max-width: 700px;
189
- }
190
-
191
- .modal-content, #caption {
192
- animation-name: zoom;
193
- animation-duration: 0.6s;
194
- }
195
-
196
- @keyframes zoom {
197
- from {transform: scale(0)}
198
- to {transform: scale(1)}
199
- }
200
-
201
- .close {
202
- position: absolute;
203
- top: 15px;
204
- right: 35px;
205
- color: #f1f1f1;
206
- font-size: 40px;
207
- font-weight: bold;
208
- transition: 0.3s;
209
- }
210
-
211
- .close:hover,
212
- .close:focus {
213
- color: #bbb;
214
- text-decoration: none;
215
- cursor: pointer;
216
- }
217
- input[type="text"]:focus, textarea:focus {
218
- background-color: #e9e9e9;
219
- border-color: #aaa;
220
- outline: none;
221
- }
222
-
223
- /* Specific styles for different textboxes */
224
-
225
- .user-description-textarea {
226
- width: 400px;
227
- height: 40px; /* Adjust as needed for 3 lines */
228
- resize: vertical;
229
- background: none;
230
- font-family: "ScalySansRemake";
231
- font-weight: 800;
232
-
233
- }
234
- /* Focus styles for description textbox */
235
- .user-description-textarea:focus {
236
- background-color: #e9e9e9;
237
- border-color: #aaa;
238
- outline: none;
239
- }
240
-
241
- .heading-textarea {
242
- width: 100%;
243
- font-size: .458cm; /* Matches the font size of an h4 heading */
244
- line-height: .7em;
245
- font-weight: 800;
246
- border: none;
247
- background: none;
248
- margin: 0;
249
- padding: 0;
250
- resize: none; /* Prevents the textarea from being resizable */
251
- overflow: hidden; /* Prevents scrollbars */
252
- outline: none; /* Removes the focus outline */
253
- font-family: "MrEavesRemake"; /* Ensures font family is inherited */
254
- color: var(--HB_Color_HeaderText)
255
-
256
- }
257
- .title-textarea{
258
- height:30px;
259
- width: 100%;
260
- margin-bottom: 5px;
261
- column-span: all;
262
- font-size: .89cm;
263
- line-height: 1em;
264
- font-family: "MrEavesRemake";
265
- font-weight: 800;
266
- color: var(--HB_Color_HeaderText);
267
- border: 0;
268
- font: inherit;
269
- background: none;
270
- padding: 0;
271
- resize: none; /* Prevents the textarea from being resizable */
272
- overflow: hidden; /* Prevents scrollbars */
273
- outline: none; /* Removes the focus outline */
274
-
275
- }
276
-
277
- .subtitle-textarea{
278
- height:20px;
279
- width: 100%;
280
- margin-bottom: 5px;
281
- column-span: all;
282
- font-size: .89cm;
283
- line-height: 1em;
284
- font-family: "MrEavesRemake";
285
- font-weight: 800;
286
- color: var(--HB_Color_HeaderText);
287
- border: 0;
288
- font: inherit;
289
- background: none;
290
- padding: 0;
291
- resize: none; /* Prevents the textarea from being resizable */
292
- overflow: hidden; /* Prevents scrollbars */
293
- outline: none; /* Removes the focus outline */
294
-
295
- }
296
-
297
- div[contenteditable="true"]:focus {
298
- background-color: #e9e9e9;
299
- border-color: #aaa;
300
- outline: none;
301
- }
302
-
303
- div[contenteditable="true"] p::first-letter {
304
- float: left;
305
- padding-bottom: 2px;
306
- padding-left: 40px;
307
- margin-top: 0cm;
308
- margin-bottom: -20px;
309
- margin-left: -40px;
310
- font-family: "SolberaImitationRemake";
311
- font-size: 3.5cm;
312
- line-height: 1em;
313
- color: rgba(0, 0, 0, 0);
314
- background-image: linear-gradient(-45deg, #322814, #998250, #322814);
315
- -webkit-background-clip: text;
316
- background-clip: text;
317
- border: 0;
318
- }
319
- .properties-textarea {
320
- width: 100%;
321
- font-size: 12px;
322
- font-weight: 400;
323
- line-height: .7em;
324
- margin-bottom: 0;
325
- font-style: italic;
326
- box-sizing: border-box;
327
- border: 0;
328
- font-family: "ScalySansRemake";
329
- vertical-align: baseline;
330
- margin: 0;
331
- padding: 0;
332
- overflow-wrap: break-word;
333
- text-rendering: optimizeLegibility;
334
- background: none;
335
- resize: none; /* Prevents the textarea from being resizable */
336
-
337
- }
338
-
339
- .description-textarea {
340
- width: 100%;
341
- height: auto;
342
- font-size: .318cm;
343
- font-weight: 400;
344
- line-height: .9em;
345
- margin-bottom: 0;
346
- font-style: italic;
347
- box-sizing: border-box;
348
- border: 0;
349
- font-family: "ScalySansSmallCapsRemake";
350
- vertical-align: baseline;
351
- margin: 0;
352
- padding: 0;
353
- overflow-wrap: break-word;
354
- text-rendering: optimizeLegibility;
355
- background: none;
356
- resize: none; /* Prevents the textarea from being manually resizable */
357
- overflow: hidden; /* Hide scrollbars */
358
- }
359
-
360
- .red-integer-stat-textarea {
361
- width: 20px;
362
- height:13px;
363
- font-size: .318cm;
364
- font-weight: 400;
365
- line-height: 1.2em;
366
- margin-bottom: 0;
367
- font-style: italic;
368
- box-sizing: border-box;
369
- border: 0;
370
- font-family: "ScalySansSmallCapsRemake";
371
- vertical-align: baseline;
372
- margin: 0;
373
- padding: 0;
374
- overflow-wrap: break-word;
375
- text-rendering: optimizeLegibility;
376
- background: none;
377
- resize: none; /* Prevents the textarea from being manually resizable */
378
- overflow: hidden; /* Hide scrollbars */
379
- color: var(--HB_Color_HeaderText);
380
- white-space: pre-line;
381
- }
382
-
383
- .integer-stat-textarea {
384
- width: 20px;
385
- height:13px;
386
- font-size: .318cm;
387
- font-weight: 400;
388
- line-height: 1.2em;
389
- margin-bottom: 0;
390
- font-style: italic;
391
- box-sizing: border-box;
392
- border: 0;
393
- font-family: "ScalySansRemake";
394
- vertical-align: baseline;
395
- margin: 0;
396
- padding: 0;
397
- overflow-wrap: break-word;
398
- text-rendering: optimizeLegibility;
399
- background: none;
400
- resize: none; /* Prevents the textarea from being manually resizable */
401
- overflow: hidden; /* Hide scrollbars */
402
- white-space: pre-line;
403
- }
404
-
405
- .string-stat-textarea {
406
- width: 200px;
407
- height:13px;
408
- font-size: .318cm;
409
- font-weight: 400;
410
- line-height: 1.2em;
411
- margin-bottom: 0;
412
- font-style: italic;
413
- box-sizing: border-box;
414
- border: 0;
415
- font-family: "ScalySansRemake";
416
- vertical-align: baseline;
417
- margin: 0;
418
- padding: 0;
419
- overflow-wrap: break-word;
420
- text-rendering: optimizeLegibility;
421
- background: none;
422
- resize: none; /* Prevents the textarea from being manually resizable */
423
- overflow: hidden; /* Hide scrollbars */
424
- white-space: pre-wrap;
425
- }
426
-
427
- .string-action-name-textarea {
428
- width: 100%;
429
- height:13px;
430
- font-size: .318cm;
431
- font-style: italic;
432
- font-weight: bold;
433
- line-height: 1.2em;
434
- margin-bottom: 0;
435
- font-style: italic;
436
- box-sizing: border-box;
437
- border: 0;
438
- font-family: "ScalySansRemake";
439
- vertical-align: baseline;
440
- margin: 0;
441
- padding: 0;
442
- overflow-wrap: break-word;
443
- text-rendering: optimizeLegibility;
444
- background: none;
445
- resize: none; /* Prevents the textarea from being manually resizable */
446
- overflow: hidden; /* Hide scrollbars */
447
-
448
- }
449
-
450
- .string-action-description-textarea {
451
- width: 100%;
452
- height:16px;
453
- font-size: 14px;
454
- font-weight: 400;
455
- line-height: 16px;
456
- margin-bottom: 0;
457
- box-sizing: border-box;
458
- border: 0;
459
- font-family: "ScalySansRemake";
460
- vertical-align: baseline;
461
- margin: 0;
462
- padding: 0;
463
- overflow-wrap: break-word;
464
- text-rendering: optimizeLegibility;
465
- background: none;
466
- resize: none; /* Prevents the textarea from being manually resizable */
467
- overflow: hidden; /* Hide scrollbars */
468
- }
469
-
470
- .block.monster.frame.wide {
471
- column-count: inherit;
472
- min-height: 100px; /* Set an appropriate minimum height */
473
- height: 859px; /* Allow height to expand automatically */
474
- column-fill: auto;
475
- overflow: hidden; /* Ensure content overflow is visible */
476
- width: 100%; /* Ensure it takes the full width of the container */
477
-
478
- }
479
-
480
- .highlight-page {
481
- outline: 2px dashed #2196F3; /* Blue dashed border */
482
- background-color: rgba(33, 150, 243, 0.1); /* Light blue background */
483
- }
484
-
485
- .highlight-block {
486
- border-bottom: 2px solid #2196F3; /* Blue solid border */
487
- background-color: rgba(33, 150, 243, 0.1); /* Light blue background */
488
- }
489
-
490
- .highlight-block-top {
491
- border-top: 2px solid #2196F3; /* Blue solid border at the top */
492
- background-color: rgba(33, 150, 243, 0.1); /* Light blue background */
493
- }
494
-
495
- .name-textbox {
496
- width: 50px;
497
- font-size: 1.5em;
498
- padding: 10px;
499
- }
500
-
501
- .stat-textbox {
502
- width: 50px;
503
- text-align: center;
504
- font-size: 1em;
505
- padding: 5px;
506
- }
507
-
508
- .trash-area {
509
- position: fixed;
510
- bottom: 20px;
511
- right: 20px;
512
- width: 100px;
513
- height: 100px;
514
-
515
- display: flex;
516
- align-items: center;
517
- justify-content: center;
518
-
519
- cursor: pointer;
520
- background-image: url('./closed-mimic-trashcan.png'); /* Adjust the path to your image file */
521
- background-size: contain;
522
- background-repeat: no-repeat;
523
- background-position: center;
524
- }
525
-
526
- .trash-area:hover {
527
- background-image: url('./mimic_trashcan.png');
528
- }
529
- .trash-area.over {
530
- color: white;
531
- background-image: url('./mimic_trashcan.png'); /* Example image change */
532
- }
533
-
534
-
535
-
536
- </style>
537
  <body>
538
  <div class="grid-container">
539
  <div class="block-container" id="blockContainer" >
@@ -541,17 +21,20 @@ div[contenteditable="true"] p::first-letter {
541
  <!-- Blocks will be wrapped in a page div and loaded here -->
542
  </div>
543
  </div>
 
544
  <div class="page-container" id="pageContainer">
545
- <div class="brewRenderer">
546
- <h1>Describe your creature</h1>
547
  <textarea id="user-description" class="user-description-textarea"
548
  hx-post="/update-stats" hx-trigger="change"
549
  hx-target="#user-description" hx-swap="outerHTML"
550
  title="As much or as little description as you want to provide. You can provide specific employees, inventory etc">A very standard gear store run by a fae potted plant named Gorgeous</textarea>
551
  <button id="submitDescription">Submit</button>
552
  <button id="parseHTML">Parse HTML</button>
553
- <button id="resetButton">Reset</button>
554
- <div class="pages">
 
 
 
555
  <div id="page-1" class="page" data-page-id="page-0">
556
  <div class="columnWrapper">
557
  <div class="block monster frame wide">
@@ -570,792 +53,7 @@ div[contenteditable="true"] p::first-letter {
570
  <img class="modal-content" id="modalImage">
571
  <div id="caption"></div>
572
  </div>
573
- <script>
574
- // Waits for DOM content to be fully loaded and assigns critical elements to variables.
575
- let initialPositions = [];
576
- document.addEventListener("DOMContentLoaded", function() {
577
- const blockContainer = document.getElementById('blockContainer');
578
- let blockContainerPage = document.getElementById('block-page');
579
- const pageContainer = document.getElementById('pageContainer');
580
- const trashArea = document.getElementById('trashArea');
581
- const resetButton = document.getElementById('resetButton');
582
- let currentPage = pageContainer.querySelector('.block.monster.frame.wide');
583
- const modal = document.getElementById('imageModal');
584
- const modalImg = document.getElementById('modalImage');
585
- const captionText = document.getElementById('caption');
586
- const closeModal = document.getElementsByClassName('close')[0];
587
- const MAX_COLUMN_HEIGHT = 847;
588
-
589
- if (!blockContainer || !pageContainer || !trashArea || !currentPage) {
590
- console.error('Required elements are null');
591
- return;
592
- }
593
- if (!modal) {
594
- console.error('modal element not found');
595
- return;
596
- }
597
- if (!modalImg) {
598
- console.error('modalImg element not found');
599
- return;
600
- }
601
- if (!captionText) {
602
- console.error('captionText element not found');
603
- return;
604
- }
605
- if (!closeModal) {
606
- console.error('closeModal element not found');
607
- return;
608
- }
609
-
610
- // Event delegation for image clicks
611
- blockContainer.addEventListener('click', function(event) {
612
- console.log('Click detected in blockContainer:', event.target);
613
- if (event.target.tagName === 'IMG' && event.target.id.startsWith('generated-image-')) {
614
- console.log('Image clicked for modal display. Image ID:', event.target.id);
615
- modal.style.display = 'block';
616
- modalImg.src = event.target.src;
617
- captionText.innerHTML = event.target.alt;
618
- } else {
619
- console.log('Clicked element is not an image or does not match ID pattern.');
620
- }
621
- });
622
-
623
- // Function to close the modal
624
- closeModal.onclick = function() {
625
- modal.style.display = "none";
626
- }
627
-
628
- // Function to close the modal when clicking outside of the modal content
629
- window.onclick = function(event) {
630
- if (event.target == modal) {
631
- modal.style.display = "none";
632
- }
633
- }
634
-
635
- document.getElementById('submitDescription').addEventListener('click', function() {
636
- const userInput = document.getElementById('user-description').value;
637
- // Clear the block container before inserting new blocks
638
- blockContainerPage.innerHTML = '';
639
-
640
-
641
- fetch('http://127.0.0.1:5000/process-description', {
642
- method: 'POST',
643
- headers: {
644
- 'Content-Type': 'application/json'
645
- },
646
- body: JSON.stringify({ user_input: userInput })
647
- })
648
- .then(response => response.json())
649
- .then(data => {
650
- console.log('Success:', data);
651
- initialPositions.length = 0; // Clear the initialPositions array
652
- insertHtmlBlocks(data.html_blocks);
653
- const blocks = blockContainerPage.querySelectorAll('.block-item');
654
- blocks.forEach(block => {
655
- block.setAttribute('data-page-id', 'block-container');
656
- block.setAttribute('draggable', true);
657
- block.addEventListener('dragstart', handleDragStart);
658
- block.addEventListener('dragend', handleDragEnd);
659
- });
660
- storeInitialPositions();
661
- })
662
- .catch((error) => {
663
- console.error('Error:', error);
664
- });
665
- });
666
-
667
- // Store initial positions of the blocks
668
- function storeInitialPositions() {
669
- initialPositions = []; // Clear initialPositions before updating
670
- const blocks = blockContainer.querySelectorAll('.block-item');
671
- blocks.forEach((block, index) => {
672
- const blockId = block.getAttribute('data-block-id');
673
- if (!blockId) {
674
- console.error(`Block at index ${index} is missing data-block-id`);
675
- }
676
- initialPositions.push({
677
- id: blockId,
678
- index: index
679
- });
680
- });
681
- console.log('Initial positions:', initialPositions);
682
- }
683
-
684
- function insertHtmlBlocks(blocks) {
685
- console.log('blockContainerPage = ', blockContainerPage)
686
- console.log('List of blocks:', blocks);
687
-
688
- const parser = new DOMParser();
689
-
690
- blocks.forEach(blockHtml => {
691
- console.log('Original blockHtml:', blockHtml);
692
-
693
- // Parse the HTML string
694
- const doc = parser.parseFromString(blockHtml, 'text/html');
695
- console.log('Parsed document:', doc);
696
- const block = doc.body.firstChild;
697
- console.log('Parsed block:', block);
698
- if (block) {
699
- blockContainerPage.appendChild(block); // Append the parsed block to the container
700
- console.log('Appended block:', block);
701
- }
702
-
703
- });
704
- // console.log('Final state of blockContainer:', blockContainer.innerHTML);
705
- initializeTextareaResizing();
706
- }
707
-
708
- storeInitialPositions();
709
-
710
- function adjustTextareaHeight(el) {
711
- if (el.scrollHeight > 16){
712
- el.style.height = 'auto';
713
- el.style.height = (el.scrollHeight) + 'px';
714
- }
715
- console.log('Original height:', el.style.height);
716
- }
717
-
718
- function initializeTextareaResizing() {
719
- const classes = [
720
- 'description-textarea',
721
- 'user-description-textarea',
722
- 'heading-textarea',
723
- 'properties-textarea',
724
- 'string-stat-textarea',
725
- 'string-action-description-textarea',
726
- ];
727
-
728
- classes.forEach(className => {
729
- const textareas = document.querySelectorAll(`.${className}`);
730
- console.log(`Textareas found for ${className}:`, textareas.length); // Debugging line
731
- textareas.forEach(textarea => {
732
- console.log('scrollHeight:', textarea.scrollHeight);
733
- console.log('clientHeight:', textarea.clientHeight);
734
- console.log('offsetHeight:', textarea.offsetHeight);
735
- console.log('Computed line-height:', window.getComputedStyle(textarea).lineHeight);
736
-
737
- // Adjust height on page load
738
- adjustTextareaHeight(textarea);
739
- // Adjust height on input
740
- textarea.addEventListener('input', function() {
741
- adjustTextareaHeight(textarea);
742
- console.log('Input event triggered for:', textarea.id); // Debugging line
743
- });
744
- });
745
- });
746
- }
747
-
748
- // Initial run on page load
749
- initializeTextareaResizing();
750
-
751
- async function extractBlocks() {
752
-
753
- try {
754
- if (blockContainerPage.children.length > 0) {
755
- console.log('Blocks already loaded, skipping fetch');
756
- return;
757
- }
758
- const response = await fetch('The_Mirage_Emporium.html');
759
- if (!response.ok) {
760
- throw new Error('Network response was not ok ' + response.statusText);
761
- }
762
- const text = await response.text();
763
- const parser = new DOMParser();
764
- const doc = parser.parseFromString(text, 'text/html');
765
- const blocks = doc.querySelectorAll('[class^="Block_"]');
766
-
767
-
768
- blocks.forEach((block, index) => {
769
- const blockContent = block.innerHTML;
770
- const blockItem = document.createElement('div');
771
- blockItem.classList.add('block-item');
772
- blockItem.innerHTML = blockContent;
773
- const blockId = `block-${index}`;
774
- blockItem.setAttribute('data-block-id', blockId);
775
- const pageId = 'block-container';
776
- blockItem.setAttribute('data-page-id', pageId);
777
- blockItem.setAttribute('draggable', true);
778
- blockItem.addEventListener('dragstart', handleDragStart);
779
- blockItem.addEventListener('dragend', handleDragEnd);
780
-
781
- console.log(`Loaded block with ID: ${blockId}`);
782
- blockContainerPage.appendChild(blockItem);
783
- });
784
-
785
- storeInitialPositions();
786
- } catch (error) {
787
- console.error('Error fetching and parsing template.html:', error);
788
- }
789
- }
790
-
791
- blockContainer.addEventListener('click', function(event) {
792
- if (event.target && event.target.classList.contains('generate-image-button')) {
793
- const blockId = event.target.getAttribute('data-block-id');
794
- generateImage(blockId);
795
- }
796
- });
797
-
798
- // Function to generate image
799
- function generateImage(blockId) {
800
- const sdPromptElement = document.getElementById(`user-storefront-prompt-${blockId}`);
801
- const imageElement = document.getElementById(`generated-image-${blockId}`);
802
-
803
- if (!sdPromptElement) {
804
- console.error('Element with ID user-storefront-prompt not found');
805
- return;
806
- }
807
-
808
- if (!imageElement) {
809
- console.error('Element with ID generated-image not found');
810
- return;
811
- }
812
-
813
- const sdPrompt = sdPromptElement.value;
814
-
815
- fetch('http://127.0.0.1:5000/generate-image', {
816
- method: 'POST',
817
- headers: {
818
- 'Content-Type': 'application/json'
819
- },
820
- body: JSON.stringify({ sd_prompt: sdPrompt })
821
- })
822
- .then(response => response.json())
823
- .then(data => {
824
- console.log('Received data:', data);
825
- imageElement.src = data.image_url;
826
- imageElement.style.display = 'block';
827
-
828
- // Log the image element's HTML structure
829
- console.log('Updated imageElement HTML:', imageElement.outerHTML);
830
- })
831
- .catch((error) => {
832
- console.error('Error:', error);
833
- });
834
- }
835
-
836
- function handleDragStart(e) {
837
- const target = e.target.closest('.block-item, .block-content');
838
- if (!target) {
839
- console.error('Drag started for an element without a valid target');
840
- return;
841
- }
842
- const blockId = target.getAttribute('data-block-id');
843
- const pageId = target.getAttribute('data-page-id');
844
- if (!blockId) {
845
- console.error('Drag started for an element without a data-block-id');
846
- return;
847
- }
848
- if (!pageId) {
849
- console.error('Drag started for an element without a data-page-id');
850
- return;
851
- }
852
- const innerHTML = target.innerHTML;
853
- e.dataTransfer.setData('block-id', blockId);
854
- e.dataTransfer.setData('text/plain', innerHTML); // Store inner HTML
855
- e.dataTransfer.setData('data-page-id', pageId); // Store original page ID
856
- e.dataTransfer.effectAllowed = 'move';
857
- target.style.opacity = '0.4';
858
-
859
- // Create an invisible drag image
860
- const dragImage = document.createElement('div');
861
- dragImage.style.width = '1px';
862
- dragImage.style.height = '1px';
863
- dragImage.style.opacity = '0';
864
- document.body.appendChild(dragImage);
865
- e.dataTransfer.setDragImage(dragImage, 0, 0);
866
-
867
- console.log(`Drag started for block ID: ${blockId} page ID: ${pageId}`);
868
- }
869
-
870
- function handleDragEnd(e) {
871
- const target = e.target.closest('.block-item, .block-content');
872
- if (target) {
873
- target.style.opacity = '1'; // Reset the opacity
874
- const blockId = target.getAttribute('data-block-id');
875
- console.log(`Drag ended for block ID: ${blockId}`);
876
- }
877
-
878
- // Remove highlight classes from pages and blocks
879
- document.querySelectorAll('.highlight-page').forEach(el => el.classList.remove('highlight-page'));
880
- document.querySelectorAll('.highlight-block').forEach(el => el.classList.remove('highlight-block'));
881
- document.querySelectorAll('.highlight-block-top').forEach(el => el.classList.remove('highlight-block-top'));
882
- }
883
-
884
- function handleDragOver(e) {
885
- e.preventDefault();
886
- e.dataTransfer.dropEffect = 'move';
887
- console.log('Drag over event');
888
-
889
- const targetPage = e.target.closest('.page');
890
- if (targetPage) {
891
- targetPage.classList.add('highlight-page'); // Add highlight class for pages
892
- }
893
-
894
- const targetBlock = e.target.closest('.block-item, .block-content');
895
- if (targetBlock) {
896
- const bounding = targetBlock.getBoundingClientRect();
897
- const offset = e.clientY - bounding.top;
898
- if (offset > bounding.height / 2) {
899
- targetBlock.classList.add('highlight-block');
900
- targetBlock.classList.remove('highlight-block-top');
901
- } else {
902
- targetBlock.classList.add('highlight-block-top');
903
- targetBlock.classList.remove('highlight-block');
904
- }
905
- }
906
- }
907
-
908
- function handleDrop(e) {
909
- e.preventDefault();
910
- const blockId = e.dataTransfer.getData('block-id');
911
- const originalPageId = e.dataTransfer.getData('data-page-id');
912
- const innerHTML = e.dataTransfer.getData('text/plain');
913
- console.log(`Drop event for block ID: ${blockId} from page ID: ${originalPageId}`);
914
-
915
- // Ensure we are not dropping into a textarea or another block
916
- if (event.target.classList.contains('block-item', 'block-content') || event.target.tagName === 'TEXTAREA') {
917
- console.log('Cannot drop block inside another block or textarea');
918
- return;
919
- }
920
-
921
- if (blockId && originalPageId) {
922
- const originalBlock = document.querySelector(`[data-block-id="${blockId}"]`);
923
- const newPage = e.target.closest('.page');
924
- console.log(`Over page ${newPage} from page ID: ${originalPageId}`);
925
- const newPageId = newPage.getAttribute('data-page-id');
926
-
927
- // Ensure the original block exists before proceeding
928
- if (!originalBlock || !newPage) {
929
- console.error(`Block with ID ${blockId} on page ${originalPageId} not found`);
930
- return;
931
- }
932
-
933
- const newBlockContent = document.createElement('div');
934
- newBlockContent.classList.add('block-content');
935
- newBlockContent.innerHTML = originalBlock.innerHTML; // Transfer inner content only
936
-
937
- // Add necessary attributes and event listeners
938
- newBlockContent.setAttribute('data-block-id', blockId);
939
- newBlockContent.setAttribute('data-page-id', newPageId);
940
- console.log('newPageID:', newPageId);
941
- newBlockContent.setAttribute('draggable', true);
942
- newBlockContent.addEventListener('dragstart', handleDragStart);
943
- newBlockContent.addEventListener('dragend', handleDragEnd);
944
-
945
- const target = e.target.closest('.block-item, .block-content');
946
- let targetColumn = 1;
947
- if (target) {
948
- const bounding = target.getBoundingClientRect();
949
- const offset = e.clientY - bounding.top;
950
-
951
- console.log('Drop target found:', target);
952
- console.log('Bounding rectangle:', bounding);
953
- console.log('Offset from top:', offset);
954
- console.log('Target height:', bounding.height);
955
- console.log('Insert before or after decision point (height / 2):', bounding.height / 2);
956
-
957
- targetColumn = getColumnFromOffset(target, offset);
958
- if (offset > bounding.height / 2) {
959
- console.log('Inserting after the target');
960
- target.parentNode.insertBefore(newBlockContent, target.nextSibling);
961
- } else {
962
- console.log('Inserting before the target');
963
- target.parentNode.insertBefore(newBlockContent, target);
964
- }
965
-
966
- // Remove highlight borders
967
- target.style['border-bottom'] = '';
968
- target.style['border-top'] = '';
969
- } else {
970
- console.log('No valid drop target found, appending to the end');
971
- newPage.querySelector('.block.monster.frame.wide').appendChild(newBlockContent);
972
- }
973
-
974
- // Remove the original block from the original container
975
- originalBlock.parentNode.removeChild(originalBlock);
976
-
977
- // Reset opacity of dragged element
978
- newBlockContent.style.opacity = '1';
979
- console.log(`Moved existing block with ID: ${blockId} to page ID: ${newPageId}`);
980
- initializeTextareaResizing();
981
- // Adjust layouts
982
- if (originalPageId !== 'block-container') {
983
- adjustPageLayout(originalPageId);
984
- }
985
- adjustPageLayout(newPageId, targetColumn);
986
- } else {
987
- console.log('No data transferred');
988
- }
989
- }
990
-
991
- function getColumnFromOffset(block, offset) {
992
- const page = block.closest('.page');
993
- if (!page) return 1;
994
- const columnWrapper = page.querySelector('.columnWrapper');
995
- const columnWrapperRect = columnWrapper.getBoundingClientRect();
996
- const relativeOffset = offset - columnWrapperRect.left; // Calculate the offset relative to the column wrapper
997
- const columnWidth = columnWrapper.clientWidth / 2; // Assuming two columns
998
-
999
- // Log details for debugging
1000
- console.log('Block offset:', offset);
1001
- console.log('Relative offset:', relativeOffset);
1002
-
1003
- const columnNumber = Math.ceil(relativeOffset / columnWidth);
1004
-
1005
- // Ensure the column number is within valid bounds (1 or 2)
1006
- const validColumnNumber = Math.min(Math.max(columnNumber, 1), 2);
1007
- return validColumnNumber;
1008
- }
1009
-
1010
-
1011
- // Function to get the height of a column by index
1012
- function getColumnHeights(pageElement) {
1013
- const columns = [0, 0]; // Assuming two columns for simplicity
1014
- const blocks = pageElement.querySelectorAll('.block-content');
1015
- blocks.forEach(block => {
1016
- const column = getColumnFromOffset(block, block.getBoundingClientRect().left);
1017
- columns[column - 1] += block.offsetHeight;
1018
- });
1019
- return columns;
1020
- }
1021
-
1022
- function adjustPageLayout(pageId) {
1023
- const page = document.querySelector(`[data-page-id="${pageId}"]`);
1024
- if (!page) {
1025
- console.error(`Page with ID ${pageId} not found`);
1026
- return;
1027
- }
1028
-
1029
- const columnHeights = getColumnHeights(page);
1030
- console.log(`Total height of columns in ${pageId}: ${columnHeights}`);
1031
-
1032
- for (let i = 0; i < columnHeights.length; i++) {
1033
- if (columnHeights[i] > MAX_COLUMN_HEIGHT) {
1034
- console.log(`Column ${i + 1} in ${pageId} exceeds max height, total height: ${columnHeights[i]}px`);
1035
- handleColumnOverflow(page, i + 1);
1036
- }
1037
- }
1038
- }
1039
-
1040
- let pageCounter = 1;
1041
- // Function to create new page
1042
- function createNewPage() {
1043
- const newPage = document.createElement('div');
1044
- newPage.classList.add('page');
1045
- newPage.setAttribute('data-page-id', `page-${pageCounter}`);
1046
- newPage.id = `page-${pageCounter}`;
1047
-
1048
- const columnWrapper = document.createElement('div');
1049
- columnWrapper.classList.add('columnWrapper');
1050
-
1051
- const newMonsterFrame = document.createElement('div');
1052
- newMonsterFrame.classList.add('block', 'monster', 'frame', 'wide');
1053
-
1054
- columnWrapper.appendChild(newMonsterFrame);
1055
- newPage.appendChild(columnWrapper);
1056
- pageContainer.appendChild(newPage);
1057
-
1058
- currentPage = newMonsterFrame;
1059
- console.log(`Created new page with ID: ${newPage.id}`);
1060
-
1061
- // Add event listeners to the new currentPage
1062
- currentPage.addEventListener('dragover', handleDragOver);
1063
- currentPage.addEventListener('drop', handleDrop);
1064
-
1065
- pageCounter++;
1066
- return newPage;
1067
- }
1068
-
1069
- function handleColumnOverflow(page, targetColumn) {
1070
- console.log(`Handling overflow for page ID: ${page.getAttribute('data-page-id')} in column ${targetColumn}`);
1071
- const blocks = Array.from(page.querySelectorAll('.block-content'));
1072
- let columnHeights = [0, 0];
1073
- let overflowStartIndex = -1;
1074
-
1075
- // Find the start index where overflow begins in the target column
1076
- blocks.forEach((block, index) => {
1077
- const column = getColumnFromOffset(block, block.getBoundingClientRect().left);
1078
- columnHeights[column - 1] += block.offsetHeight;
1079
- if (columnHeights[targetColumn - 1] > MAX_COLUMN_HEIGHT && overflowStartIndex === -1) {
1080
- overflowStartIndex = index;
1081
- }
1082
- });
1083
-
1084
- // If no overflow, return early
1085
- if (overflowStartIndex === -1) {
1086
- return;
1087
- }
1088
- const overflowBlocks = blocks.slice(overflowStartIndex);
1089
- const overflowHeight = overflowBlocks.reduce((acc, block) => acc + block.offsetHeight, 0);
1090
-
1091
- // If the target column is the first column, check if the second column has enough space
1092
- if (targetColumn === 1) {
1093
- const secondColumnAvailableHeight = MAX_COLUMN_HEIGHT - columnHeights[1];
1094
-
1095
- if (overflowHeight <= secondColumnAvailableHeight) {
1096
- // Move the overflowing blocks to the second column within the same page
1097
- overflowBlocks.forEach(block => {
1098
- const blockWrapper = block.closest('.block.monster.frame.wide');
1099
- if (blockWrapper) {
1100
- blockWrapper.appendChild(block);
1101
- block.setAttribute('data-page-id', page.getAttribute('data-page-id'));
1102
- }
1103
- });
1104
- return;
1105
- }
1106
- }
1107
-
1108
- // Get the next page if it exists
1109
- const nextPage = getNextPage(page);
1110
- if (nextPage) {
1111
- const nextPageBlocks = nextPage.querySelectorAll('.block-content, .block-item');
1112
- let nextPageColumnHeights = [0, 0];
1113
-
1114
- nextPageBlocks.forEach(block => {
1115
- const column = getColumnFromOffset(block, block.getBoundingClientRect().left);
1116
- nextPageColumnHeights[column - 1] += block.offsetHeight;
1117
- });
1118
-
1119
- // Check if there's enough space in the target column of the next page
1120
- if (nextPageColumnHeights[targetColumn - 1] + overflowHeight <= MAX_COLUMN_HEIGHT) {
1121
- const nextPageContainer = nextPage.querySelector('.block.monster.frame.wide');
1122
- overflowBlocks.forEach(block => {
1123
- nextPageContainer.appendChild(block);
1124
- block.setAttribute('data-page-id', nextPage.getAttribute('data-page-id'));
1125
- });
1126
- return;
1127
- }
1128
-
1129
- // If the next page's second column has enough space for overflow from the first column
1130
- if (targetColumn === 1 && nextPageColumnHeights[1] + overflowHeight <= MAX_COLUMN_HEIGHT) {
1131
- const nextPageContainer = nextPage.querySelector('.block.monster.frame.wide');
1132
- overflowBlocks.forEach(block => {
1133
- nextPageContainer.appendChild(block);
1134
- block.setAttribute('data-page-id', nextPage.getAttribute('data-page-id'));
1135
- });
1136
- return;
1137
- }
1138
- }
1139
-
1140
- // Otherwise, create a new page and move the overflowing blocks there
1141
- const newPage = createNewPage();
1142
- if (!newPage) {
1143
- console.error('Failed to create a new page');
1144
- return;
1145
- }
1146
- const newMonsterFrame = newPage.querySelector('.block.monster.frame.wide');
1147
- if (!newMonsterFrame) {
1148
- console.error('New monster frame not found in the new page');
1149
- return;
1150
- }
1151
-
1152
-
1153
- overflowBlocks.forEach(block => {
1154
- newMonsterFrame.appendChild(block);
1155
- });
1156
- console.log(`Moved overflowing blocks to new page with ID: ${newPage.getAttribute('data-page-id')}`);
1157
- }
1158
-
1159
- // Utility function to get the next page element
1160
- function getNextPage(currentPage) {
1161
- const nextPageId = parseInt(currentPage.getAttribute('data-page-id').split('-')[1]) + 1;
1162
- return document.querySelector(`[data-page-id="page-${nextPageId}"]`);
1163
- }
1164
-
1165
- function moveBlockToPage(block, newPageId) {
1166
- block.setAttribute('data-page-id', newPageId);
1167
- const newPage = document.querySelector(`[data-page-id="${newPageId}"] .block-container`);
1168
- newPage.appendChild(block);
1169
- }
1170
-
1171
- // Handle the drop event on the trash area
1172
- function handleTrashDrop(e) {
1173
- e.preventDefault();
1174
- const innerHTML = e.dataTransfer.getData('text/plain');
1175
- const blockId = e.dataTransfer.getData('block-id');
1176
- console.log('Trash Drop event:', e);
1177
- console.log('Dragged block ID to trash:', blockId);
1178
-
1179
- if (innerHTML && blockId) {
1180
- // Find the dragged element and remove it from the DOM
1181
- let draggedElement = document.querySelector(`[data-block-id="${blockId}"].block-content`);
1182
- if (!draggedElement) {
1183
- draggedElement = document.querySelector(`[data-block-id="${blockId}"].block-item`);
1184
- }
1185
- if (draggedElement && draggedElement.parentElement) {
1186
- draggedElement.parentElement.removeChild(draggedElement);
1187
- console.log(`Removed block with ID: ${blockId} from the page`);
1188
- }
1189
-
1190
- // Check if the block already exists in the block-container and remove it if it does
1191
- let existingBlock = blockContainer.querySelector(`[data-block-id="${blockId}"].block-content`);
1192
- if (!existingBlock) {
1193
- existingBlock = blockContainer.querySelector(`[data-block-id="${blockId}"].block-item`);
1194
- }
1195
- if (existingBlock && existingBlock.parentElement) {
1196
- existingBlock.parentElement.removeChild(existingBlock);
1197
- console.log(`Removed duplicate block with ID: ${blockId} from block-container`);
1198
- }
1199
-
1200
- // Create a new block-item to be placed back in the block-container
1201
- const newBlock = document.createElement('div');
1202
- newBlock.classList.add('block-item');
1203
- newBlock.setAttribute('data-block-id', blockId);
1204
- newBlock.setAttribute('data-page-id', 'block-container');
1205
- newBlock.innerHTML = innerHTML;
1206
- newBlock.setAttribute('draggable', true);
1207
- newBlock.addEventListener('dragstart', handleDragStart);
1208
- newBlock.addEventListener('dragend', handleDragEnd);
1209
-
1210
- // Ensure the block is appended to the page wrapper inside blockContainer
1211
- let pageWrapper = blockContainer.querySelector('.page');
1212
- if (!pageWrapper) {
1213
- pageWrapper = document.createElement('div');
1214
- pageWrapper.classList.add('page');
1215
- pageWrapper.setAttribute('data-page-id', 'block-container');
1216
- blockContainer.appendChild(pageWrapper);
1217
- }
1218
-
1219
- // Debugging output
1220
- console.log('Page wrapper:', pageWrapper);
1221
- console.log('New block:', newBlock);
1222
-
1223
- // Find the original position to insert the new block
1224
- const originalPosition = initialPositions.find(pos => pos.id === blockId);
1225
- console.log('Original position:', originalPosition);
1226
-
1227
- if (originalPosition) {
1228
- const blocks = pageWrapper.querySelectorAll('.block-item');
1229
- console.log('Blocks in pageWrapper:', blocks);
1230
- console.log('Inserting at position:', originalPosition.index);
1231
-
1232
- if (originalPosition.index < blocks.length) {
1233
- const referenceNode = blocks[originalPosition.index];
1234
- if (referenceNode && referenceNode.parentNode === pageWrapper) {
1235
- console.log('Inserting before block at index:', originalPosition.index);
1236
- pageWrapper.insertBefore(newBlock, referenceNode);
1237
- console.log(`Moved block back to original position ${originalPosition.index} in block-container`);
1238
- } else {
1239
- console.warn('Reference node does not belong to pageWrapper, appending to the end');
1240
- pageWrapper.appendChild(newBlock);
1241
- console.log('Appended block to the end of block-container');
1242
- }
1243
- } else {
1244
- console.log('Appending block to the end of pageWrapper');
1245
- pageWrapper.appendChild(newBlock);
1246
- console.log('Appended block to the end of block-container');
1247
- }
1248
- } else {
1249
- console.log('Original position not found, appending block to the end of pageWrapper');
1250
- pageWrapper.appendChild(newBlock);
1251
- console.log('Appended block to the end of block-container');
1252
- }
1253
-
1254
- console.log(`Restored block with ID: ${blockId}`);
1255
- } else {
1256
- console.log('No data transferred');
1257
- }
1258
-
1259
- // Remove the "over" class and reset the background image
1260
- trashArea.classList.remove('over');
1261
- trashArea.style.backgroundImage = "url('./closed-mimic-trashcan.png')";
1262
- initializeTextareaResizing();
1263
- }
1264
-
1265
- function handleTrashOver(e) {
1266
- e.preventDefault();
1267
- e.dataTransfer.dropEffect = 'move';
1268
- trashArea.classList.add('over');
1269
- trashArea.style.backgroundImage = "url('./mimic_trashcan.png')";
1270
- console.log('Trash over event');
1271
- }
1272
-
1273
- function handleTrashLeave(e) {
1274
- trashArea.classList.remove('over');
1275
- trashArea.style.backgroundImage = "url('./closed-mimic-trashcan.png')";
1276
- console.log('Trash leave event');
1277
- }
1278
-
1279
- currentPage.addEventListener('dragover', handleDragOver);
1280
- currentPage.addEventListener('drop', handleDrop);
1281
-
1282
- trashArea.addEventListener('dragover', handleTrashOver);
1283
- trashArea.addEventListener('dragleave', handleTrashLeave);
1284
- trashArea.addEventListener('drop', handleTrashDrop);
1285
-
1286
- function handleReset() {
1287
- console.log('Reset button clicked');
1288
-
1289
- // Collect all blocks from all pages
1290
- const allBlocks = [];
1291
- const pages = document.querySelectorAll('.page');
1292
- pages.forEach(page => {
1293
- const blocksOnPage = page.querySelectorAll('[data-block-id]');
1294
- blocksOnPage.forEach(block => {
1295
- const blockId = block.getAttribute('data-block-id');
1296
- allBlocks.push({
1297
- id: blockId,
1298
- innerHTML: block.innerHTML
1299
- });
1300
- block.remove();
1301
- console.log(`Removed block with ID: ${blockId} from page ID: ${page.getAttribute('data-page-id')}`);
1302
- });
1303
- });
1304
-
1305
- // Clear all pages
1306
- pages.forEach(page => page.remove());
1307
-
1308
- // Clear blockContainer before reinserting blocks
1309
- blockContainer.innerHTML = '';
1310
-
1311
- // Reinsert blocks back into the blockContainer in their original order
1312
- let pageWrapper = blockContainer.querySelector('.page');
1313
- if (!pageWrapper) {
1314
- pageWrapper = document.createElement('div');
1315
- pageWrapper.classList.add('page');
1316
- pageWrapper.setAttribute('id', 'block-page');
1317
- blockContainer.appendChild(pageWrapper);
1318
- }
1319
- // Reassign blockContainerPage to the newly created block-page element
1320
- blockContainerPage = document.getElementById('block-page');
1321
-
1322
- initialPositions.forEach(pos => {
1323
- const blockData = allBlocks.find(block => block.id === pos.id);
1324
- if (blockData) {
1325
- const newBlock = document.createElement('div');
1326
- newBlock.classList.add('block-item');
1327
- newBlock.setAttribute('data-block-id', blockData.id);
1328
- newBlock.setAttribute('data-page-id', 'block-container');
1329
- newBlock.innerHTML = blockData.innerHTML;
1330
- newBlock.setAttribute('draggable', true);
1331
- newBlock.addEventListener('dragstart', handleDragStart);
1332
- newBlock.addEventListener('dragend', handleDragEnd);
1333
-
1334
- const blocks = pageWrapper.querySelectorAll('.block-item');
1335
- if (pos.index < blocks.length) {
1336
- pageWrapper.insertBefore(newBlock, blocks[pos.index]);
1337
- console.log(`Moved block back to original position ${pos.index} in block-container`);
1338
- } else {
1339
- pageWrapper.appendChild(newBlock);
1340
- console.log('Appended block to the end of block-container');
1341
- }
1342
- }
1343
- });
1344
- createNewPage();
1345
-
1346
- console.log('Reset complete, all blocks moved back to block-container');
1347
- initializeTextareaResizing();
1348
- }
1349
-
1350
- pageContainer.addEventListener('dragover', handleDragOver);
1351
- pageContainer.addEventListener('drop', handleDrop);
1352
-
1353
- trashArea.addEventListener('dragover', handleTrashOver);
1354
- trashArea.addEventListener('dragleave', handleTrashLeave);
1355
- trashArea.addEventListener('drop', handleTrashDrop);
1356
- resetButton.addEventListener('click', handleReset);
1357
- extractBlocks();
1358
- });
1359
 
1360
  </script>
1361
  </body>
 
8
  <link href='./dependencies/bundle.css' rel='stylesheet' />
9
  <link href="./dependencies/style.css" rel='stylesheet' />
10
  <link href="./dependencies/5ePHBstyle.css" rel='stylesheet' />
11
+ <link href="./storeUI.css" rel='stylesheet' />
12
  <title>DnD Stat Block</title>
13
  <link rel="stylesheet" href="styles.css">
14
  <script src="https://unpkg.com/[email protected]/dist/htmx.min.js"></script>
15
  </head>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  <body>
18
  <div class="grid-container">
19
  <div class="block-container" id="blockContainer" >
 
21
  <!-- Blocks will be wrapped in a page div and loaded here -->
22
  </div>
23
  </div>
24
+
25
  <div class="page-container" id="pageContainer">
26
+ <h1>Describe your creature</h1>
 
27
  <textarea id="user-description" class="user-description-textarea"
28
  hx-post="/update-stats" hx-trigger="change"
29
  hx-target="#user-description" hx-swap="outerHTML"
30
  title="As much or as little description as you want to provide. You can provide specific employees, inventory etc">A very standard gear store run by a fae potted plant named Gorgeous</textarea>
31
  <button id="submitDescription">Submit</button>
32
  <button id="parseHTML">Parse HTML</button>
33
+ <button id="resetButton">Reset</button>
34
+ <button onclick="printPageContainer()">Print to PDF</button>
35
+ <div class="brewRenderer" id="brewRenderer">
36
+
37
+ <div class="pages" id="pages">
38
  <div id="page-1" class="page" data-page-id="page-0">
39
  <div class="columnWrapper">
40
  <div class="block monster frame wide">
 
53
  <img class="modal-content" id="modalImage">
54
  <div id="caption"></div>
55
  </div>
56
+ <script src="scripts.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  </script>
59
  </body>
store_helper.py CHANGED
@@ -1,5 +1,3 @@
1
- from flask import Flask, request, jsonify
2
- from flask_cors import CORS
3
  import ast
4
  import gc
5
  from openai import OpenAI
 
 
 
1
  import ast
2
  import gc
3
  from openai import OpenAI
template.html DELETED
@@ -1,581 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <link href="./dependencies/all.css" rel="stylesheet" />
7
- <link href="./dependencies/css.css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
8
- <link href='./dependencies/bundle.css' rel='stylesheet' />
9
- <link href="./dependencies/style.css" rel='stylesheet' />
10
- <link href="./dependencies/5ePHBstyle.css" rel='stylesheet' />
11
- <title>Template</title>
12
- <link rel="stylesheet" href="styles.css">
13
- <script src="https://unpkg.com/[email protected]/dist/htmx.min.js"></script>
14
- </head>
15
- <style>
16
- :root {
17
- --HB_Color_Background: #EEE5CE;
18
- --HB_Color_Accent: #E0E5C1;
19
- --HB_Color_HeaderUnderline: #C0AD6A;
20
- --HB_Color_HorizontalRule: #9C2B1B;
21
- --HB_Color_HeaderText: #58180D;
22
- --HB_Color_MonsterStatBackground: #F2E5B5;
23
- --HB_Color_CaptionText: #766649;
24
- --HB_Color_WatercolorStain: #BBAD82;
25
- --HB_Color_Footnotes: #C9AD6A;
26
- }
27
- input[type="text"], textarea {
28
- width: auto;
29
- padding: 8px;
30
- margin: 5px 0;
31
- border: 1px solid #ccc;
32
- border-radius: 4px;
33
- font-size: 14px;
34
- background-color: #f9f9f9;
35
- transition: background-color 0.3s ease, border-color 0.3s ease;
36
- }
37
- .grid-container {
38
- display: grid;
39
- grid-template-columns: 1fr 3fr; /* Two columns with the second column being three times as wide */
40
- grid-gap: 20px;
41
- padding: 20px;
42
- height: 100vh;
43
- }
44
- .block-container {
45
- display: flex;
46
- flex-direction: column;
47
- gap: 20px;
48
- overflow-y: auto;
49
- border-right: 1px solid #ccc;
50
- padding-right: 20px;
51
- }
52
- .block-item {
53
- border: 1px solid #ccc;
54
- border-radius: 8px;
55
- background-color: #f9f9f9;
56
- padding: 15px;
57
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
58
- transition: transform 0.3s;
59
- }
60
- .block-item:hover {
61
- transform: translateY(-5px);
62
- }
63
- .page .monster hr:last-of-type + * {
64
- margin-top: .1cm;
65
- }
66
- .page * + h4 {
67
- margin-top: .1cm;
68
- }
69
- .page h4 + * {
70
- margin-top: .1cm;
71
- }
72
- .page dl + * {
73
- margin-top: .1cm;
74
- }
75
- .page p + * {
76
- margin-top: .1cm;
77
- }
78
- .columnWrapper {
79
- column-gap: inherit;
80
- max-height: 100%;
81
- column-span: all;
82
- columns: inherit;
83
- height: 100%; /* Ensure it takes full height of the parent */
84
- box-sizing: border-box; /* Ensures padding and border are included in the element's total width and height */
85
- }
86
- input[type="text"]:focus, textarea:focus {
87
- background-color: #e9e9e9;
88
- border-color: #aaa;
89
- outline: none;
90
- }
91
-
92
- /* Specific styles for different textboxes */
93
-
94
- .user-description-textarea {
95
- width: 400px;
96
- height: 40px; /* Adjust as needed for 3 lines */
97
- resize: vertical;
98
- background: none;
99
- font-family: "ScalySansRemake";
100
- font-weight: 800;
101
-
102
- }
103
- /* Focus styles for description textbox */
104
- .user-description-textarea:focus {
105
- background-color: #e9e9e9;
106
- border-color: #aaa;
107
- outline: none;
108
- }
109
-
110
- .heading-textarea {
111
- width: 100%;
112
- font-size: .458cm; /* Matches the font size of an h4 heading */
113
- line-height: .7em;
114
- font-weight: 800;
115
- border: none;
116
- background: none;
117
- margin: 0;
118
- padding: 0;
119
- resize: none; /* Prevents the textarea from being resizable */
120
- overflow: hidden; /* Prevents scrollbars */
121
- outline: none; /* Removes the focus outline */
122
- font-family: "MrEavesRemake"; /* Ensures font family is inherited */
123
- color: var(--HB_Color_HeaderText)
124
- }
125
- .properties-textarea {
126
- width: 100%;
127
- font-size: 12px;
128
- font-weight: 400;
129
- line-height: .7em;
130
- margin-bottom: 0;
131
- font-style: italic;
132
- box-sizing: border-box;
133
- border: 0;
134
- font-family: "ScalySansRemake";
135
- vertical-align: baseline;
136
- margin: 0;
137
- padding: 0;
138
- overflow-wrap: break-word;
139
- text-rendering: optimizeLegibility;
140
- background: none;
141
- resize: none; /* Prevents the textarea from being resizable */
142
-
143
- }
144
-
145
- .description-textarea {
146
- width: 100%;
147
- height: 125px;
148
- font-size: .318cm;
149
- font-weight: 400;
150
- line-height: .9em;
151
- margin-bottom: 0;
152
- font-style: italic;
153
- box-sizing: border-box;
154
- border: 0;
155
- font-family: "ScalySansSmallCapsRemake";
156
- vertical-align: baseline;
157
- margin: 0;
158
- padding: 0;
159
- overflow-wrap: break-word;
160
- text-rendering: optimizeLegibility;
161
- background: none;
162
- resize: none; /* Prevents the textarea from being manually resizable */
163
- overflow: hidden; /* Hide scrollbars */
164
- }
165
-
166
- .red-integer-stat-textarea {
167
- width: 20px;
168
- height:13px;
169
- font-size: .318cm;
170
- font-weight: 400;
171
- line-height: 1.2em;
172
- margin-bottom: 0;
173
- font-style: italic;
174
- box-sizing: border-box;
175
- border: 0;
176
- font-family: "ScalySansSmallCapsRemake";
177
- vertical-align: baseline;
178
- margin: 0;
179
- padding: 0;
180
- overflow-wrap: break-word;
181
- text-rendering: optimizeLegibility;
182
- background: none;
183
- resize: none; /* Prevents the textarea from being manually resizable */
184
- overflow: hidden; /* Hide scrollbars */
185
- color: var(--HB_Color_HeaderText);
186
- white-space: pre-line;
187
- }
188
-
189
- .integer-stat-textarea {
190
- width: 20px;
191
- height:13px;
192
- font-size: .318cm;
193
- font-weight: 400;
194
- line-height: 1.2em;
195
- margin-bottom: 0;
196
- font-style: italic;
197
- box-sizing: border-box;
198
- border: 0;
199
- font-family: "ScalySansRemake";
200
- vertical-align: baseline;
201
- margin: 0;
202
- padding: 0;
203
- overflow-wrap: break-word;
204
- text-rendering: optimizeLegibility;
205
- background: none;
206
- resize: none; /* Prevents the textarea from being manually resizable */
207
- overflow: hidden; /* Hide scrollbars */
208
- white-space: pre-line;
209
- }
210
-
211
- .string-stat-textarea {
212
- width: 200px;
213
- height:13px;
214
- font-size: .318cm;
215
- font-weight: 400;
216
- line-height: 1.2em;
217
- margin-bottom: 0;
218
- font-style: italic;
219
- box-sizing: border-box;
220
- border: 0;
221
- font-family: "ScalySansRemake";
222
- vertical-align: baseline;
223
- margin: 0;
224
- padding: 0;
225
- overflow-wrap: break-word;
226
- text-rendering: optimizeLegibility;
227
- background: none;
228
- resize: none; /* Prevents the textarea from being manually resizable */
229
- overflow: hidden; /* Hide scrollbars */
230
- white-space: pre-wrap;
231
- }
232
-
233
- .string-action-name-textarea {
234
- width: 100%;
235
- height:13px;
236
- font-size: .318cm;
237
- font-style: italic;
238
- font-weight: bold;
239
- line-height: 1.2em;
240
- margin-bottom: 0;
241
- font-style: italic;
242
- box-sizing: border-box;
243
- border: 0;
244
- font-family: "ScalySansRemake";
245
- vertical-align: baseline;
246
- margin: 0;
247
- padding: 0;
248
- overflow-wrap: break-word;
249
- text-rendering: optimizeLegibility;
250
- background: none;
251
- resize: none; /* Prevents the textarea from being manually resizable */
252
- overflow: hidden; /* Hide scrollbars */
253
-
254
- }
255
-
256
- .string-action-description-textarea {
257
- width: 100%;
258
- height:30px;
259
- font-size: .318cm;
260
- font-weight: 400;
261
- line-height: 1.2em;
262
- margin-bottom: 0;
263
- box-sizing: border-box;
264
- border: 0;
265
- font-family: "ScalySansRemake";
266
- vertical-align: baseline;
267
- margin: 0;
268
- padding: 0;
269
- overflow-wrap: break-word;
270
- text-rendering: optimizeLegibility;
271
- background: none;
272
- resize: none; /* Prevents the textarea from being manually resizable */
273
- overflow: hidden; /* Hide scrollbars */
274
- white-space: pre-wrap;
275
-
276
-
277
- }
278
-
279
- .name-textbox {
280
- width: 50px;
281
- font-size: 1.5em;
282
- padding: 10px;
283
- }
284
-
285
- .stat-textbox {
286
- width: 50px;
287
- text-align: center;
288
- font-size: 1em;
289
- padding: 5px;
290
- }
291
- </style>
292
- <body>
293
- <div class="brewRenderer">
294
- <div class="pages">
295
- <div class="page" id="p1" key="0">
296
- <div class="columnWrapper">
297
- <div class="block monster frame wide">
298
- <div class="Block_1">
299
- <textarea class="heading-textarea" id="user-monster-name" hx-post="/update-stats" hx-trigger="change" hx-target="#user-monster-name" hx-swap="outerHTML" title=" Name of creature">Ebony, the Twisted Fairy</textarea>
300
- </div>
301
- <div class="Block_2">
302
- <p>
303
- <textarea class="properties-textarea" id="user-monster-properties" hx-post="/update-stats" hx-trigger="change"
304
- hx-target="#user-monster-properties" hx-swap="outerHTML" title=" Size, Type, Alignment">Tiny, Fey, Chaotic Evil</textarea>
305
- </p>
306
- </div>
307
- <div class="Block_3">
308
- <p>
309
- <img class="monster-image" id="monster-image" style="width:300px; height:300px; mix-blend-mode:multiply; border:3px solid black;"
310
- src="Ebony,%20the%20Twisted%20Fairy_files/out.png" alt="image"
311
- hx-get="/get-new-image" hx-trigger="load" hx-target="#monster-image" hx-swap="outerHTML">
312
- </p>
313
- </div>
314
- <div class="Block_4">
315
- <div class="block descriptive">
316
- <textarea class="description-textarea" id="user-monster-description" hx-post="/update-stats" hx-trigger="change"
317
- hx-target="#user-monster-description" hx-swap="outerHTML" title="Any amount or style of description">Once a cheerful and benign spirit of the forest, Ebony has been corrupted by dark magic, transforming her into a sinister force of malevolence. Despite her tiny stature, her powers have grown exponentially. Her once fairy-like aura now radiates dread, and she is capable of casting deadly spells that can reduce any foe to dust. Ebony delights in tormenting the innocent and disrupting the natural balance of the world.</textarea></h5>
318
- </div>
319
- </div>
320
- <div class="Block_5"><hr>
321
- <dl><strong>Armor Class : </strong><textarea class="integer-stat-textarea" id="user-monster-armor-class" hx-post="/update-stats" hx-trigger="change"
322
- hx-target="#user-monster-armor-class" hx-swap="outerHTML" title="Integer">14</textarea>
323
- <strong>Hit Points : </strong><textarea class="integer-stat-textarea" id="user-monster-hit-points" hx-post="/update-stats" hx-trigger="change"
324
- hx-target="#user-monster-hit-points" hx-swap="outerHTML" title="Integer">75</textarea>
325
- <strong>Speed : </strong> Walk: <textarea class="integer-stat-textarea" id="user-monster-speed-walk" hx-post="/update-stats" hx-trigger="change"
326
- hx-target="#user-monster-speed" hx-swap="outerHTML" title="Integer">10</textarea> Fly :<textarea class="integer-stat-textarea" id="user-monster-speed-fly" hx-post="/update-stats" hx-trigger="change"
327
- hx-target="#user-monster-speed" hx-swap="outerHTML" title="Integer">60</textarea>
328
- </dl>
329
- </div>
330
- <div class="Block_6"><hr>
331
- <table>
332
- <thead>
333
- <tr>
334
- <th align="center">STR</th>
335
- <th align="center">DEX</th>
336
- <th align="center">CON</th>
337
- <th align="center">INT</th>
338
- <th align="center">WIS</th>
339
- <th align="center">CHA</th>
340
- </tr>
341
- </thead>
342
- <tbody>
343
- <tr>
344
- <td align="center"><textarea class="red-integer-stat-textarea" id="user-monster-strength" hx-post="/update-stats" hx-trigger="change"
345
- hx-target="#user-monster-strength" hx-swap="outerHTML" title="Integer">5</textarea></td>
346
- <td align="center"><textarea class="red-integer-stat-textarea" id="user-monster-dexterity" hx-post="/update-stats" hx-trigger="change"
347
- hx-target="#user-monster-dexterity" hx-swap="outerHTML" title="Integer">18</textarea></td>
348
- <td align="center"><textarea class="red-integer-stat-textarea" id="user-monster-constitution" hx-post="/update-stats" hx-trigger="change"
349
- hx-target="#user-monster-constitution" hx-swap="outerHTML" title="Integer">14</textarea></td>
350
- <td align="center"><textarea class="red-integer-stat-textarea" id="user-monster-intellgience" hx-post="/update-stats" hx-trigger="change"
351
- hx-target="#user-monster-intelligence" hx-swap="outerHTML" title="Integer">16</textarea></td>
352
- <td align="center"><textarea class="red-integer-stat-textarea" id="user-monster-wisdom" hx-post="/update-stats" hx-trigger="change"
353
- hx-target="#user-monster-wisdom" hx-swap="outerHTML" title="Integer">12</textarea></td>
354
- <td align="center"><textarea class="red-integer-stat-textarea" id="user-monster-charisma" hx-post="/update-stats" hx-trigger="change"
355
- hx-target="#user-monster-charisma" hx-swap="outerHTML" title="Integer">20</textarea></td>
356
- </tr>
357
- </tbody>
358
- </table>
359
- </div>
360
- <div class="Block_7">
361
- <hr>
362
- <strong>Saving Throws</strong>
363
- <textarea class="string-stat-textarea" id="user-monster-saves" hx-post="/update-stats" hx-trigger="change"
364
- hx-target="#user-monster-saves" hx-swap="outerHTML" title="[Stat colon integer 2x space] STR: 2 DEX: 7">STR: 2 DEX: 7 WIS: 5</textarea>
365
- <br><strong>Resistances :</strong> <textarea class="string-stat-textarea" id="user-monster-wis-save" hx-post="/update-stats" hx-trigger="change"
366
- hx-target="#user-monster-wis-save" hx-swap="outerHTML" title="Integer">None</textarea>
367
- <br><strong>Senses :</strong><textarea class="string-stat-textarea" id="user-monster-senses" hx-post="/update-stats" hx-trigger="change"
368
- hx-target="#user-monster-senses" hx-swap="outerHTML" title="[Sense colon integer] Darkvision: 60">Darkvision: 60</textarea>
369
- <br><strong>Languages :</strong><textarea class="string-stat-textarea" id="user-monster-languages" hx-post="/update-stats" hx-trigger="change"
370
- hx-target="#user-monster-languages" hx-swap="outerHTML" title="[language comma space] Common, Sylvan">Common, Sylvan</textarea>
371
- <br><strong>Challenge Rating :</strong><textarea class="string-stat-textarea" id="user-monster-languages" hx-post="/update-stats" hx-trigger="change"
372
- hx-target="#user-monster-cr" hx-swap="outerHTML" title="[CR space parenthesis XP parenthesis] 6 (2300)">6 (2300)</textarea>
373
- </div>
374
- <div class="Block_8">
375
- <hr>
376
- <h4 id="actions">Actions</h4>
377
- <strong>
378
- <textarea class="string-action-name-textarea"
379
- id="user-monster-action_name_1"
380
- hx-post="/update-stats"
381
- hx-trigger="change"
382
- hx-target="#user-monster-action_name_1"
383
- hx-swap="outerHTML"
384
- title="[Action Name colon] Fairy Bolt:">Fairy Bolt: </textarea>
385
- </strong>
386
- <textarea class="string-action-description-textarea"
387
- id="user-monster-action_details_1"
388
- hx-post="/update-stats"
389
- hx-trigger="change"
390
- hx-target="#user-monster-action_details_1"
391
- hx-swap="outerHTML"
392
- title="[Action Type colon to hit bonus comma range comma number of targets space Hit colon damage parenthesis damage dice parenthesis damage type] Ranged Spell Attack: +7 to hit, range 60 ft., one target. Hit: 21 (3d10 + 4) radiant damage.">Ranged Spell Attack: +7 to hit, range 60 ft., one target. Hit: 21 (3d10 + 4) radiant damage.</textarea>
393
- <strong>
394
- <textarea class="string-action-name-textarea"
395
- id="user-monster-action_name_2"
396
- hx-post="/update-stats" hx-trigger="change"
397
- hx-target="#user-monster-action_name_2"
398
- hx-swap="outerHTML"
399
- title="[Action Name colon] Fairy Bolt:">Poison Dust: </textarea>
400
- </strong>
401
- <textarea class="string-action-description-textarea"
402
- id="user-monster-action_details_1"
403
- hx-post="/update-stats"
404
- hx-trigger="change"
405
- hx-target="#user-monster-action_details_1"
406
- hx-swap="outerHTML"
407
- title="[Action Type colon to hit bonus comma range comma number of targets space Hit colon damage parenthesis damage dice parenthesis damage type] Ranged Spell Attack: +7 to hit, range 60 ft., one target. Hit: 21 (3d10 + 4) radiant damage.">Ebony releases a cloud of toxic dust in a 10-foot radius. Each creature within the area must succeed on a DC 15 Constitution saving throw or take 15 (3d8) poison damage and become poisoned for 1 minute. The poisoned creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.</textarea>
408
- </div>
409
- <div class="Block_9">
410
- <h4 id="cantrips">Cantrips</h4>
411
- <strong>
412
- <textarea class="string-action-name-textarea"
413
- id="user-monster-action_name_2"
414
- hx-post="/update-stats" hx-trigger="change"
415
- hx-target="#user-monster-action_name_2"
416
- hx-swap="outerHTML"
417
- title="[Action Name colon] Fairy Bolt:">Eldritch Blast: </textarea>
418
- </strong>
419
- <textarea class="string-action-description-textarea"
420
- id="user-monster-action_details_1"
421
- hx-post="/update-stats"
422
- hx-trigger="change"
423
- hx-target="#user-monster-action_details_1"
424
- hx-swap="outerHTML"
425
- title="[Action description range mechanics effect] Ranged Spell Attack: +7 to hit, range 60 ft., one target. Hit: 21 (3d10 + 4) radiant damage.">A beam of crackling energy streaks toward a creature within range. Make a ranged spell attack against the target. On a hit, the target takes 1d10 force damage.</textarea>
426
- </div>
427
- <div class="Block_10">
428
- <h4 id="spell slots">Spell Slots</h4>
429
- <dl><dt><em><strong>1st level</strong></em>:</dt><dd><textarea class="integer-stat-textarea" id="level-1-slots" hx-post="/update-stats" hx-trigger="change"
430
- hx-target="#user-monster-armor-class" hx-swap="outerHTML" title="Integer">4</textarea></dd></dl>
431
- <dl><dt><em><strong>2nd level</strong></em>:</dt><dd><textarea class="integer-stat-textarea" id="level-2-slots" hx-post="/update-stats" hx-trigger="change"
432
- hx-target="#user-monster-armor-class" hx-swap="outerHTML" title="Integer">4</textarea></dd></dl>
433
- <dl><dt><em><strong>3rd level</strong></em>:</dt><dd><textarea class="integer-stat-textarea" id="level-3-slots" hx-post="/update-stats" hx-trigger="change"
434
- hx-target="#user-monster-armor-class" hx-swap="outerHTML" title="Integer">4</textarea></dd></dl>
435
- <h4 id="known spells">Known Spells</h4>
436
- <strong>
437
- <textarea class="string-action-name-textarea"
438
- id="user-monster-action_name_2"
439
- hx-post="/update-stats" hx-trigger="change"
440
- hx-target="#user-monster-action_name_2"
441
- hx-swap="outerHTML"
442
- title="[Action Name colon] Fairy Bolt:">Charm Person: </textarea>
443
- </strong>
444
- <textarea class="string-action-description-textarea"
445
- id="user-monster-action_details_1"
446
- hx-post="/update-stats"
447
- hx-trigger="change"
448
- hx-target="#user-monster-action_details_1"
449
- hx-swap="outerHTML"
450
- title="[Level colon description range mechanics effect] Level: 2nd. A creature you touch becomes invisible until the spell ends. Anything the target is wearing or carrying is invisible as long as it is on the target's person..">Level: 1st. You attempt to charm a humanoid you can see within range. It must make a Wisdom saving throw, and does so with advantage if you or your companions are fighting it. If it fails the saving throw, it is charmed by you until the spell ends or until you or your companions do anything harmful to it.</textarea>
451
- <strong>
452
- <textarea class="string-action-name-textarea"
453
- id="user-monster-action_name_2"
454
- hx-post="/update-stats" hx-trigger="change"
455
- hx-target="#user-monster-action_name_2"
456
- hx-swap="outerHTML"
457
- title="[Action Name colon] Fairy Bolt:">Invisibility: </textarea>
458
- </strong>
459
- <textarea class="string-action-description-textarea"
460
- id="user-monster-action_details_1"
461
- hx-post="/update-stats"
462
- hx-trigger="change"
463
- hx-target="#user-monster-action_details_1"
464
- hx-swap="outerHTML"
465
- title="[Level colon description range mechanics effect] Level: 2nd. A creature you touch becomes invisible until the spell ends. Anything the target is wearing or carrying is invisible as long as it is on the target's person.">Level: 2nd. A creature you touch becomes invisible until the spell ends. Anything the target is wearing or carrying is invisible as long as it is on the target's person.</textarea>
466
- <strong>
467
- <textarea class="string-action-name-textarea"
468
- id="user-monster-action_name_2"
469
- hx-post="/update-stats" hx-trigger="change"
470
- hx-target="#user-monster-action_name_2"
471
- hx-swap="outerHTML"
472
- title="[Action Name colon] Fairy Bolt:">Fireball: </textarea>
473
- </strong>
474
- <textarea class="string-action-description-textarea"
475
- id="user-monster-action_details_1"
476
- hx-post="/update-stats"
477
- hx-trigger="change"
478
- hx-target="#user-monster-action_details_1"
479
- hx-swap="outerHTML"
480
- title="[Level colon description range mechanics effect] Level: 2nd. A creature you touch becomes invisible until the spell ends. Anything the target is wearing or carrying is invisible as long as it is on the target's person.">Level: 3rd. A bright streak flashes from your pointing finger to a point you choose within range and then blossoms with a low roar into an explosion of flame. Each creature in a 20-foot radius sphere centered on that point must make a Dexterity saving throw. A target takes 8d6 fire damage on a failed save, or half as much damage on a successful one.</textarea>
481
- </div>
482
- <div class="Block_9">
483
- <h4 id="legendary actions">Legendary Actions</h4>
484
- <textarea class="string-action-description-textarea"
485
- id="user-monster-action_details_1"
486
- hx-post="/update-stats"
487
- hx-trigger="change"
488
- hx-target="#user-monster-action_details_1"
489
- hx-swap="outerHTML"
490
- title="[Number of legendary actions period How many actions per turn and when to play period Action regain rules] Ebony can take 3 legendary actions, choosing from the options below. Only one legendary action can be used at a time and only at the end of another creature's turn. Ebony regains spent legendary actions at the start of her turn.">Ebony can take 3 legendary actions, choosing from the options below. Only one legendary action can be used at a time and only at the end of another creature's turn. Ebony regains spent legendary actions at the start of her turn.</textarea>
491
- <strong>
492
- <textarea class="string-action-name-textarea"
493
- id="user-monster-action_name_2"
494
- hx-post="/update-stats" hx-trigger="change"
495
- hx-target="#user-monster-action_name_2"
496
- hx-swap="outerHTML"
497
- title="[Action Name colon] Fairy Bolt:">Dark Whispers: </textarea>
498
- </strong>
499
- <textarea class="string-action-description-textarea"
500
- id="user-monster-action_details_1"
501
- hx-post="/update-stats"
502
- hx-trigger="change"
503
- hx-target="#user-monster-action_details_1"
504
- hx-swap="outerHTML"
505
- title="[Level colon description range mechanics effect] Level: 2nd. A creature you touch becomes invisible until the spell ends. Anything the target is wearing or carrying is invisible as long as it is on the target's person.">Ebony whispers insidiously to a target within 30 feet. The target must succeed on a DC 16 Wisdom saving throw or take 10 (3d6) psychic damage and become frightened until the end of its next turn.</textarea>
506
- <strong>
507
- <textarea class="string-action-name-textarea"
508
- id="user-monster-action_name_2"
509
- hx-post="/update-stats" hx-trigger="change"
510
- hx-target="#user-monster-action_name_2"
511
- hx-swap="outerHTML"
512
- title="[Action Name colon] Fairy Bolt:">Teleport: </textarea>
513
- </strong>
514
- <textarea class="string-action-description-textarea"
515
- id="user-monster-action_details_1"
516
- hx-post="/update-stats"
517
- hx-trigger="change"
518
- hx-target="#user-monster-action_details_1"
519
- hx-swap="outerHTML"
520
- title="[Level colon description range mechanics effect] Level: 2nd. A creature you touch becomes invisible until the spell ends. Anything the target is wearing or carrying is invisible as long as it is on the target's person.">Ebony magically teleports, along with any equipment she is wearing or carrying, up to 60 feet to an unoccupied space she can see.</textarea>
521
- <strong>
522
- <textarea class="string-action-name-textarea"
523
- id="user-monster-action_name_2"
524
- hx-post="/update-stats" hx-trigger="change"
525
- hx-target="#user-monster-action_name_2"
526
- hx-swap="outerHTML"
527
- title="[Action Name colon] Fairy Bolt:">Fairy Glow: </textarea>
528
- </strong>
529
- <textarea class="string-action-description-textarea"
530
- id="user-monster-action_details_1"
531
- hx-post="/update-stats"
532
- hx-trigger="change"
533
- hx-target="#user-monster-action_details_1"
534
- hx-swap="outerHTML"
535
- title="[Level colon description range mechanics effect] Level: 2nd. A creature you touch becomes invisible until the spell ends. Anything the target is wearing or carrying is invisible as long as it is on the target's person.">Ebony emits a burst of glowing lights. Each creature of her choice within 20 feet of her must succeed on a DC 16 Dexterity saving throw or be blinded until the end of Ebony's next turn.</textarea>
536
- </div>
537
- </div>
538
- </div>
539
- </div>
540
- </div>
541
- </div>
542
-
543
- <script>
544
- document.addEventListener("DOMContentLoaded", function() {
545
- function adjustTextareaHeight(el) {
546
- console.log('Start height:', el.scrollHeight);
547
- if (el.scrollHeight > 16) {
548
- el.style.height = 'auto'; // Reset the height
549
- console.log('Auto height:', el.scrollHeight);
550
- console.log('Adjusting height for:', el.id); // Debugging line
551
- el.style.height = (el.scrollHeight) + 'px'; // Set it to the scroll height
552
- console.log('New height:', el.style.height);
553
- }
554
- }
555
-
556
- const classes = [
557
- 'description-textarea',
558
- 'user-description-textarea',
559
- 'heading-textarea',
560
- 'properties-textarea',
561
- 'string-stat-textarea',
562
- 'string-action-description-textarea'
563
- ];
564
-
565
- classes.forEach(className => {
566
- const textareas = document.querySelectorAll(`.${className}`);
567
- console.log(`Textareas found for ${className}:`, textareas.length); // Debugging line
568
- textareas.forEach(textarea => {
569
- // Adjust height on page load
570
- adjustTextareaHeight(textarea);
571
- // Adjust height on input
572
- textarea.addEventListener('input', function() {
573
- adjustTextareaHeight(textarea);
574
- console.log('Input event triggered for:', textarea.id); // Debugging line
575
- });
576
- });
577
- });
578
- });
579
- </script>
580
- </body>
581
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
template_update.html ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="page" id="block-page" data-page-id="block-container">
2
+ <div class="block-item" data-block-id="0" data-page-id="block-container" draggable="true">
3
+ <h1>
4
+ <textarea class="title-textarea" id="user-store-title" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-name" hx-swap="outerHTML" title="Name of store">Enchanted Roots Gear Emporium</textarea>
5
+ </h1>
6
+ <div contenteditable="true" class="description-textarea" id="user-store-description" hx-post="/update-stats" hx-trigger="change" hx-target="#user-monster-description" hx-swap="outerHTML" title="Any amount or style of description" style="height: 195px;">
7
+ <p>Nestled in the heart of the bustling Market District, Enchanted Roots Gear Emporium is a veritable Eden for adventurers seeking gear with a twist of magic and a dash of the unexpected. A vivid cacophony of wild, glowing flora complements the vast inventory of essential equipment and enchanting curiosities. Enchanted Roots was established by Gorgeous, an intelligent fae plant, after it was discovered by a wandering druid in a mystical forest. With an innate understanding of magical flora and fauna, Gorgeous decided to settle in town and share its treasures with the world. Renowned for its unique owner and unusual collection, adventurers and local townsfolk alike swear by the quality and charm of the items sold here.</p>
8
+ </div>
9
+ </div>
10
+
11
+ <div class="block-item" data-block-id="1" data-page-id="block-container" draggable="true">
12
+ <textarea class="string-action-description-textarea" id="user-storefront-prompt-1" hx-post="/update-stats" hx-trigger="change" hx-target="#user-sd-prompt" hx-swap="outerHTML" title="Storefront image description" style="height: 80px;">A highly detailed fantasy painting of a curious sentient potted plant in a vibrant gear shop. The plant has phosphorescent leaves and delicate, intricate roots. The shop is filled with glowing flora, magical tools, and adventure gear. The background shows enchanted trees intertwined with the walls and ceiling.</textarea>
13
+ <button class="generate-image-button" data-block-id="1">Generate Image</button>
14
+ <img id="generated-image-1" alt="" style="display: none; cursor: pointer;">
15
+ </div>
16
+
17
+ <div class="block-item" data-block-id="2" data-page-id="block-container" draggable="true">
18
+ <div class="block classTable frame decoration">
19
+ <table>
20
+ <thead>
21
+ <tr>
22
+ <th align="left"></th>
23
+ <th align="center"></th>
24
+ <th align="center"></th>
25
+ </tr>
26
+ </thead>
27
+ <tbody>
28
+ <tr>
29
+ <td align="left"><strong>Size</strong></td>
30
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-size-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-size-2t" hx-swap="outerHTML" title="Store Size">Medium</textarea></td>
31
+ </tr>
32
+ <tr>
33
+ <td align="left"><strong>Town</strong></td>
34
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-town-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-town-2t" hx-swap="outerHTML" title="Store Size">Everbright</textarea></td>
35
+ </tr>
36
+ <tr>
37
+ <td align="left"><strong>District</strong></td>
38
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-district-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-district-2t" hx-swap="outerHTML" title="Store Size">Market District</textarea></td>
39
+ </tr>
40
+ <tr>
41
+ <td align="left"><strong>Street</strong></td>
42
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-street-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-street-2t" hx-swap="outerHTML" title="Store Size">Wanderer's Way</textarea></td>
43
+ </tr>
44
+ <tr>
45
+ <td align="left"><strong>Type</strong></td>
46
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-type-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-type-2t" hx-swap="outerHTML" title="Store Size">Gear Shop</textarea></td>
47
+ </tr>
48
+ <tr>
49
+ <td align="left"><strong>Store Hours</strong></td>
50
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-hours-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-hours-2t" hx-swap="outerHTML" title="Store Size">9 AM - 6 PM, daily</textarea></td>
51
+ </tr>
52
+ <tr>
53
+ <td align="left"><strong>Store Services</strong></td>
54
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-services-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-services-2t" hx-swap="outerHTML" title="">Plant Whispering</textarea></td>
55
+ </tr>
56
+ <tr>
57
+ <td align="left"><strong>Store Services</strong></td>
58
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-services-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-services-2t" hx-swap="outerHTML" title="">Enchantment Infusion</textarea></td>
59
+ </tr>
60
+ <tr>
61
+ <td align="left"><strong>Store Specialties</strong></td>
62
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-specialties-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-specialties-2t" hx-swap="outerHTML" title="">Fae Light Compass</textarea></td>
63
+ </tr>
64
+ <tr>
65
+ <td align="left"><strong>Store Rumors</strong></td>
66
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-rumors-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-2t" hx-swap="outerHTML" title="Rumors" style="height: 64px;">It's whispered that if a seed from Gorgeous's pot is planted under a full moon, it will sprout a magical beanstalk leading to another realm.</textarea></td>
67
+ </tr>
68
+ <tr>
69
+ <td align="left"><strong>Store Reputation</strong></td>
70
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-reputation-2" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-reputation-2t" hx-swap="outerHTML" title="Store Size" style="height: 80px;">Renowned for its unique owner and unusual collection, adventurers and local townsfolk alike swear by the quality and charm of the items sold here.</textarea></td>
71
+ </tr>
72
+ </tbody>
73
+ </table>
74
+ </div>
75
+ </div>
76
+
77
+ <div class="block-item" data-block-id="3" data-page-id="block-container" draggable="true">
78
+ <textarea class="string-action-description-textarea" id="user-storefront-prompt-3" hx-post="/update-stats" hx-trigger="change" hx-target="#user-sd-prompt" hx-swap="outerHTML" title="Storefront image description" style="height: 48px;">A highly detailed fantasy drawing of a sentient potted plant with glowing tendrils, set in an enchanting gear shop filled with vibrant flora and a myriad of magical items.</textarea>
79
+ <button class="generate-image-button" data-block-id="3">Generate Image</button>
80
+ <img id="generated-image-3" alt="" style="display: none; cursor: pointer;">
81
+ </div>
82
+
83
+ <div class="block-item" data-block-id="4" data-page-id="block-container" draggable="true">
84
+ <h2 id="owner">Owner</h2>
85
+ <h3 id="owner_1"><textarea class="subtitle-textarea" id="user-store-owner-4" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owner-4t" hx-swap="outerHTML" title="Owner Name">Gorgeous</textarea></h3>
86
+ <table>
87
+ <thead>
88
+ <tr>
89
+ <th align="center"></th>
90
+ <th align="center"></th>
91
+ </tr>
92
+ </thead>
93
+ <tbody>
94
+ <tr>
95
+ <td align="left"><strong>Owner</strong></td>
96
+ <td align="right"><textarea class="string-action-description-textarea" id="Owner-4" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owners-4t" hx-swap="outerHTML" title="">Gorgeous</textarea></td>
97
+ </tr>
98
+ <tr>
99
+ <td align="left"><strong>Species</strong></td>
100
+ <td align="right"><textarea class="string-action-description-textarea" id="Species-4" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owners-4t" hx-swap="outerHTML" title="">Fae Plant</textarea></td>
101
+ </tr>
102
+ <tr>
103
+ <td align="left"><strong>Class</strong></td>
104
+ <td align="right"><textarea class="string-action-description-textarea" id="Class-4" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owners-4t" hx-swap="outerHTML" title="">Druid</textarea></td>
105
+ </tr>
106
+ <tr>
107
+ <td align="left"><strong>Description</strong></td>
108
+ <td align="right"><textarea class="string-action-description-textarea" id="Description-4" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owners-4t" hx-swap="outerHTML" title="" style="height: 32px;">A vibrant potted plant with bioluminescent tendrils and a captivating aura.</textarea></td>
109
+ </tr>
110
+ <tr>
111
+ <td align="left"><strong>Personality</strong></td>
112
+ <td align="right"><textarea class="string-action-description-textarea" id="Personality-4" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owners-4t" hx-swap="outerHTML" title="" style="height: 32px;">Charming, knowledgeable, with a dry sense of humor.</textarea></td>
113
+ </tr>
114
+ <tr>
115
+ <td align="left"><strong>Secrets</strong></td>
116
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-secrets-4" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-secrets-4t" hx-swap="outerHTML" title="Store Size">Contains hidden seeds of a rare, sentient forest.</textarea></td>
117
+ </tr>
118
+ <tr>
119
+ <td align="left"><strong>Secrets</strong></td>
120
+ <td align="right"><textarea class="string-action-description-textarea" id="user-store-secrets-4" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-secrets-4t" hx-swap="outerHTML" title="Store Size" style="height: 32px;">Can communicate with other plants within a mile radius.</textarea></td>
121
+ </tr>
122
+ </tbody>
123
+ </table>
124
+ </div>
125
+
126
+ <div class="block-item" data-block-id="5" data-page-id="block-container" draggable="true">
127
+ <textarea class="string-action-description-textarea" id="user-storefront-prompt-5" hx-post="/update-stats" hx-trigger="change" hx-target="#user-sd-prompt" hx-swap="outerHTML" title="Storefront image description" style="height: 49px;">A highly detailed fantasy image of a half-elf shopkeeper with forest-green eyes and flower-adorned hair, set in a magical gear shop filled with glowing plants and enchanted equipment.</textarea>
128
+ <button class="generate-image-button" data-block-id="5">Generate Image</button>
129
+ <img id="generated-image-5" alt="" style="display: none; cursor: pointer;">
130
+ </div>
131
+
132
+ <div class="block-item" data-block-id="6" data-page-id="block-container" draggable="true">
133
+ <h2 id="employee">Employee</h2>
134
+ <h3 id="owner_1"><textarea class="subtitle-textarea" id="user-store-employee-6" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-employee-6t" hx-swap="outerHTML" title="Employee Name">Briar</textarea></h3>
135
+ <table>
136
+ <thead>
137
+ <tr>
138
+ <th align="center"></th>
139
+ <th align="center"></th>
140
+ </tr>
141
+ </thead>
142
+ <tbody>
143
+ <tr>
144
+ <td align="left"><strong>Employee</strong></td>
145
+ <td align="right"><textarea class="string-action-description-textarea" id="Employee-6" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-employee-6t" hx-swap="outerHTML" title="">Briar</textarea></td>
146
+ </tr>
147
+ <tr>
148
+ <td align="left"><strong>Role</strong></td>
149
+ <td align="right"><textarea class="string-action-description-textarea" id="Role-6" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-employee-6t" hx-swap="outerHTML" title="">Shopkeeper</textarea></td>
150
+ </tr>
151
+ <tr>
152
+ <td align="left"><strong>Species</strong></td>
153
+ <td align="right"><textarea class="string-action-description-textarea" id="Species-6" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-employee-6t" hx-swap="outerHTML" title="">Half-Elf</textarea></td>
154
+ </tr>
155
+ <tr>
156
+ <td align="left"><strong>Description</strong></td>
157
+ <td align="right"><textarea class="string-action-description-textarea" id="Description-6" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-employee-6t" hx-swap="outerHTML" title="" style="height: 32px;">A lithe figure with forest-green eyes and hair adorned with tiny flowers.</textarea></td>
158
+ </tr>
159
+ <tr>
160
+ <td align="left"><strong>Personality</strong></td>
161
+ <td align="right"><textarea class="string-action-description-textarea" id="Personality-6" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-employee-6t" hx-swap="outerHTML" title="" style="height: 32px;">Warm, effervescent, with an encyclopedic knowledge of magical flora.</textarea></td>
162
+ </tr>
163
+ </tbody>
164
+ </table>
165
+ </div>
166
+
167
+ <div class="block-item" data-block-id="7" data-page-id="block-container" draggable="true">
168
+ <h1 id="store-quests">Customers</h1>
169
+ <h3 id="customer_1">
170
+ <textarea class="subtitle-textarea" id="user-store-customer-7" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-customer-7t" hx-swap="outerHTML" title="Customer Name">Thistle</textarea>
171
+ </h3>
172
+ <p>
173
+ <textarea class="string-action-description-textarea" id="user-store-customer-7" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-customer-7t" hx-swap="outerHTML" title="Customer Description" style="height: 32px;">Description: A mischievous forest sprite often seen fluttering among the flora displays.</textarea>
174
+ </p>
175
+ <p>
176
+ <textarea class="string-action-description-textarea" id="user-store-customer-7" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-customer-7t" hx-swap="outerHTML" title="Customer Influence">Influence: Helps attract other mythical creatures to the shop.</textarea>
177
+ </p>
178
+ </div>
179
+
180
+ <div class="block-item" data-block-id="8" data-page-id="block-container" draggable="true">
181
+ <h1 id="store-quests">Store Quests</h1>
182
+ <h3 id="quest_1">
183
+ <textarea class="subtitle-textarea" id="user-store-quest-8" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-quest-8t" hx-swap="outerHTML" title="Quest Name">The Lost Seed</textarea>
184
+ </h3>
185
+ <p>
186
+ <textarea class="string-action-description-textarea" id="user-store-quest-8" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-quest-8t" hx-swap="outerHTML" title="Quest Description" style="height: 63px;">Description: Gorgeous has lost a mystical seed that grants immense power to the one who plants it. Locate the seed somewhere in the mystical forest, but beware of the enchanted creatures residing there.</textarea>
187
+ </p>
188
+ <p>
189
+ <textarea class="string-action-description-textarea" id="user-store-quest-8" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-quest-8t" hx-swap="outerHTML" title="Quest Reward" style="height: 32px;">Reward: An enchanted satchel that holds double its volume without increasing in weight.</textarea>
190
+ </p>
191
+ </div>
192
+
193
+ <div class="block-item" data-block-id="9" data-page-id="block-container" draggable="true">
194
+ <h1 id="store-quests">Services</h1>
195
+ <h3 id="service_1">
196
+ <textarea class="subtitle-textarea" id="user-store-service-9" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-service-9t" hx-swap="outerHTML" title="Service Name">Plant Whispering</textarea>
197
+ </h3>
198
+ <p>
199
+ <textarea class="string-action-description-textarea" id="user-store-service-9" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-service-9t" hx-swap="outerHTML" title="Service Description" style="height: 48px;">Description: A unique service where Gorgeous communicates with the plants brought in by customers, diagnosing their needs and healing them.</textarea>
200
+ </p>
201
+ <p>
202
+ <textarea class="string-action-description-textarea" id="user-store-service-9" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-service-9t" hx-swap="outerHTML" title="Service Price">Price: 5 gold pieces per session</textarea>
203
+ </p>
204
+ </div>
205
+
206
+ <div class="block-item" data-block-id="10" data-page-id="block-container" draggable="true">
207
+ <h3 id="service_2">
208
+ <textarea class="subtitle-textarea" id="user-store-service-10" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-service-10t" hx-swap="outerHTML" title="Service Name">Enchantment Infusion</textarea>
209
+ </h3>
210
+ <p>
211
+ <textarea class="string-action-description-textarea" id="user-store-service-10" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-service-10t" hx-swap="outerHTML" title="Service Description" style="height: 32px;">Description: Infuse your regular gear with minor enchantments for enhanced performance.</textarea>
212
+ </p>
213
+ <p>
214
+ <textarea class="string-action-description-textarea" id="user-store-service-10" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-service-10t" hx-swap="outerHTML" title="Service Price">Price: 20 gold pieces per item</textarea>
215
+ </p>
216
+ </div>
217
+
218
+ <div class="block-item" data-block-id="11" data-page-id="block-container" draggable="true">
219
+ <h1 id="store-quests">Specialties</h1>
220
+ <h3 id="specialty_1">
221
+ <textarea class="subtitle-textarea" id="user-store-specialty-11" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-specialty-11t" hx-swap="outerHTML" title="Specialty Name">Fae Light Compass</textarea>
222
+ </h3>
223
+ <p>
224
+ <textarea class="string-action-description-textarea" id="user-store-specialty-11" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-specialty-11t" hx-swap="outerHTML" title="Specialty Description" style="height: 32px;">Description: A magical compass that not only points north but also glows brightly in the presence of nearby hidden treasures.</textarea>
225
+ </p>
226
+ <p>
227
+ <textarea class="string-action-description-textarea" id="user-store-specialty-11" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-specialty-11t" hx-swap="outerHTML" title="Specialty Price">Price: 35 gold pieces</textarea>
228
+ </p>
229
+ </div>
230
+
231
+ <div class="block-item" data-block-id="12" data-page-id="block-container" draggable="true">
232
+ <h1 id="store-quests">Security</h1>
233
+ <h3 id="security_1">
234
+ <textarea class="subtitle-textarea" id="user-store-security-12" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-security-12t" hx-swap="outerHTML" title="Security Name">Root Sentinels</textarea>
235
+ </h3>
236
+ <p>
237
+ <textarea class="string-action-description-textarea" id="user-store-security-12" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-security-12t" hx-swap="outerHTML" title="Security Description" style="height: 32px;">Description: Invisible roots that prevent theft by entangling or tripping would-be thieves.</textarea>
238
+ </p>
239
+ <p>
240
+ <textarea class="string-action-description-textarea" id="user-store-security-12" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-security-12t" hx-swap="outerHTML" title="Security Mechanics" style="height: 32px;">Mechanics: Automatically triggered by any unauthorized attempt to take an item, they immobilize and alert the staff.</textarea>
241
+ </p>
242
+ </div>
243
+
244
+ <div class="block-item" data-block-id="13" data-page-id="block-container" draggable="true">
245
+ <div class="block classTable frame decoration">
246
+ <h5 id="inventory">Inventory</h5>
247
+ <table>
248
+ <thead>
249
+ <tr>
250
+ <th align="center">Name</th>
251
+ <th align="center">Type</th>
252
+ <th align="left">Cost</th>
253
+ <th align="center">Properties</th>
254
+ </tr>
255
+ </thead>
256
+ <tbody>
257
+ <tr>
258
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-name-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-name-13t" hx-swap="outerHTML" title="Item Name" style="height: 32px;">Traveler's Cloak</textarea></td>
259
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-type-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-type-13t" hx-swap="outerHTML" title="Item Type">Apparel</textarea></td>
260
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-cost-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-cost-13t" hx-swap="outerHTML" title="Item Cost">12 gold pieces</textarea></td>
261
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-properties-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-properties-13t" hx-swap="outerHTML" title="Item Properties" style="height: 48px;">Weather-resistant, Self-cleaning</textarea></td>
262
+ </tr>
263
+ <tr>
264
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-name-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-name-13t" hx-swap="outerHTML" title="Item Name" style="height: 32px;">Explorer's Rope</textarea></td>
265
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-type-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-type-13t" hx-swap="outerHTML" title="Item Type">Equipment</textarea></td>
266
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-cost-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-cost-13t" hx-swap="outerHTML" title="Item Cost">8 gold pieces</textarea></td>
267
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-properties-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-properties-13t" hx-swap="outerHTML" title="Item Properties" style="height: 32px;">Unbreakable, 50 feet long</textarea></td>
268
+ </tr>
269
+ <tr>
270
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-name-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-name-13t" hx-swap="outerHTML" title="Item Name" style="height: 32px;">Glowing Map</textarea></td>
271
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-type-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-type-13t" hx-swap="outerHTML" title="Item Type" style="height: 32px;">Navigational Aid</textarea></td>
272
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-cost-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-cost-13t" hx-swap="outerHTML" title="Item Cost">15 gold pieces</textarea></td>
273
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-properties-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-properties-13t" hx-swap="outerHTML" title="Item Properties" style="height: 49px;">Illuminates in the dark, Self-updating</textarea></td>
274
+ </tr>
275
+ <tr>
276
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-name-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-name-13t" hx-swap="outerHTML" title="Item Name" style="height: 32px;">Mystic Lantern</textarea></td>
277
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-type-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-type-13t" hx-swap="outerHTML" title="Item Type">Tool</textarea></td>
278
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-cost-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-cost-13t" hx-swap="outerHTML" title="Item Cost">10 gold pieces</textarea></td>
279
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-properties-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-properties-13t" hx-swap="outerHTML" title="Item Properties" style="height: 48px;">Ever-burning flame, Detects magical auras</textarea></td>
280
+ </tr>
281
+ <tr>
282
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-name-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-name-13t" hx-swap="outerHTML" title="Item Name" style="height: 32px;">Waterproof Satchel</textarea></td>
283
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-type-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-type-13t" hx-swap="outerHTML" title="Item Type">Bag</textarea></td>
284
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-cost-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-cost-13t" hx-swap="outerHTML" title="Item Cost">18 gold pieces</textarea></td>
285
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-properties-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-properties-13t" hx-swap="outerHTML" title="Item Properties" style="height: 64px;">Waterproof, Pockets that adjust for extra space</textarea></td>
286
+ </tr>
287
+ <tr>
288
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-name-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-name-13t" hx-swap="outerHTML" title="Item Name" style="height: 32px;">Verdant Blade</textarea></td>
289
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-type-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-type-13t" hx-swap="outerHTML" title="Item Type">Sword</textarea></td>
290
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-cost-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-cost-13t" hx-swap="outerHTML" title="Item Cost">50 gold pieces</textarea></td>
291
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-properties-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-properties-13t" hx-swap="outerHTML" title="Item Properties" style="height: 80px;">Chlorophyll-infused edge, Regenerates minor damage over time</textarea></td>
292
+ </tr>
293
+ <tr>
294
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-name-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-name-13t" hx-swap="outerHTML" title="Item Name" style="height: 32px;">Barkskin Armor</textarea></td>
295
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-type-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-type-13t" hx-swap="outerHTML" title="Item Type">Light Armor</textarea></td>
296
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-cost-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-cost-13t" hx-swap="outerHTML" title="Item Cost">40 gold pieces</textarea></td>
297
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-properties-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-properties-13t" hx-swap="outerHTML" title="Item Properties" style="height: 80px;">Provides moderate protection, Camouflages in forested areas</textarea></td>
298
+ </tr>
299
+ <tr>
300
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-name-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-name-13t" hx-swap="outerHTML" title="Item Name" style="height: 32px;">Elixir of Root Strength</textarea></td>
301
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-type-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-type-13t" hx-swap="outerHTML" title="Item Type">Potion</textarea></td>
302
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-cost-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-cost-13t" hx-swap="outerHTML" title="Item Cost">25 gold pieces</textarea></td>
303
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-properties-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-properties-13t" hx-swap="outerHTML" title="Item Properties" style="height: 63px;">Temporarily grants enhanced strength and resistance</textarea></td>
304
+ </tr>
305
+ <tr>
306
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-name-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-name-13t" hx-swap="outerHTML" title="Item Name" style="height: 32px;">Seed of Instant Growth</textarea></td>
307
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-type-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-type-13t" hx-swap="outerHTML" title="Item Type">Seed</textarea></td>
308
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-cost-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-cost-13t" hx-swap="outerHTML" title="Item Cost">30 gold pieces</textarea></td>
309
+ <td align="center"><textarea class="string-action-description-textarea" id="user-store-item-properties-13" hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-item-properties-13t" hx-swap="outerHTML" title="Item Properties" style="height: 80px;">Grows into a full-sized tree within minutes, Can be used once</textarea></td>
310
+ </tr>
311
+ </tbody>
312
+ </table>
313
+ </div>
314
+ </div>
315
+ </div>