var byBook = {};
var size = 0;
var result = [];
//var getprob = [];
//var redo = [];
//var sets = [];
function loadJson()
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
result = JSON.parse(this.responseText);
size = result.length;
for (var i = 0; i < result.length; i++)
{
var numv = parseInt(result[i].numVerses);
if (numv < 0 || numv > 5)
continue;
getprob.push([result[i].ques, result[i].ans]);
if (Object.keys(byBook).indexOf(result[i].Book) != -1)
byBook[result[i].Book].push(i);
else
{
byBook[result[i].Book] = [];
byBook[result[i].Book].push(i);
}
}
size = getprob.length;
init();
}
};
xmlhttp.open("GET", "faith.json", true);
xmlhttp.send();
}
function init()
{
sets = [];
redo = [];
var url = window.location.toString();
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
if (start === null)
{
start = 0;
}
if (end === null)
{
end = getprob.length;
}
size = getprob.length;
for (var i = 0; i < size; i++)
{
var x = document.getElementById("start");
var option = document.createElement("option");
option.text = i;
option.value = i;
if (i === 0)
option.selected = true;
x.add(option);
}
for (i = 0; i < size; i++)
{
x = document.getElementById("end");
option = document.createElement("option");
option.text = i;
option.value = i;
if (i == size-1)
option.selected = true;
x.add(option);
}
//This sets up my sets array.
for (i = start; i < end; i++)
sets[i - start] = i;
//end of that part.
document.getElementById("left").innerHTML = "Questions Left: " + sets.length;
var txtOut = "<div id='match' class='col-xs-12 col-sm-12 col-md-12 col-lg-12'><div class='row col-xs-12 col-sm-12 col-md-12 col-lg-12'><div class='col-xs-8 col-sm-8 col-md-9 col-lg-9 cL'><INPUT TYPE=checkbox ID=\"chk2\" style=\"visibility:hidden\">";
document.getElementById("output").innerHTML = "";
getnum();
}
function init2()
{
sets = [];
redo = [];
//This sets up my sets Array.
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
if (start === null)
{
start = 0;
}
if (end === null)
{
end = getprob.length;
}
//This sets up my sets array.
for(var i = start; i < end; i++)
sets[i - start] = i;
//End of that part.
getnum();
}
function getques()
{
cans = getprob[hist[curr-1]][0] + " - " + getprob[hist[curr-1]][1]; //curr is always at least 1, so curr-1 cannot return a negative number.
document.getElementById("text").innerHTML = "<INPUT TYPE=checkbox ID=chk2 NAME=chk2> Last ans: " + cans
if (curr >= 2)
{
lques = getprob[hist[curr-2]][0];
document.getElementById("text").innerHTML += "<br><br><INPUT TYPE=checkbox ID=chk1 NAME=chk1>" + hist[curr-1] + ") " + lques;
curr--;
curr--;
}
else
document.getElementById("text").innerHTML += "<br><br><INPUT TYPE=checkbox ID=chk1 NAME=chk1 style=\"visibility:hidden\">";
}
function getans2(num)
{
document.getElementById("text").innerHTML = "<INPUT TYPE=checkbox ID=chk2 NAME=chk2> Last ans: " + last[0] + " - " + last[1];
}
function getnum()
{
var quest = [];
if (sets.length === 0 && redo.length === 0)
init2();
else if (sets.length === 0 && redo.length !== 0)
{
if (curr == hist.length)
{
ans2 = Math.floor(redo.length*Math.random()+1); //gets a new problem number.
hist[hist.length] = ans2;
quest = getprob[redo[ans2-1]]; //looks up the specified problem number.
var temp = redo[ans2-1];
redo[ans2-1] = redo[redo.length-1];
redo[length-1] = temp;
delete redo[redo.length-1];
redo.length --;
ans2 = temp;
document.getElementById("left").innerHTML = "Questions Left: " + redo.length;
curr = hist.length;
}
else
{
ans2 = hist[curr];
quest = getprob[redo[ans2-1]]; //looks up the specified problem number.
curr++;
}
document.getElementById("text").innerHTML += "<br><br><INPUT TYPE=checkbox ID=chk1 NAME=chk1> " + ans2 + ") " + quest[0]; //Outputs problem number and then the question.
last = quest;
}
else
{
if (curr == hist.length)
{
ans2 = Math.floor(sets.length*Math.random()); //gets a new problem number.
hist.push(ans2);
quest = getprob[sets[ans2]]; //looks up the specified problem number.
var temp = sets[ans2-1];
sets[ans2-1] = sets[sets.length-1];
sets[length-1] = temp;
delete sets[sets.length-1];
sets.length --;
ans2 = temp;
document.getElementById("left").innerHTML = "Questions Left: " + sets.length;
curr = hist.length;
}
else
{
ans2 = hist[curr];
quest = getprob[ans2]; //looks up the specified problem number.
curr++;
}
document.getElementById("text").innerHTML += "<br><br><INPUT TYPE=checkbox ID=chk1 NAME=chk1> " + ans2 + ") " + quest[0]; //Outputs problem number and then the question.
last = quest;
}
}
function updateRedo()
{
var chk1 = document.getElementById("chk1");
var chk2 = document.getElementById("chk2");
if (chk1 != null && chk1.checked == true && redo[redo.length] != ans2)
redo[redo.length] = ans2;
else if (chk1 != null && chk1.checked == false && redo[redo.length] == ans2)
delete redo[redo.length];
if (chk2 != null && chk2.checked == true && redo[redo.length] != num)
redo[redo.length] = num;
else if (chk2 != null && chk2.checked == false && redo[redo.length] == ans2-1)
delete redo[redo.length];
getans2();
getnum();
}
var size = 0;
var result = [];
var getprob = [];
var redo = [];
var sets = [];
function loadJson()
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
result = JSON.parse(this.responseText);
size = result.length;
for (var i = 0; i < result.length; i++)
{
var numv = parseInt(result[i].numVerses);
if (numv < 0 || numv > 5)
continue;
getprob.push([result[i].ques, result[i].ans]);
if (Object.keys(byBook).indexOf(result[i].Book) != -1)
byBook[result[i].Book].push(i);
else
{
byBook[result[i].Book] = [];
byBook[result[i].Book].push(i);
}
}
size = getprob.length;
init();
}
};
xmlhttp.open("GET", "faith.json", true);
xmlhttp.send();
}
function init()
{
sets = [];
redo = [];
var url = window.location.toString();
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
if (start === null)
{
start = 0;
}
if (end === null)
{
end = getprob.length;
}
size = getprob.length;
for (var i = 0; i < size; i++)
{
var x = document.getElementById("start");
var option = document.createElement("option");
option.text = i;
option.value = i;
if (i === 0)
option.selected = true;
x.add(option);
}
for (i = 0; i < size; i++)
{
x = document.getElementById("end");
option = document.createElement("option");
option.text = i;
option.value = i;
if (i == size-1)
option.selected = true;
x.add(option);
}
//This sets up my sets array.
for (i = start; i < end; i++)
sets[i - start] = i;
//end of that part.
document.getElementById("left").innerHTML = "Questions Left: " + sets.length;
var txtOut = "<div id='match' class='col-xs-12 col-sm-12 col-md-12 col-lg-12'><div class='row col-xs-12 col-sm-12 col-md-12 col-lg-12'><div class='col-xs-8 col-sm-8 col-md-9 col-lg-9 cL'><INPUT TYPE=checkbox ID=\"chk2\" style=\"visibility:hidden\">";
document.getElementById("output").innerHTML = "";
getnum();
}
function init2()
{
sets = [];
redo = [];
//This sets up my sets Array.
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
if (start === null)
{
start = 0;
}
if (end === null)
{
end = getprob.length;
}
//This sets up my sets array.
for(var i = start; i < end; i++)
sets[i - start] = i;
//End of that part.
getnum();
}
function getques()
{
cans = getprob[hist[curr-1]][0] + " - " + getprob[hist[curr-1]][1]; //curr is always at least 1, so curr-1 cannot return a negative number.
document.getElementById("text").innerHTML = "<INPUT TYPE=checkbox ID=chk2 NAME=chk2> Last ans: " + cans
if (curr >= 2)
{
lques = getprob[hist[curr-2]][0];
document.getElementById("text").innerHTML += "<br><br><INPUT TYPE=checkbox ID=chk1 NAME=chk1>" + hist[curr-1] + ") " + lques;
curr--;
curr--;
}
else
document.getElementById("text").innerHTML += "<br><br><INPUT TYPE=checkbox ID=chk1 NAME=chk1 style=\"visibility:hidden\">";
}
function getans2(num)
{
document.getElementById("text").innerHTML = "<INPUT TYPE=checkbox ID=chk2 NAME=chk2> Last ans: " + last[0] + " - " + last[1];
}
function getnum()
{
var quest = [];
if (sets.length === 0 && redo.length === 0)
init2();
else if (sets.length === 0 && redo.length !== 0)
{
if (curr == hist.length)
{
ans2 = Math.floor(redo.length*Math.random()+1); //gets a new problem number.
hist[hist.length] = ans2;
quest = getprob[redo[ans2-1]]; //looks up the specified problem number.
var temp = redo[ans2-1];
redo[ans2-1] = redo[redo.length-1];
redo[length-1] = temp;
delete redo[redo.length-1];
redo.length --;
ans2 = temp;
document.getElementById("left").innerHTML = "Questions Left: " + redo.length;
curr = hist.length;
}
else
{
ans2 = hist[curr];
quest = getprob[redo[ans2-1]]; //looks up the specified problem number.
curr++;
}
document.getElementById("text").innerHTML += "<br><br><INPUT TYPE=checkbox ID=chk1 NAME=chk1> " + ans2 + ") " + quest[0]; //Outputs problem number and then the question.
last = quest;
}
else
{
if (curr == hist.length)
{
ans2 = Math.floor(sets.length*Math.random()); //gets a new problem number.
hist.push(ans2);
quest = getprob[sets[ans2]]; //looks up the specified problem number.
var temp = sets[ans2-1];
sets[ans2-1] = sets[sets.length-1];
sets[length-1] = temp;
delete sets[sets.length-1];
sets.length --;
ans2 = temp;
document.getElementById("left").innerHTML = "Questions Left: " + sets.length;
curr = hist.length;
}
else
{
ans2 = hist[curr];
quest = getprob[ans2]; //looks up the specified problem number.
curr++;
}
document.getElementById("text").innerHTML += "<br><br><INPUT TYPE=checkbox ID=chk1 NAME=chk1> " + ans2 + ") " + quest[0]; //Outputs problem number and then the question.
last = quest;
}
}
function updateRedo()
{
var chk1 = document.getElementById("chk1");
var chk2 = document.getElementById("chk2");
if (chk1 != null && chk1.checked == true && redo[redo.length] != ans2)
redo[redo.length] = ans2;
else if (chk1 != null && chk1.checked == false && redo[redo.length] == ans2)
delete redo[redo.length];
if (chk2 != null && chk2.checked == true && redo[redo.length] != num)
redo[redo.length] = num;
else if (chk2 != null && chk2.checked == false && redo[redo.length] == ans2-1)
delete redo[redo.length];
getans2();
getnum();
}
[![enter image description here][1]][1]
This is a look at what the flash page should look like when its up and running. [1]: https://i.sstatic.net/wjtspOjY.png//