본문 바로가기
Science

ChatGPT Prompting 으로 ILV 턱걸이 타이머 만들기

by 애일리언 2023. 3. 23.
반응형
ILV Workout

ILV Workout

6.00

 

ChatGPT Prompt : 

1. write in Html.

2. center the title "ILV Workout".

3. create a large, centered "Start" button below it.

4. Below the Start button is a timer, hold at an initial value of 6.00, with values from 6.00 to 1.00.

5. When you press the Start button, the Start button turns into a Stop button, and taken to the next section.

6. The timer counting down from 6.00 value to 1.00 seconds, and at the same time, one of the random letters (I, L, V) is displayed large and centered below the timer.

7. When it reaches 1.00 seconds, it goes back to 6.00 seconds, and the letters randomly change to other letters. 7. Pressing the "Stop" button will stop the timer, display the elapsed time below the letters, and turn the "Stop" button into a "start" button.

8. At this point, pressing the Start button will reset the total time to 0.00 seconds and repeat the above process again.

9. After pressing Stop, pressing Start will reset the accumulated time to 0.00 and make it start at 6.00 seconds again.

ChatGPT작성 html:

 

<!DOCTYPE html>
<html>
<head>
  <title>ILV Workout</title>
  <style>
    /* Center the title and the button */
    h1, button {
      display: block;
      margin: auto;
      text-align: center;
      font-size: 5em;
    }
    
    /* Center the timer and the letter */
    #timer, #letter {
      display: block;
      margin: auto;
      text-align: center;
      font-size: 5em;
      font-weight: bold;
    }
  </style>
</head>
<body>
  <h1>ILV Workout</h1>
  <button id="startstop" onclick="startstop()">Start</button>
  <div id="timer">6.00</div>
  <div id="letter"></div>

  <script>
    var timer = null;
    var startTime = null;
    var elapsed = null;
    var letters = ["I", "L", "V"];
    
  function startstop() {
  var button = document.getElementById("startstop");

  if (timer == null) { // start the timer
    document.getElementById("timer").innerHTML = "6.00";
    startTime = new Date().getTime();
    timer = setInterval(countdown, 10);
    button.innerHTML = "Stop";
  } else { // stop the timer
    clearInterval(timer);
    elapsed = new Date().getTime() - startTime;
    timer = null;
    button.innerHTML = "Start";
    document.getElementById("timer").innerHTML = (elapsed / 1000).toFixed(2);
    accumulatedTime += elapsed; // accumulate elapsed time
  }
}

function reset() {
  clearInterval(timer);
  timer = null;
  accumulatedTime = 0; // reset accumulated time
  document.getElementById("timer").innerHTML = "6.00";
  document.getElementById("letter").innerHTML = "";
  document.getElementById("startstop").innerHTML = "Start";
}

    
    function countdown() {
      var t = parseFloat(document.getElementById("timer").innerHTML);
      var letter = document.getElementById("letter");
      
      if (t <= 1.00) { // reset the timer and change the letter
        t = 6.00;
        letter.innerHTML = letters[Math.floor(Math.random() * letters.length)];
      } else {
        t -= 0.01;
      }
      
      document.getElementById("timer").innerHTML = t.toFixed(2);
    }
  </script>
</body>
</html>

반응형

댓글