drakosfire commited on
Commit
01f4554
·
2 Parent(s): 1996f8e eba7f1d

Fixing merge conflicts

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,899 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // if (!printWindow) {
100
+ // console.error('Failed to open print window.');
101
+ // return;
102
+ // }
103
+
104
+ console.log('Page container content:', pageContainer.innerHTML); // Debugging line
105
+
106
+ printWindow.document.write(`
107
+ <!DOCTYPE html>
108
+ <html lang="en">
109
+ <head>
110
+ <meta charset="UTF-8">
111
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
112
+ <link href="./dependencies/all.css" rel="stylesheet">
113
+ <link href="./dependencies/css.css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css">
114
+ <link href="./dependencies/bundle.css" rel="stylesheet">
115
+ <link href="./dependencies/style.css" rel="stylesheet">
116
+ <link href="./dependencies/5ePHBstyle.css" rel="stylesheet">
117
+ <link href="./storeUI.css" rel="stylesheet">
118
+ <title>Print Preview - DnD Stat Block</title>
119
+ <link rel="stylesheet" href="styles.css">
120
+ <style>
121
+ @media print {
122
+
123
+ .page {
124
+ page-break-before: auto;
125
+ page-break-after: avoid;
126
+ page-break-inside: avoid;
127
+
128
+ }
129
+ .columnWrapper {
130
+ overflow: visible;
131
+ }
132
+
133
+ }
134
+ </style>
135
+ </head>
136
+ <body>
137
+ ${pageContainer.innerHTML}
138
+ </body>
139
+ </html>
140
+ `);
141
+
142
+ // Wait for the content to be fully loaded before printing
143
+ printWindow.onload = function() {
144
+ printWindow.print();
145
+ printWindow.close(); // Close the print window after printing
146
+ };
147
+ } else {
148
+ console.error('Element with ID "pages" not found.');
149
+ }
150
+ };
151
+
152
+
153
+ // Store initial positions of the blocks
154
+ function storeInitialPositions() {
155
+ const blocks = blockContainer.querySelectorAll('.block-item');
156
+ blocks.forEach((block, index) => {
157
+ const blockId = block.getAttribute('data-block-id');
158
+ if (!blockId) {
159
+ console.error(`Block at index ${index} is missing data-block-id`);
160
+ }
161
+ initialPositions.push({
162
+ id: blockId,
163
+ index: index
164
+ });
165
+ });
166
+ console.log('Initial positions:', initialPositions);
167
+ }
168
+
169
+ function sortBlocksById() {
170
+ // Select all blocks inside the block-container
171
+ const blocks = Array.from(blockContainerPage.querySelectorAll('.block-item'));
172
+ console.log('Blocks in blockContainerPage:', blocks);
173
+
174
+ // Sort the blocks based on their block-id attribute
175
+ blocks.sort((a, b) => {
176
+ const idA = parseInt(a.getAttribute('data-block-id'), 10);
177
+ const idB = parseInt(b.getAttribute('data-block-id'), 10);
178
+ return idA - idB; // Ascending order
179
+ });
180
+
181
+ // Clear the block-container before re-appending the sorted blocks
182
+ blockContainerPage.innerHTML = '';
183
+
184
+ // Re-append the blocks in the sorted order
185
+ blocks.forEach(block => blockContainerPage.appendChild(block));
186
+
187
+ console.log('Blocks have been sorted and re-appended based on block-id');
188
+ }
189
+
190
+ function reinsertBlock(blockContainerPage, blockId, innerHTML) {
191
+ const originalPosition = initialPositions.find(pos => pos.id === blockId);
192
+ console.log('Original position:', originalPosition);
193
+
194
+ if (originalPosition) {
195
+ const blocks = blockContainerPage.querySelectorAll('.block-item');
196
+ console.log('Blocks in blockContainerPage:', blocks);
197
+
198
+ // Adding debugging output for index details
199
+ console.log(`Attempting to insert block with ID: ${blockId} at original index: ${originalPosition.index}`);
200
+
201
+ const newBlock = document.createElement('div');
202
+ newBlock.classList.add('block-item');
203
+ newBlock.setAttribute('data-block-id', blockId);
204
+ newBlock.setAttribute('data-page-id', 'block-container');
205
+ newBlock.innerHTML = innerHTML;
206
+ newBlock.setAttribute('draggable', true);
207
+ newBlock.addEventListener('dragstart', handleDragStart);
208
+ newBlock.addEventListener('dragend', handleDragEnd);
209
+
210
+ if (originalPosition.index < blocks.length) {
211
+ const referenceNode = blocks[originalPosition.index];
212
+
213
+ // Debugging output to ensure the correct reference node is identified
214
+ console.log(`Reference node index: ${originalPosition.index}, Node:`, referenceNode);
215
+
216
+ if (referenceNode && referenceNode.parentNode === blockContainerPage) {
217
+ console.log(`Inserting before block at index: ${originalPosition.index}`);
218
+ blockContainerPage.insertBefore(newBlock, referenceNode);
219
+ } else {
220
+ console.warn('Reference node does not belong to blockContainerPage, appending to the end');
221
+ blockContainerPage.appendChild(newBlock);
222
+ }
223
+ } else {
224
+ console.log('Original index exceeds current blocks, appending block to the end');
225
+ blockContainerPage.appendChild(newBlock);
226
+ }
227
+ } else {
228
+ console.warn('Original position not found, appending block to the end of blockContainerPage');
229
+ const newBlock = document.createElement('div');
230
+ newBlock.classList.add('block-item');
231
+ newBlock.setAttribute('data-block-id', blockId);
232
+ newBlock.setAttribute('data-page-id', 'block-container');
233
+ newBlock.innerHTML = innerHTML;
234
+ newBlock.setAttribute('draggable', true);
235
+ newBlock.addEventListener('dragstart', handleDragStart);
236
+ newBlock.addEventListener('dragend', handleDragEnd);
237
+
238
+ blockContainerPage.appendChild(newBlock);
239
+ }
240
+
241
+ console.log(`Restored block with ID: ${blockId}`);
242
+ }
243
+
244
+ function insertHtmlBlocks(blocks) {
245
+ console.log('blockContainerPage = ', blockContainerPage)
246
+ console.log('List of blocks:', blocks);
247
+ const parser = new DOMParser();
248
+
249
+ blocks.forEach(blockHtml => {
250
+ console.log('Original blockHtml:', blockHtml);
251
+ // Parse the HTML string
252
+ const doc = parser.parseFromString(blockHtml, 'text/html');
253
+ const block = doc.body.firstChild;
254
+ if (block) {
255
+ blockContainerPage.appendChild(block); // Append the parsed block to the container
256
+ console.log('Appended block:', block);
257
+ }
258
+ });
259
+ // console.log('Final state of blockContainer:', blockContainer.innerHTML);
260
+ initializeTextareaResizing();
261
+ }
262
+
263
+ storeInitialPositions();
264
+
265
+ function adjustTextareaHeight(el) {
266
+ if (el.scrollHeight > 16){
267
+ el.style.height = 'auto';
268
+ el.style.height = (el.scrollHeight) + 'px';
269
+ }
270
+ }
271
+
272
+ function initializeTextareaResizing() {
273
+ const classes = [
274
+ 'description-textarea',
275
+ 'user-description-textarea',
276
+ 'heading-textarea',
277
+ 'properties-textarea',
278
+ 'string-stat-textarea',
279
+ 'string-action-description-textarea',
280
+ ];
281
+
282
+ classes.forEach(className => {
283
+ const textareas = document.querySelectorAll(`.${className}`);
284
+ textareas.forEach(textarea => {
285
+
286
+ // Adjust height on page load
287
+ adjustTextareaHeight(textarea);
288
+ // Adjust height on input
289
+ textarea.addEventListener('input', function() {
290
+ adjustTextareaHeight(textarea);
291
+ console.log('Input event triggered for:', textarea.id); // Debugging line
292
+ });
293
+ });
294
+ });
295
+ }
296
+
297
+ // Initial run on page load
298
+ initializeTextareaResizing();
299
+
300
+ async function extractBlocks() {
301
+ try {
302
+ if (blockContainerPage.children.length > 0) {
303
+ console.log('Blocks already loaded, skipping fetch');
304
+ return;
305
+ }
306
+
307
+ const response = await fetch('template_update.html');
308
+ if (!response.ok) {
309
+ throw new Error('Network response was not ok ' + response.statusText);
310
+ }
311
+
312
+ const text = await response.text();
313
+ const parser = new DOMParser();
314
+ const doc = parser.parseFromString(text, 'text/html');
315
+
316
+ // Selecting all elements with the 'block-item' class
317
+ const blocks = doc.querySelectorAll('.block-item');
318
+
319
+ blocks.forEach((block, index) => {
320
+ const blockContent = block.innerHTML;
321
+ const blockItem = document.createElement('div');
322
+ blockItem.classList.add('block-item');
323
+ blockItem.innerHTML = blockContent;
324
+
325
+ // Assigning unique block ID
326
+ const blockId = `block-${index}`;
327
+ blockItem.setAttribute('data-block-id', blockId);
328
+
329
+ // Setting the page ID and other attributes
330
+ const pageId = 'block-container';
331
+ blockItem.setAttribute('data-page-id', pageId);
332
+ blockItem.setAttribute('draggable', true);
333
+
334
+ // Add event listeners for drag and drop functionality
335
+ blockItem.addEventListener('dragstart', handleDragStart);
336
+ blockItem.addEventListener('dragend', handleDragEnd);
337
+
338
+ console.log(`Loaded block with ID: ${blockId}`);
339
+
340
+ // Append block to the container
341
+ blockContainerPage.appendChild(blockItem);
342
+ });
343
+
344
+ // Store the initial positions of the blocks (if needed for drag and drop)
345
+ storeInitialPositions();
346
+
347
+ } catch (error) {
348
+ console.error('Error fetching and parsing template_update.html:', error);
349
+ }
350
+ }
351
+
352
+
353
+ blockContainer.addEventListener('click', function(event) {
354
+ if (event.target && event.target.classList.contains('generate-image-button')) {
355
+ const blockId = event.target.getAttribute('data-block-id');
356
+ generateImage(blockId);
357
+ }
358
+ });
359
+
360
+ // Function to generate image
361
+ function generateImage(blockId) {
362
+ const sdPromptElement = document.getElementById(`user-storefront-prompt-${blockId}`);
363
+ const imageElement = document.getElementById(`generated-image-${blockId}`);
364
+
365
+ if (!sdPromptElement) {
366
+ console.error('Element with ID user-storefront-prompt not found');
367
+ return;
368
+ }
369
+
370
+ if (!imageElement) {
371
+ console.error('Element with ID generated-image not found');
372
+ return;
373
+ }
374
+
375
+ const sdPrompt = sdPromptElement.value;
376
+
377
+ fetch('/generate-image', {
378
+ method: 'POST',
379
+ headers: {
380
+ 'Content-Type': 'application/json'
381
+ },
382
+ body: JSON.stringify({ sd_prompt: sdPrompt })
383
+ })
384
+ .then(response => response.json())
385
+ .then(data => {
386
+ console.log('Received data:', data);
387
+ imageElement.src = data.image_url;
388
+ imageElement.style.display = 'block';
389
+
390
+ // Log the image element's HTML structure
391
+ console.log('Updated imageElement HTML:', imageElement.outerHTML);
392
+ })
393
+ .catch((error) => {
394
+ console.error('Error:', error);
395
+ });
396
+ }
397
+
398
+ function lockTextareas() {
399
+ const textareas = document.querySelectorAll('textarea');
400
+
401
+ textareas.forEach(textarea => {
402
+ textarea.setAttribute('disabled', true);
403
+ });
404
+
405
+ const descriptionTextareas = document.querySelectorAll('.description-textarea');
406
+
407
+ descriptionTextareas.forEach(descriptionTextarea => {
408
+ descriptionTextarea.removeAttribute('contenteditable');
409
+ });
410
+
411
+ console.log('All textareas have been locked.');
412
+ }
413
+
414
+ function unlockTextareas() {
415
+ const textareas = document.querySelectorAll('textarea');
416
+
417
+ textareas.forEach(textarea => {
418
+ textarea.removeAttribute('disabled');
419
+ });
420
+
421
+ const descriptionTextareas = document.querySelectorAll('.description-textarea');
422
+
423
+ descriptionTextareas.forEach(descriptionTextarea => {
424
+ descriptionTextarea.setAttribute('contenteditable', 'true');
425
+ });
426
+
427
+ console.log('All textareas have been unlocked.');
428
+ }
429
+
430
+ function handleDragStart(e) {
431
+ lockTextareas();
432
+ const target = e.target.closest('.block-item, .block-content');
433
+ if (!target) {
434
+ console.error('Drag started for an element without a valid target');
435
+ return;
436
+ }
437
+ const blockId = target.getAttribute('data-block-id');
438
+ const pageId = target.getAttribute('data-page-id');
439
+ if (!blockId) {
440
+ console.error('Drag started for an element without a data-block-id');
441
+ return;
442
+ }
443
+ if (!pageId) {
444
+ console.error('Drag started for an element without a data-page-id');
445
+ return;
446
+ }
447
+
448
+ // Store the block ID and inner HTML in the data transfer object
449
+ const innerHTML = target.innerHTML;
450
+ e.dataTransfer.setData('block-id', blockId);
451
+ e.dataTransfer.setData('text/plain', innerHTML); // Store inner HTML
452
+ e.dataTransfer.setData('data-page-id', pageId); // Store original page ID
453
+ e.dataTransfer.effectAllowed = 'move';
454
+ target.style.opacity = '0.4';
455
+
456
+ // Create an invisible drag image
457
+ const dragImage = document.createElement('div');
458
+ dragImage.style.width = '1px';
459
+ dragImage.style.height = '1px';
460
+ dragImage.style.opacity = '0';
461
+ document.body.appendChild(dragImage);
462
+ e.dataTransfer.setDragImage(dragImage, 0, 0);
463
+
464
+ console.log(`Drag started for block ID: ${blockId} page ID: ${pageId}`);
465
+ }
466
+
467
+ function handleDragEnd(e) {
468
+ const target = e.target.closest('.block-item, .block-content');
469
+ if (target) {
470
+ target.style.opacity = '1'; // Reset the opacity
471
+ const blockId = target.getAttribute('data-block-id');
472
+ console.log(`Drag ended for block ID: ${blockId}`);
473
+ }
474
+
475
+ // Remove highlight classes from pages and blocks
476
+ document.querySelectorAll('.highlight-page').forEach(el => el.classList.remove('highlight-page'));
477
+ document.querySelectorAll('.highlight-block').forEach(el => el.classList.remove('highlight-block'));
478
+ document.querySelectorAll('.highlight-block-top').forEach(el => el.classList.remove('highlight-block-top'));
479
+ unlockTextareas()
480
+
481
+ }
482
+
483
+ function handleDragOver(e) {
484
+ e.preventDefault();
485
+ // Get the element currently under the cursor
486
+ const elementUnderCursor = document.elementFromPoint(e.clientX, e.clientY);
487
+
488
+ if (elementUnderCursor) {
489
+ // Check if the element is a block or textarea
490
+ if (elementUnderCursor.classList.contains('block-item')) {
491
+ console.log('Dragging over a block-item:', elementUnderCursor);
492
+ console.log('Block ID:', elementUnderCursor.getAttribute('data-block-id'));
493
+ } else if (elementUnderCursor.tagName === 'TEXTAREA') {
494
+ console.log('Dragging over a textarea:', elementUnderCursor);
495
+ } else {
496
+ // Log other elements if needed
497
+ console.log('Dragging over another element:', elementUnderCursor.tagName);
498
+ }
499
+ }
500
+ // Check if the drop target is a TEXTAREA or any other non-droppable area
501
+ if (e.target.tagName === 'TEXTAREA' || e.target.closest('.block-item')) {
502
+ e.dataTransfer.dropEffect = 'none'; // Indicate that drop is not allowed
503
+ return;
504
+ }
505
+ e.dataTransfer.dropEffect = 'move'; // Indicate that drop is allowed
506
+
507
+ const targetPage = e.target.closest('.page');
508
+ if (targetPage) {
509
+ targetPage.classList.add('highlight-page'); // Add highlight class for pages
510
+ }
511
+
512
+ const targetBlock = e.target.closest('.block-item, .block-content');
513
+ if (targetBlock) {
514
+ const bounding = targetBlock.getBoundingClientRect();
515
+ const offset = e.clientY - bounding.top;
516
+ if (offset > bounding.height / 2) {
517
+ targetBlock.classList.add('highlight-block');
518
+ targetBlock.classList.remove('highlight-block-top');
519
+ } else {
520
+ targetBlock.classList.add('highlight-block-top');
521
+ targetBlock.classList.remove('highlight-block');
522
+ }
523
+ }
524
+ }
525
+
526
+ function handleDrop(e) {
527
+ e.preventDefault();
528
+ // Ensure we are not dropping into a textarea or another block
529
+ if (e.target.classList.contains('block-item', 'block-content', 'description-textarea') || e.target.tagName === 'TEXTAREA') {
530
+ console.log('Cannot drop block inside another block or textarea');
531
+ return;
532
+ }
533
+ const blockId = e.dataTransfer.getData('block-id');
534
+ const originalPageId = e.dataTransfer.getData('data-page-id');
535
+ const innerHTML = e.dataTransfer.getData('text/plain');
536
+ console.log(`Drop event for block ID: ${blockId} from page ID: ${originalPageId}`);
537
+
538
+ if (blockId && originalPageId) {
539
+ const originalBlock = document.querySelector(`[data-block-id="${blockId}"]`);
540
+ const newPage = e.target.closest('.page');
541
+ console.log(`Over page ${newPage} from page ID: ${originalPageId}`);
542
+ const newPageId = newPage.getAttribute('data-page-id');
543
+
544
+ // Ensure the original block exists before proceeding
545
+ if (!originalBlock || !newPage) {
546
+ console.error(`Block with ID ${blockId} on page ${originalPageId} not found`);
547
+
548
+ return;
549
+ }
550
+
551
+ const newBlockContent = document.createElement('div');
552
+ newBlockContent.classList.add('block-content');
553
+ newBlockContent.innerHTML = originalBlock.innerHTML; // Transfer inner content only
554
+
555
+ // Add necessary attributes and event listeners
556
+ newBlockContent.setAttribute('data-block-id', blockId);
557
+ newBlockContent.setAttribute('data-page-id', newPageId);
558
+ console.log('newPageID:', newPageId);
559
+ newBlockContent.setAttribute('draggable', true);
560
+ newBlockContent.addEventListener('dragstart', handleDragStart);
561
+ newBlockContent.addEventListener('dragend', handleDragEnd);
562
+
563
+ const target = e.target.closest('.block-item, .block-content');
564
+ let targetColumn = 1;
565
+ if (target) {
566
+ const bounding = target.getBoundingClientRect();
567
+ const offset = e.clientY - bounding.top;
568
+
569
+ console.log('Drop target found:', target);
570
+ console.log('Bounding rectangle:', bounding);
571
+ console.log('Offset from top:', offset);
572
+ console.log('Target height:', bounding.height);
573
+ console.log('Insert before or after decision point (height / 2):', bounding.height / 2);
574
+
575
+ targetColumn = getColumnFromOffset(target, offset);
576
+ if (offset > bounding.height / 2) {
577
+ console.log('Inserting after the target');
578
+ target.parentNode.insertBefore(newBlockContent, target.nextSibling);
579
+
580
+ } else {
581
+ console.log('Inserting before the target');
582
+ target.parentNode.insertBefore(newBlockContent, target);
583
+
584
+ }
585
+
586
+ // Remove highlight borders
587
+ target.style['border-bottom'] = '';
588
+ target.style['border-top'] = '';
589
+ } else {
590
+ console.log('No valid drop target found, appending to the end');
591
+ newPage.querySelector('.block.monster.frame.wide').appendChild(newBlockContent);
592
+
593
+ }
594
+
595
+ // Remove the original block from the original container
596
+ originalBlock.parentNode.removeChild(originalBlock);
597
+
598
+ // Reset opacity of dragged element
599
+ newBlockContent.style.opacity = '1';
600
+ console.log(`Moved existing block with ID: ${blockId} to page ID: ${newPageId}`);
601
+ initializeTextareaResizing();
602
+ // Adjust layouts
603
+ if (originalPageId !== 'block-container') {
604
+ adjustPageLayout(originalPageId);
605
+ }
606
+ adjustPageLayout(newPageId, targetColumn);
607
+ } else {
608
+ console.log('No data transferred');
609
+ }
610
+
611
+ }
612
+
613
+ function getColumnFromOffset(block, offset) {
614
+ const page = block.closest('.page');
615
+ if (!page) return 1;
616
+ const columnWrapper = page.querySelector('.columnWrapper');
617
+ const columnWrapperRect = columnWrapper.getBoundingClientRect();
618
+ const relativeOffset = offset - columnWrapperRect.left; // Calculate the offset relative to the column wrapper
619
+ const columnWidth = columnWrapper.clientWidth / 2; // Assuming two columns
620
+
621
+ // Log details for debugging
622
+ console.log('Block offset:', offset);
623
+ console.log('Relative offset:', relativeOffset);
624
+
625
+ const columnNumber = Math.ceil(relativeOffset / columnWidth);
626
+
627
+ // Ensure the column number is within valid bounds (1 or 2)
628
+ const validColumnNumber = Math.min(Math.max(columnNumber, 1), 2);
629
+
630
+
631
+ return validColumnNumber;
632
+ }
633
+
634
+
635
+ // Function to get the height of a column by index
636
+ function getColumnHeights(pageElement) {
637
+ const columns = [0, 0]; // Assuming two columns for simplicity
638
+ const blocks = pageElement.querySelectorAll('.block-content');
639
+ blocks.forEach(block => {
640
+ const column = getColumnFromOffset(block, block.getBoundingClientRect().left);
641
+ columns[column - 1] += block.offsetHeight;
642
+ });
643
+ return columns;
644
+ }
645
+
646
+ function adjustPageLayout(pageId) {
647
+ const page = document.querySelector(`[data-page-id="${pageId}"]`);
648
+ if (!page) {
649
+ console.error(`Page with ID ${pageId} not found`);
650
+ return;
651
+ }
652
+
653
+ const columnHeights = getColumnHeights(page);
654
+ console.log(`Total height of columns in ${pageId}: ${columnHeights}`);
655
+
656
+ for (let i = 0; i < columnHeights.length; i++) {
657
+ if (columnHeights[i] > MAX_COLUMN_HEIGHT) {
658
+ console.log(`Column ${i + 1} in ${pageId} exceeds max height, total height: ${columnHeights[i]}px`);
659
+ handleColumnOverflow(page, i + 1);
660
+ }
661
+ }
662
+ }
663
+
664
+ let pageCounter = 1;
665
+ // Function to create new page
666
+ function addPage() {
667
+ const newPage = document.createElement('div');
668
+ newPage.classList.add('page');
669
+ newPage.setAttribute('data-page-id', `page-${pageCounter}`);
670
+ newPage.id = `page-${pageCounter}`;
671
+
672
+ const columnWrapper = document.createElement('div');
673
+ columnWrapper.classList.add('columnWrapper');
674
+
675
+ const newMonsterFrame = document.createElement('div');
676
+ newMonsterFrame.classList.add('block', 'monster', 'frame', 'wide');
677
+
678
+ columnWrapper.appendChild(newMonsterFrame);
679
+ newPage.appendChild(columnWrapper);
680
+ pageContainer.appendChild(newPage);
681
+
682
+ currentPage = newMonsterFrame;
683
+ console.log(`Created new page with ID: ${newPage.id}`);
684
+
685
+ // Add event listeners to the new currentPage
686
+ currentPage.addEventListener('dragover', handleDragOver);
687
+ currentPage.addEventListener('drop', handleDrop);
688
+
689
+ pageCounter++;
690
+ return newPage;
691
+ }
692
+
693
+ function removePage() {
694
+ const pages = pageContainer.querySelectorAll('.page');
695
+
696
+ if (pages.length > 1) { // Ensure at least one page remains
697
+ const lastPage = pages[pages.length - 1];
698
+ pageContainer.removeChild(lastPage);
699
+ console.log(`Page removed with ID: ${lastPage.id}`);
700
+ } else {
701
+ console.log('Cannot remove the last page.');
702
+ }
703
+ }
704
+
705
+ function handleColumnOverflow(page, targetColumn) {
706
+ console.log(`Handling overflow for page ID: ${page.getAttribute('data-page-id')} in column ${targetColumn}`);
707
+ const blocks = Array.from(page.querySelectorAll('.block-content'));
708
+ let columnHeights = [0, 0];
709
+ let overflowStartIndex = -1;
710
+
711
+ // Find the start index where overflow begins in the target column
712
+ blocks.forEach((block, index) => {
713
+ const column = getColumnFromOffset(block, block.getBoundingClientRect().left);
714
+ columnHeights[column - 1] += block.offsetHeight;
715
+ if (column === 2 && columnHeights[1] > MAX_COLUMN_HEIGHT && overflowStartIndex === -1) {
716
+ overflowStartIndex = index;
717
+ }
718
+ });
719
+
720
+ // If no overflow, return early
721
+ if (overflowStartIndex === -1) {
722
+ return;
723
+ }
724
+ const overflowBlocks = blocks.slice(overflowStartIndex);
725
+ const overflowHeight = overflowBlocks.reduce((acc, block) => acc + block.offsetHeight, 0);
726
+
727
+ // Get the next page if it exists
728
+ const nextPage = getNextPage(page);
729
+ if (nextPage) {
730
+ const nextPageBlocks = nextPage.querySelectorAll('.block-content, .block-item');
731
+ let nextPageColumnHeights = [0, 0];
732
+
733
+ nextPageBlocks.forEach(block => {
734
+ const column = getColumnFromOffset(block, block.getBoundingClientRect().left);
735
+ nextPageColumnHeights[column - 1] += block.offsetHeight;
736
+ });
737
+
738
+ // Check if there's enough space in the target column of the next page
739
+ if (nextPageColumnHeights[targetColumn - 1] + overflowHeight <= MAX_COLUMN_HEIGHT) {
740
+ const nextPageContainer = nextPage.querySelector('.block.monster.frame.wide');
741
+ overflowBlocks.forEach(block => {
742
+ nextPageContainer.appendChild(block);
743
+ block.setAttribute('data-page-id', nextPage.getAttribute('data-page-id'));
744
+ });
745
+ return;
746
+ }
747
+ }
748
+
749
+ // Otherwise, create a new page and move the overflowing blocks there
750
+ const newPage = addPage();
751
+ if (!newPage) {
752
+ console.error('Failed to create a new page');
753
+ return;
754
+ }
755
+ const newMonsterFrame = newPage.querySelector('.block.monster.frame.wide');
756
+ if (!newMonsterFrame) {
757
+ console.error('New monster frame not found in the new page');
758
+ return;
759
+ }
760
+
761
+ overflowBlocks.forEach(block => {
762
+ newMonsterFrame.appendChild(block);
763
+ block.setAttribute('data-page-id', newPage.getAttribute('data-page-id'));
764
+ });
765
+ console.log(`Moved overflowing blocks to new page with ID: ${newPage.getAttribute('data-page-id')}`);
766
+ }
767
+
768
+ // Utility function to get the next page element
769
+ function getNextPage(currentPage) {
770
+ const nextPageId = parseInt(currentPage.getAttribute('data-page-id').split('-')[1]) + 1;
771
+ return document.querySelector(`[data-page-id="page-${nextPageId}"]`);
772
+ }
773
+
774
+ // Handle the drop event on the trash area
775
+ function handleTrashDrop(e) {
776
+ e.preventDefault();
777
+ const innerHTML = e.dataTransfer.getData('text/plain');
778
+ const blockId = e.dataTransfer.getData('block-id');
779
+ console.log('Trash Drop event:', e);
780
+ console.log('Dragged block ID to trash:', blockId);
781
+
782
+ if (innerHTML && blockId) {
783
+ // Find the dragged element and remove it from the DOM
784
+ let draggedElement = document.querySelector(`[data-block-id="${blockId}"].block-content`);
785
+ if (!draggedElement) {
786
+ draggedElement = document.querySelector(`[data-block-id="${blockId}"].block-item`);
787
+ }
788
+ if (draggedElement && draggedElement.parentElement) {
789
+ draggedElement.parentElement.removeChild(draggedElement);
790
+ console.log(`Removed block with ID: ${blockId} from the page`);
791
+ }
792
+
793
+ // Check if the block already exists in the block-container and remove it if it does
794
+ let existingBlock = blockContainer.querySelector(`[data-block-id="${blockId}"].block-content`);
795
+ if (!existingBlock) {
796
+ existingBlock = blockContainer.querySelector(`[data-block-id="${blockId}"].block-item`);
797
+ }
798
+ if (existingBlock && existingBlock.parentElement) {
799
+ existingBlock.parentElement.removeChild(existingBlock);
800
+ console.log(`Removed duplicate block with ID: ${blockId} from block-container`);
801
+ }
802
+
803
+ // Ensure the block is appended to the page wrapper inside blockContainer
804
+ let blockContainerPage = blockContainer.querySelector('.page');
805
+ if (!blockContainerPage) {
806
+ blockContainerPage = document.createElement('div');
807
+ blockContainerPage.classList.add('page');
808
+ blockContainerPage.setAttribute('data-page-id', 'block-container');
809
+ blockContainer.appendChild(blockContainerPage);
810
+ }
811
+
812
+ // Reinsert the block using the refactored function
813
+ reinsertBlock(blockContainerPage, blockId, innerHTML);
814
+ sortBlocksById();
815
+ } else {
816
+ console.log('No data transferred');
817
+ }
818
+ // Remove the "over" class and reset the background image
819
+ trashArea.classList.remove('over');
820
+ trashArea.style.backgroundImage = "url('./closed-mimic-trashcan.png')";
821
+
822
+ initializeTextareaResizing();
823
+ }
824
+
825
+ function handleTrashOver(e) {
826
+ e.preventDefault();
827
+ e.dataTransfer.dropEffect = 'move';
828
+ trashArea.classList.add('over');
829
+ trashArea.style.backgroundImage = "url('./mimic_trashcan.png')";
830
+ console.log('Trash over event');
831
+ }
832
+
833
+ function handleTrashLeave(e) {
834
+ trashArea.classList.remove('over');
835
+ trashArea.style.backgroundImage = "url('./closed-mimic-trashcan.png')";
836
+ console.log('Trash leave event');
837
+ }
838
+
839
+ function handleReset() {
840
+ console.log('Reset button clicked');
841
+
842
+ // Collect all blocks from all pages
843
+ const allBlocks = [];
844
+ const pages = document.querySelectorAll('.page');
845
+ pages.forEach(page => {
846
+ const blocksOnPage = page.querySelectorAll('[data-block-id]');
847
+ blocksOnPage.forEach(block => {
848
+ const blockId = block.getAttribute('data-block-id');
849
+ allBlocks.push({
850
+ id: blockId,
851
+ innerHTML: block.innerHTML
852
+ });
853
+ block.remove();
854
+ console.log(`Removed block with ID: ${blockId} from page ID: ${page.getAttribute('data-page-id')}`);
855
+ });
856
+ });
857
+
858
+ // Clear all pages
859
+ pages.forEach(page => page.remove());
860
+
861
+ // Clear blockContainer before reinserting blocks
862
+ blockContainer.innerHTML = '';
863
+
864
+ // Reinsert blocks back into the blockContainer in their original order
865
+
866
+ if (!blockContainerPage) {
867
+ blockContainerPage = document.createElement('div');
868
+ blockContainerPage.classList.add('page');
869
+ blockContainerPage.setAttribute('id', 'block-page');
870
+ blockContainer.appendChild(blockContainerPage);
871
+ }
872
+ // Reassign blockContainerPage to the newly created block-page element
873
+ blockContainerPage = document.getElementById('block-page');
874
+
875
+ initialPositions.forEach(pos => {
876
+ const blockData = allBlocks.find(block => block.id === pos.id);
877
+ if (blockData) {
878
+ reinsertBlock(blockContainerPage, blockData.id, blockData.innerHTML);
879
+ sortBlocksById();
880
+ }
881
+ });
882
+ addPage();
883
+
884
+ console.log('Reset complete, all blocks moved back to block-container');
885
+ initializeTextareaResizing();
886
+ }
887
+
888
+
889
+ blockContainer.addEventListener('dragover', handleDragOver);
890
+ blockContainer.addEventListener('drop', handleDrop);
891
+ pageContainer.addEventListener('dragover', handleDragOver);
892
+ pageContainer.addEventListener('drop', handleDrop);
893
+
894
+ trashArea.addEventListener('dragover', handleTrashOver);
895
+ trashArea.addEventListener('dragleave', handleTrashLeave);
896
+ trashArea.addEventListener('drop', handleTrashDrop);
897
+ resetButton.addEventListener('click', handleReset);
898
+ extractBlocks();
899
+ });
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>
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>