Defkhan5960 commited on
Commit
df858b2
·
verified ·
1 Parent(s): 5261cce

Okey, now we see the result in the bottom of the page but still there are no clouds.

Browse files
Files changed (1) hide show
  1. script.js +32 -23
script.js CHANGED
@@ -51,26 +51,25 @@ document.addEventListener('DOMContentLoaded', async function() {
51
  }
52
  });
53
  function createClouds() {
54
- cloudContainer.innerHTML = '';
55
-
56
- // Calculate positions for two rows of clouds
57
- const containerWidth = cloudContainer.offsetWidth;
58
- const containerHeight = cloudContainer.offsetHeight;
59
-
60
- // First row (top)
61
- for (let i = 0; i < 5; i++) {
62
- const x = (i + 0.5) * (containerWidth / 5.5);
63
- const y = containerHeight * 0.3;
64
- createCloud(cloudData[i], x, y, 60);
65
- }
 
 
66
 
67
- // Second row (bottom)
68
- for (let i = 5; i < 10; i++) {
69
- const x = (i - 4.5) * (containerWidth / 5.5);
70
- const y = containerHeight * 0.7;
71
- createCloud(cloudData[i], x, y, 60);
72
- }
73
- }
74
  function createCloud(data, x, y, baseSize) {
75
  const cloud = document.createElement('custom-cloud');
76
  cloud.setAttribute('text', data.text);
@@ -82,13 +81,17 @@ function createCloud(data, x, y, baseSize) {
82
  cloud.style.top = `${y}px`;
83
  cloud.style.transform = 'translate(-50%, -50%)';
84
 
85
- // Scale based on percentage
86
- const scale = 0.5 + (data.percentage / 100);
87
  cloud.style.transform += ` scale(${scale})`;
88
 
89
- // Add animation delay for staggered appearance
 
90
  cloud.style.animationDelay = `${Math.random() * 0.5}s`;
91
 
 
 
 
92
  cloudContainer.appendChild(cloud);
93
  return cloud;
94
  }
@@ -152,8 +155,14 @@ function updateClouds() {
152
  const y = centerY + Math.sin(angle) * radius;
153
 
154
  // Create cloud with size based on percentage
155
- const baseSize = 30 + (cloud.percentage * 0.7);
156
  createCloud(cloud, x, y, baseSize);
 
 
 
 
 
 
157
  });
158
  }
159
  function showResults(inputText, similarities) {
 
51
  }
52
  });
53
  function createClouds() {
54
+ cloudContainer.innerHTML = '';
55
+
56
+ const containerWidth = cloudContainer.offsetWidth;
57
+ const containerHeight = cloudContainer.offsetHeight;
58
+
59
+ // Create a circular layout for initial clouds
60
+ const centerX = containerWidth / 2;
61
+ const centerY = containerHeight / 2;
62
+ const radius = Math.min(containerWidth, containerHeight) * 0.35;
63
+
64
+ cloudData.forEach((cloud, i) => {
65
+ const angle = (i / cloudData.length) * Math.PI * 2;
66
+ const x = centerX + Math.cos(angle) * radius;
67
+ const y = centerY + Math.sin(angle) * radius;
68
 
69
+ // Create cloud with base size
70
+ createCloud(cloud, x, y, 40);
71
+ });
72
+ }
 
 
 
73
  function createCloud(data, x, y, baseSize) {
74
  const cloud = document.createElement('custom-cloud');
75
  cloud.setAttribute('text', data.text);
 
81
  cloud.style.top = `${y}px`;
82
  cloud.style.transform = 'translate(-50%, -50%)';
83
 
84
+ // Scale based on percentage (even if 0%)
85
+ const scale = 0.7 + (data.percentage / 150);
86
  cloud.style.transform += ` scale(${scale})`;
87
 
88
+ // Add animation
89
+ cloud.style.animation = `float 3s ease-in-out infinite`;
90
  cloud.style.animationDelay = `${Math.random() * 0.5}s`;
91
 
92
+ // Make sure clouds are visible even at 0%
93
+ cloud.style.opacity = '0.9';
94
+
95
  cloudContainer.appendChild(cloud);
96
  return cloud;
97
  }
 
155
  const y = centerY + Math.sin(angle) * radius;
156
 
157
  // Create cloud with size based on percentage
158
+ const baseSize = 40 + (cloud.percentage * 0.8);
159
  createCloud(cloud, x, y, baseSize);
160
+
161
+ // Make sure clouds are visible even at 0%
162
+ if (cloud.percentage === 0) {
163
+ const cloudElement = cloudContainer.lastChild;
164
+ cloudElement.style.opacity = '0.6';
165
+ }
166
  });
167
  }
168
  function showResults(inputText, similarities) {