diff --git a/README.md b/README.md
index e3e2576..b5d942b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Simple Variable List Iterator
+# Bulk Template Generator
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
- [ ] Footer with Git reference + License
- [ ] Save everything temporary to local storage to avoid data loss
+- [x] Shareable link generation
diff --git a/index.html b/index.html
index 5ec7b1c..f1b1787 100644
--- a/index.html
+++ b/index.html
@@ -31,7 +31,6 @@
});
results.push(modifiedText);
}
-
document.getElementById('outputContainer').value = results.join('\n');
}
@@ -51,6 +50,50 @@
document.execCommand('copy');
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 = ``;
+ variableContainer.appendChild(newVariableGroup);
+ });
+ }
+ }
+
+ document.addEventListener('DOMContentLoaded', loadFromUrl);