File size: 10,450 Bytes
af24c60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Number System Converter</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
        }
        .result-box {
            transition: all 0.3s ease;
        }
        .result-box:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .copy-btn {
            transition: all 0.2s ease;
        }
        .copy-btn:hover {
            background-color: rgba(255,255,255,0.2);
        }
        .copy-btn:active {
            transform: scale(0.95);
        }
        .pulse {
            animation: pulse 1.5s infinite;
        }
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
    </style>
</head>
<body class="min-h-screen gradient-bg text-white">
    <div class="container mx-auto px-4 py-12">
        <div class="max-w-2xl mx-auto">
            <div class="text-center mb-10">
                <h1 class="text-4xl font-bold mb-2">Number System Converter</h1>
                <p class="text-lg opacity-90">Convert decimal numbers to binary, hexadecimal, and octal</p>
            </div>

            <div class="bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl shadow-2xl p-6 mb-8">
                <div class="flex items-center mb-6">
                    <div class="mr-4">
                        <i class="fas fa-exchange-alt text-2xl text-yellow-300"></i>
                    </div>
                    <div>
                        <h2 class="text-xl font-semibold">Input Number</h2>
                        <p class="text-sm opacity-80">Enter a decimal number to convert</p>
                    </div>
                </div>

                <div class="relative">
                    <input 
                        type="number" 
                        id="decimalInput" 
                        placeholder="Enter decimal number"
                        class="w-full bg-white bg-opacity-20 border border-white border-opacity-30 rounded-lg py-3 px-4 text-white placeholder-white placeholder-opacity-70 focus:outline-none focus:ring-2 focus:ring-yellow-300 focus:border-transparent"
                        oninput="convertNumber()"
                    >
                    <button 
                        onclick="clearInput()"
                        class="absolute right-3 top-1/2 transform -translate-y-1/2 text-white opacity-70 hover:opacity-100 transition-opacity"
                    >
                        <i class="fas fa-times"></i>
                    </button>
                </div>
            </div>

            <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                <!-- Binary Result -->
                <div class="result-box bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl shadow-lg p-6">
                    <div class="flex justify-between items-center mb-4">
                        <div class="flex items-center">
                            <div class="w-10 h-10 rounded-full bg-blue-500 flex items-center justify-center mr-3">
                                <span class="font-mono font-bold">BIN</span>
                            </div>
                            <div>
                                <h3 class="font-semibold">Binary</h3>
                                <p class="text-xs opacity-70">Base 2</p>
                            </div>
                        </div>
                        <button 
                            onclick="copyToClipboard('binaryResult')"
                            class="copy-btn w-8 h-8 rounded-full bg-white bg-opacity-10 flex items-center justify-center hover:bg-opacity-20"
                            title="Copy to clipboard"
                        >
                            <i class="fas fa-copy text-sm"></i>
                        </button>
                    </div>
                    <div class="bg-black bg-opacity-30 rounded-lg p-3 font-mono overflow-x-auto">
                        <span id="binaryResult" class="text-yellow-300">-</span>
                    </div>
                </div>

                <!-- Hexadecimal Result -->
                <div class="result-box bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl shadow-lg p-6">
                    <div class="flex justify-between items-center mb-4">
                        <div class="flex items-center">
                            <div class="w-10 h-10 rounded-full bg-green-500 flex items-center justify-center mr-3">
                                <span class="font-mono font-bold">HEX</span>
                            </div>
                            <div>
                                <h3 class="font-semibold">Hexadecimal</h3>
                                <p class="text-xs opacity-70">Base 16</p>
                            </div>
                        </div>
                        <button 
                            onclick="copyToClipboard('hexResult')"
                            class="copy-btn w-8 h-8 rounded-full bg-white bg-opacity-10 flex items-center justify-center hover:bg-opacity-20"
                            title="Copy to clipboard"
                        >
                            <i class="fas fa-copy text-sm"></i>
                        </button>
                    </div>
                    <div class="bg-black bg-opacity-30 rounded-lg p-3 font-mono overflow-x-auto">
                        <span id="hexResult" class="text-yellow-300">-</span>
                    </div>
                </div>

                <!-- Octal Result -->
                <div class="result-box bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl shadow-lg p-6">
                    <div class="flex justify-between items-center mb-4">
                        <div class="flex items-center">
                            <div class="w-10 h-10 rounded-full bg-purple-500 flex items-center justify-center mr-3">
                                <span class="font-mono font-bold">OCT</span>
                            </div>
                            <div>
                                <h3 class="font-semibold">Octal</h3>
                                <p class="text-xs opacity-70">Base 8</p>
                            </div>
                        </div>
                        <button 
                            onclick="copyToClipboard('octalResult')"
                            class="copy-btn w-8 h-8 rounded-full bg-white bg-opacity-10 flex items-center justify-center hover:bg-opacity-20"
                            title="Copy to clipboard"
                        >
                            <i class="fas fa-copy text-sm"></i>
                        </button>
                    </div>
                    <div class="bg-black bg-opacity-30 rounded-lg p-3 font-mono overflow-x-auto">
                        <span id="octalResult" class="text-yellow-300">-</span>
                    </div>
                </div>
            </div>

            <div class="mt-8 text-center text-sm opacity-80">
                <p>Made with <i class="fas fa-heart text-red-400"></i> using HTML, CSS & JavaScript</p>
            </div>
        </div>
    </div>

    <script>
        function convertNumber() {
            const decimalInput = document.getElementById('decimalInput').value;
            
            if (decimalInput === '') {
                document.getElementById('binaryResult').textContent = '-';
                document.getElementById('hexResult').textContent = '-';
                document.getElementById('octalResult').textContent = '-';
                return;
            }

            const decimalNumber = parseInt(decimalInput);
            
            // Binary conversion
            const binary = decimalNumber.toString(2);
            document.getElementById('binaryResult').textContent = binary;
            
            // Hexadecimal conversion
            const hex = decimalNumber.toString(16).toUpperCase();
            document.getElementById('hexResult').textContent = `0x${hex}`;
            
            // Octal conversion
            const octal = decimalNumber.toString(8);
            document.getElementById('octalResult').textContent = `0${octal}`;
        }

        function clearInput() {
            document.getElementById('decimalInput').value = '';
            convertNumber();
            document.getElementById('decimalInput').focus();
        }

        function copyToClipboard(elementId) {
            const element = document.getElementById(elementId);
            const text = element.textContent;
            
            if (text === '-') return;
            
            navigator.clipboard.writeText(text.replace(/^0x|^0/, ''));
            
            // Visual feedback
            const originalText = element.textContent;
            element.textContent = 'Copied!';
            element.classList.add('text-green-400');
            
            setTimeout(() => {
                element.textContent = originalText;
                element.classList.remove('text-green-400');
            }, 1000);
        }

        // Focus input on page load
        document.addEventListener('DOMContentLoaded', () => {
            document.getElementById('decimalInput').focus();
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=adrianoL/conversor-de-n-meros" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>