Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
3.4 kB
41
Indexable
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Text Converter Tool</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .container {
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            width: 80%;
            max-width: 600px;
            text-align: center; /* Center align text and buttons */
        }

        textarea {
            width: 100%;
            height: 150px;
            padding: 10px;
            box-sizing: border-box;
            margin-bottom: 10px;
            resize: none;
        }

        button {
            padding: 10px 20px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            margin: 5px;
        }

        button:hover {
            background-color: #0056b3;
        }

        .copy-button {
            background-color: #28a745;
        }

        .copy-button:hover {
            background-color: #218838;
        }

        .paste-button {
            background-color: #17a2b8;
        }

        .paste-button:hover {
            background-color: #117a8b;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Uppercase Text Converter Tool</h1>
        <div class="text-box">
            <textarea id="text-box" placeholder="Enter your text here..."></textarea>
            <button onclick="convertToUppercase()">Convert to Uppercase</button>
            <button class="copy-button" onclick="copyToClipboard()">Copy</button>
            <button class="paste-button" onclick="pasteFromClipboard()">Paste</button>
        </div>
    </div>
    <script>
        function convertToUppercase() {
            // Get the text area element
            const textBox = document.getElementById('text-box');
            
            // Convert the text to uppercase
            textBox.value = textBox.value.toUpperCase();
        }

        function copyToClipboard() {
            // Get the text area element
            const textBox = document.getElementById('text-box');
            
            // Select the text
            textBox.select();
            textBox.setSelectionRange(0, 99999); // For mobile devices

            // Copy the text
            document.execCommand('copy');

            // Alert the user that the text has been copied
            alert('Copied to clipboard!');
        }

        function pasteFromClipboard() {
            // Get the text area element
            const textBox = document.getElementById('text-box');
            
            // Paste the text from the clipboard
            navigator.clipboard.readText().then(text => {
                textBox.value = text;
            }).catch(err => {
                console.error('Failed to read clipboard contents: ', err);
            });
        }
    </script>
</body>
</html>
Leave a Comment