var myFlashcards = [{
question: 'content 1',
answer: 'answer1'
}, {
question: 'content 2',
answer: 'answer2'
}, {
question: 'content 3',
answer: 'answer3'
}, {
question: 'content 4',
answer: 'answe4r'
}];
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
var flashCardID = makeid(15);
(function(exports) {
function loadFromArray(array) {
ouicards.flashcards = array;
resetBuckets();
}
function loadFromBrowser(selector, delimiter) {
var flashcards = [],
userInput = $(selector).val().split('\n');
/* Get rid of empty questions*/
userInput = userInput.filter(function(card) {
return card !== "";
});
if (userInput.length === 0) {
console.log('There are no flashcards');
return;
}
userInput.forEach(function(card) {
var parsedCard = card.split(delimiter);
flashcards.push({
question: parsedCard[0],
answer: parsedCard[1]
});
});
ouicards.flashcards = flashcards;
resetBuckets();
return getFromLS();
}
function next() {
var newQuestion,
bigInterval = Math.ceil(ouicards.flashcards.length / 3) + 1,
smallInterval = Math.ceil(ouicards.flashcards.length / 6) + 1;
/* Show an answer from bucket C once every bigInterval
So long as Bucket C it's not empty*/
if (ouicards.counter % bigInterval === 0 && ouicards.bucketC.length !== 0) {
newQuestion = getQuestion(ouicards.bucketC);
ouicards.currentBucket = ouicards.bucketC;
/* Show an answer from bucket B once every smallInterval
So long as Bucket B it's not empty */
} else if (ouicards.counter % smallInterval === 0 && ouicards.bucketB.length !== 0) {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.