Skip to content

Commit

Permalink
Merge pull request #20 from TRMSC:result-edit-mode
Browse files Browse the repository at this point in the history
Result-edit-mode #16
  • Loading branch information
TRMSC authored Nov 11, 2023
2 parents 14513d3 + 6c9ee07 commit feddbaa
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/icons/cog.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,18 @@ <h3>
</div>

<div id="resultpart" class="smallpart" style="display: none;">
<h3>
Ergebnis
</h3>
<div class="stretchpart">
<h3>
Ergebnis
</h3>
<span id="imagescene-edit" class="ic-font-3" title="Bearbeiten">
<img class="ic-icon-3" src="icons/cog.svg">
</span>
</div>
<div class="input-container edit-container ic-d-none">
<label for="imagescene-filename" class="miniheading">Dateiname (ohne Endung):</label>
<textarea class="generate" id="imagescene-filename" name="imagescene-filename" rows="1" spellcheck="false" wrap="off" placeholder="Freilassen für automatische Bezeichnung..."></textarea>
</div>
<div class="input-container">
<label for="imagescene-result" class="miniheading">Code:</label>
<textarea id="imagescene-result" name="imagescene-result" rows="6" spellcheck="false" wrap="off" readonly></textarea>
Expand Down
31 changes: 30 additions & 1 deletion docs/src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ listenEvents = () => {
let generateButton = document.getElementById('imagescene-generate');
generateButton.addEventListener('click', generateScene);

// Toggle settings
let settingToggle = document.getElementById('imagescene-edit');
settingToggle.addEventListener('click', handleSettings);

// Copy to clipboard
let clipboardButton = document.getElementById('imagescene-copy');
clipboardButton.addEventListener('click', copyClipboard);
Expand Down Expand Up @@ -480,6 +484,26 @@ scrollResult = () => {
};


/**
* Handle Settings
*
* @function handleSettings
* @returns {void}
*
*/
handleSettings = () => {

// Declare target elements
let editContainers = document.querySelectorAll('.edit-container');

// Toggle each element
editContainers.forEach(container => {
container.classList.toggle('ic-d-none');
});

};


/**
* Share page by using the share api
*
Expand Down Expand Up @@ -598,6 +622,11 @@ downloadFile = (type) => {
const seconds = String(date.getSeconds()).padStart(2, '0');
const currentDate = `${year}-${month}-${day}-${hours}-${minutes}-${seconds}`;

// Get filename
let userInput = document.getElementById('imagescene-filename');
let defaultFilename = currentDate + '-imagescene-' + template;
let filename = userInput.value.trim() !== '' ? userInput.value + '.' + type : defaultFilename

// Add XML declaration for SVG type
if (type === 'svg') html = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n${html}`;

Expand All @@ -608,7 +637,7 @@ downloadFile = (type) => {
// Download
const a = document.createElement('a');
a.href = url;
a.download = currentDate + '-' + 'imagescene-' + template;
a.download = filename;
a.click();

// Release URL resource
Expand Down
3 changes: 3 additions & 0 deletions docs/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ h3 {
.ic-hidden {
visibility: hidden;
}
.ic-d-none {
display: none!important;
}
input[type="button"] {
cursor: pointer;
border-radius: 3px;
Expand Down

0 comments on commit feddbaa

Please sign in to comment.