another small glitch I encountered. I made a modification to the code to allow for a blinking cursor (I found some code someone posted and used it). It works fine when I run the sketch but when I copy all the files onto the server and onto my live site (baseballinfographics.com/rankometer), it doesn't allow for data entry (ie nothing happens). Any thoughts? Code below:
// setup
String typing = "";
String saved = "";
String typedText = "Enter Team Name: ";
void setup() {
size(1280, 800);
PFont font = loadFont("CenturyGothic-20.vlw");
textFont(font);
lines = loadStrings("rankometerdata.txt"); // parsing data from external file (column [0] is list of names, column [1] is ranks, column [2] is abbreviated team name)
}
// background
int r1=240;
int g1=235;
int b1=235;
// highlighted color
int r2=165;
int g2=165;
int b2=165;
//text color
int r3=250;
int g3=250;
int b3=250;
String[] lines;
boolean TeamFound = false;
// entry of team name
void keyPressed() {
if (key == CODED) return; // Ignore coded keys
// If the return key is pressed, save the String and clear it
if (key == '\n' ) {
saved = typing.toUpperCase();
// A String can be cleared by setting it equal to ""
typing = "";
}
else {
// Otherwise, concatenate the String
// Each character typed by the user is added to the end of the String variable.
typing = typing + key;
}
}
void draw() {
background (r1, g1, b1); //gray
int indent = 50;
fill(0);
textSize(16);
text(typedText+(frameCount/10 % 2 == 0 ? "_" : ""), indent, 100);
text(typing,200,100);
text("RANKOMETER FOR:", 915, 100);
text(saved,1070,100);
text("#1 pitcher",45,670);
text("#2 pitcher",260,670);
text("#3 pitcher",485,670);
text("#4 pitcher",700,670);
text("#5 pitcher",925,670);
for (int k=0; k<5; k++) { // master loop to format 5 columns of names
TeamFound = false; // re-setting boolean to false
fill(r1, g1, b1); // re-setting box color to background color (ie. no box appears)
for (int j=k*14; j<k*14+14; j++) { //sub loop to format 14 rows of names within each column
int z=j-k*14; // special variable I use to index down and across rows and columns
String[] name = splitTokens(lines[j+1]);
// drawing boxes
//if (name[2].equals(team)) { //Determine if team = "BOS" and then highlight boxes for that row and rows below
if (name[2].equals(saved)) { //Determine if team = "BOS" and then highlight boxes for that row and rows below
TeamFound = true; // Apply box to the remainder of the column
}
if (TeamFound) {
fill(r2, g2, b2); // if so, draw box with darker gray and those below in column
rect(k*220+45, 230+z*30, 170, 25);
}
// overlaying text
noStroke();
textSize(16);
fill(r3, g3, b3); //text color
text(name[0]+" ["+name[2]+"]", k*220+55, 250+z*30);
}
}
stroke(150);
strokeWeight(2);
line (45,110,1100,110);
line (45,650,1100,650);
}