<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Remove Whitespace</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
}
.container {
max-width: 500px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
}
textarea {
width: 100%;
height: 100px;
margin-bottom: 10px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 14px;
}
#output {
border: 1px solid #ccc;
border-radius: 5px;
font-size: 14px;
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
#copyButton {
display: none;
width: 100%;
padding: 10px;
background-color: #28a745;
color: #fff;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
#copyButton:hover {
background-color: #218838;
}
</style>
</head>
<body>
<div class="container">
<h1>Remove Whitespace from Text</h1>
<textarea id="inputText" placeholder="Enter text with whitespace..."></textarea>
<button onclick="removeWhitespace()">Remove Whitespace</button>
<textarea id="output" placeholder="Result will appear here..." readonly></textarea>
<button id="copyButton" onclick="copyToClipboard()">Copy All</button>
<a id="downloadLink" style="display: none;">Download text</a>
</div>
<script>
function pkRemoveWhitespace() {
const pkInputText = document.getElementById("inputText").value;
const pkOutputText = pkInputText.replace(/\s+/g, ''); // Remove all whitespace characters
document.getElementById("output").value = pkOutputText;
const pkBlob = new Blob([pkOutputText], { type: "text/plain" });
const pkUrl = URL.createObjectURL(pkBlob);
const pkDownloadLink = document.getElementById("downloadLink");
pkDownloadLink.href = pkUrl;
pkDownloadLink.download = "cleaned_text.txt";
pkDownloadLink.style.display = "block";
document.getElementById("copyButton").style.display = "block";
}
function pkCopyToClipboard() {
const pkOutputTextarea = document.getElementById("output");
pkOutputTextarea.select();
document.execCommand("copy");
alert("Text copied to clipboard!");
}
</script>
</body>
</html>
0 Comments