Embedding virtual slide rule in your page
If you have slide rule related web page and would like to give the user
the ability to "try" slide rules you are writing about or to evaluate
slide rule calculation examples, then you may wish to embed an emulator
in your page.
This page describes how to do this with
yet another slide rule emulator used throughout this
site.
Internal information
The emulator is written in javascript with use of Internet Explorer
browser and Netscape Navigator object model.
This means that your page will not provide "virtual
slide rule" for users without IE4.0 (or later) or NN4.04 (or later).
(I did not have chance
to test it on platforms other than Windows).
However this should not
provide any uncomfortable side effects and your page should still be
viewable by other browsers (if it was designed to).
I do have plans to make emulator compatible with any Java capable
browser but currently only IE and NN are supported.
Emulator consists of 3 parts:
- File createrule.js that contains interface functions
to create virtual slide rule.
- File rule.htm that contains generic layout of the slide
rule window and procedures for mouse and keyboard control.
- Set of picture files each of which represents single scale
in appropriate resolution. The filename without extension and path is
considered "scale ID" and used to identify the scale in slide rule
layout description. Scale ID is case sensitive.
You do not need to have these files on your site in order to run emulator
from your page.
Emulator location
Currently emulator is located on the NBCi.com web site that provides free
web hosting. It is located in the folder
http://members.nbci.com/_XMCM/nsg21/slide/yasre.
Wherever later in this page you are asked to enter "emulator location" you
should enter this folder.
For some reasons NBCi site may become unavailable from time to time and
emulator will not be available to visitors of your page at those moments.
You may download the whole emulator (.zip
is available) to you own site and use it locally.
In this case you should use the url of the folder you put it in wherever
"emulator location" is mentioned.
Please,
drop me e-mail
if you choose to do it this way.
The drawback of this approach is that your page will not use the latest
and best version of the emulator. Drop me
e-mail if you want me to send you
notification when new version is ready. I do not do this often, so, do not
be afraid that I will overwhelm your mailbox.
Changes to your page
First of all you will need to add line
<script src="emulator_location/createrule.js"></script>
in the very beginning of your file (for example in <HEAD> section). This may be
<script src="http://members.nbci.com/_XMCM/nsg21/slide/yasre/createrule.js"></script>
if you are using original location, or
<script src="./yasre/createrule.js"></script>
if you are using local copy.
This script file contains function
create_rule(rt,rd[,rn]) that (when called with appropriate parameters) will
create new window with a slide rule. The parameters are:
- rt
- String containing location of slide rule template
file -- rule.htm. Consists of emulator location folder and file name.
For example: "http://members.nbci.com/_XMCM/nsg21/slide/yasre/rule.htm"
- rd
- String with slide rule scale layout. Contains comma separated list
of scales present on your rule in the order from top to bottom with
slide scales emphasised with '[' and ']'. For duplex rules back side may be
entered separated by the front side with '/'. For example:
"A[B,C]D/DF[CF,C]D". Scale IDs are case sensitive. According to convention,
scales whose IDs ending with '~' always point downwards, scales ending
with '_' always point upwards.
The list of available scales can be obtained from
scale selector form. The scale list
is by no means full, but I am working on this. Please drop me
e-mail with the scale you want
to be added, its formula, ID and slide rule where it is used.
- rn
- String with rule name. For example "Pickett N4-ES". Will just appear in
the window title.
It is a nice idea to define a variable with rule template location
<script><!--
var RULETEMP="http://members.nbci.com/_XMCM/nsg21/slide/yasre/rule.htm";
//--></script>
somewhere in your code (preferrably in the <HEAD>
section), if you are going to use it more than once.
Button
With this definition you may create button control that will
create virtual slide rule when pressed. For example:
<form><input
value="Create slide rule"
type=button
onclick="create_rule(RULETEMP,'A[B,C]D','Mannheim')"
></form>
Hyperlynk
Another approach is to use hyperlink. The html code example:
<p>This calcualation can be easily performed with
<a href=javascript:create_rule(RULETEMP,'S~,A[B,S~,-,T,C]D,T','Unique')>
Unique navigational</a> slide rule.
Hyperlynk in harsh environment
Virtual slide rule hyperlinks on these pages follow another approach.
The reason for this is that pages can be viewed either directly or
in a frame of NBCi envelope. In latter case the method described
above will not work for some reasons (still mysterious for me).
If your page also have chances to
be displayed as a frame in aggresive parent frameset (for example, it may
try to manipulate its children's hyperlinks like NBCi envelope does),
you may try the following method:
<a href=javascript:noaction() onclick=javascript:create_rule(RULETEMP,"R1[R1~,R2_]R2",'Precision')>
Try</a> to multiply using extended precision scales.
Here fake href
provides distinguished formatting that allows visually identify
entity as a hyperlink, "hand" cursor when hovered over and tab stop when
navigating using keyboard. Actual job is done by onclick
clause. Function noaction() is defined in file
createrule.js and does nothing. Its only purpose is to
provide syntactically correct link.
This site also uses stylesheet to color this kind of hyperlinks
in green color -- to distingush them from regular ones.
Copyright and license
"Yet another slide rule emulator" is copyright (C) 2000 by Andrew Nikitin.
This software is provided ``as is'' and without any express or
implied warranties, including, without limitation, the implied
warranties of merchantability and fitness for a particular purpose.
You may use it free of charge. "Do not eat".
[
Index page
|
SR Emulator
|
Gallery
|
Deframe
|
Feedback
]