xxxxxxxxxx
62
let state ="intro"
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
if(state== "intro"){
introState();
} else if(state =="sql1"){sql1_state();} else if (state =="sql2"){sql2_state();}else if (state =="sql3"){sql3_state();}
}
function introState(){
ask = "select user from tweet where text like '%25valg%25'" ;
loadJSON("https://tdb01.ruc.dk/tdb-api/?q="+ask, gotdata);
textSize(20);
text ("Liste med corona", 100, 100);
if(keyIsDown(49)){state = "sql1";}
}
function sql1_state(){
ask = "select user from tweet where text like '%25corona%25'" ;
loadJSON("https://tdb01.ruc.dk/tdb-api/?q="+ask, gotdata);
text("Første", 200, 200);
circle(10,10,10) ;
if(keyIsDown(50)){state = "sql2";}
}
function sql2_state(){
ask = "select user from tweet where text like '%25ukraine%25'" ;
loadJSON("https://tdb01.ruc.dk/tdb-api/?q="+ask, gotdata);
text("Anden", 200, 200);
circle(10,10,10) ;
if(keyIsDown(51)){state = "sql3";}
}
function sql3_state(){
ask = "select user from tweet where text like '%25mink%25'" ;
loadJSON("https://tdb01.ruc.dk/tdb-api/?q="+ask, gotdata);
text("Tredje", 200, 200);
circle(10,10,10) ;
if(keyIsDown(52)){state = "intro";}
}
function gotdata(rows){
for (i=0;i<rows.length;i++){ print(rows[i].user);}
}