Can I convert my script to something that will work on a webpage?

I want to take this script, and place in online, so that anyone can use it, not necessarily mac based users.
it is a ‘magical’ mind reading script, the ‘spectator’ thinks of any card in a normal deck, and the script figures out what it is.

but I would like for it to be able to be online.

any help is greatly appreciated.


property cardList : {"King", "Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "--You cheated, it wasn't in all four!"}
property colorList : {"Heart", "Diamond", "Spade", "Club"}
property questionList : {"Is the rank of your card equal to any of these? 3, Jack, 5, Ace, 9, 7?", "Ok, how about these? 10, 3, 6, 2, 7, Jack?", "Almost done, how about these? 5, Queen, 6, 7, 4?", "Last round: Queen, 9, 8, Jack, 10"}

	display dialog "Think of any playing card in a normal deck...
And for the moment, just forget about the suit, and the color of your card. Only think of the number or letter."
	set theResult to 0
	repeat with i from 1 to 4
		set b to button returned of (display dialog item i of questionList buttons {"No", "Yes"})
		if b is "Yes" then set theResult to (theResult + (2 ^ (i - 1))) as integer
	end repeat
		set theResult to item (theResult + 1) of cardList
		exit repeat
	on error
		display dialog "--You cheated, it wasn't in all four!" buttons {"Cancel", "Try Again"} default button 2
	end try
end repeat

--figure out the color
display dialog "Great, now I want you to remember the color of your card. Imagine it bright and vivid in your mind."
if button returned of result is "OK" then
	display dialog "Ok, I am getting something, does the word 'cherry' mean anything to you?" buttons ["Nope", "Yes, it does"]
	if button returned of result is "Yes, it does" then
		set theColor to 1 -- "red"
		set theColor to 3 -- "black"
		display dialog "Oh.. well I meant 'Black Cherry', we'll move on."
	end if
end if
display dialog "Your card is a " & item theColor of colorList & " correct?" buttons ["No, its not", "Yes, it is"]
if button returned of result is "Yes, it is" then
	display dialog "I thought so, you're thinking of the " & theResult & " of " & item theColor of colorList & "s." buttons {"Have a great day!"} default button 1
	display dialog "Oh, well I sometimes have trouble with the " & theResult & " of " & item (theColor + 1) of colorList & "s." buttons {"Have a great day!"} default button 1
end if

Since your users are “not necessarily Mac users”, your choices are these: write an ACGI script (Asynchronous Common Gateway Interface web-server extension) that serves up a series of forms, rewrite this in JavaScript so it will run on the downloaded page, or write it in Java which will run on a lot of operating systems.

This would be difficult to implement as a CGI since it requires multiple question/answer interactions with the user - your CGI would have to keep track of which questions have been answered, and how, potentially for many users at a time.

It could be done, but it would require a radical rewrite.

Implementing it in JavaScript might be viable, depending on your JavaScript abilities. It does, of course, expose your ‘magic’ to the rest of the world, which is half the point.

Another option would be Flash which can create interactive web applications, including the associated logic to determine the desired outcome.