/* Javascript for Coffee Recommender */ // load the questions array and declare other global vars var questions = loadCSVdata( "/media/document/1/questions.csv" ); var tmp = questions.shift(); // get rid of the header row to put us sync with the DOM "rows" tmp.shift(); var content; var rows; var totals = new Array(); for ( var i=0; i js array // ******************* function loadCSVdata( url ) { var http = new JKL.ParseXML.CSV( url ); var data = http.parse(); return data; } // ******************* // vote for a profile by clicking // ******************* function vote( q, a ) { var answers = rows[q].getElementsByTagName("li"); // the last answer "no thanks" decrements the scores for selected answers on that question if ( a == 4 ) { for ( var i=0; i<4; i++ ) { if ( totals[i] > 0 && answers[i].className == "selected" ) totals[i]--; answers[i].className = "answer"; } // any other answer will increment the score for that profile } else if ( answers[a].className != "selected" ) { answers[4].className = "noThanks"; totals[a]++; } answers[a].className = "selected"; return; } // ******************* // getProfile // function to calculate which profile to choose // ******************* function getProfile () { var highscore = 0; var profiles = new Array(); // first get the high score for ( var i=0; i highscore ) highscore = totals[i]; } // find which answers had the high score for ( var i=0; i