Advertisement
Orisphera

Untitled

Mar 9th, 2023
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.71 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>...</title>
  6.     <style>
  7.         .question-btn {background-color: #0000FF;}
  8.         .question-btn:disabled {background-color: #C0C0C0;}
  9.         * {font-size: 200px;}
  10.         body {background-color: cyan;}
  11.         ... {
  12.             width: 1000px;
  13.             height: 1000px;
  14.             overflow: hidden;
  15.         }
  16.         ... img {
  17.             width: ...;
  18.             height: ...;
  19.             object-fit: fill;
  20.         }
  21.         .centering {
  22.             position: absolute;
  23.             top: 50;
  24.             left: 50%;
  25.             transform: translate(-50%, 50%);
  26.         }
  27.         .no-wrap {
  28.             white-space: nowrap;
  29.         }
  30.         .inner-td {
  31.             width: 80%;
  32.             margin-right: 20%;
  33.         }
  34.     </style>
  35.     <script type="text/javascript">
  36.         const questionCategories = [...];
  37.         let questionsFlat = {};
  38.         let curQID = 0;
  39.         function onLoad() {
  40.             const loading = document.getElementById("loading");
  41.             loading.innerHTML = "Загрузка...";
  42.             let questionButtons = "";
  43.             for (let categoryID = 0; categoryID < questionCategories.length; categoryID += 1) {
  44.                const category = questionCategories[categoryID];
  45.                let questions = [...category.questions];
  46.                questions.sort((a, b) => a.score - b.score);
  47.                 let curCatQs = "";
  48.                 for (let questionID = 0; questionID < questions.length; questionID += 1) {
  49.                    const question = questions[questionID];
  50.                    const fullQID = categoryID + '_' + questionID;
  51.                    questionsFlat[fullQID] = question;
  52.                    curCatQs += '<td class="inner-td"><button class="question-btn" id="question' + fullQID + 'btn" onclick="loadQuestion(\'' + fullQID + '\')">' + question.score + '</button></td>';
  53.                 }
  54.                 questionButtons += '<tr><td class="inner-td no-wrap">' + category.name + "</td>" + curCatQs + "</tr>";
  55.             }
  56.             document.getElementById("main_menu_inner").innerHTML = questionButtons;
  57.             document.getElementById("main_menu").style.display = "block";
  58.             loading.style.display = "none";
  59.         }
  60.         function loadQuestion(questionID) {
  61.             document.getElementById("main_menu").style.display = "none";
  62.             curQID = questionID;
  63.             let question = questionsFlat[questionID];
  64.             document.getElementById("question_text").innerHTML = question.question;
  65.             document.getElementById("question_o1").style.display = "block";
  66.             document.getElementById("question_o2").style.display = "none";
  67.             document.getElementById("question_answer").innerHTML = question.answer;
  68.             document.getElementById("question").style.display = "block";
  69.         }
  70.         function showAnswer() {
  71.             document.getElementById("question_o1").style.display = "none";
  72.             document.getElementById("question_o2").style.display = "block";
  73.         }
  74.         function closeQuestion() {
  75.             document.getElementById("question").style.display = "none";
  76.             document.getElementById("question" + curQID + "btn").disabled = true;
  77.             document.getElementById("main_menu").style.display = "block";
  78.         }
  79.     </script>
  80. </head>
  81. <body onload="onLoad()">
  82.     <div class="centering">
  83.         <div id="loading">Должен быть включён JavaScript</div>
  84.         <div id="main_menu" style="display: none;">
  85.             <h1>...</h1>
  86.             <table>
  87.                 <tbody>
  88.                     <tr>
  89.                         <td>
  90.                             <table>
  91.                                 <tbody id="main_menu_inner"></tbody>
  92.                             </table>
  93.                         </td>
  94.                         <td>
  95.                             <div class="...">
  96.                                 <img src="...">
  97.                             </div>
  98.                         </td>
  99.                     </tr>
  100.                 </tbody>
  101.             </table>
  102.         </div>
  103.         <div id="question" style="display: none;">
  104.             <div id="question_text"></div>
  105.             <br>
  106.             <div id="question_o1" style="text_align:center;">
  107.                 <button onclick="showAnswer()">Показать ответ</button>
  108.             </div>
  109.             <div id="question_o2">
  110.                 <div id="question_answer"></div>
  111.                 <div style="text_aling: right;">
  112.                     <button onclick="closeQuestion()">Закрыть вопрос</button>
  113.                 </div>
  114.             </div>
  115.         </div>
  116.     </div>
  117. </body>
  118. </html>
  119.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement