JS toolbox for astronomical software interoperation based on samp.js
AstroTools depends on jQuery and modified sampjs library, so first you must include them
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="https://github.com/AnotherOneAckap/AstroTools/raw/master/js/samp.js"></script>
Then astrotools library itself:
<script type="text/javascript" src="https://github.com/AnotherOneAckap/AstroTools/raw/master/js/astrotools.js"></script>
And do not forget css file ( which you can customize )
<head>
...
<link rel="stylesheet" href="https://github.com/AnotherOneAckap/AstroTools/blob/master/css/astrotools.css" />
...
</head>
After document is loaded, you can configure and start Astrotools just like this
<script type="text/javascript">
$( function() {
AstroTools.tableId = 'data';
AstroTools.init();
});
</script>
You can pass options object to initialization function:
AstroTools.init({ iconUrl: '/media/images/icon.png });
iconUrl absolute or relative path to client icon to display in hub window
defaultHubUrl absolute or relative path to default hub ( .jnlp file to load and launch )
appendToBody boolean, true (default) — AstroTools would create HTML for its UI, false — you carry for AstroTools UI
tableOptions object which passed to Table constructor options argument
VOMenu a list of launchers shown in AstroTools panel, default is
[ { name: 'aladin', title: 'launch Aladin', link: 'http://aladin.u-strasbg.fr/java/nph-aladin.pl?frame=get&id=AladinBeta.jnlp' }, { name: 'topcat', title: 'launch Topcat', link: 'http://andromeda.star.bris.ac.uk/~mbt/topcat/topcat-full.jnlp' } ]
aladinScript an aladin script which will be send by coordinate cell handler, default is
get Aladin(DSS2) #{coords} 15arcmin;sync;"UCAC3, #{name}" = get VizieR(UCAC3,allcolumns) #{coords} #{radius}arcmin;sync;set "UCAC3, #{name}" shape=triangle color=red
where #{coords}, #{name} and #{radius} are placeholders. IMPORTANT: To be able send scripts to aladin, you must use included in distribution jnlp file as default hub. JSAMP hub used in Topcat restricts by default unknown MTypes, so it is necessary to run it with -web:norestrictmtypes key.
e.g. customizing table headings sort icons
var tOptions = { sortIcon: { asc: '<img src="https://github.com/AnotherOneAckap/AstroTools/raw/master/up.png"/>', desc: '<img src="https://github.com/AnotherOneAckap/AstroTools/raw/master/down.png"/>' } };
AstroTools.init({ tableOptions: tOptions })
var t = new AstroTools.Table( tableId, options )
makes possible to add sorting, row highlighting and point at coordinates through SAMP connection.
For example, you have table
<table id="myAwesomeTable">
...
</table>
First, your table has to be correctly marked
Table tag must have following attributes with appropriate values:
Don't miss thead and tbody tags
allows to sort columns by clicking on column headings, markup you need for this:
allows to highlight rows in table by mouse on page and on samp-clients subscribed on 'table.highlight.row' message, also receives such messages and shows selected rows. To make it work you need:
allows to show point at the sky in sky atlases like Aladin. It needs:
Just define id of your table before initialization:
AstroTools.tableId = 'myAwesomeTable';
AstroTools.init();
And after connection to hub you will receive all features described above.
<table id="myAwesomeTable"
data-vo-table-id="some_id"
data-vo-table-name="Some Catalog"
data-vo-table-url="http://somesite/sometable/">
<colgroup>
<col>
<col class="coords">
</colgroup>
<thead>
<tr>
<th data-type="string">Name</th>
<th data-type="sexagesimal">Coordinates</th>
</tr>
</thead>
<tbody>
<tr data-index="0" data-coords="06:07:27.8 +24:05:53" data-name="NGC 2158" data-radius="13.500">
<td>FooBar</td>
<td>06:07:27.8</td>
</tr>
</tbody>
</table>
You can add class at-table-link to any hyperlink making it broadcastable after connection. You must also define data-vo-table-id and data-vo-table-name attributes.
Markup Example
<a class="at-table-link" data-vo-table-id="123456" href="http://andromeda.star.bris.ac.uk/data/messier.xml" data-vo-table-name="Exampe table">Table</a>
Contact me anotheroneackap@gmail.com, if you still have a question.