Example 1
(view): Simply insert the chart
into your webpage as two lines of HTML-code, as in this example::
<img src='http://www.urania.ru/cgi-bin/ucs_chart.pl?uid=u0044&sid=ex1ch1&size=600&backgr=204,255,204'>
<!--astrodata/ex1ch1 date=07.12.2003
time=14:30 lat=55.75 lon=37.58 house=Koch /astrodata-->
The first line contains IMG-tag of picture with the astrological
chart, generated by script "usc_chart.pl", which
calculates and draws this chart. The second line contains
the astrological data as a HTML comment. Correspondence between
the chart and the data is determined by te chart identificator,
which is marked above in red.
Detailed description of parameters, used when accessing the
script and setting astrological parameters, is given in the
interface description.
A number of parameters can be set by default, as shown in
the next example.
Example 2
(view): In this example only necessary
parameters are set, and default settings are used for the
chart size, background color, date, time and house system:
<img src='http://www.urania.ru/cgi-bin/ucs_chart.pl?uid=u0044&sid=ex2ch1'>
<!--astrodata/ex2ch1 lat=-50
lon=-20 /astrodata-->
If the astrological data for the chart does not include the
date and time, in this case transit chart is drawn for the
current time, i.e., for the time when the visitor's browser
addresses the script service for the chart picture.
An experienced webdesigner can instantly say that browsers
will have problems with cashing pictures. Indeed, most browsers,
when viewing the picture page for the second time, will not
show a new picture, but an earlier picture, saved by the browser
in cash.
Example 3
(view): This example shows how
to use paratemer "rnd" and JavaScript to avoid problems
with cashing pictures by browsers and how to get a refreshed
transit chart. Astrological data, as in previous examples,
is located on the chart page as a commentary line:
<!--astrodata/ex3ch1
lat=55.75 lon=37.58 /astrodata-->
Drawing the chart and procedures for its refreshing are contained
in a separate JS file, inserted on the webpage as one line:
<script language="JavaScript"
src="example3.js"></script>
Please, see contents of example3.js file below:
var ucs_chartsrc = 'http://www.urania.ru/cgi-bin/ucs_chart.pl';
var ucs_uid = 'u0044'; // User ID
var ucs_chartid = 'ex3ch1'; //
Chart ID
var ucs_chartsize = '600';
var ucs_chartbackgr = 'transparent';
var ucs_delay = 60 * 1000; // Chart refreshing every 60 seconds
//-----------
document.writeln('<img name=chart src=' + newchartsrc()
+ ' width='+ ucs_chartsize +' height='+ ucs_chartsize +'>');
setTimeout('setnewchartsrc()', ucs_delay);
//-----------
function newchartsrc () {
var rnd = Math.round(Math.random() * 1000000000);
return ucs_chartsrc + '?uid='+ ucs_uid +'&sid='+ ucs_chartid
+'&size='+ ucs_chartsize +'&backgr='+ ucs_chartbackgr
+'&rnd=' + rnd;
}
//-----------
function setnewchartsrc () {
document.images.chart.src=newchartsrc();
setTimeout('setnewchartsrc()', ucs_delay);
}
In this example we use standard function setTimeout
to make the browser call the handler (the function setnewchartsrc),
every minute. This handler assigns to parameter "scr"
the new value of URL source address. Thanks to random meanings
of parameter "rnd" in this address, the browser
is forced not to take the chart from cash, but address the
astrological service script and obtain new chart picture.
Example 4
(view): This example shows how
to use several charts on one page. We draw two transit charts
in Placidus and Koch systems. The astrological service does
not restrict the number of charts per page; you only have
to remember, that astrological charts are pictures of 10 Kb
and more, and it takes some time for the browser to load them.
The chart is drawn by JavaScript-function chartoutput,
which has ony one parameter, chart ID. This function, as well
as the procedures for refreshing the charts, are contained
in a separate file example4.js. Please, see its contents below:
var ucs_chartsrc = 'http://www.urania.ru/cgi-bin/ucs_chart.pl';
var ucs_uid = 'u0044'; // User ID
var ucs_chartsize = '300';
var ucs_chartbackgr = 'transparent';
var ucs_delay = 60 * 1000; // Chart refreshing every 60 seconds
var ucs_rnd = 0;
//-----------
setTimeout('setnewchartsrc()', ucs_delay);
//-----------
function chartoutput (sid) {
document.writeln('<img name=chart_'+ sid +' src=' + newchartsrc(sid)
+ ' width='+ ucs_chartsize +' height='+ ucs_chartsize +' hspace=10
vspace=10>');
}
//-----------
function newchartsrc (sid) {
if(ucs_rnd == 0) ucs_rnd = Math.round(Math.random() * 1000000000);
return ucs_chartsrc + '?uid=' + ucs_uid + '&sid=' + sid
+ '&size=' + ucs_chartsize + '&backgr=' + ucs_chartbackgr
+ '&rnd=' + ucs_rnd;
}
//-----------
function setnewchartsrc () {
ucs_rnd = 0;
document.images.chart_ex4placidus.src=newchartsrc('ex4placidus');
document.images.chart_ex4koch.src=newchartsrc('ex4koch');
setTimeout('setnewchartsrc()', ucs_delay);
}
Procedures are set so that, at every refreshing, parameter
"rnd" has the same non-zero value for both charts,
thus speeding up the chart drawing by cashing astrological
data.
This is how it is done: in order to to draw the first chart,
the browser addresses the astrological script, which reads
the astrological data source for this chart. During this procedure
the service reads astrological data for all the charts and
stores it in a special cash. Parameter "rnd" is
the key to this cash, and when the browser addresses the service
for the picture of the second chart, there is no need to read
the data source again, and the astrological data for this
chart is taken from the cash.
Example 5
(view): This example shows how
to use JavaScript language to view the list of astrological
charts.
Elements of the "charts" list have values from
"chart01" up to "chart10", which are used
as charts' IDs. The chart is drawn with the help of function
setnewchartsrc, which is called
from the onChange handler of
the "charts" list. Function "setnewchartsrc"
recognizes the current chart ID and calls the astrological
service for chart picture refreshing.
As in above examples, all JavaScript constants and procedures
are contained in a separate file example5.js (please, see
its contents below).
var ucs_chartsrc = 'http://www.urania.ru/cgi-bin/ucs_chart.pl';
var ucs_uid = 'u0044'; // User ID
var ucs_chartsize = '500';
var ucs_chartbackgr = 'transparent';
var ucs_data = '/Chart/example5.data'; // Data source file
//-----------
function chartoutput (sid) {
document.writeln('<img name=chart src=' + newchartsrc(sid)
+ ' width='+ ucs_chartsize +' height='+ ucs_chartsize);
}
//-----------
function newchartsrc (sid) {
return ucs_chartsrc + '?uid=' + ucs_uid + '&sid=' + sid
+ '&size=' + ucs_chartsize + '&backgr=' + ucs_chartbackgr
+ '&rnd=1&data=' + ucs_data;
}
//-----------
function setnewchartsrc () {
var cs = document.form1.charts;
var ndx = cs.selectedIndex;
var sid = cs.options[ndx].value;
document.images.chart.src=newchartsrc(sid);
}
Note 1: This is the first example of the use of an
external astrological data source: in this case it is a simple
text file "example5.data" with the astrological
data for all the charts on the list. When setting the "data"
parameter for adressing the service, please, note the following:
a) the data source should be in the same domain as the page
with the charts;
b) it is necessary to state the full path to the source within
this domain.
Note 2: Parameter "rnd" has the same non-zero
value of 1. Because of this, the service addresses the data
source only when drawing the first chart. Data for the rest
of the charts are taken from the internal data cash. Moreover,
since the URL-address of the chart picture remains the same,
for next viewing of the chart most browsers will take this
picture from its cash, without addresing the chart drawing
service.
This was the simples example of a static HTML-file with a
fixed chart list. Programmers, experienced in work with dymanic
pages will have no problems with creating astrological charts
lists which can be edited and will be able to apply the astrological
service to already existing data bases.
Example 6
(view) - This example
shows the simplest dialogue form which allows to draw the
astrological chart for the chosen moment. Here CGI-interface
is used. Processing of the form data and generating the chart
page is done in PERL (please, see the
text of this script), but other dynamic technologies can
be used, e.g., ASP.
Brief algorithm description: the script receives
the field values of the form and remorizes it in a data source
file in the format, corresponding to the astrological
service interface; the chart ID is generated at random
in order to avoid confusion when several visitors view the
chart page at the same time (for the same purpose the source
data file contains data for several recent charts). Then the
script generates HTML-code of the chart page and returns it
to the browser. Request parameters ("sid" - chart
ID and "data" - data source) of the astrological
service clearly define, where the service should look for
the chart data.
This example allows you to create an intercative astrological
chart page; you only have to add the necessary field (name,
geographical location, e-mail, etc.), and verification of
the data entered
|