mizzzuno commited on
Commit
8a0dd1e
·
verified ·
1 Parent(s): dedbe0a

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +29 -51
templates/index.html CHANGED
@@ -148,6 +148,16 @@
148
  transition: transform 0.3s ease-in-out, visibility 0s 0s,
149
  opacity 0.3s ease-in-out; /* すぐに表示 */
150
  }
 
 
 
 
 
 
 
 
 
 
151
  </style>
152
 
153
  <script>
@@ -343,82 +353,50 @@
343
  before_rate = [tmp_rate];
344
  }
345
  count_voice++;
346
- // 一人モードでは常に緑色とグレーの組み合わせを使用
347
- speechChart.data.labels = [members[0], "無音"];
348
- speechChart.data.datasets[0].backgroundColor = ["#4caf50", "#757575"];
349
  } else {
350
- // 複数人モードの処理
351
- if (!Array.isArray(newRate)) {
352
- console.error("newRate is not an array:", newRate);
353
- return;
354
- }
355
- if (newRate.length !== members.length) {
356
- console.error(
357
- "newRate length does not match members length:",
358
- newRate,
359
- members
360
- );
361
- return;
362
- }
363
- let averagedRates = new Array(newRate.length);
364
  for (let i = 0; i < newRate.length; i++) {
365
- let tmp_rate;
366
- if (count_voice === 0) {
367
- // 初回はそのまま
368
- tmp_rate = newRate[i];
369
- } else {
370
- // 2回目以降は、過去の平均値と現在の値を加重平均する
371
- tmp_rate =
372
- (newRate[i] + before_rate[i] * count_voice) / (count_voice + 1);
373
- }
374
- averagedRates[i] = tmp_rate;
375
  }
376
- // before_rateを更新
377
- before_rate = averagedRates;
378
- //グラフに反映
379
- speechChart.data.datasets[0].data = averagedRates;
380
- count_voice++;
381
- speechChart.data.datasets[0].backgroundColor = getMemberColors(
382
- members.length
383
- );
384
  }
385
- speechChart.update();
386
  }
387
 
388
- // メニューの表示・非表示
389
  function toggleMenu(event) {
390
  event.stopPropagation();
391
  const menu = document.getElementById("menu");
392
  menu.classList.toggle("open");
393
  }
394
 
 
395
  function closeMenu(event) {
396
  const menu = document.getElementById("menu");
397
- if (
398
- menu.classList.contains("open") &&
399
- !menu.contains(event.target) &&
400
- !event.target.closest("#menuButton")
401
- ) {
402
  menu.classList.remove("open");
403
  }
404
  }
405
 
406
- // リセットボタンの処理
407
- function resetAction() {
408
- alert("リセットが実行されました!");
409
- }
410
-
411
  function showUserRegister() {
412
- fetch("/reset");
413
- window.location.href = "userregister";
414
  }
415
 
416
  function showTalkdetail() {
417
- window.location.href = "talk_detail";
418
  }
419
 
420
  function showResults() {
421
- window.location.href = "feedback";
 
 
 
 
422
  }
423
  </script>
424
  </body>
 
148
  transition: transform 0.3s ease-in-out, visibility 0s 0s,
149
  opacity 0.3s ease-in-out; /* すぐに表示 */
150
  }
151
+
152
+ /* レスポンシブデザイン */
153
+ @media (max-width: 640px) {
154
+ .w-72 {
155
+ width: 90%;
156
+ }
157
+ .h-72 {
158
+ height: 300px;
159
+ }
160
+ }
161
  </style>
162
 
163
  <script>
 
353
  before_rate = [tmp_rate];
354
  }
355
  count_voice++;
 
 
 
356
  } else {
357
+ // 複数モードの時の処理
358
+ let sum_rate = 0;
 
 
 
 
 
 
 
 
 
 
 
 
359
  for (let i = 0; i < newRate.length; i++) {
360
+ sum_rate += newRate[i];
 
 
 
 
 
 
 
 
 
361
  }
362
+ // 各メンバーの割合を計算
363
+ for (let i = 0; i < members.length; i++) {
364
+ voiceData[i] = (newRate[i] / sum_rate) * 100;
365
+ }
366
+ updateChart();
 
 
 
367
  }
 
368
  }
369
 
370
+ // メニューの開閉
371
  function toggleMenu(event) {
372
  event.stopPropagation();
373
  const menu = document.getElementById("menu");
374
  menu.classList.toggle("open");
375
  }
376
 
377
+ // メニュー外クリックで閉じる
378
  function closeMenu(event) {
379
  const menu = document.getElementById("menu");
380
+ if (!menu.contains(event.target)) {
 
 
 
 
381
  menu.classList.remove("open");
382
  }
383
  }
384
 
385
+ // 以下の関数はサンプルのためのスタブです。必要に応じて実装を加えてください。
 
 
 
 
386
  function showUserRegister() {
387
+ console.log("ユーザー登録画面を表示");
 
388
  }
389
 
390
  function showTalkdetail() {
391
+ console.log("会話履歴画面を表示");
392
  }
393
 
394
  function showResults() {
395
+ console.log("結果画面を表示");
396
+ }
397
+
398
+ function resetAction() {
399
+ console.log("リセット処理を実行");
400
  }
401
  </script>
402
  </body>