Spaces:
Running
Running
Add 3 files
Browse files- README.md +6 -4
- index.html +736 -19
- prompts.txt +0 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: red
|
| 5 |
-
colorTo:
|
| 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: teste
|
| 3 |
+
emoji: 🐳
|
| 4 |
colorFrom: red
|
| 5 |
+
colorTo: gray
|
| 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,736 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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+
<title>Statistical Calculator</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 9 |
+
<style>
|
| 10 |
+
.cell:focus {
|
| 11 |
+
outline: 2px solid #3b82f6;
|
| 12 |
+
z-index: 10;
|
| 13 |
+
}
|
| 14 |
+
.selected {
|
| 15 |
+
background-color: #bfdbfe;
|
| 16 |
+
}
|
| 17 |
+
.header-cell {
|
| 18 |
+
background-color: #f3f4f6;
|
| 19 |
+
font-weight: 600;
|
| 20 |
+
}
|
| 21 |
+
.formula-bar {
|
| 22 |
+
border-bottom: 1px solid #d1d5db;
|
| 23 |
+
}
|
| 24 |
+
.stat-card {
|
| 25 |
+
transition: all 0.3s ease;
|
| 26 |
+
}
|
| 27 |
+
.stat-card:hover {
|
| 28 |
+
transform: translateY(-2px);
|
| 29 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 30 |
+
}
|
| 31 |
+
</style>
|
| 32 |
+
</head>
|
| 33 |
+
<body class="bg-gray-50 min-h-screen">
|
| 34 |
+
<div class="container mx-auto px-4 py-8">
|
| 35 |
+
<!-- Header -->
|
| 36 |
+
<header class="mb-8">
|
| 37 |
+
<h1 class="text-3xl font-bold text-gray-800">Statistical Calculator</h1>
|
| 38 |
+
<p class="text-gray-600">Enter your data and get instant statistical analysis</p>
|
| 39 |
+
</header>
|
| 40 |
+
|
| 41 |
+
<!-- Toolbar -->
|
| 42 |
+
<div class="bg-white rounded-lg shadow-sm p-4 mb-4 flex flex-wrap gap-3 items-center">
|
| 43 |
+
<button id="add-col" class="bg-blue-50 text-blue-600 px-3 py-1 rounded hover:bg-blue-100 flex items-center">
|
| 44 |
+
<i class="fas fa-plus-circle mr-2"></i> Add Column
|
| 45 |
+
</button>
|
| 46 |
+
<button id="add-row" class="bg-blue-50 text-blue-600 px-3 py-1 rounded hover:bg-blue-100 flex items-center">
|
| 47 |
+
<i class="fas fa-plus-square mr-2"></i> Add Row
|
| 48 |
+
</button>
|
| 49 |
+
<button id="clear-data" class="bg-red-50 text-red-600 px-3 py-1 rounded hover:bg-red-100 flex items-center">
|
| 50 |
+
<i class="fas fa-trash-alt mr-2"></i> Clear Data
|
| 51 |
+
</button>
|
| 52 |
+
<div class="ml-auto flex items-center">
|
| 53 |
+
<span class="text-gray-500 mr-2"><i class="fas fa-info-circle"></i></span>
|
| 54 |
+
<span class="text-sm text-gray-600">Double-click to edit formulas</span>
|
| 55 |
+
</div>
|
| 56 |
+
</div>
|
| 57 |
+
|
| 58 |
+
<!-- Formula Bar -->
|
| 59 |
+
<div class="bg-white rounded-t-lg shadow-sm formula-bar p-2 mb-0 flex items-center">
|
| 60 |
+
<span class="text-gray-500 font-mono mr-2">Formula:</span>
|
| 61 |
+
<input id="formula-input" type="text" class="flex-grow border border-gray-300 rounded px-2 py-1 font-mono" placeholder="Enter formula (e.g., =AVERAGE(A1:A10))">
|
| 62 |
+
</div>
|
| 63 |
+
|
| 64 |
+
<!-- Spreadsheet -->
|
| 65 |
+
<div class="overflow-auto">
|
| 66 |
+
<table id="spreadsheet" class="bg-white shadow-sm w-full">
|
| 67 |
+
<thead>
|
| 68 |
+
<tr id="header-row">
|
| 69 |
+
<th class="w-10 h-10 border border-gray-200 header-cell"></th>
|
| 70 |
+
<!-- Column headers will be added here -->
|
| 71 |
+
</tr>
|
| 72 |
+
</thead>
|
| 73 |
+
<tbody>
|
| 74 |
+
<!-- Rows will be added here -->
|
| 75 |
+
</tbody>
|
| 76 |
+
</table>
|
| 77 |
+
</div>
|
| 78 |
+
|
| 79 |
+
<!-- Statistics Cards -->
|
| 80 |
+
<div id="stats-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mt-8">
|
| 81 |
+
<!-- Stats cards will be added here -->
|
| 82 |
+
</div>
|
| 83 |
+
|
| 84 |
+
<!-- Charts -->
|
| 85 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8 mt-8">
|
| 86 |
+
<div class="bg-white p-6 rounded-lg shadow-sm">
|
| 87 |
+
<h3 class="text-lg font-semibold mb-4">Data Distribution</h3>
|
| 88 |
+
<canvas id="histogram-chart" height="300"></canvas>
|
| 89 |
+
</div>
|
| 90 |
+
<div class="bg-white p-6 rounded-lg shadow-sm">
|
| 91 |
+
<h3 class="text-lg font-semibold mb-4">Trend Analysis</h3>
|
| 92 |
+
<canvas id="line-chart" height="300"></canvas>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
|
| 97 |
+
<script>
|
| 98 |
+
// Initialize spreadsheet with 10 rows and 5 columns
|
| 99 |
+
const rows = 10;
|
| 100 |
+
const cols = 5;
|
| 101 |
+
let spreadsheetData = [];
|
| 102 |
+
let selectedCell = null;
|
| 103 |
+
let histChart = null;
|
| 104 |
+
let lineChart = null;
|
| 105 |
+
|
| 106 |
+
// Initialize the spreadsheet
|
| 107 |
+
function initSpreadsheet() {
|
| 108 |
+
const headerRow = document.getElementById('header-row');
|
| 109 |
+
const tbody = document.querySelector('#spreadsheet tbody');
|
| 110 |
+
|
| 111 |
+
// Clear existing content
|
| 112 |
+
headerRow.innerHTML = '<th class="w-10 h-10 border border-gray-200 header-cell"></th>';
|
| 113 |
+
tbody.innerHTML = '';
|
| 114 |
+
|
| 115 |
+
// Create column headers (A, B, C, ...)
|
| 116 |
+
for (let col = 0; col < cols; col++) {
|
| 117 |
+
const colHeader = document.createElement('th');
|
| 118 |
+
colHeader.className = 'w-24 h-10 border border-gray-200 header-cell';
|
| 119 |
+
colHeader.textContent = String.fromCharCode(65 + col);
|
| 120 |
+
headerRow.appendChild(colHeader);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
// Initialize data structure and create rows
|
| 124 |
+
spreadsheetData = [];
|
| 125 |
+
for (let row = 0; row < rows; row++) {
|
| 126 |
+
const tr = document.createElement('tr');
|
| 127 |
+
const rowHeader = document.createElement('th');
|
| 128 |
+
rowHeader.className = 'w-10 h-10 border border-gray-200 header-cell';
|
| 129 |
+
rowHeader.textContent = row + 1;
|
| 130 |
+
tr.appendChild(rowHeader);
|
| 131 |
+
|
| 132 |
+
const rowData = [];
|
| 133 |
+
for (let col = 0; col < cols; col++) {
|
| 134 |
+
const td = document.createElement('td');
|
| 135 |
+
td.className = 'border border-gray-200 h-10 p-0';
|
| 136 |
+
|
| 137 |
+
const input = document.createElement('input');
|
| 138 |
+
input.type = 'text';
|
| 139 |
+
input.className = 'cell w-full h-full px-2 border-0 focus:ring-0';
|
| 140 |
+
input.dataset.row = row;
|
| 141 |
+
input.dataset.col = col;
|
| 142 |
+
|
| 143 |
+
td.appendChild(input);
|
| 144 |
+
tr.appendChild(td);
|
| 145 |
+
|
| 146 |
+
// Initialize cell data
|
| 147 |
+
if (!spreadsheetData[row]) spreadsheetData[row] = [];
|
| 148 |
+
spreadsheetData[row][col] = {
|
| 149 |
+
value: '',
|
| 150 |
+
formula: '',
|
| 151 |
+
computedValue: ''
|
| 152 |
+
};
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
tbody.appendChild(tr);
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
// Add event listeners to all cells
|
| 159 |
+
addCellEventListeners();
|
| 160 |
+
|
| 161 |
+
// Initialize charts
|
| 162 |
+
initCharts();
|
| 163 |
+
|
| 164 |
+
// Update stats
|
| 165 |
+
updateStatistics();
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
// Add event listeners to cells
|
| 169 |
+
function addCellEventListeners() {
|
| 170 |
+
document.querySelectorAll('.cell').forEach(cell => {
|
| 171 |
+
// Clear existing listeners to avoid duplicates
|
| 172 |
+
cell.replaceWith(cell.cloneNode(true));
|
| 173 |
+
});
|
| 174 |
+
|
| 175 |
+
document.querySelectorAll('.cell').forEach(cell => {
|
| 176 |
+
cell.addEventListener('focus', handleCellFocus);
|
| 177 |
+
cell.addEventListener('blur', handleCellBlur);
|
| 178 |
+
cell.addEventListener('keydown', handleCellKeyDown);
|
| 179 |
+
cell.addEventListener('dblclick', handleCellDoubleClick);
|
| 180 |
+
cell.addEventListener('input', handleCellInput);
|
| 181 |
+
});
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
// Handle cell focus
|
| 185 |
+
function handleCellFocus(e) {
|
| 186 |
+
const cell = e.target;
|
| 187 |
+
const row = parseInt(cell.dataset.row);
|
| 188 |
+
const col = parseInt(cell.dataset.col);
|
| 189 |
+
|
| 190 |
+
// Remove selection from previous cell
|
| 191 |
+
if (selectedCell) {
|
| 192 |
+
selectedCell.classList.remove('selected');
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
// Add selection to current cell
|
| 196 |
+
cell.classList.add('selected');
|
| 197 |
+
selectedCell = cell;
|
| 198 |
+
|
| 199 |
+
// Update formula bar
|
| 200 |
+
const formulaInput = document.getElementById('formula-input');
|
| 201 |
+
const cellData = spreadsheetData[row][col];
|
| 202 |
+
formulaInput.value = cellData.formula ? `=${cellData.formula}` : '';
|
| 203 |
+
formulaInput.dataset.row = row;
|
| 204 |
+
formulaInput.dataset.col = col;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
// Handle cell blur
|
| 208 |
+
function handleCellBlur(e) {
|
| 209 |
+
e.target.classList.remove('selected');
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
// Handle cell key down (for formula input)
|
| 213 |
+
function handleCellKeyDown(e) {
|
| 214 |
+
if (e.key === 'Enter') {
|
| 215 |
+
e.preventDefault();
|
| 216 |
+
const row = parseInt(e.target.dataset.row);
|
| 217 |
+
const col = parseInt(e.target.dataset.col);
|
| 218 |
+
|
| 219 |
+
// If the input starts with '=', treat it as a formula
|
| 220 |
+
if (e.target.value.startsWith('=')) {
|
| 221 |
+
spreadsheetData[row][col].formula = e.target.value.substring(1);
|
| 222 |
+
computeFormula(row, col);
|
| 223 |
+
} else {
|
| 224 |
+
spreadsheetData[row][col].value = e.target.value;
|
| 225 |
+
spreadsheetData[row][col].computedValue = e.target.value;
|
| 226 |
+
updateDependentCells(row, col);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
updateStatistics();
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
// Handle cell double click (for formula editing)
|
| 234 |
+
function handleCellDoubleClick(e) {
|
| 235 |
+
const row = parseInt(e.target.dataset.row);
|
| 236 |
+
const col = parseInt(e.target.dataset.col);
|
| 237 |
+
const cellData = spreadsheetData[row][col];
|
| 238 |
+
|
| 239 |
+
if (cellData.formula) {
|
| 240 |
+
e.target.value = `=${cellData.formula}`;
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
// Handle cell input (for direct value editing)
|
| 245 |
+
function handleCellInput(e) {
|
| 246 |
+
const row = parseInt(e.target.dataset.row);
|
| 247 |
+
const col = parseInt(e.target.dataset.col);
|
| 248 |
+
|
| 249 |
+
// If not starting with '=', treat as direct value
|
| 250 |
+
if (!e.target.value.startsWith('=')) {
|
| 251 |
+
spreadsheetData[row][col].value = e.target.value;
|
| 252 |
+
spreadsheetData[row][col].computedValue = e.target.value;
|
| 253 |
+
spreadsheetData[row][col].formula = '';
|
| 254 |
+
updateDependentCells(row, col);
|
| 255 |
+
updateStatistics();
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
// Compute formula for a cell
|
| 260 |
+
function computeFormula(row, col) {
|
| 261 |
+
const cellData = spreadsheetData[row][col];
|
| 262 |
+
if (!cellData.formula) return;
|
| 263 |
+
|
| 264 |
+
try {
|
| 265 |
+
// Simple formula parser (supports basic functions and ranges)
|
| 266 |
+
let formula = cellData.formula;
|
| 267 |
+
|
| 268 |
+
// Handle AVERAGE
|
| 269 |
+
if (formula.startsWith('AVERAGE(')) {
|
| 270 |
+
const range = formula.match(/AVERAGE\(([^)]+)\)/)[1];
|
| 271 |
+
const values = getRangeValues(range);
|
| 272 |
+
const sum = values.reduce((a, b) => parseFloat(a) + parseFloat(b), 0);
|
| 273 |
+
const avg = sum / values.length;
|
| 274 |
+
cellData.computedValue = isNaN(avg) ? '#ERROR!' : avg.toFixed(2);
|
| 275 |
+
}
|
| 276 |
+
// Handle SUM
|
| 277 |
+
else if (formula.startsWith('SUM(')) {
|
| 278 |
+
const range = formula.match(/SUM\(([^)]+)\)/)[1];
|
| 279 |
+
const values = getRangeValues(range);
|
| 280 |
+
const sum = values.reduce((a, b) => parseFloat(a) + parseFloat(b), 0);
|
| 281 |
+
cellData.computedValue = isNaN(sum) ? '#ERROR!' : sum.toFixed(2);
|
| 282 |
+
}
|
| 283 |
+
// Handle COUNT
|
| 284 |
+
else if (formula.startsWith('COUNT(')) {
|
| 285 |
+
const range = formula.match(/COUNT\(([^)]+)\)/)[1];
|
| 286 |
+
const values = getRangeValues(range);
|
| 287 |
+
cellData.computedValue = values.length.toString();
|
| 288 |
+
}
|
| 289 |
+
// Handle MAX
|
| 290 |
+
else if (formula.startsWith('MAX(')) {
|
| 291 |
+
const range = formula.match(/MAX\(([^)]+)\)/)[1];
|
| 292 |
+
const values = getRangeValues(range).map(Number);
|
| 293 |
+
cellData.computedValue = Math.max(...values).toString();
|
| 294 |
+
}
|
| 295 |
+
// Handle MIN
|
| 296 |
+
else if (formula.startsWith('MIN(')) {
|
| 297 |
+
const range = formula.match(/MIN\(([^)]+)\)/)[1];
|
| 298 |
+
const values = getRangeValues(range).map(Number);
|
| 299 |
+
cellData.computedValue = Math.min(...values).toString();
|
| 300 |
+
}
|
| 301 |
+
// Handle simple arithmetic
|
| 302 |
+
else {
|
| 303 |
+
// Replace cell references with their values
|
| 304 |
+
const cellRefRegex = /([A-Z])(\d+)/g;
|
| 305 |
+
let computedFormula = formula.replace(cellRefRegex, (match, colChar, rowNum) => {
|
| 306 |
+
const refCol = colChar.charCodeAt(0) - 65;
|
| 307 |
+
const refRow = parseInt(rowNum) - 1;
|
| 308 |
+
if (spreadsheetData[refRow] && spreadsheetData[refRow][refCol]) {
|
| 309 |
+
return spreadsheetData[refRow][refCol].computedValue || '0';
|
| 310 |
+
}
|
| 311 |
+
return '0';
|
| 312 |
+
});
|
| 313 |
+
|
| 314 |
+
// Evaluate the formula
|
| 315 |
+
cellData.computedValue = eval(computedFormula).toString();
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
// Update the cell display
|
| 319 |
+
const cell = document.querySelector(`.cell[data-row="${row}"][data-col="${col}"]`);
|
| 320 |
+
if (cell) {
|
| 321 |
+
cell.value = cellData.computedValue;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
// Update any cells that depend on this one
|
| 325 |
+
updateDependentCells(row, col);
|
| 326 |
+
|
| 327 |
+
} catch (e) {
|
| 328 |
+
cellData.computedValue = '#ERROR!';
|
| 329 |
+
const cell = document.querySelector(`.cell[data-row="${row}"][data-col="${col}"]`);
|
| 330 |
+
if (cell) {
|
| 331 |
+
cell.value = '#ERROR!';
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
// Get values from a range (e.g., "A1:B5")
|
| 337 |
+
function getRangeValues(range) {
|
| 338 |
+
const values = [];
|
| 339 |
+
|
| 340 |
+
// Check if it's a single cell
|
| 341 |
+
if (/^[A-Z]\d+$/.test(range)) {
|
| 342 |
+
const col = range.charCodeAt(0) - 65;
|
| 343 |
+
const row = parseInt(range.substring(1)) - 1;
|
| 344 |
+
if (spreadsheetData[row] && spreadsheetData[row][col]) {
|
| 345 |
+
const val = spreadsheetData[row][col].computedValue || spreadsheetData[row][col].value;
|
| 346 |
+
if (val && !isNaN(parseFloat(val))) {
|
| 347 |
+
values.push(parseFloat(val));
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
return values;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
// Check if it's a range (e.g., A1:B5)
|
| 354 |
+
const rangeMatch = range.match(/^([A-Z])(\d+):([A-Z])(\d+)$/);
|
| 355 |
+
if (rangeMatch) {
|
| 356 |
+
const startCol = rangeMatch[1].charCodeAt(0) - 65;
|
| 357 |
+
const startRow = parseInt(rangeMatch[2]) - 1;
|
| 358 |
+
const endCol = rangeMatch[3].charCodeAt(0) - 65;
|
| 359 |
+
const endRow = parseInt(rangeMatch[4]) - 1;
|
| 360 |
+
|
| 361 |
+
for (let row = startRow; row <= endRow; row++) {
|
| 362 |
+
for (let col = startCol; col <= endCol; col++) {
|
| 363 |
+
if (spreadsheetData[row] && spreadsheetData[row][col]) {
|
| 364 |
+
const val = spreadsheetData[row][col].computedValue || spreadsheetData[row][col].value;
|
| 365 |
+
if (val && !isNaN(parseFloat(val))) {
|
| 366 |
+
values.push(parseFloat(val));
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
}
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
return values;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
// Update cells that depend on this cell
|
| 377 |
+
function updateDependentCells(row, col) {
|
| 378 |
+
// This is a simplified version - in a real app, you'd track dependencies
|
| 379 |
+
// For now, we'll just recompute all formulas
|
| 380 |
+
for (let r = 0; r < spreadsheetData.length; r++) {
|
| 381 |
+
for (let c = 0; c < spreadsheetData[r].length; c++) {
|
| 382 |
+
if (spreadsheetData[r][c].formula) {
|
| 383 |
+
computeFormula(r, c);
|
| 384 |
+
}
|
| 385 |
+
}
|
| 386 |
+
}
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
// Add a new column
|
| 390 |
+
function addColumn() {
|
| 391 |
+
const headerRow = document.getElementById('header-row');
|
| 392 |
+
const colChar = String.fromCharCode(65 + cols);
|
| 393 |
+
|
| 394 |
+
// Add column header
|
| 395 |
+
const colHeader = document.createElement('th');
|
| 396 |
+
colHeader.className = 'w-24 h-10 border border-gray-200 header-cell';
|
| 397 |
+
colHeader.textContent = colChar;
|
| 398 |
+
headerRow.appendChild(colHeader);
|
| 399 |
+
|
| 400 |
+
// Add column to each row
|
| 401 |
+
document.querySelectorAll('#spreadsheet tbody tr').forEach((tr, row) => {
|
| 402 |
+
const td = document.createElement('td');
|
| 403 |
+
td.className = 'border border-gray-200 h-10 p-0';
|
| 404 |
+
|
| 405 |
+
const input = document.createElement('input');
|
| 406 |
+
input.type = 'text';
|
| 407 |
+
input.className = 'cell w-full h-full px-2 border-0 focus:ring-0';
|
| 408 |
+
input.dataset.row = row;
|
| 409 |
+
input.dataset.col = cols;
|
| 410 |
+
|
| 411 |
+
td.appendChild(input);
|
| 412 |
+
tr.appendChild(td);
|
| 413 |
+
|
| 414 |
+
// Initialize cell data
|
| 415 |
+
if (!spreadsheetData[row]) spreadsheetData[row] = [];
|
| 416 |
+
spreadsheetData[row][cols] = {
|
| 417 |
+
value: '',
|
| 418 |
+
formula: '',
|
| 419 |
+
computedValue: ''
|
| 420 |
+
};
|
| 421 |
+
});
|
| 422 |
+
|
| 423 |
+
// Update cols count
|
| 424 |
+
cols++;
|
| 425 |
+
|
| 426 |
+
// Add event listeners to new cells
|
| 427 |
+
addCellEventListeners();
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
// Add a new row
|
| 431 |
+
function addRow() {
|
| 432 |
+
const tbody = document.querySelector('#spreadsheet tbody');
|
| 433 |
+
const row = spreadsheetData.length;
|
| 434 |
+
const tr = document.createElement('tr');
|
| 435 |
+
|
| 436 |
+
// Add row header
|
| 437 |
+
const rowHeader = document.createElement('th');
|
| 438 |
+
rowHeader.className = 'w-10 h-10 border border-gray-200 header-cell';
|
| 439 |
+
rowHeader.textContent = row + 1;
|
| 440 |
+
tr.appendChild(rowHeader);
|
| 441 |
+
|
| 442 |
+
// Add cells for each column
|
| 443 |
+
for (let col = 0; col < cols; col++) {
|
| 444 |
+
const td = document.createElement('td');
|
| 445 |
+
td.className = 'border border-gray-200 h-10 p-0';
|
| 446 |
+
|
| 447 |
+
const input = document.createElement('input');
|
| 448 |
+
input.type = 'text';
|
| 449 |
+
input.className = 'cell w-full h-full px-2 border-0 focus:ring-0';
|
| 450 |
+
input.dataset.row = row;
|
| 451 |
+
input.dataset.col = col;
|
| 452 |
+
|
| 453 |
+
td.appendChild(input);
|
| 454 |
+
tr.appendChild(td);
|
| 455 |
+
|
| 456 |
+
// Initialize cell data
|
| 457 |
+
if (!spreadsheetData[row]) spreadsheetData[row] = [];
|
| 458 |
+
spreadsheetData[row][col] = {
|
| 459 |
+
value: '',
|
| 460 |
+
formula: '',
|
| 461 |
+
computedValue: ''
|
| 462 |
+
};
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
tbody.appendChild(tr);
|
| 466 |
+
|
| 467 |
+
// Add event listeners to new cells
|
| 468 |
+
addCellEventListeners();
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
// Clear all data
|
| 472 |
+
function clearData() {
|
| 473 |
+
if (confirm('Are you sure you want to clear all data?')) {
|
| 474 |
+
spreadsheetData.forEach(row => {
|
| 475 |
+
row.forEach(cell => {
|
| 476 |
+
cell.value = '';
|
| 477 |
+
cell.formula = '';
|
| 478 |
+
cell.computedValue = '';
|
| 479 |
+
});
|
| 480 |
+
});
|
| 481 |
+
|
| 482 |
+
document.querySelectorAll('.cell').forEach(cell => {
|
| 483 |
+
cell.value = '';
|
| 484 |
+
});
|
| 485 |
+
|
| 486 |
+
updateStatistics();
|
| 487 |
+
}
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
// Initialize charts
|
| 491 |
+
function initCharts() {
|
| 492 |
+
const histCtx = document.getElementById('histogram-chart').getContext('2d');
|
| 493 |
+
const lineCtx = document.getElementById('line-chart').getContext('2d');
|
| 494 |
+
|
| 495 |
+
histChart = new Chart(histCtx, {
|
| 496 |
+
type: 'bar',
|
| 497 |
+
data: { labels: [], datasets: [{ data: [] }] },
|
| 498 |
+
options: {
|
| 499 |
+
responsive: true,
|
| 500 |
+
scales: { y: { beginAtZero: true } }
|
| 501 |
+
}
|
| 502 |
+
});
|
| 503 |
+
|
| 504 |
+
lineChart = new Chart(lineCtx, {
|
| 505 |
+
type: 'line',
|
| 506 |
+
data: { labels: [], datasets: [{ data: [] }] },
|
| 507 |
+
options: { responsive: true }
|
| 508 |
+
});
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
// Update charts with current data
|
| 512 |
+
function updateCharts(numericData) {
|
| 513 |
+
if (numericData.length === 0) return;
|
| 514 |
+
|
| 515 |
+
// Update histogram
|
| 516 |
+
const histData = createHistogramData(numericData);
|
| 517 |
+
histChart.data.labels = histData.labels;
|
| 518 |
+
histChart.data.datasets[0].data = histData.values;
|
| 519 |
+
histChart.data.datasets[0].backgroundColor = 'rgba(59, 130, 246, 0.5)';
|
| 520 |
+
histChart.data.datasets[0].borderColor = 'rgba(59, 130, 246, 1)';
|
| 521 |
+
histChart.data.datasets[0].borderWidth = 1;
|
| 522 |
+
histChart.update();
|
| 523 |
+
|
| 524 |
+
// Update line chart
|
| 525 |
+
lineChart.data.labels = Array.from({ length: numericData.length }, (_, i) => i + 1);
|
| 526 |
+
lineChart.data.datasets[0].data = numericData;
|
| 527 |
+
lineChart.data.datasets[0].backgroundColor = 'rgba(16, 185, 129, 0.1)';
|
| 528 |
+
lineChart.data.datasets[0].borderColor = 'rgba(16, 185, 129, 1)';
|
| 529 |
+
lineChart.data.datasets[0].borderWidth = 2;
|
| 530 |
+
lineChart.data.datasets[0].tension = 0.1;
|
| 531 |
+
lineChart.update();
|
| 532 |
+
}
|
| 533 |
+
|
| 534 |
+
// Create histogram data
|
| 535 |
+
function createHistogramData(data) {
|
| 536 |
+
const min = Math.min(...data);
|
| 537 |
+
const max = Math.max(...data);
|
| 538 |
+
const range = max - min;
|
| 539 |
+
const binCount = Math.min(10, Math.ceil(Math.sqrt(data.length)));
|
| 540 |
+
const binSize = range / binCount;
|
| 541 |
+
|
| 542 |
+
const bins = Array(binCount).fill(0);
|
| 543 |
+
const labels = [];
|
| 544 |
+
|
| 545 |
+
for (let i = 0; i < binCount; i++) {
|
| 546 |
+
const lower = min + (i * binSize);
|
| 547 |
+
const upper = lower + binSize;
|
| 548 |
+
labels.push(`${lower.toFixed(1)}-${upper.toFixed(1)}`);
|
| 549 |
+
|
| 550 |
+
for (const value of data) {
|
| 551 |
+
if (value >= lower && (i === binCount - 1 ? value <= upper : value < upper)) {
|
| 552 |
+
bins[i]++;
|
| 553 |
+
}
|
| 554 |
+
}
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
return { labels, values: bins };
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
// Update statistics display
|
| 561 |
+
function updateStatistics() {
|
| 562 |
+
// Get all numeric values from the spreadsheet
|
| 563 |
+
const numericData = [];
|
| 564 |
+
spreadsheetData.forEach(row => {
|
| 565 |
+
row.forEach(cell => {
|
| 566 |
+
const val = cell.computedValue || cell.value;
|
| 567 |
+
if (val && !isNaN(parseFloat(val))) {
|
| 568 |
+
numericData.push(parseFloat(val));
|
| 569 |
+
}
|
| 570 |
+
});
|
| 571 |
+
});
|
| 572 |
+
|
| 573 |
+
// Calculate statistics
|
| 574 |
+
const stats = calculateStatistics(numericData);
|
| 575 |
+
|
| 576 |
+
// Update stats cards
|
| 577 |
+
updateStatsCards(stats);
|
| 578 |
+
|
| 579 |
+
// Update charts
|
| 580 |
+
updateCharts(numericData);
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
// Calculate basic statistics
|
| 584 |
+
function calculateStatistics(data) {
|
| 585 |
+
if (data.length === 0) {
|
| 586 |
+
return {
|
| 587 |
+
count: 0,
|
| 588 |
+
sum: 0,
|
| 589 |
+
mean: 0,
|
| 590 |
+
median: 0,
|
| 591 |
+
min: 0,
|
| 592 |
+
max: 0,
|
| 593 |
+
range: 0,
|
| 594 |
+
variance: 0,
|
| 595 |
+
stdDev: 0
|
| 596 |
+
};
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
// Basic stats
|
| 600 |
+
const count = data.length;
|
| 601 |
+
const sum = data.reduce((a, b) => a + b, 0);
|
| 602 |
+
const mean = sum / count;
|
| 603 |
+
const sorted = [...data].sort((a, b) => a - b);
|
| 604 |
+
const median = sorted[Math.floor(count / 2)];
|
| 605 |
+
const min = Math.min(...data);
|
| 606 |
+
const max = Math.max(...data);
|
| 607 |
+
const range = max - min;
|
| 608 |
+
|
| 609 |
+
// Variance and standard deviation
|
| 610 |
+
const variance = data.reduce((a, b) => a + Math.pow(b - mean, 2), 0) / count;
|
| 611 |
+
const stdDev = Math.sqrt(variance);
|
| 612 |
+
|
| 613 |
+
return {
|
| 614 |
+
count,
|
| 615 |
+
sum: sum.toFixed(2),
|
| 616 |
+
mean: mean.toFixed(2),
|
| 617 |
+
median: median.toFixed(2),
|
| 618 |
+
min: min.toFixed(2),
|
| 619 |
+
max: max.toFixed(2),
|
| 620 |
+
range: range.toFixed(2),
|
| 621 |
+
variance: variance.toFixed(2),
|
| 622 |
+
stdDev: stdDev.toFixed(2)
|
| 623 |
+
};
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
// Update statistics cards
|
| 627 |
+
function updateStatsCards(stats) {
|
| 628 |
+
const statsContainer = document.getElementById('stats-container');
|
| 629 |
+
|
| 630 |
+
const cards = [
|
| 631 |
+
{
|
| 632 |
+
title: 'Count',
|
| 633 |
+
value: stats.count,
|
| 634 |
+
icon: 'fas fa-hashtag',
|
| 635 |
+
color: 'bg-blue-100 text-blue-800'
|
| 636 |
+
},
|
| 637 |
+
{
|
| 638 |
+
title: 'Mean',
|
| 639 |
+
value: stats.mean,
|
| 640 |
+
icon: 'fas fa-calculator',
|
| 641 |
+
color: 'bg-green-100 text-green-800'
|
| 642 |
+
},
|
| 643 |
+
{
|
| 644 |
+
title: 'Median',
|
| 645 |
+
value: stats.median,
|
| 646 |
+
icon: 'fas fa-sort',
|
| 647 |
+
color: 'bg-purple-100 text-purple-800'
|
| 648 |
+
},
|
| 649 |
+
{
|
| 650 |
+
title: 'Std Dev',
|
| 651 |
+
value: stats.stdDev,
|
| 652 |
+
icon: 'fas fa-chart-line',
|
| 653 |
+
color: 'bg-yellow-100 text-yellow-800'
|
| 654 |
+
},
|
| 655 |
+
{
|
| 656 |
+
title: 'Min',
|
| 657 |
+
value: stats.min,
|
| 658 |
+
icon: 'fas fa-arrow-down',
|
| 659 |
+
color: 'bg-red-100 text-red-800'
|
| 660 |
+
},
|
| 661 |
+
{
|
| 662 |
+
title: 'Max',
|
| 663 |
+
value: stats.max,
|
| 664 |
+
icon: 'fas fa-arrow-up',
|
| 665 |
+
color: 'bg-indigo-100 text-indigo-800'
|
| 666 |
+
},
|
| 667 |
+
{
|
| 668 |
+
title: 'Range',
|
| 669 |
+
value: stats.range,
|
| 670 |
+
icon: 'fas fa-ruler',
|
| 671 |
+
color: 'bg-pink-100 text-pink-800'
|
| 672 |
+
},
|
| 673 |
+
{
|
| 674 |
+
title: 'Variance',
|
| 675 |
+
value: stats.variance,
|
| 676 |
+
icon: 'fas fa-square-root-alt',
|
| 677 |
+
color: 'bg-teal-100 text-teal-800'
|
| 678 |
+
}
|
| 679 |
+
];
|
| 680 |
+
|
| 681 |
+
statsContainer.innerHTML = cards.map(card => `
|
| 682 |
+
<div class="stat-card ${card.color} p-4 rounded-lg shadow">
|
| 683 |
+
<div class="flex items-center">
|
| 684 |
+
<div class="p-2 rounded-full ${card.color.replace('bg-', 'bg-opacity-20 ')} mr-3">
|
| 685 |
+
<i class="${card.icon}"></i>
|
| 686 |
+
</div>
|
| 687 |
+
<div>
|
| 688 |
+
<h3 class="text-sm font-medium">${card.title}</h3>
|
| 689 |
+
<p class="text-2xl font-bold">${card.value}</p>
|
| 690 |
+
</div>
|
| 691 |
+
</div>
|
| 692 |
+
</div>
|
| 693 |
+
`).join('');
|
| 694 |
+
}
|
| 695 |
+
|
| 696 |
+
// Handle formula bar input
|
| 697 |
+
function handleFormulaInput(e) {
|
| 698 |
+
if (e.key === 'Enter') {
|
| 699 |
+
const row = parseInt(e.target.dataset.row);
|
| 700 |
+
const col = parseInt(e.target.dataset.col);
|
| 701 |
+
|
| 702 |
+
if (!isNaN(row) && !isNaN(col)) {
|
| 703 |
+
const formula = e.target.value.startsWith('=') ? e.target.value.substring(1) : '';
|
| 704 |
+
spreadsheetData[row][col].formula = formula;
|
| 705 |
+
|
| 706 |
+
if (formula) {
|
| 707 |
+
computeFormula(row, col);
|
| 708 |
+
} else {
|
| 709 |
+
// If formula is empty, show the raw value
|
| 710 |
+
const cell = document.querySelector(`.cell[data-row="${row}"][data-col="${col}"]`);
|
| 711 |
+
if (cell) {
|
| 712 |
+
cell.value = spreadsheetData[row][col].value;
|
| 713 |
+
spreadsheetData[row][col].computedValue = spreadsheetData[row][col].value;
|
| 714 |
+
}
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
updateStatistics();
|
| 718 |
+
}
|
| 719 |
+
}
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
// Initialize the app
|
| 723 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 724 |
+
initSpreadsheet();
|
| 725 |
+
|
| 726 |
+
// Add event listeners to buttons
|
| 727 |
+
document.getElementById('add-col').addEventListener('click', addColumn);
|
| 728 |
+
document.getElementById('add-row').addEventListener('click', addRow);
|
| 729 |
+
document.getElementById('clear-data').addEventListener('click', clearData);
|
| 730 |
+
|
| 731 |
+
// Add event listener to formula bar
|
| 732 |
+
document.getElementById('formula-input').addEventListener('keydown', handleFormulaInput);
|
| 733 |
+
});
|
| 734 |
+
</script>
|
| 735 |
+
<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=cltservices/teste" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 736 |
+
</html>
|
prompts.txt
ADDED
|
File without changes
|