I chose to make a task timer application that would keep a record of times spent on tasks. As with most programming into uncharted territory, I ran into some typical misconceptions and some minor oohs and ahas. Let me outline my approach.
- create a mysql database with entries [user, task, timestamp, code, seconds]
- create a php script to connect to the database
- format the output and make it interactive using the form tag
- when the job is running have the elapse time update
- connect it up to Facebook
For number 3 and 4, this took perhaps a bit more time (on and off about five+ hours -- not an easy thing to manage teaching five courses). My formating and html skills dated and are pretty much on the need-to-know basis but at least for my web pages I can achieve what I want. So after a bit of stumbling I was able to hack together this page(you will need to have a Facebook account to view it)--here is the php code. Probably the bulk of the time was figuring out how to get the times to update. I did this in Javascript a language I am not very familiar with. It took me a while to unravel the clock applications that I saw kicking around. Part of the problem was that I didn't initially recognize the recursive call.
var startSeconds=Math.round(new Date().getTime()/1000);
function startclock(){
var seconds=Math.round(new Date().getTime()/1000);
document.form0.update.value=convertSec(8232+seconds-
startSeconds - 1202100203+1202137950)+" **";
document.form1.update.value=convertSec(228249+seconds-
startSeconds - 1202132449+1202137950)+" **";
document.form2.update.value=convertSec(6);
document.form3.update.value=convertSec(5);
document.form4.update.value=convertSec(44374);
document.form5.update.value=convertSec(12106);
setTimeout('startclock()',1000);
}
The numbers in above code is generated from the database and for form# are pulled into forms in a table. The first to variables form0 and form1 are current running task so they need to be aware of the current time. The calculation is a bit messy since the client's machine may not have the same time as the server's time.
So numbers 1 through 4 gave me the following:
hello 711501151 (hmmm a name would be nice...)
task | time | adjust |
new task |
$facebook->require_frame();
I have also been playing with adding stuff to the profile but I run into similar formatting issues
$facebook->api_client->profile_setFBML($out1, $user);
I'm a little unclear on how to proceed with this format issue. With reading about Facebook and Javascript it seems like I may have some issues with the approach.
So round one goes to Facebook. I may just go straight for a Java solution since it's more my native language anyway.
No comments:
Post a Comment