diff --git a/index.html b/index.html index 4fc0790..9bc5e5c 100644 --- a/index.html +++ b/index.html @@ -6,17 +6,44 @@ -
- - + +
+ + + +
+ + + +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +
+ + +

Result:

- + - \ No newline at end of file + diff --git a/playground.js b/playground.js new file mode 100644 index 0000000..8f1bbd3 --- /dev/null +++ b/playground.js @@ -0,0 +1,31 @@ +const form = document.getElementById('form') + +form.addEventListener('submit', function (e) { + e.preventDefault() + if (form === null) { + console.error('form element not found') + return + } + + const fd = new FormData(form) + + const replacement = fd.get('replacement') + const lowercase = fd.get('lowercase') + const trim = fd.get('trim') + const fallback = fd.get('fallback') + + const opts = {} + + if (replacement.length > 0) { + opts.replacement = replacement + } + + opts.lower = lowercase !== null + + opts.trim = trim !== null + + opts.fallback = fallback !== null + + const output = window.slug(document.getElementById('input').value, opts) + document.getElementById('slugOutput').innerText = output +})