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 (the same one that is
used throughout this site).
Internal information
The emulator is written in javascript. It uses Internet Explorer (at least 4.0)
object model.
This means that your page will not provide "virtual
slide rule" unless it is being browsed with IE4.0 (or later).
However this should not
create any uncomfortable side effects and your page should still be
viewable by other browsers (if it was designed to).
I did have plans to make emulator compatible with any Java capable
browser but currently only IE
is 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. (Well, it actually depends
on a type of server the page is hosted.)
Technically, you do not need to have these files on your site in order to run
emulator from your page, and the following description applies to this kind of
embedding. But since yasre is hosted on one of a free web
servers, it may be
against this server policy to reference material other than web pages (such as
image files) directly.
Emulator location
Currently emulator is located on the
nsg.upor.net web site which hosts it
for free.
It is located in the folder
http://nsg.upor.net/slide/yasre.
Wherever later in this page I mention "emulator location", I mean
this folder.
Alternatively, you may download the whole emulator (.zip) and place it on your own site.
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. Since I update it only periodically, it
mat be not much of a drawback at all.
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://nsg.upor.net/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://nsg.upor.net/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://nsg.upor.net/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. Good HREF="#" may seem
like good alternative, but it works in strange ways in different versions of
IE and NN.
This site also uses stylesheet to color this kind of hyperlinks
in green color -- to distingush them from regular ones.
Direct hyperlink
And the last, but not least way to include regular hyperlink:
<a target=_blank href=http://nsg.upor.net/slide/yasre/rule.htm?A[B,C]D>Click</a>
Click
You can even put this link on your windows desktop, or even in Start menu --
instead of that stupid calculator in Accessories.
Support
If you have any problems (other than complains that it is not working in
Netscape or FireFox) regarding this software, please, feel free
to contact me.
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. Harmful when swallowed, not for use as a
flotation device, keep away from children.
[
Index page
|
Emulator
|
Notation
|
Deframe
|
Feedback
]