|
211 | 211 | </div> |
212 | 212 |
|
213 | 213 | <script> |
| 214 | + const DEFAULT_POLLY_URL = 'https://app.apptivegrid.de/api/users/62398e23b8b578b35b971df0/spaces/66bcc1d7f549cad6d6dbf2be/grids/66bcc1dcf549ca6236dbf2c4/entities/BqWFtLCV6KM?layout=key'; |
| 215 | + |
214 | 216 | const thumb = document.getElementById('thumb'); |
215 | 217 | const needle = document.getElementById('needle'); |
216 | 218 | const valueDisplay = document.getElementById('valueDisplay'); |
|
310 | 312 | hasSubmitted = true; // Mark as submitted |
311 | 313 | drawCircles(); |
312 | 314 | calculatePercentages(entity); |
| 315 | + setVoteSubmitted(); |
313 | 316 | }) |
314 | 317 | .catch(error => { |
315 | 318 | console.error('Failed to post data:', error); |
|
427 | 430 | }); |
428 | 431 | document.addEventListener("DOMContentLoaded", function() { |
429 | 432 | const urlParams = new URLSearchParams(window.location.search); |
430 | | - const url = urlParams.get('url') || 'https://app.apptivegrid.de/api/users/62398e23b8b578b35b971df0/spaces/66bcc1d7f549cad6d6dbf2be/grids/66bcc1dcf549ca6236dbf2c4/entities/BqWFtLCV6KM?layout=key'; |
| 433 | + const url = urlParams.get('url') || DEFAULT_POLLY_URL; |
431 | 434 | const username = urlParams.get('username') || '23bd064465e583233eab7807507a715c'; |
432 | 435 | const password = urlParams.get('password') || 'a7hkqxt2qj8rfverccyzn4agt'; |
433 | 436 |
|
|
452 | 455 | document.getElementById('question').textContent = data['question'] || 'No question found in response.'; |
453 | 456 | document.getElementById('answer1').textContent = data['answer_1'] || 'No answer_1 found in response.'; |
454 | 457 | document.getElementById('answer2').textContent = data['answer_2'] || 'No answer_2 found in response.'; |
455 | | - document.getElementById('numberOfResultsDisplay').textContent = data['numberOfResults']['value'] || 'No numberOfResults found in response.'; |
| 458 | + if (previouslySubmitted()) { |
| 459 | + showResults(); |
| 460 | + } |
456 | 461 | }) |
457 | 462 | .catch(error => { |
458 | 463 | document.getElementById('valueDisplay').textContent = 'Fehler: ' + error.message; |
|
462 | 467 | } |
463 | 468 | }); |
464 | 469 |
|
| 470 | + function getPollyEntity() { |
| 471 | + const urlParams = new URLSearchParams(window.location.search); |
| 472 | + return urlParams.get('url') || DEFAULT_POLLY_URL; |
| 473 | + } |
| 474 | + |
| 475 | + function getVotedUrlArray() { |
| 476 | + const stringArray = localStorage.getItem('voteUrl') |
| 477 | + if (!stringArray) { |
| 478 | + return [] |
| 479 | + } |
| 480 | + return JSON.parse(stringArray) |
| 481 | + } |
| 482 | + |
| 483 | + function setVoteSubmitted() { |
| 484 | + const array = getVotedUrlArray(); |
| 485 | + array.push(getPollyEntity()); |
| 486 | + localStorage.setItem('voteUrl', JSON.stringify(array)); |
| 487 | + } |
| 488 | + |
| 489 | + function previouslySubmitted() { |
| 490 | + const array = getVotedUrlArray(); |
| 491 | + return array.includes(getPollyEntity()); |
| 492 | + } |
| 493 | + |
| 494 | + function showResults() { |
| 495 | + hasSubmitted = true; // Mark as submitted |
| 496 | + document.getElementById('needle').setAttribute('style', 'display: none') |
| 497 | + document.getElementById('thumb').setAttribute('style', 'display: none') |
| 498 | + document.getElementById('arrows').setAttribute('style', 'display: none') |
| 499 | + drawCircles(); |
| 500 | + calculatePercentages(entity); |
| 501 | + } |
| 502 | + |
465 | 503 | async function postDataToApptiveGrid(data) { |
466 | 504 | const url = entity['flow_uri']; |
467 | 505 |
|
|
0 commit comments