ADD shareable link generation
This commit is contained in:
parent
945556bdc9
commit
348b3153aa
|
@ -1,4 +1,4 @@
|
||||||
# Simple Variable List Iterator
|
# Bulk Template Generator
|
||||||
|
|
||||||
Choosing names was never my strength.
|
Choosing names was never my strength.
|
||||||
|
|
||||||
|
@ -87,3 +87,4 @@ Download the `index.html` file, open it in your browser, done. Everything you ne
|
||||||
- [ ] License
|
- [ ] License
|
||||||
- [ ] Footer with Git reference + License
|
- [ ] Footer with Git reference + License
|
||||||
- [ ] Save everything temporary to local storage to avoid data loss
|
- [ ] Save everything temporary to local storage to avoid data loss
|
||||||
|
- [x] Shareable link generation
|
||||||
|
|
58
index.html
58
index.html
|
@ -31,7 +31,6 @@
|
||||||
});
|
});
|
||||||
results.push(modifiedText);
|
results.push(modifiedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('outputContainer').value = results.join('\n');
|
document.getElementById('outputContainer').value = results.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +50,50 @@
|
||||||
document.execCommand('copy');
|
document.execCommand('copy');
|
||||||
alert('Copied to clipboard!');
|
alert('Copied to clipboard!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyShareableLink() {
|
||||||
|
const shareableLink = document.getElementById('shareableLink');
|
||||||
|
shareableLink.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
alert('Shareable link copied to clipboard!');
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateShareableLink() {
|
||||||
|
const inputText = document.getElementById('inputText').value;
|
||||||
|
const variableInputs = document.querySelectorAll('.variableInput');
|
||||||
|
const variables = Array.from(variableInputs).map(textarea => textarea.value.split('\n').map(word => word.trim()).join(',')).join(';');
|
||||||
|
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
url.searchParams.set('template', btoa(inputText));
|
||||||
|
url.searchParams.set('variables', btoa(variables));
|
||||||
|
|
||||||
|
const shareableLink = document.getElementById('shareableLink');
|
||||||
|
shareableLink.value = url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadFromUrl() {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const template = urlParams.get('template');
|
||||||
|
const variables = urlParams.get('variables');
|
||||||
|
|
||||||
|
if (template) {
|
||||||
|
document.getElementById('inputText').value = atob(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (variables) {
|
||||||
|
const variableContainer = document.getElementById('variableContainer');
|
||||||
|
variableContainer.innerHTML = ''; // Clear existing variables
|
||||||
|
const variableList = atob(variables).split(';');
|
||||||
|
variableList.forEach((variable, index) => {
|
||||||
|
const newVariableGroup = document.createElement('div');
|
||||||
|
newVariableGroup.className = 'variable-group';
|
||||||
|
newVariableGroup.innerHTML = `<textarea placeholder="Enter one word per line for [var${index + 1}]" rows="5" class="variableInput">${variable.split(',').join('\n')}</textarea>`;
|
||||||
|
variableContainer.appendChild(newVariableGroup);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', loadFromUrl);
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
@ -157,10 +200,11 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Simple Variable List Iterator</h1>
|
<h1>Simple Variable List Iterator</h1>
|
||||||
<h3>Template:</h3>
|
<hr>
|
||||||
|
<h2>Template:</h2>
|
||||||
<textarea id="inputText">Example: host [var1] has IP [var2].</textarea>
|
<textarea id="inputText">Example: host [var1] has IP [var2].</textarea>
|
||||||
<hr>
|
<hr>
|
||||||
<h3>Variables:</h3>
|
<h2>Variables:</h2>
|
||||||
<div id="variableContainer" class="variables">
|
<div id="variableContainer" class="variables">
|
||||||
<div class="variable-group">
|
<div class="variable-group">
|
||||||
<textarea placeholder="Enter one word per line for [var1]" rows="5" class="variableInput"></textarea>
|
<textarea placeholder="Enter one word per line for [var1]" rows="5" class="variableInput"></textarea>
|
||||||
|
@ -171,11 +215,17 @@
|
||||||
</div>
|
</div>
|
||||||
<button class="yellow-button" onclick="addVariable()">Add Variable</button><br>
|
<button class="yellow-button" onclick="addVariable()">Add Variable</button><br>
|
||||||
<hr>
|
<hr>
|
||||||
|
<h2>Generating:</h2>
|
||||||
<button class="green-button" onclick="customizeText()">RUN</button>
|
<button class="green-button" onclick="customizeText()">RUN</button>
|
||||||
<textarea id="outputContainer" class="output" row="10" readonly></textarea>
|
<textarea id="outputContainer" class="output" row="10" readonly></textarea>
|
||||||
<button class="blue-button" onclick="copyToClipboard()">Copy</button>
|
<button class="blue-button" onclick="copyToClipboard()">Copy</button>
|
||||||
<button class="blue-button" onclick="exportToTextFile()">Export to File</button>
|
<button class="blue-button" onclick="exportToTextFile()">Export to File</button>
|
||||||
|
<hr>
|
||||||
|
<h2>Sharing:</h2>
|
||||||
|
<button class="blue-button" onclick="generateShareableLink()">Generate Shareable Link</button>
|
||||||
|
<textarea id="shareableLink" class="output" readonly></textarea>
|
||||||
|
<button class="blue-button" onclick="copyShareableLink()">Copy Link</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue