akiragosho commited on
Commit
e6660a4
·
verified ·
1 Parent(s): 7e3502e

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +190 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Random Number
3
- emoji: 🌍
4
- colorFrom: purple
5
- colorTo: blue
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: random-number
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: pink
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,190 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Random Number Generator</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ @keyframes pulse {
11
+ 0% { transform: scale(1); }
12
+ 50% { transform: scale(1.05); }
13
+ 100% { transform: scale(1); }
14
+ }
15
+ .animate-pulse-custom {
16
+ animation: pulse 1.5s infinite;
17
+ }
18
+ .number-display {
19
+ transition: all 0.3s ease;
20
+ }
21
+ .glow {
22
+ box-shadow: 0 0 15px rgba(99, 102, 241, 0.7);
23
+ }
24
+ </style>
25
+ </head>
26
+ <body class="bg-gradient-to-br from-indigo-900 to-purple-800 min-h-screen flex items-center justify-center p-4">
27
+ <div class="max-w-md w-full bg-white/10 backdrop-blur-lg rounded-2xl overflow-hidden shadow-2xl border border-white/20">
28
+ <div class="p-6 sm:p-8">
29
+ <div class="flex items-center justify-between mb-6">
30
+ <h1 class="text-2xl font-bold text-white">Randomizer</h1>
31
+ <div class="flex space-x-2">
32
+ <button id="infoBtn" class="text-white/70 hover:text-white transition">
33
+ <i class="fas fa-info-circle"></i>
34
+ </button>
35
+ <button id="settingsBtn" class="text-white/70 hover:text-white transition">
36
+ <i class="fas fa-cog"></i>
37
+ </button>
38
+ </div>
39
+ </div>
40
+
41
+ <div class="bg-white/5 rounded-xl p-6 mb-6 border border-white/10">
42
+ <div class="flex justify-between items-center mb-4">
43
+ <label class="text-white/80 text-sm">Range</label>
44
+ <div class="flex items-center space-x-2">
45
+ <input type="number" id="minValue" value="1" min="0" class="w-16 bg-white/10 border border-white/20 rounded px-2 py-1 text-white text-center">
46
+ <span class="text-white">to</span>
47
+ <input type="number" id="maxValue" value="100" min="1" class="w-16 bg-white/10 border border-white/20 rounded px-2 py-1 text-white text-center">
48
+ </div>
49
+ </div>
50
+
51
+ <div class="flex justify-between items-center">
52
+ <label class="text-white/80 text-sm">Allow duplicates</label>
53
+ <label class="relative inline-flex items-center cursor-pointer">
54
+ <input type="checkbox" id="allowDuplicates" class="sr-only peer">
55
+ <div class="w-11 h-6 bg-white/20 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-500"></div>
56
+ </label>
57
+ </div>
58
+ </div>
59
+
60
+ <div id="numberDisplay" class="number-display bg-white/5 rounded-xl p-8 mb-6 border border-white/10 flex items-center justify-center">
61
+ <span id="currentNumber" class="text-6xl font-bold text-white">?</span>
62
+ </div>
63
+
64
+ <button id="generateBtn" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-4 px-4 rounded-xl transition-all duration-300 flex items-center justify-center animate-pulse-custom">
65
+ <i class="fas fa-random mr-2"></i>
66
+ <span>Generate Number</span>
67
+ </button>
68
+
69
+ <div id="history" class="mt-6 flex flex-wrap gap-2 max-h-20 overflow-y-auto">
70
+ <!-- History items will appear here -->
71
+ </div>
72
+ </div>
73
+ </div>
74
+
75
+ <!-- Info Modal -->
76
+ <div id="infoModal" class="fixed inset-0 bg-black/70 flex items-center justify-center p-4 z-50 hidden">
77
+ <div class="bg-white rounded-xl max-w-md w-full p-6 relative">
78
+ <button id="closeInfoModal" class="absolute top-4 right-4 text-gray-500 hover:text-gray-700">
79
+ <i class="fas fa-times"></i>
80
+ </button>
81
+ <h2 class="text-xl font-bold mb-4">About Randomizer</h2>
82
+ <p class="text-gray-700 mb-4">This app generates random numbers within your specified range. You can customize the minimum and maximum values, and choose whether to allow duplicate numbers.</p>
83
+ <p class="text-gray-700">Made with ❤️ using HTML, CSS & JavaScript</p>
84
+ </div>
85
+ </div>
86
+
87
+ <script>
88
+ document.addEventListener('DOMContentLoaded', function() {
89
+ const generateBtn = document.getElementById('generateBtn');
90
+ const currentNumber = document.getElementById('currentNumber');
91
+ const minValue = document.getElementById('minValue');
92
+ const maxValue = document.getElementById('maxValue');
93
+ const allowDuplicates = document.getElementById('allowDuplicates');
94
+ const numberDisplay = document.getElementById('numberDisplay');
95
+ const history = document.getElementById('history');
96
+ const infoBtn = document.getElementById('infoBtn');
97
+ const infoModal = document.getElementById('infoModal');
98
+ const closeInfoModal = document.getElementById('closeInfoModal');
99
+
100
+ let previousNumbers = [];
101
+
102
+ // Generate random number
103
+ generateBtn.addEventListener('click', function() {
104
+ const min = parseInt(minValue.value);
105
+ const max = parseInt(maxValue.value);
106
+
107
+ // Validate inputs
108
+ if (min > max) {
109
+ alert('Minimum value cannot be greater than maximum value');
110
+ return;
111
+ }
112
+
113
+ let randomNum;
114
+
115
+ if (!allowDuplicates.checked && (max - min + 1) <= previousNumbers.length) {
116
+ alert('All possible numbers in this range have been generated!');
117
+ return;
118
+ }
119
+
120
+ // Generate unique number if duplicates not allowed
121
+ if (!allowDuplicates.checked) {
122
+ do {
123
+ randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
124
+ } while (previousNumbers.includes(randomNum));
125
+ } else {
126
+ randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
127
+ }
128
+
129
+ // Add to history if not duplicate or if duplicates allowed
130
+ if (allowDuplicates.checked || !previousNumbers.includes(randomNum)) {
131
+ previousNumbers.push(randomNum);
132
+ addToHistory(randomNum);
133
+ }
134
+
135
+ // Animation
136
+ numberDisplay.classList.add('glow');
137
+ currentNumber.style.opacity = '0';
138
+ currentNumber.style.transform = 'translateY(-20px)';
139
+
140
+ setTimeout(() => {
141
+ currentNumber.textContent = randomNum;
142
+ currentNumber.style.opacity = '1';
143
+ currentNumber.style.transform = 'translateY(0)';
144
+
145
+ setTimeout(() => {
146
+ numberDisplay.classList.remove('glow');
147
+ }, 500);
148
+ }, 300);
149
+ });
150
+
151
+ // Add number to history
152
+ function addToHistory(num) {
153
+ const historyItem = document.createElement('div');
154
+ historyItem.className = 'bg-indigo-500/20 text-indigo-200 px-3 py-1 rounded-full text-sm flex items-center';
155
+ historyItem.innerHTML = `<span class="mr-1">#${num}</span>`;
156
+ history.insertBefore(historyItem, history.firstChild);
157
+
158
+ // Limit history to 10 items
159
+ if (history.children.length > 10) {
160
+ history.removeChild(history.lastChild);
161
+ }
162
+ }
163
+
164
+ // Modal controls
165
+ infoBtn.addEventListener('click', () => {
166
+ infoModal.classList.remove('hidden');
167
+ });
168
+
169
+ closeInfoModal.addEventListener('click', () => {
170
+ infoModal.classList.add('hidden');
171
+ });
172
+
173
+ infoModal.addEventListener('click', (e) => {
174
+ if (e.target === infoModal) {
175
+ infoModal.classList.add('hidden');
176
+ }
177
+ });
178
+
179
+ // Input validation
180
+ minValue.addEventListener('change', function() {
181
+ if (parseInt(this.value) < 0) this.value = 0;
182
+ });
183
+
184
+ maxValue.addEventListener('change', function() {
185
+ if (parseInt(this.value) < 1) this.value = 1;
186
+ });
187
+ });
188
+ </script>
189
+ <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=akiragosho/random-number" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
190
+ </html>