Web 2.0 research – tagging, social networks, folksonomies.

Entries from July 2007

Ajax GET and POST

July 23, 2007 · Leave a Comment

I’m posting my GET and POST ajax code it will hopefully be useful to some people.

I searched a lot to find some simple code as i didn’t need to validate the forms. So many scripts didn’t work properly or seemed unnecesserily complicated for my requirements.

The code has been adapted from
http://www.w3schools.com/ajax/def

the GET from:
http://www.openjs.com/articles/ajax_xmlhttp_using_post.php

Hope you find this helpful!

//Set up the XMLHttpRequest

var http = createRequestObject();
function createRequestObject() {
var objAjax;
var browser = navigator.appName;
if(browser == “Microsoft Internet Explorer”){
objAjax = new ActiveXObject(“Microsoft.XMLHTTP”);
}else{
objAjax = new XMLHttpRequest();
}
return objAjax;
}

//THE GET

function getNewContent(){
http.open(‘get’,'newcontent.php’);
http.onreadystatechange = updateNewContent;
http.send(null);
return false;
}

function updateNewContent(){
if(http.readyState == 4){
document.getElementById(‘Content’).innerHTML = http.responseText;
}
}

//THE POST

function postForm() {
var url = “formentry.php”;
var formtag = document.getElementById(‘fmfield’).value;
var params = “newfield=” + formfield;
http.open(“POST”, url, true);

//Send the proper header information along with the request
http.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
http.setRequestHeader(“Content-length”, params.length);
http.setRequestHeader(“Connection”, “close”);

http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
document.getElementById(‘fomentered’).innerHTML = http.responseText;
document.getElementById(‘fmfield’).value = “”;
}
}
http.send(params);
}

the functions are called through an onclick event
e.g.
GET <a href=”#” onclick=”getNewContent()”>New Content</a>
POST <a href=”#” onclick=”postForm()”><img src=”Submit.gif”></a>

I couldn’t get it to work properly with a button with type image and i wanted an image so i did it with an <a> tag – i think it works with a normal <input type=”button” onclick=”postForm()”> But it won’t work if you have an <input type=”submit”> button.

I am still trying to figure out how to get it to work when the user presses return or enter – it calls the postForm() but refreshes the page.

If any one can help me on this please comment!!

Categories: Ajax · VideoTag · development · general · programming · web2.0

Firebug, Pitfalls and Videos

July 22, 2007 · Leave a Comment

Decided this is a good place to put notes for my final report – mostly critical evaluation, rather than a word document where i’ll never rememeber the title and end up opening a different one each time, at least here they’re in one place and i can browse through and pick bits out that might be useful.

So firstly testing – i have discovered how useful the firebug extension for firefox is. I’ve had it for ages and never used it but it’s fantastic. I found it particularly useful when developing the Ajax sections of the site as i could tell whether or not the script was making the ajax call and whether the problem was with an other area of the code. It was sometimes one or the other, but then i could fix the relevent bit instead of spending hours just messing around wondering what wasn’t working.

Secondly pitfalls – how did i create them? Basically, in most cases i entered the first tags that came to mind when i thought of the video. I figured that as this would make them the tags that took least cognitive effort to create, this would make it likely that players of the game would also think of the same tags. Some are very basic, some not so. I did watch a couple of videos and come up with tags that were based on objects or words that stood out. This was especially the case for videos in tougher levels where more pitfalls needed to be found.

What criteria did i use to select the videos? A painful process of watching clips, seeing if they made me laugh or at least smile, sometimes then having to rule them out because although the begining was funny it got a bit silly toward the end. I was also careful to avoid videos with strong language, sexual references or violence – so that ruled out half of what i had looked at. I have let the odd mild violence video through – comparable with Tom and Jerry or The Simpsons levels of violence and there is the odd isolated case of strong language. As my demographic age range is over 18’s then i reasoned that the content was suitable for the percieved audience. Some videos aren’t histerically funny, but were ‘nice’ videos, or scary or simply high rated and i was running out of time and patience so they’ve made it in there. 3 of the videos are what 3 very kind people uploaded to my youtube group. If i get more and they are suitable, i will consider adding some extra videos to the game over the next couple of months as it will keep it fresh.

I have one problem left to fix with the game points and the tags not updating from a set timeout function which is frustrating – again it’s because i’m trying to be clever and use ajax! i need to build my admin section and create a questionnairre. i think that’s it i’m so close, i reckon 3 or 4 hurdles to go to the finish line.

Categories: Project Managment · development · general · programming

Post your favourite videos

July 17, 2007 · Leave a Comment

I’ve created a youtube group for VideoTag so that any kind people out there can join the group and post some of their favourite videos to it. If they’re suitable then they will be included in the game.

Here’s the link:

http://www.youtube.com/group/videotag

Categories: VideoTag · YouTube

I’ve nearly built a game!!

July 17, 2007 · Leave a Comment

Wow, i’m nearly there.  Taking a breather from coding to write this, i have programmed solidly pretty much for over a week.  I’ve been dreaming about programming, a little piece of my mind has constantly been writing scripts no matter what else i’m doing.  But it’s been worth it as i nearly have a finished game.  I have managed to get the http requests working which was a real headache The most annoying thing, once i’d fixed something i’d be all happy and then it would have created a new problem that i’ve had to fix.  Sometimes the fixes are not best for usability, ie the form submits using ajax so that the page doesn’t refresh, but if the user presses enter/return it doesn’t call the function and attempts to submit the form normally.  I couldn’t find a fix for this as any onkeypress functions made the page refresh even when calling the ajax function.  Very irratating so i have had to resort to disabling the return key on the text box.  Not the best move, it’s annoying me so will probably annoy lots of other people too, but at least their video isn’t refreshing after every tag entry, that would annoy them more i reckon.

My  problem solving skills have been pushed to the limits coding this game.

The final problem that i don’t know if i’ll be able to solve is that as the video is being downloaded from youtube, and entering tags and getting suggestions involves requests to the server, the whole thing is very slow – any i have a good internet connection.  I’ve thought about pre loading, but to pre load all the videos may mean a user is waiting 10 minutes before they get to play the game so they’d have left by then anyway.   So not sure what to do about that.

I think i’m going to leave the board of shame off.  To allow other users to state whether or not they think a tag is relevent or not will involve moderation, which i don’t have the time to do.  Also it is my opinion over another persons opinion over anothers, so i’ve decided to trust that people are not going ot cheat!

The only other big job now is to create the page that shows thumbnails of the videos and the tags entered and then the admin section which will allow me to pull off stats.  And then i need to make it look pretty.  So the end of the month is looking attainable – never thought in a million years it would be!

Well ths has been a brain dumping excercise to try and clear my  mind a bit – and also have somewhere i can read it back again in future in case any of it is relevent for the critical evaluation.

Categories: development

Register to Play VideoTag

July 9, 2007 · Leave a Comment

I am in the process of building the VideoTag game. There is a registration page live at the moment. If you are interested in the VideoTag project and would like to register an interest to play the game, I will email you when the game is live and you will be able to log straight in and play.

Here is the link to register:

www.videotag.co.uk/register

Categories: VideoTag

Programming Hell

July 9, 2007 · Leave a Comment

Oh how i enjoy my work!  I do really.  Especially at the end when it’s finished and i have something to show for the blood, sweat and tears!  I haven’t written anything for ages, obviously i used this a distraction when writing my literature review.  Or the novelty of blog writing ran out very quick, most likely a bit of both.

Anyway i have finished the literature review.  I created a poster which was submitted to the i3 conference at Robert Gordon University.  I met some lovely people at the pre-conference workshop, which i really enjoyed and now I am busy building the game itself.  And it’s as difficult as i anticipated.  Thankfully there are some really helpful forums and tutorials out there to help me find out how to do things.

The best language for a game is probably Java, as I’m using YouTubes Flash player to embed the videos, i could have used Flash 8 to create the game – as i don’t know enough about either i am using php and javascript.  As my research is all about Web2.0 i am also going to use aspects of Ajax.  I need the XMLHttpRequest() function in particular as i need lots of bits of the page to update independently without refreshing the page.  A challenge and a half – never created an Ajax app before.   I’ve barely got passed document.write in javascript, so I’ve set myself a big challenge.

What a sense of achievement i will have when i get the game built.  At the moment i can’t quite get my head round all the bits and bobs I’ve got to bolt together to get a fully functional game that does everything i want it too.

It’s going to be a bit of a hack job. but I’m sure I’ll get it done.  At the moment i am using dreaded frames – i hate myself, i feel bad enough for using tables instead of rising to the css and div tag challenge.  I figured my time better spent in programming than messing about endlessly with layout.  I know where i am with tables.

I’ve waffled enough – back to work.

I’m going to post a link to the registration page of VideoTag – if i put it here no one will read it, i’m sure anyone who stumbled upon this page has now got bored of my waffle!

Categories: development