Skip to content

Instantly share code, notes, and snippets.

@jabbate19
Created January 28, 2020 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jabbate19/0710c4b17b27be28c98f47c47857b209 to your computer and use it in GitHub Desktop.
Save jabbate19/0710c4b17b27be28c98f47c47857b209 to your computer and use it in GitHub Desktop.
var questions = ["What is your team number?"];
var teams = [];
var teamData = [];
var activeQ = 0;
var activeInt = [];
var activeTeamData = ["N/A"];
//updateAll();
onEvent("questionBtn", "click", function(event) {
setScreen("questions");
activeQ = 0;
updateQuestion();
});
onEvent("interview", "click", function(event) {
setScreen("int");
activeQ = 0;
activeInt = [];
updateInterview();
});
onEvent("team", "click", function(event) {
setScreen("result");
activeQ = 0;
activeTeamData = [];
setText("resultQ",questions[activeQ]);
});
onEvent("addBtn", "click", function(event) {
appendItem(questions,getText("qInput"));
updateQuestion();
});
onEvent("remove", "click", function(event) {
removeItem(questions,activeQ);
updateQuestion();
});
onEvent("qRight", "click", function(event) {
activeQ++;
updateQuestion();
});
onEvent("qLeft", "click", function(event) {
activeQ--;
updateQuestion();
});
onEvent("Submit", "click", function(event) {
appendItem(activeInt,getText("intInput"));
nextQuestionInt();
updateInterview();
});
onEvent("qBack", "click", function(event) {
setScreen("start");
});
onEvent("iBack", "click", function(event) {
setScreen("start");
});
onEvent("Go", "click", function(event) {
activeTeamData = ["N/A"];
for( var i = 0; i < teamData.length; i++ ){
var temp = teamData[i];
if( temp[0] == getText("teamNum")){
activeTeamData = teamData[i];
}
}
updateData();
});
function updateQuestion(){
if( activeQ < 0 ){
activeQ = 0;
}else if( activeQ >= questions.length ){
activeQ = questions.length - 1;
}
if( questions.length > 0 ){
setText("qOutput","Question " + (activeQ + 1) + ": " + questions[activeQ]);
}
}
function updateInterview(){
if(activeInt.length == questions.length){
setText("intQuestions","Complete! Return to home menu");
}else{
setText("intQuestions",questions[activeQ]);
}
}
function updateData(){
setText("resultQ",questions[activeQ]);
if( activeTeamData[0] != "N/A" ){
setText("resOut",activeTeamData[activeQ]);
}else{
setText("resOut","No Data Found");
}
}
function nextQuestionInt(){
if(activeInt.length == questions.length){
appendItem(teamData,activeInt);
}else{
activeQ++;
}
}
function updateAll(){
updateQuestion();
updateInterview();
}
onEvent("rightRes", "click", function(event) {
if( activeQ < questions.length-1 ){
activeQ++;
}
updateData();
});
onEvent("leftRes", "click", function(event) {
if( activeQ > 0 ){
activeQ--;
}
updateData();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment