Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 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,19 @@
byId('stats').innerHTML = '<span class="failure">' + escapeHTML(err) + '</span>';
byId('minify-btn').disabled = false;
});
byId('copy-btn').onclick = function() {
let bgColorButton = byId('copy-btn').style.backgroundColor;
let copyText = byId('output');
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
byId('copy-btn').innerHTML = 'Copied!'
byId('copy-btn').style.backgroundColor = 'green';
setTimeout(function() {
byId('copy-btn').innerHTML = 'Copy Result';
byId('copy-btn').style.backgroundColor = bgColorButton;
}, 5000)
}
};

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="minify-button">
<button type="button" id="copy-btn" disabled>Copy Result</button>
</div>
<p id="stats"></p>
</div>
<div id="options">
Expand Down