Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions assets/master.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ h1 span { font-size: 0.6em; }
button { font-weight: bold; width: 100px; }

.minify-button { margin: 16px 0; }
.copy-button { margin: 16px 0; }
.copied-button { margin: 16px 0; background-color: green; }
#outer-wrapper { overflow: hidden; }
#wrapper { width: 65%; float: left; }
#input { width: 99%; height: 18em; }
Expand Down
18 changes: 18 additions & 0 deletions assets/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
}

byId('minify-btn').onclick = function() {
byId('copy-btn').disabled = false;
byId('minify-btn').disabled = true;
var originalValue = byId('input').value;
minify(originalValue, getOptions(), function(minifiedValue) {
Expand All @@ -104,6 +105,23 @@
byId('stats').innerHTML = '<span class="failure">' + escapeHTML(err) + '</span>';
byId('minify-btn').disabled = false;
});
byId('copy-btn').onclick = function() {
navigator.permissions.query({ name: 'clipboard-write' })
.then(function(permissionStatus) {
if (permissionStatus.state === 'granted' || permissionStatus.state === 'prompt') {
navigator.clipboard.writeText(byId('output').value);
byId('copy-btn').innerText = 'Copied!';
byId('copy-btn').className = 'copied-button';
setTimeout(function() {
byId('copy-btn').innerText = 'Copy Result';
byId('copy-btn').className = 'copy-button';
}, 5000);
}
else {
alert('Access was denied to clipboard-write, please give access to continue.');
}
});
};
};

byId('select-all').onclick = function() {
Expand Down
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ <h1>HTML Minifier <span>(v4.0.0)</span></h1>
<button type="button" id="minify-btn">Minify</button>
</div>
<textarea rows="8" cols="40" id="output" readonly></textarea>

<div class="copy-button">
<button type="button" id="copy-btn" disabled>Copy Result</button>
</div>
<p id="stats"></p>
</div>
<div id="options">
Expand Down