1const quizIntro = { 2 title: "Who is your fated mate in Prythian?", 3 description: "Find out which character you belong with from ACOTAR.", 4 startButtonText: "Take the quiz", 5 resultText: "Your fated mate is:", 6}; 7const questions = [ 8 { 9 question: "When do you usually wake up in the morning?", 10 answers: [ 11 { text: "I never slept", type: "A" }, 12 { text: "10am, I like a lie in", type: "B" }, 13 { text: "5am sharp for my morning run!", type: "C" }, 14 { text: "I'd prefer not to say", type: "D" }, 15 { text: "That would depend on how late I was out dancing...", type: "E" }, 16 { text: "Sleep is for the weak", type: "F" }, 17 { text: "My alarm is set for 7am most days", type: "G" }, 18 { text: "Whenever, wherever, with whoever", type: "H" }, 19 { text: "I like to rise with the sun", type: "I" }, 20 { text: "As the birds begin to sing", type: "J" }, 21 ] 22 }, 23 { 24 question: "Choose a snack:", 25 answers: [ 26 { text: "A good, vintage red wine", type: "A" }, 27 { text: "Chocolate", type: "B" }, 28 { text: "Fresh fruit", type: "C" }, 29 { text: "Salted cashews", type: "D" }, 30 { text: "Macarons", type: "E" }, 31 { text: "The blood of my enemies", type: "F" }, 32 { text: "S'mores", type: "G" }, 33 { text: "A dry martini", type: "H" }, 34 { text: "A slice of cake", type: "I" }, 35 { text: "Carrot sticks", type: "J" }, 36 ] 37 }, 38 { 39 question: "Choose a magical power:", 40 answers: [ 41 { text: "Flying", type: "A" }, 42 { text: "Mind infiltration (like the Daemati)", type: "B" }, 43 { text: "Immense strength", type: "C" }, 44 { text: "Invisibility", type: "D" }, 45 { text: "Teleportation (a.k.a winnowing)", type: "E" }, 46 { text: "The ability to sense riches and power in others", type: "F" }, 47 { text: "Emotional manipulation", type: "G" }, 48 { text: "Time travel", type: "H" }, 49 { text: "Seer (the ability to predict the future)", type: "I" }, 50 { text: "The power to manipulate nature", type: "J" }, 51 ] 52 }, 53 { 54 question: "How are you spending your weekend?", 55 answers: [ 56 { text: "Community outreach", type: "A" }, 57 { text: "Visiting an art gallery", type: "B" }, 58 { text: "Hitting the gym for some weight lifting", type: "C" }, 59 { text: "Travelling for work", type: "D" }, 60 { text: "Attending multiple parties", type: "E" }, 61 { text: "Lounging in silk pajamas", type: "F" }, 62 { text: "A long walk in the forest", type: "G" }, 63 { text: "Hanging with my best friends", type: "H" }, 64 { text: "Gardening", type: "I" }, 65 { text: "Scheming against my enemies", type: "J" }, 66 ] 67 }, 68 { 69 question: "What's your greatest weakness?", 70 answers: [ 71 { text: "I find it hard to ask for help", type: "A" }, 72 { text: "Admitting my weaknesses", type: "B" }, 73 { text: "Pride", type: "C" }, 74 { text: "I'm haunted by my past", type: "D" }, 75 { text: "I don't take things seriously enough", type: "E" }, 76 { text: "I donât have any weaknesses", type: "F" }, 77 { text: "I'm not very confident", type: "G" }, 78 { text: "I don't think before I speak", type: "H" }, 79 { text: "I don't like sharing my feelings", type: "I" }, 80 { text: "I'm very stubborn", type: "J" }, 81 ] 82 }, 83 { 84 question: "I like to read...", 85 answers: [ 86 { text: "To my children", type: "A" }, 87 { text: "Beneath the stars", type: "B" }, 88 { text: "Something spicy", type: "C" }, 89 { text: "Other people's diaries", type: "D" }, 90 { text: "Expensive menus", type: "E" }, 91 { text: "High-end auction catalogues", type: "F" }, 92 { text: "Surrounded by nature", type: "G" }, 93 { text: "Military history", type: "H" }, 94 { text: "Epic adventure tales", type: "I" }, 95 { text: "My tax returns", type: "J" }, 96 ] 97 }, 98 { 99 question: "Your ideal party would involve...", 100 answers: [ 101 { text: "Rooftop cocktails", type: "A" }, 102 { text: "Something cosy with the people I love", type: "B" }, 103 { text: "A raucous pub night", type: "C" }, 104 { text: "No party", type: "D" }, 105 { text: "Lots of dancing", type: "E" }, 106 { text: "Something exclusive, VIP only", type: "F" }, 107 { text: "Poetry readings", type: "G" }, 108 { text: "I'd rather read a book", type: "H" },
109 { text: "A royal ball", type: "I" }, 110 { text: "My band playing!", type: "J" }, 111 ] 112 }, 113 { 114 question: "What do your friends love most about you?", 115 answers: [ 116 { text: "My resilience", type: "A" }, 117 { text: "My compassion", type: "B" }, 118 { text: "I'm their ride or die", type: "C" }, 119 { text: "My kindness", type: "D" }, 120 { text: "The fun we have together!", type: "E" }, 121 { text: "My wisdom", type: "F" }, 122 { text: "I'm a good listener", type: "G" }, 123 { text: "My courage", type: "H" }, 124 { text: "My loyalty", type: "I" }, 125 { text: "My excellent hair", type: "J" }, 126 ] 127 }, 128 { 129 question: "What would you most love to receive as a gift?", 130 answers: [ 131 { text: "Time alone with my partner", type: "A" }, 132 { text: "A beautiful painting", type: "B" }, 133 { text: "A new weapon to add to my collection", type: "C" }, 134 { text: "Jewellery", type: "D" }, 135 { text: "Something I've chosen myself", type: "E" }, 136 { text: "I prefer giving the gifts!", type: "F" }, 137 { text: "A day out filled with my favorite things", type: "G" }, 138 { text: "Gifts aren't important to me", type: "H" }, 139 { text: "Something homemade with sentimental value", type: "I" }, 140 { text: "Time to myself", type: "J" }, 141 ] 142 }, 143 { 144 question: "Your friend betrays you to your enemy, what do you do?", 145 answers: [ 146 { text: "Play the long game", type: "A" }, 147 { text: "Talk it out", type: "B" }, 148 { text: "Immediately attack", type: "C" }, 149 { text: "I'd snoop and find out why", type: "D" }, 150 { text: "Ghost them", type: "E" }, 151 { text: "Burn the world down", type: "F" }, 152 { text: "I'd try to forgive", type: "G" }, 153 { text: "I would curse them", type: "H" }, 154 { text: "Probably cry", type: "I" }, 155 { text: "I'd lock them up", type: "J" }, 156 ] 157 },//*/ 158]; 159 160const resultsMapping = { 161 A: { name: 'Rhysand', quote: 'âTo the stars who listenâ and the dreams that are answered.â' }, 162 B: { name: 'Feyre', quote: 'âNo one was my masterâ but I might be master of everything, if I wished. If I dared.â' }, 163 C: { name: 'Cassian', quote: 'âCome on, Feyre. We donât bite. Unless you ask us to.â' }, 164 D: { name: 'Azriel', quote: 'âBe careful how you speak about my High Lady.â' }, 165 E: { name: 'Mor', quote: 'âWith enough courage, you can say to hell with a reputation. You do what you love, what you need.â' }, 166 F: { name: 'Amren', quote: 'âThe quickest way to a manâs heart is through the fourth and fifth ribs.â' }, 167 G: { name: 'Lucien', quote: 'âIf I offer you the moon on a string, will you give me a kiss, too?â' }, 168 H: { name: 'Nesta', quote: 'âShe felt it allâtoo keenly, too sharply. Hated and cared and loved and dreaded, more than other people, she sometimes thought.â' }, 169 I: { name: 'Elain', quote: 'âAnd it was ElainâElainâwho sighed and murmured, âI hope they all burn in hell.â' }, 170 J: { name: 'Tamlin', quote: 'âDon\'t feel bad for one moment about doing what brings you joy.â' }, 171}; 172 173let currentQuestionIndex = 0; 174let answersCount = { 175 A: 0, 176 B: 0, 177 C: 0, 178 D: 0, 179 E: 0, 180 F: 0, 181 G: 0, 182 H: 0, 183 I: 0, 184 J: 0, 185}; 186 187function shuffle(array) { 188 for (let i = array.length - 1; i > 0; i--) { 189 const j = Math.floor(Math.random() * (i + 1)); 190 [array[i], array[j]] = [array[j], array[i]]; 191 } 192} 193 194function adjustBorderHeight() { 195 const quizBorder = document.getElementById('quiz-border'); 196 const quizWrapperInner = document.getElementById('quiz-wrapper-inner'); 197 const firstChild = quizWrapperInner.firstElementChild; 198 const borderWidth = 46 * 2; // Total border width (23px top + 23px bottom) 199 quizBorder.style.height = `${firstChild.offsetHeight + borderWidth}px`; 200} 201 202function showInitialScreen() { 203 const initialContainer = document.getElementById('initial-container'); 204 initialContainer.innerHTML = ` 205 <div><h1>${quizIntro.title}</h1> 206 <h4>${quizIntro.description}</h4> 207 <button id="start-btn" class="btn" onclick="startQuiz()">${quizIntro.startButtonText}</button></div> 208 `; 209 fadeInElement(initialContainer); 210 document.getElementById('quiz-container').style.display = 'none'; 211 document.getElementById('result-container').style.display = 'none'; 212 adjustBorderHeight(); // Adjust height on initial screen 213} 214 215function startQuiz() { 216 currentQuestionIndex = 0; 217 for (let key in answersCount) { 218 if (answersCount.hasOwnProperty(key)) { 219 answersCount[key] = 0; 220 } 221 } 222 223 const quizContainer = document.getElementById('quiz-container'); 224 const resultContainer = document.getElementById('result-container'); 225 quizContainer.classList.remove('final-fade-out'); 226 resultContainer.classList.remove('final-fade-in'); 227 228 fadeOutElement(document.getElementById('initial-container'), () => { 229 fadeOutElement(document.getElementById('result-container'), () => { 230 showQuestion(questions[currentQuestionIndex]); 231 fadeInElement(document.getElementById('quiz-container'), updateProgress);
232 adjustBorderHeight(); // Adjust height after showing question 233 }); 234 }); 235} 236 237function showQuestion(question) { 238 const questionContainer = document.getElementById('question-container'); 239 questionContainer.innerHTML = `<h2>${question.question}</h2>`; 240 241 const answersContainer = document.getElementById('answers-container'); 242 answersContainer.innerHTML = ''; 243 const shuffledAnswers = [...question.answers]; 244 shuffle(shuffledAnswers); 245 246 shuffledAnswers.forEach(answer => { 247 const button = document.createElement('button'); 248 button.innerText = answer.text; 249 button.classList.add('btn'); 250 251 let touchMoved = false; 252 253 if (window.innerWidth < 1024) { 254 button.addEventListener('touchstart', function() { 255 touchMoved = false; 256 }); 257 258 button.addEventListener('touchmove', function() { 259 touchMoved = true; 260 }); 261 262 button.addEventListener('touchend', function(event) { 263 if (!touchMoved) { 264 event.preventDefault(); // Prevent the click event from firing 265 button.click(); 266 } 267 }); 268 } 269 270 button.onclick = () => selectAnswer(answer.type); 271 272 answersContainer.appendChild(button); 273 }); 274 275 // Scroll to the top of the quiz container on mobile with header offset 276 scrollToElement('quiz-anchor'); 277 adjustBorderHeight(); // Adjust height after showing question 278} 279 280 281function updateProgress() { 282 const progressText = document.getElementById('progress-text'); 283 progressText.innerText = `${currentQuestionIndex + 1} / ${questions.length}`; 284 285 const progressBar = document.getElementById('progress-bar'); 286 const progressPercentage = (currentQuestionIndex / questions.length) * 100; 287 progressBar.style.width = `${progressPercentage}%`; 288} 289 290function scrollToElement(anchorId) { 291 let headerHeight; 292 if (window.innerWidth >= 1024) { 293 headerHeight = document.querySelector('.header-nav').offsetHeight + 25; 294 } else { 295 headerHeight = document.querySelector('.header').offsetHeight + 25; 296 } 297 const anchor = document.getElementById(anchorId); 298 const anchorPosition = anchor.getBoundingClientRect().top + window.scrollY - headerHeight; 299 window.scrollTo({ top: anchorPosition, behavior: 'smooth' }); 300} 301 302function selectAnswer(answerType) { 303 answersCount[answerType]++; 304 305 // Remove focus from the button that was clicked 306 if (document.activeElement && document.activeElement.tagName === 'BUTTON') { 307 setTimeout(() => { 308 document.activeElement.blur(); 309 }, 10); // Small delay to ensure blur is processed correctly 310 } 311 312 fadeOutElement(document.getElementById('quiz-container'), () => { 313 currentQuestionIndex++; 314 if (currentQuestionIndex < questions.length) { 315 showQuestion(questions[currentQuestionIndex]); 316 fadeInElement(document.getElementById('quiz-container'), updateProgress); 317 adjustBorderHeight(); // Adjust height after showing question 318 } else { 319 showResult(); 320 } 321 }); 322} 323 324function showResult() { 325 const resultContainer = document.getElementById('result-container'); 326 const highestType = Object.keys(answersCount).reduce((a, b) => answersCount[a] > answersCount[b] ? a : b); 327 const result = resultsMapping[highestType]; 328 resultContainer.innerHTML = ` 329 <div> 330 <h4>${quizIntro.resultText}</h4> 331 <h1>${result.name}</h1> 332 <h2><em>${result.quote}</em></h2> 333 <button id="start-btn" class="btn m-bot-25" onclick="startQuiz()">Retake the quiz</button> 334 <p><small>Don't forget to share your results with your friends!</small></p> 335 </div>`; 336 fadeOutElement(document.getElementById('quiz-container'), () => { 337 resultContainer.style.display = 'flex'; // Ensure it's displayed before fading in 338 fadeInElement(resultContainer, null, true); 339 adjustBorderHeight(); // Adjust height after showing question 340 }, true); 341 scrollToElement('quiz-anchor'); 342} 343 344function fadeOutElement(element, callback, isFinal = false) { 345 if (isFinal) { 346 element.classList.add('final-fade-out'); 347 element.classList.remove('fade-in'); 348 } else { 349 element.classList.add('fade-out'); 350 element.classList.remove('fade-in'); 351 } 352 setTimeout(() => { 353 element.style.display = 'none'; 354 if (callback) callback(); 355 }, isFinal ? 250 : 250); // Match the duration of the CSS transition 356} 357 358function fadeInElement(element, callback, isFinal = false) { 359 element.style.display = 'block'; 360 setTimeout(() => { 361 if (isFinal) { 362 element.classList.remove('final-fade-out'); 363 element.classList.add('final-fade-in'); 364 } else { 365 element.classList.remove('fade-out'); 366 element.classList.add('fade-in'); 367 } 368 if (callback) { 369 setTimeout(callback, isFinal ? 500 : 250); // Ensure callback is called after fade-in is complete 370 } 371 }, 10); // Small delay to trigger the transition 372} 373 374document.addEventListener('DOMContentLoaded', () => { 375 showInitialScreen(); 376});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.