eaglelandsonce commited on
Commit
ee060f4
·
verified ·
1 Parent(s): 1c054b4

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +122 -18
index.html CHANGED
@@ -1,19 +1,123 @@
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 UI Component on Canvas</title>
7
+ <style>
8
+ canvas {
9
+ border: 1px solid black;
10
+ }
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <canvas id="myCanvas" width="800" height="600"></canvas>
15
+ <script>
16
+ const canvas = document.getElementById('myCanvas');
17
+ const ctx = canvas.getContext('2d');
18
+ const components = [
19
+ createButton,
20
+ createTextInput,
21
+ createColorPicker,
22
+ createCheckbox,
23
+ createRadioButton,
24
+ createRangeSlider
25
+ ];
26
+
27
+ function createButton() {
28
+ ctx.fillStyle = '#000000';
29
+ ctx.fillText('Button:', 10, 30);
30
+ const button = document.createElement('button');
31
+ button.innerText = 'Click Me';
32
+ button.style.position = 'absolute';
33
+ button.style.left = '70px';
34
+ button.style.top = '10px';
35
+ document.body.appendChild(button);
36
+ return button;
37
+ }
38
+
39
+ function createTextInput() {
40
+ ctx.fillStyle = '#000000';
41
+ ctx.fillText('Text Input:', 10, 60);
42
+ const input = document.createElement('input');
43
+ input.type = 'text';
44
+ input.style.position = 'absolute';
45
+ input.style.left = '90px';
46
+ input.style.top = '40px';
47
+ document.body.appendChild(input);
48
+ return input;
49
+ }
50
+
51
+ function createColorPicker() {
52
+ ctx.fillStyle = '#000000';
53
+ ctx.fillText('Color Picker:', 10, 90);
54
+ const input = document.createElement('input');
55
+ input.type = 'color';
56
+ input.style.position = 'absolute';
57
+ input.style.left = '100px';
58
+ input.style.top = '70px';
59
+ document.body.appendChild(input);
60
+ return input;
61
+ }
62
+
63
+ function createCheckbox() {
64
+ ctx.fillStyle = '#000000';
65
+ ctx.fillText('Checkbox:', 10, 120);
66
+ const input = document.createElement('input');
67
+ input.type = 'checkbox';
68
+ input.style.position = 'absolute';
69
+ input.style.left = '80px';
70
+ input.style.top = '100px';
71
+ document.body.appendChild(input);
72
+ return input;
73
+ }
74
+
75
+ function createRadioButton() {
76
+ ctx.fillStyle = '#000000';
77
+ ctx.fillText('Radio Button:', 10, 150);
78
+ const input = document.createElement('input');
79
+ input.type = 'radio';
80
+ input.name = 'radioGroup';
81
+ input.style.position = 'absolute';
82
+ input.style.left = '100px';
83
+ input.style.top = '130px';
84
+ document.body.appendChild(input);
85
+ return input;
86
+ }
87
+
88
+ function createRangeSlider() {
89
+ ctx.fillStyle = '#000000';
90
+ ctx.fillText('Range Slider:', 10, 180);
91
+ const input = document.createElement('input');
92
+ input.type = 'range';
93
+ input.style.position = 'absolute';
94
+ input.style.left = '100px';
95
+ input.style.top = '160px';
96
+ document.body.appendChild(input);
97
+ return input;
98
+ }
99
+
100
+ function clearCanvas() {
101
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
102
+ }
103
+
104
+ function clearUIComponents() {
105
+ const components = document.querySelectorAll('input, button');
106
+ components.forEach(component => {
107
+ document.body.removeChild(component);
108
+ });
109
+ }
110
+
111
+ function drawRandomComponent() {
112
+ clearCanvas();
113
+ clearUIComponents();
114
+ ctx.font = '16px Arial';
115
+ const randomComponent = components[Math.floor(Math.random() * components.length)];
116
+ randomComponent();
117
+ }
118
+
119
+ drawRandomComponent();
120
+ setInterval(drawRandomComponent, 5000);
121
+ </script>
122
+ </body>
123
  </html>