//CURRENT VERSION
// Create an array to store the flashcards
var flashcards = [];
var flashcardnum = 0;
setInterval(function () {
chrome.windows.create({
url: 'popup.html',//new html doc that only shows the outputs
type: 'popup', width: 400, height: 400,
});
}, 60000); //creates a popup with a question and delayed answer every 60 seconds
//Function to create a new flashcard
function createFlashcard(front, back) {
var flashcard = {
front: front,
back: back,
};
flashcards.push(flashcard);
return flashcard;
}
// Function to review the flashcards
function reviewFlashcards(interval, interval2) {
// Shuffle the flashcards
// shuffleArray(flashcards);
// Loop through the flashcards and show each one
//for (var i = 0; i < flashcards.length; i++) {
var flashcard = flashcards[Math.floor(Math.random() * flashcards.length)];
// Show the front of the flashcard
console.log(flashcard.front);
document.getElementById('frontcard').innerHTML = flashcard.front;
//setText(body, flashcard.front);
document.getElementById('backcard').innerHTML = '<br/>' + '<br/>' + '';
// Wait for the specified interval before showing the back of the flashcard
setTimeout(function () {
console.log(flashcard.back);
document.getElementById('backcard').innerHTML =
'<br/>' + '<br/>' + flashcard.back;
setTimeout(function () {
document.getElementById('backcard').innerHTML = '<br/>' + '<br/>' + '';
document.getElementById('frontcard').innerHTML = '';
console.log ("cleared");
}, interval2);
}, interval);
flashcardnum = flashcardnum + 1;
console.log(flashcardnum);
}
createFlashcard('Who created chocolate milk?', 'Coenraad Johannes van Houten');
createFlashcard('What is the first ever board game?', 'Senet');
createFlashcard('Who is the 21st president?', 'Chester A. Arthur');
createFlashcard('How many organs are there in the human body?', '79');
createFlashcard('What is the first movie ever made?', 'Roundhay Garden Scene');
createFlashcard('Who created Starburst candies?', 'The Wrigley Company');
createFlashcard('Who is the ceo of Google?', 'Sundar Pichai');
createFlashcard('Who invented McDonalds?', 'Ray Kroc');
createFlashcard('Who was the first US president born in a hospital?','Jimmy Carter' );
createFlashcard('What country do bagels originate from?', 'Poland');
createFlashcard(
'Which planet in our solar system has the most moons?',
'Jupiter'
);
createFlashcard(
'What was the name of the king that ruled Troy during the Trojan War?',
'Priam'
);
createFlashcard('How many muscles does a cat have in each ear?', '32');
createFlashcard('What was the first bird to be domesticated by man?', 'Goose');
createFlashcard(
'How many federally recognised holidays are there in a year?',
'11'
);
setInterval(function () {
reviewFlashcards(4000, 6000); //first one is time between question and answer, second is time between question and clear
}, 60000); //time between questions
// Create an array to store the flashcards
var flashcards = [];
var flashcardnum = 0;
// Function to create a new flashcard
function createFlashcard(front, back) {
var flashcard = {
front: front,
back: back,
};
flashcards.push(flashcard);
return flashcard;
}
// Function to review the flashcards
function reviewFlashcards(interval, interval2) {
// Shuffle the flashcards
shuffleArray(flashcards);
// Loop through the flashcards and show each one
//for (var i = 0; i < flashcards.length; i++) {
var flashcard = flashcards[Math.floor(Math.random() * flashcards.length)];
// Show the front of the flashcard
console.log(flashcard.front);
document.getElementById('frontcard').innerHTML = flashcard.front;
//setText(body, flashcard.front);
document.getElementById('backcard').innerHTML = '<br/>' + '<br/>' + '';
// Wait for the specified interval before showing the back of the flashcard
setTimeout(function () {
//setText(body, flashcard.back);
console.log(flashcard.back);
//document.write(flashcard.back);
document.getElementById('backcard').innerHTML =
'<br/>' + '<br/>' + flashcard.back;
setTimeout(function () {
document.getElementById('backcard').innerHTML = '<br/>' + '<br/>' + '';
document.getElementById('frontcard').innerHTML = '';
console.log ("cleared");
}, interval2);
}, interval);
flashcardnum = flashcardnum + 1;
console.log(flashcardnum);
// }
}
// Helper function to shuffle an array
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
createFlashcard('Who created chocolate milk?', 'Coenraad Johannes van Houten');
createFlashcard('What is the first ever board game?', 'Senet');
createFlashcard('Who is the 21st president?', 'Chester A. Arthur');
createFlashcard('How many organs are there in the human body?', '79');
createFlashcard('What is the first movie ever made?', 'Roundhay Garden Scene');
createFlashcard('Who created Starburst candies?', 'The Wrigley Company');
createFlashcard('Who is the ceo of Google?', 'Sundar Pichai');
createFlashcard('Who invented McDonalds?', 'Ray Kroc');
createFlashcard(
'Who was the first US president born in a hospital?',
'Jimmy Carter'
);
createFlashcard('What country do bagels originate from?', 'Poland');
createFlashcard(
'Which planet in our solar system has the most moons?',
'Jupiter'
);
createFlashcard(
'What was the name of the king that ruled Troy during the Trojan War?',
'Priam'
);
createFlashcard('How many muscles does a cat have in each ear?', '32');
createFlashcard('What was the first bird to be domesticated by man?', 'Goose');
createFlashcard(
'How many federally recognised holidays are there in a year?',
'11'
);
//for (var i = 0; i < flashcards.length; i++) {
setInterval(function () {
reviewFlashcards(4000, 6000); //first one is time between question and answer, second is time between question and clear
}, 60000); //time between questions
var ggg = 0;
setInterval(function () {
console.log(ggg);
ggg++;
}, 1000);
//}
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="src/style.css" />
</head>
<body>
<br />
</body>
<body><div id="frontcard">
<br />frontcard
</div></body>
<br />
<body><br/><div id="backcard">
backcard
</div></body>
<script type="text/javascript" async="" src="src/script.js"></script>
</html>
body {
background: transparent; /* Make it white if you need */
color: #991200;
padding: 0 24px;
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
min-width: 500px;
max-width: 100%;
position: relative;
vertical-align: middle;
text-align: center;
background-color: #f4f6f4;
}
h1 {
color: #a11412;
}