473,654 Members | 3,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert javascript-powered web page to standalone application

Hi,

I've written an engine in Javascript for running text adventure games
on a web page:

http://www.robinjohnson.f9.co.uk/adventure/hamlet.html (That's the
only game I've written with it so far, and a version of the engine
that is slightly less sophisticated than my development copy, which
has cleaner code and a more authentic Infocom-style scrolling display,
but I digress.)

There is essentially only one function each for input (take_command() )
and output (say()) so the user-interface code is nice and seperate
from the muscle.

I'd like to be able to produce a download-and-run version of the game
with, crucially, the ability to do some simple file I/O for saving
games (the web version does that with cookies, which work sometimes,
and tend to screw things up if they get too big.) So I know I'll have
to take it outside Javascript, but I'd like to carry on with the code
I've already written.

I did a bit of googling and found Rhino, so I'm guessing I can use
that, and write new user interface and file i/o methods in Java, to
work around the existing code. I'm not very familiar with Java but
maybe this is my chance to learn. (And hopefully there won't be much
complicated stuff to be done anyway; I only want a console-window
app.)

I wondered if anyone here has experience of doing something similar -
basically, of converting a web application to a standalone one - and
might care to shave some advice (or, on the offchance, existing
code...) before I reinvent the wheel.

Thanks

--
Robin Johnson
http://www.robinjohnson.f9.co.uk
rj at robinjohnson dot f9 dot co dot uk
Jul 23 '05 #1
5 5613
"Robin Johnson" <rj@robinjohnso n.f9.co.uk> wrote in message
news:5b******** *************** ***@posting.goo gle.com...
Hi,

I've written an engine in Javascript for running text adventure games
on a web page:

http://www.robinjohnson.f9.co.uk/adventure/hamlet.html (That's the
only game I've written with it so far, and a version of the engine
that is slightly less sophisticated than my development copy, which
has cleaner code and a more authentic Infocom-style scrolling display,
but I digress.)

There is essentially only one function each for input (take_command() )
and output (say()) so the user-interface code is nice and seperate
from the muscle.

I'd like to be able to produce a download-and-run version of the game
with, crucially, the ability to do some simple file I/O for saving
games (the web version does that with cookies, which work sometimes,
and tend to screw things up if they get too big.) So I know I'll have
to take it outside Javascript, but I'd like to carry on with the code
I've already written.


If you don't mind reloading pages, then PHP or PERL is probably a good way
to go. Converting it to PHP wouldn't be all that hard, IMO.

For a downloadable, stand-alone, Java may be the way to go, but as I
understand it, the user will need a Java interpreter for it to work.

Is there a reason you want to have the user download it, rather than staying
online?

Jul 23 '05 #2
Tony wrote:
Is there a reason you want to have the user download it, rather than staying online?


So it can do file I/O, and so the user doesn't have to be online to use
it. (Other than ease of distribution, there's no real advantage to it
being on the web.)

Robin Johnson

Jul 23 '05 #3
wl
"Robin Johnson" <rj@robinjohnso n.f9.co.uk> wrote in message
news:5b******** *************** ***@posting.goo gle.com...
Hi,

I've written an engine in Javascript for running text adventure games
on a web page:

http://www.robinjohnson.f9.co.uk/adventure/hamlet.html (That's the
only game I've written with it so far, and a version of the engine
that is slightly less sophisticated than my development copy, which
has cleaner code and a more authentic Infocom-style scrolling display,
but I digress.)

There is essentially only one function each for input (take_command() )
and output (say()) so the user-interface code is nice and seperate
from the muscle.

I'd like to be able to produce a download-and-run version of the game
with, crucially, the ability to do some simple file I/O for saving
games (the web version does that with cookies, which work sometimes,
and tend to screw things up if they get too big.) So I know I'll have
to take it outside Javascript, but I'd like to carry on with the code
I've already written.

I did a bit of googling and found Rhino, so I'm guessing I can use
that, and write new user interface and file i/o methods in Java, to
work around the existing code. I'm not very familiar with Java but
maybe this is my chance to learn. (And hopefully there won't be much
complicated stuff to be done anyway; I only want a console-window
app.)

I wondered if anyone here has experience of doing something similar -
basically, of converting a web application to a standalone one - and
might care to shave some advice (or, on the offchance, existing
code...) before I reinvent the wheel.

Thanks

--
Robin Johnson
http://www.robinjohnson.f9.co.uk
rj at robinjohnson dot f9 dot co dot uk

Hi Robin,

For compiling javascript into Java classes, so these can be run on any
system having a Java virtual machine, have a look at Mozilla's project
'Rhino' (http://www.mozilla.org/rhino/)

I had some nice good experiences with it in the past.

Wim
Jul 23 '05 #4
rj@robinjohnson .f9.co.uk (Robin Johnson) wrote in message news:<5b******* *************** ****@posting.go ogle.com>...
I've written an engine in Javascript for running text adventure games
on a web page:

http://www.robinjohnson.f9.co.uk/adventure/hamlet.html (That's the
only game I've written with it so far, and a version of the engine
that is slightly less sophisticated than my development copy, which
has cleaner code and a more authentic Infocom-style scrolling display,
but I digress.)
[...]
I'd like to be able to produce a download-and-run version of the game
with, crucially, the ability to do some simple file I/O for saving
games (the web version does that with cookies, which work sometimes,
and tend to screw things up if they get too big.) So I know I'll have
to take it outside Javascript, but I'd like to carry on with the code
I've already written.
[...]
I wondered if anyone here has experience of doing something similar -
basically, of converting a web application to a standalone one - and
might care to shave some advice (or, on the offchance, existing
code...) before I reinvent the wheel.


</delurk>
Funny you should mention that. In the last few days I've just
finished translating a simple text adventure game the other way
around - into JavaScript from Perl.

It helped a little that I'm not a total novice in either
language, but I'm no expert either. I was surprised how simple it
all was. You imply that your code is fairly modular, and that
will definitely help. Translating one routine at a time makes the
progress seem much quicker.

Mine looks to be quite a bit simpler (in a not-so-good way) than
yours, mainly because I originally started writing it as a
manifestation of a telephone tech-support joke - The one that
runs like: "Thank you for calling So-and-so & Co. For tech
support you must find the silver key and escape the enchanted
forest. Press 2 for north, 4 for west, 6 for east, 8 for south.
etc.etc."

The Perl version's not anywhere downloadable (perhaps I should do
something about that...), but the JS version is at:
http://www.cyreksoft.yorks.com/raw/textAdv.php

There's contact details on the website for questions and stuff.
(The googlenews@... address falls into a black hole).

Cheers,
Carl - relurking
Jul 23 '05 #5
Take a look at HTA's (HTML Applications). Only for Windows, but gives
you the IE container without the web browser wrapper. Just rename an
..html file to .hta and double click it to see it in action. I'd
personally wrap it in either a ZIP or a basic installer (NSIS installer
works really well and is free/open source) that adds start menu options,
etc. Otherwise, you'll be dealing with "What do I do with this .hta file?".

I posted this sample in another thread earlier today, but here's a basic
sample, which also shows how to use WScript objects through the WSH
(Windows Scripting Host). The example is running a local application,
but HTA's also allow access to the local filesystem, registry, etc.

------------yourfile.hta---------------
<HTML>
<HEAD>
<TITLE>Your HTA Application</TITLE>
<HTA:APPLICATIO N ID="yourHTA"
APPLICATIONNAME ="Your HTA Application"
BORDER="thin"
CAPTION="yes"
CONTEXTMENU="ye s"
ICON=""
INNERBORDER="no "
MAXIMIZEBUTTON= "yes"
MINIMIZEBUTTON= "yes"
NAVIGABLE="yes"
SCROLL="auto"
SELECTION="yes"
SHOWINTASKBAR=" yes"
SINGLEINSTANCE= "no"
SYSMENU="no"
VERSION="1.0"
WINDOWSTATE="no rmal"/>
<script language="javas cript">
<!--
function edit_hta(){
$this_hta = yourHTA.command Line;
$command = "notepad.ex e " + $this_hta;
$objShell = new ActiveXObject(" WScript.Shell") ;
$lngReturn = $objShell.Run ($command, 1, true);
}
// -->
</script>
</HEAD>
<BODY>
Your HTA content goes here. Simply <a href="#"
onclick="edit_h ta();">open this HTA file</a> in a text editor and go to
town. If you're looking to make this window look much more like a
regular Windows application, I recommend looking at the <a
href="http://webfx.eae.net/docs/environ.html">C SS values that you can
grab from the current Windows theme</a>. By setting your CSS to use
those values instead of things like #CCCCCC, you can make the HTA app
blend in with the current Windows settings.
</BODY>
</HTML>

Robin Johnson wrote:
Hi,

I've written an engine in Javascript for running text adventure games
on a web page:

http://www.robinjohnson.f9.co.uk/adventure/hamlet.html (That's the
only game I've written with it so far, and a version of the engine
that is slightly less sophisticated than my development copy, which
has cleaner code and a more authentic Infocom-style scrolling display,
but I digress.)

There is essentially only one function each for input (take_command() )
and output (say()) so the user-interface code is nice and seperate
from the muscle.

I'd like to be able to produce a download-and-run version of the game
with, crucially, the ability to do some simple file I/O for saving
games (the web version does that with cookies, which work sometimes,
and tend to screw things up if they get too big.) So I know I'll have
to take it outside Javascript, but I'd like to carry on with the code
I've already written.

I did a bit of googling and found Rhino, so I'm guessing I can use
that, and write new user interface and file i/o methods in Java, to
work around the existing code. I'm not very familiar with Java but
maybe this is my chance to learn. (And hopefully there won't be much
complicated stuff to be done anyway; I only want a console-window
app.)

I wondered if anyone here has experience of doing something similar -
basically, of converting a web application to a standalone one - and
might care to shave some advice (or, on the offchance, existing
code...) before I reinvent the wheel.

Thanks

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
36791
by: mprocopio | last post by:
Fellow JavaScripters, I am looking for code or implementation ideas for converting an integer variable to a four-byte array. I'm porting some of my code from C#, where I make use of their BitConverter utility class, but am still feeling my way around a bit here with JavaScript. The idea is that each of the four bytes that comprise an integer (I presume numeric types in JavaScript are/can be made four bytes?) are extracted, and then...
4
4293
by: CSharpener | last post by:
This should be *so* easy! How do I convert a Byte or int to a binary string representation in C# In JavaScript, it goes like this for an int: javascript:(123).toString(2 or javascript:(0xFE).toString(2 No problem. So, how do I do the same in C#? What simple thing am I missing
3
63076
by: rishabhshrivastava | last post by:
Hello All, How can I convert a value to Double in JavaScript??? In vbscript i believe its done as cDbl(Value) I tried lots of way but getting a value of "NaN". Any suggestions/ideas will be truely appreciated.
3
17493
by: Lonifasiko | last post by:
Hi, I want to convert an UTC time to a Date object in Javascript. The UTC time we have is a string that looks like "1160720058.377452373" for example. I've done it in Java but I'm not able to do it via Javascript, that should be pretty similar...
3
12263
by: vunet.us | last post by:
What is the best method to convert milliseconds (after midnight January 1, 1970 GMT) to formatted time example: 972798180000 ==10/18/2000 14:08:11
1
442
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number? ----------------------------------------------------------------------- Javascript variables are loosely typed: the conversion between a string and a number happens automatically. Since plus (+) is also used as in string concatenation, ` '1' + 1 ` is equal to ` '11' `: the String deciding...
2
2210
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number? ----------------------------------------------------------------------- Javascript variables are loosely typed: the conversion between a string and a number happens automatically. Since plus (+) is also used as in string concatenation, ` '1' + 1 ` is equal to ` '11' `: the String deciding...
9
2574
by: _Who | last post by:
I have a .htm file that shows in an iframe which is part of a master's asp:Content. I need the .htm to copy the style class from the master or set it as shown below. Below is how I set the stylesheet in the master. What I'd like to do, is change that code into javascript and run it in the
2
2339
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number? ----------------------------------------------------------------------- Variables are not typed; their values are. The conversion between a string and a number happens automatically. Since plus (` + `) is also used as in string concatenation, ` '1' + 1 ` is equal to ` '11' `. The string...
2
7742
by: murugavelmsc | last post by:
Hi, i have a javascript code. I want to convert into VBscript. pls help me Javascript Code:
0
8376
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8594
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.