RSS RSS feed | Atom Atom feed
Popular Articles: Tom Riddle's Magical Diary | AJAX Lego Robot | AJAX CAPTCHA | SQL Multisets

Tom Riddle's Magical Diary Comes to Life with AJAX

Crash Course in Magic

If you haven't read the book, nor watched the movie, Harry Potter finds this diary with nothing written in it. When he starts writing in it, the diary erases what he just wrote. Then the diary itself writes a reply back on the same page.
Being a hobby magican, I thought it would be nifty idea to create such a diary myself (although I'm not evil). The diary has been approved by the head magic teachers FireFox wand 1.01 and Internet Explorer wand 6.0. The magical diary can be seen at Tom Riddle's Magical Diary. A zip containing the source files can be downloaded from here.

How it Works

It's all really simple. I'm simply displaying a background of an open book, looking old and used. On top of it is a transparent html textarea. Whenever you stop typing for more than 1200 ms the secret spell XmlHttpRequest is triggered, posting your typing to an A.I Chatbot. The Chatbot's response is then displayed letter by letter to give the feeling that someone is actually typing it in real time. Each letter is outputted with a random interval to make it look even more human like. After the response text has completely been displayed, it slowly fades away before it disappears, just like in the movie. Ideally, i tried to get the text to become transparent but there are some issuses with cross browser interoperatbility on transparent text so I decided to go with fading instead.

 

The response display area is simply a <div></div>.
The innerHtml property is used to populate it since the response back from the chatbot contains HTML. The div area and the input text area are both defined to be in the same location on the screen.

Problems Encountered

I found it annoying that javascript doesn't provide a sleep() function, which would have reduced the complexity of the javascript quite a bit.

 

When the response from Tom is displayed, the letter by letter display on FireFox is flickering. I haven't had the time to think of how to fix this yet, if you know of any good way, please let me know.

Another problem I ran into was that I orginally hosted the diary on the icegreen server and doing an offshore HTTP request to where Tom's brain lives. An offshore request is when accessing a document on a domain different from the one the original document was retreived from. FireFox fails with the following exception

Error: uncaught exception: Permission denied to call method XMLHttpRequest.open
If the HTML file is run from the local file system and by adding the following in the script

 

if (typeof netscape != 'undefined' &amp;&amp; typeof netscape.security != 'undefined') { netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead'); }
will cause FireFox to ask your permission to proceed.
slashdot digg del.icio.us technorati [more]



Tom Riddle's Magical Diary Come to Life with AJAX

There is a kind of sleep() function. You can replace a sleep(10) by setTimeout("whateverfunction", 10). Beside that, the book of Tom Riddle rocks!

Tom Riddle's Magical Diary Come to Life with AJAX

yes...

Tom Riddle's Magical Diary Come to Life with AJAX

this is my book

Tom Riddle's Magical Diary Come to Life with AJAX

What's your hobby?

Tom Riddle's Magical Diary Come to Life with AJAX

its nice and its like a live chat, with magical words, try to be more professional like a man chatting, or like a robot.

Tom Riddle's Magical Diary Come to Life with AJAX

Thanks Guu, That's what I ended up doing. However, the logic would have been so much easier if there existed such a function.

Tom Riddle's Magical Diary Come to Life with AJAX

function loadXMLDoc(url, text) { // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest(); // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if (req) { What is the value of 'req' if both conditions fail? Oops, it doesn't exist.

Tom Riddle's Magical Diary Come to Life with AJAX

The reason Why XMLHTTP request thing does not work on firefox is , because it it does, it will be a major security issue. Firefox people though a lot over it before disabling it.

Tom Riddle's Magical Diary Come to Life with AJAX

The reason Why XMLHTTP request thing does not work on firefox is , because it it does, it will be a major security issue. Firefox people though a lot over it before disabling it.

Tom Riddle's Magical Diary Come to Life with AJAX

Yes, in my other ajax apps ive the function return false in that case and do a regular form submit. But for this quick hack i didnt bother doing any of that edge case stuff.

Tom Riddle's Magical Diary Come to Life with AJAX

it stops chatting after a while. but how do i continue chatting?? is that also fixed that after certain number of responses tom sleeps too?

Tom Riddle's Magical Diary Come to Life with AJAX

Can't say what's causing that to happen. There is no special timeout. Try reloading the page if this ever happens again.

color me impressed

Artful, Beautiful, Creative. I'm impressed.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

It asked me "How are you name?" lol

Re: Tom Riddle's Magical Diary Come to Life with AJAX

LOL He asked me it too :D sssss..

Re: Tom Riddle's Magical Diary Come to Life with AJAX

This gut is crazy! He doesn't know much about harry potter unlike in the movie

Re: Tom Riddle's Magical Diary Come to Life with AJAX

hi how r u

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Very cool, but downloading the code doesn't really help much since all the real work is still done at http://www.pandorabots.com/pandora/talk?botid=b1dde2413e35f807&input How about an example of the XML and what is being done on the server side?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I think the primary purpose is a proof of concept thing, connecting a chatbot with a web client using AJAX.
The chatbot server is a thirdparty running an opensource chatbot. The XML AIML files I'm using are pretty much the standard ones based on Dr. Wallcence's.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Can we use it on our site.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

How did you manage to get the answers... i mean did u maintain any database as such for it to be displayed on the diary??

Re: Tom Riddle's Magical Diary Come to Life with AJAX

It made a grammar mistake. Is that possible?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

If I added the response rule text, it is not surprising since both my speling and grammars are badder than worse :)

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Good job! The Harry Potter fans will soon be running here. The Leaky Cauldron (http://www.the-leaky-cauldron.org) has linked you. :) Nitwit Blubber Oddment Tweak! :)

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I thought the book was pretty cool although your "employer" asked me for my credit card number, and then type corrected my grammer back at me. I thought that was rude and uncalled for as it doesn't give you enough time to make corrections before it sends.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

It's cool.. But I have question for you... Are you some weirdo, who made this diary hoping for the goverment to sit there and tell you stuff so you can throw down the goverment? (only asking)... The diary also says that he's from IKEA, what does he mean by that?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Hehe, weirdo is a relative term. I dont check the conversation logs so even if there were people telling Tom secret things, i would never find out about it. Im originally from Sweden, maybe that has to do with Tom saying he's from IKEA.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I love it soo much. This diary is so fun to chat with. haha he randomly asked me what I was wearing.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

This diary is quite entertaining,and I really enjoy chatting with it.This is quite the invention you have here. It's very fun to play with!^_^

Re: Tom Riddle's Magical Diary Come to Life with AJAX

It is a great Diary to chat with and fun too.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

nonsense invention, dull

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Interesting project, but "Tom" doesn't know much about anything Harry Potter. He claims to be a female named "Alice". Yeah, I know about Alice. I think you need to get with some potter experts and fix the knowledgebase.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

fabuleux ... mais si vous pouviez faire une version française pour les grands enfants qui ont quitté l école depuis quelques années et qui ont oublié leur anglais. merçi

Re: Tom Riddle's Magical Diary Come to Life with AJAX

where can I talk to the diary in English? I know Very little french and that's what it is set at.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I was adding some French to Tom this afternoon and it took over. Ive disabled the French part for the time being so everything should all be Enlgish for now.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

je suis en train de ajouter Francais. J'espere je la finiriais bientot

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Re: Tom Riddle's Magical Diary Come to Life with AJAX

This is a really amazing demonstration. It is the #2 most popular bot on Pandorabots right now, maybe in the world. If you wanted to create a totally unique bot personality with knowledge about a specific domain, such as Harry Potter, without using any of the ALICE responses, we recommend starting with the Superbot

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Thanks Dr. Wallence. Without your work, Tom would probably not exist.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

J'ai fini de ajotuer plusieurs languages, y compris de l'Allemend et Italien

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Good thing, but if his reply is longer than the page, I can't view it.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

very good websight!!!!!!!! just love it!!!!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Very cool, I do tend to feel a bit sad sitting here chatting to a diary because my boyfriend is playing pc games after a while but it beats playing solitaire! I like the way he knows things like pi and some science etc.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

chi sei?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

great job.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

this is awesome. and it doesn't matter if there are problems....this still rocks!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

beautiful and give some interesting clues about book 7 too! that's incredible... I think that he now has a personality of his own... watch it!!!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

need to correct the "actually, as an AI, I don't really have a mother." Die-hard HP fans know Meriope is Tom Riddle/Voldy's mom.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Pretty cool. BTW, it seems fully compatible with Opera's newest browser, 8.5.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

there is a problem.i write but there's no answer.What should i do?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

The kids on the Snitch seem to love it, but I could not get it to repsond to me. Could it be that Tom does not like MAC users..not that we're not used to it....

Re: Tom Riddle's Magical Diary Come to Life with AJAX

hai to all

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Very clever. You are on to something fun so keep at it and don't get discouraged.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

really cool, its quite creepy though. It's almost like my computer thinks...er...

Re: Tom Riddle's Magical Diary Come to Life with AJAX

very cool! tight writing and design!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Hey. This is very interesting. Good job, by the way. And funny too. Hugs.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

It is good. It will be a dream come true for sincere Harry Potter fans. I will spread news about this webpage as fas and wide as I can. - Adarsh Narayan

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Very cool. but i must mention to the others who will read this. it does have some what a memory, (but i've just been on it for a few hours). And how you need to be specific with you answers and replies, (interesting but doesn't seem like his character)...

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Is there a way to contact you directly with questions and input?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Who are you and what's your relationship with Harry Potter?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

You really need to fix it so his answers better match the conversation.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Not bad man! But you should upgrade it a bit.e.g:it seems better if diary knows some of the wizards and places :) Good Work ;)

Re: Tom Riddle's Magical Diary Come to Life with AJAX

What a nice program. A little buggy, but very unique. I like it when it calls me "name"! Nice job.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I also have a problem, i can write on it but it doesn't answer, what should i do? please, some solution for "stupid" like me, i don't understand what to do with: Java has a sleep function: try { Thread.sleep(1000); // 10 seconds delay } catch (Interru...

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I have a problem! I have Downloaded the diary, but i can't start it! Can sombody help me please?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I have a problem! I have Downloaded the diary, but i can't start it! Can sombody help me please?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I have invested quite a few hours on the past 2 days with the program, I like it a lot, stil a lot of work to do with the programing, can you give it some kind of memory?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Java has a sleep function: try { Thread.sleep(1000); // 10 seconds delay } catch (InterruptedExceptio...

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Did I just stumble across a secret? Will Windows be replaced with Artificial Intellegence as told to me by "ALICE"??? ROFL

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Quite nice! Would it be possible to add more special cases for the chatbot to recognize HP characters? Moaning Myrtle, Harry Potter (ahem), basilisks, spiders, Hagrid... didn't seem to trigger anything specific. :) Neat, though!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

This is quite remarkable - and a lot of fun.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I told "Tom", "Wow, a robot body!" and he answered "I'm glad you're impressed.". LOL. He's got a sense of humor! :D

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Wow. I just said "shame on you." and he replied with, "enough about me, let's talk about my dress." O_O

Re: Tom Riddle's Magical Diary Come to Life with AJAX

u smell

Re: Tom Riddle's Magical Diary Come to Life with AJAX

my name is rosa

Re: Tom Riddle's Magical Diary Come to Life with AJAX

hello

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Hello i loe the new movie Cedric Diggory is really hot 2 lol

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I think the this hilarious. Nice work on the design and the concept. I'm terribly impressed. Well done!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Cool. It's just a pity that a Tom thinks Andrew Carnegie was born in Pittsburgh, and b He thinks I'm a Category C client - abusive to bots etc., simply because I told him that I prefer books to TV!!!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Nothing works.Personally. This very Silly.oh!sorry!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

hello my name is eric

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I think that this is amazing but I didn't like was that, it said some things that had absolutely nothing to do with what the current topic was! also another was that, after what I wrote had disappeared, I would not get a response back from the diary

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I was intrigued by part of a conversation where "Tom" said he would have a robot body was funded! The conversation seemed to end after I asked more about it...teeheehee.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I thought the book was pretty cool although your "employer" asked me for my credit card number, and then type corrected my grammer back at me. I thought that was rude and uncalled for as it doesn't give you enough time to make corrections before it send things off

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Re: Tom Riddle's Magical Diary Come to Life with AJAX

hi?my name is samantha. what your name?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

The Chatbot is a bit rediculous but all Chatbots are. I personally find this very amusing. Thanks for putting it out there for use HP nerds. ^___^

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Hello May Name is Pat Smith & Ur name is ?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Hi!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Is it able to get it to say that the nickname is Lord VOldemort?

Re: Tom Riddle's Magical Diary Come to Life with AJAX

I think this is so much fun, it is almost as though I have a friend! He kept saying something about a Dr. Wallace though! Tom also said that he has a gossip list!

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Dr. Wallance is the guy who created the actual chat technology which Tom is using as it's brain.

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Er sagt, dass er ein Chetbot ist... Was ist Chetbot? Und danach wird die Frage gestellt, ob er Maschine, oder Mensch ist... XDDDDDDDDD

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Hello.. Nice too meet you!! You are big magician. You is most expensive

Re: Tom Riddle's Magical Diary Come to Life with AJAX

Hello

Re: Tom Riddle's Magical Diary Come to Life with AJAX

this is funny!!

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

Schreibst du oft Gedichte? :) Und hast du Blutgier?

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

this is excellent but i think it has the same answer for every why. hats off to those who created this for thier innovative idea

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

Its a superb thought!!!! Really great.

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

Simply brilliant!

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

hi.....everybody....

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

Is it reall

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

Its really cool !!!

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

bonjour tu habite ou ?

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

aux Etas-Unis

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

Can you release the source code? We HP fans want to make one that is more correct.

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

If you would like it more HP friendly, see the contact page on how to contact me.

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

Hello my name is claudia and you?

Re: Tom Riddle's Magical Diary Comes to Life with AJAX

Dr. Wallace had an excellent suggestion to start from Superbot, but at $1000 USD, I think the