Script to Detect if Celestia is available on a computer

All about writing scripts for Celestia in Lua and the .cel system
Topic author
damianpiccolo
Posts: 3
Joined: 08.06.2005
With us: 19 years 5 months

Script to Detect if Celestia is available on a computer

Post #1by damianpiccolo » 08.06.2005, 15:33

Does anybody knows if there is any kind of html (javascript, vbscript, etc) to detect if celestia is available on the computer?
Thanks a lot

Dami??n

maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #2by maxim » 08.06.2005, 21:11

This is an interesting problem.

Actually the official definition of Javascript 1.1 knows an object 'mimeTypes' which is located beneath the 'navigator' object, and adressed as 'navigator.mimeTypes[...]'. So the following html-code should show all known mime types, including the Celestia 'cel' and 'celx' type:

Code: Select all

<html>
  <head>
    <title>Mime Type Test</title>
  </head>
  <body>
    <b>The following Mime Types are known:</b>
      <script type="text/javascript">
<!--
        for(var i=0; i<navigator.mimeTypes.length; ++i)
          document.write("<br>" + navigator.mimeTypes[i].type);
//-->
      </script>
  </body>
</html>


And the following html-code should report if Celestia is available on that computer:

Code: Select all

<html>
  <head>
    <title>Celestia Existence Test</title>
    <script type="text/javascript">
<!--
      if (navigator.mimeTypes["application/celestia"])
        alert("Celestia is available on this computer!");
      else
        alert("Celestia is not available!");
//-->
    </script>
  </head>
  <body>
    Celestia Existence Test
  </body>
</html>


Unfortunately every browser is playing his own game here:

- IE knows the 'mimeType' object only for compatibility reasons, but always leaves it empty.
- Gecko engine browsers (Netscape 6 and 7, Mozilla and Firefox) only list those mime types for which there exists real browser plugins (which is not the case for cel and celx, but also - for example - jpeg).
- Opera and Netscape 4 are actually the only browsers which interprets the above examples according to the standard.

Though I like using the Firefox browser, it's Javascript compatibility seems quite lousy (instead there is an increasing plugin hype). :roll:

maxim

Topic author
damianpiccolo
Posts: 3
Joined: 08.06.2005
With us: 19 years 5 months

Post #3by damianpiccolo » 10.06.2005, 12:46

Maxim, basically you are saying that there is no standard script that will work accross browsers... )-; That's a pity... Anyways I'm going to try the second script and see the results in firefox. I'll let you know if it works

maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #4by maxim » 10.06.2005, 19:00

It will not work (spec. it will report no Celestia available). But you can compare it to a run in Opera, where it works, conformal to the standard.

maxim

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 7 months
Location: Hamburg, Germany

Post #5by t00fri » 10.06.2005, 21:01

In Linux I just type

> which celestia

on my machine the result is

>/usr/local/bin/celestia

or one may type

> locate celestia

then a very long output follows ;-)


Html or similar seems like a bad idea since usually only a very limited amount of directories is made accessible to HTML-browsing for reasons of security.

Irrespective of HTML, the task is so trivial that someone must have been joking around here...

Bye Fridger

maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #6by maxim » 11.06.2005, 09:40

I suppose that the intentation may be, to enable automatic detection via browser on a web page where some cel/URLs or links to cel-scripts are displayed. So that the user doesn't get the default 'broken link' error page, but a report of what is missing for a proper display of the links contents (or even a note where to get a Celestia installation).

Of course you can simply look on your 'installed applications' list if you want to know it for yourself. The popup messages in the example above are for demonstration only.

maxim

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #7by selden » 11.06.2005, 10:26

Damian,

It would help a lot if you told us what problem you are trying to solve rather than asking for a feature/solution that probably won't do what you want.
Selden

Topic author
damianpiccolo
Posts: 3
Joined: 08.06.2005
With us: 19 years 5 months

Post #8by damianpiccolo » 14.06.2005, 12:59

Basically I need this script to do what Maxim has said: to enable automatic detection via browser on a web page where some cel/URLs or links to cel-scripts are displayed.
I'm designing a flash file for an educational program and I'm trying to show information about planets and moons, and in case the computer has celestia I want to launch celestia with some scripts...
By the way, thanks to everybody for your answers... I tried the scripts that Maxim sent, and as he said the show no results in IE and Firefox.


Return to “Scripting”