|
18 | 18 | padding: 0px;
|
19 | 19 | font-size: 1em;
|
20 | 20 | }
|
21 |
| - #starmapper { height: 400px; width:500px; position: relative; } |
| 21 | + #starmapper, #starmapper2 { height: 400px; width:500px; position: relative; } |
22 | 22 | #virtualskyinfobox{
|
23 | 23 | font-size: 12px;
|
24 | 24 | display:none;
|
|
48 | 48 | <script src="virtualsky.js" type="text/javascript"></script>
|
49 | 49 | <script>
|
50 | 50 | $.noConflict();
|
| 51 | + var sky; |
51 | 52 | jQuery(document).ready(function($) {
|
52 | 53 | function assert_equal(actual,expected,message){
|
53 | 54 | equal(actual,expected,message);
|
|
67 | 68 | test("Initiation",function(){
|
68 | 69 |
|
69 | 70 | jQuery('#starmapper').remove();
|
| 71 | + jQuery('#starmapper2').remove(); |
70 | 72 |
|
71 | 73 | // Try setting up a planetarium with no ID provided
|
72 |
| - var sky = jQuery.virtualsky({}); |
| 74 | + sky = jQuery.virtualsky({}); |
73 | 75 | assert_equal(sky.id,"","No ID should be set if none is provided");
|
74 | 76 |
|
75 | 77 | var match = 0;
|
|
85 | 87 | // We will add a DOM element then assign it
|
86 | 88 | // Remove the existing DOM element
|
87 | 89 | jQuery('#starmapper').remove();
|
| 90 | + jQuery('#starmapper2').remove(); |
88 | 91 | jQuery('body').append('<div id="starmapper"><\/div>');
|
89 | 92 |
|
90 | 93 | sky = jQuery.virtualsky({id:'starmapper',projection:'stereo'});
|
|
106 | 109 |
|
107 | 110 | var d2r = Math.PI/180;
|
108 | 111 |
|
109 |
| - test("Times and Locations",function(){ |
| 112 | + test("Angles",function(){ |
| 113 | + |
| 114 | + sky = jQuery.virtualsky({id:'angletest','projection':'polar','width':700,'height':700}); |
| 115 | + |
| 116 | + assert_almost_equal(sky.greatCircle(180*d2r,0,180*d2r,0),0*d2r,8,"Great Circle distance for same point is zero"); |
| 117 | + assert_almost_equal(sky.greatCircle(180*d2r,0,90*d2r,0),90*d2r,8,"Great Circle distance for points separated around the equator"); |
| 118 | + assert_almost_equal(sky.greatCircle(180*d2r,0,180*d2r,45*d2r),45*d2r,8,"Great Circle distance for points separated in declination"); |
| 119 | + assert_almost_equal(sky.greatCircle(0,0,360*d2r,45*d2r),45*d2r,8,"Great Circle distance for points separated in declination and 360 degrees different"); |
| 120 | + assert_almost_equal(sky.greatCircle(10*d2r,0,10*d2r,45*d2r),45*d2r,8,"Great Circle distance for points separated in declination but at the same non-zero RA"); |
| 121 | + assert_almost_equal(sky.greatCircle(10*d2r,45*d2r,10*d2r,-45*d2r),90*d2r,8,"Great Circle distance for points separated in declination but at the same non-zero RA"); |
| 122 | + assert_almost_equal(sky.greatCircle(-180*d2r,0,180*d2r,45*d2r),45*d2r,8,"Great Circle distance for points separated in declination and 360 degrees different (one negative)"); |
| 123 | + assert_almost_equal(sky.greatCircle(190*d2r,20*d2r,10*d2r,20*d2r),140*d2r,8,"Great Circle distance for points at the same non-zero declination but 360 degrees appart in RA"); |
| 124 | + |
| 125 | + }); |
| 126 | + |
| 127 | + sky = jQuery.virtualsky({id:'starmapper'}); |
110 | 128 |
|
111 |
| - var sky = jQuery.virtualsky({id:'starmapper'}); |
| 129 | + |
| 130 | + test("Times and Locations",function(){ |
112 | 131 |
|
113 | 132 | var str = 'October 25, 1985 01:21:00'
|
114 | 133 | var clock = new Date(str);
|
|
151 | 170 |
|
152 | 171 | });
|
153 | 172 |
|
154 |
| - test("Angles",function(){ |
155 |
| - |
156 |
| - var sky = jQuery.virtualsky({id:'angletest','projection':'polar','width':700,'height':700}); |
157 |
| - |
158 |
| - assert_almost_equal(sky.greatCircle(180*d2r,0,180*d2r,0),0*d2r,8,"Great Circle distance for same point is zero"); |
159 |
| - assert_almost_equal(sky.greatCircle(180*d2r,0,90*d2r,0),90*d2r,8,"Great Circle distance for points separated around the equator"); |
160 |
| - assert_almost_equal(sky.greatCircle(180*d2r,0,180*d2r,45*d2r),45*d2r,8,"Great Circle distance for points separated in declination"); |
161 |
| - assert_almost_equal(sky.greatCircle(0,0,360*d2r,45*d2r),45*d2r,8,"Great Circle distance for points separated in declination and 360 degrees different"); |
162 |
| - assert_almost_equal(sky.greatCircle(10*d2r,0,10*d2r,45*d2r),45*d2r,8,"Great Circle distance for points separated in declination but at the same non-zero RA"); |
163 |
| - assert_almost_equal(sky.greatCircle(10*d2r,45*d2r,10*d2r,-45*d2r),90*d2r,8,"Great Circle distance for points separated in declination but at the same non-zero RA"); |
164 |
| - assert_almost_equal(sky.greatCircle(-180*d2r,0,180*d2r,45*d2r),45*d2r,8,"Great Circle distance for points separated in declination and 360 degrees different (one negative)"); |
165 |
| - assert_almost_equal(sky.greatCircle(190*d2r,20*d2r,10*d2r,20*d2r),140*d2r,8,"Great Circle distance for points at the same non-zero declination but 360 degrees appart in RA"); |
166 |
| - |
167 |
| - }); |
168 |
| - |
169 |
| - |
170 | 173 | test("Keyboard input",function(){
|
171 | 174 |
|
172 | 175 | function keypress(key,sky){
|
|
177 | 180 | sky.mouseover = mouse;
|
178 | 181 | }
|
179 | 182 |
|
180 |
| - var sky = jQuery.virtualsky({id:'starmapper'}); |
181 | 183 | var mag = sky.magnitude;
|
182 | 184 |
|
183 | 185 | keypress(38,sky);
|
|
199 | 201 |
|
200 | 202 | var clock = new Date();
|
201 | 203 | keypress('8',sky);
|
202 |
| - ok(sky.clock-clock < 2,"Keypress (8): Time is set to now"); |
| 204 | + var diff = sky.clock-clock; |
| 205 | + ok(diff < 10,"Keypress (8): Time is set to now ("+clock+", "+sky.clock+", "+(diff)+")"); |
203 | 206 |
|
204 | 207 | });
|
205 | 208 |
|
206 |
| - test("Custom input",function(){ |
207 |
| - |
208 |
| - var sky = jQuery.virtualsky({id:'starmapper',constellationboundaries: true, |
209 |
| - boundaries: [ |
210 |
| - ["And",343,34.5,343,52.5,350,52.5,350,50,353.75,50,353.75,48,2.5,48,2.5,46,13,46,13,48,16.75,48,16.75,50,20.5,50,25,50,25,47,30.625,47,30.625,50.5,37.75,50.5,37.75,36.75,30,36.75,30,35,21.125,35,21.125,33,10.75,33,10.75,23.75,12.75,23.75,12.75,21,2.125,21,2.125,22,1,22,1,28,0,28,0,31.33333,356.25,31.33333,356.25,32.08333,352.5,32.08333,352.5,34.5,343,34.5], |
211 |
| - ["Ori",69.25,0,69.25,15.5,74.5,15.5,74.5,16,80,16,80,15.5,84,15.5,84,12.5,86.5,12.5,86.5,18,85.5,18,85.5,22.83333,88.25,22.83333,88.25,21.5,93.25,21.5,93.25,17.5,94.625,17.5,94.625,12,94.625,10,93.625,10,93.625,0,93.625,-4,87.5,-4,87.5,-11,76.25,-11,76.25,-4,70,-4,70,0,69.25,0] |
212 |
| - ] |
213 |
| - }); |
214 |
| - assert_equal(sky.boundaries.length,2,"Provided boundaries are used") |
215 |
| - |
216 |
| - |
217 |
| - }); |
218 |
| - |
219 | 209 | test("Languages",function(){
|
220 |
| - var sky = jQuery.virtualsky({id:'starmapper',lang:'en'}); |
221 |
| - assert_equal(sky.getPhrase("sun"),"Sun","Check English Sun exists"); |
222 |
| - sky.changeLanguage('es'); |
223 |
| - assert_equal(sky.lang.code,"es","Change language to Spanish"); |
224 |
| - assert_equal(sky.getPhrase("sun"),"Sol","Check Spanish Sol exists"); |
| 210 | + function testLang(code,sun){ |
| 211 | + stop(); |
| 212 | + sky.changeLanguage(code,function(e){ |
| 213 | + assert_equal(sky.langcode,code,"Change language to "+this.htmlDecode(this.langs[code].language.name)); |
| 214 | + assert_equal(sky.getPhrase("sun"),sun,"Check "+sun+" is translation of 'Sun'"); |
| 215 | + start(); |
| 216 | + }); |
| 217 | + |
| 218 | + } |
225 | 219 |
|
| 220 | + testLang('en','Sun'); |
| 221 | + testLang('es','Sol'); |
| 222 | + testLang('fr','Soleil'); |
226 | 223 | });
|
227 | 224 |
|
| 225 | + |
228 | 226 | test("JSON callbacks",function(){
|
229 | 227 |
|
230 |
| - var sky = jQuery.virtualsky({id:'starmapper'}); |
231 |
| - |
232 | 228 | // We need to stop qunit until we get the ajax callback
|
233 | 229 | stop();
|
234 | 230 | sky.load('stars',sky.file.stars,function(e){
|
|
269 | 265 |
|
270 | 266 | test("Add Pointers",function(){
|
271 | 267 |
|
272 |
| - var sky = jQuery.virtualsky({id:'starmapper'}); |
273 |
| - |
274 | 268 | assert_equal(1,sky.addPointer({'ra':83.6330833,'dec':22.0145,'label':'M1 - Crab Nebula','html':'Blah blah','url':'http://www.strudel.org.uk/lookUP/?name=M1',colour:'rgb(220,220,255)'}),"Add a first pointer");
|
275 | 269 | assert_equal(2,sky.addPointer({'ra':148.9684583,'dec':69.6797028,'label':'M82','url':'http://www.strudel.org.uk/lookUP/?name=M82',colour:'rgb(220,220,255)'}),"Add a 2nd pointer");
|
276 | 270 |
|
277 | 271 | });
|
278 | 272 |
|
| 273 | + test("Custom input",function(){ |
| 274 | + |
| 275 | + jQuery('#starmapper2').remove(); |
| 276 | + var sky2 = jQuery.virtualsky({id:'starmapper2',constellationboundaries: true, |
| 277 | + boundaries: [ |
| 278 | + ["And",343,34.5,343,52.5,350,52.5,350,50,353.75,50,353.75,48,2.5,48,2.5,46,13,46,13,48,16.75,48,16.75,50,20.5,50,25,50,25,47,30.625,47,30.625,50.5,37.75,50.5,37.75,36.75,30,36.75,30,35,21.125,35,21.125,33,10.75,33,10.75,23.75,12.75,23.75,12.75,21,2.125,21,2.125,22,1,22,1,28,0,28,0,31.33333,356.25,31.33333,356.25,32.08333,352.5,32.08333,352.5,34.5,343,34.5], |
| 279 | + ["Ori",69.25,0,69.25,15.5,74.5,15.5,74.5,16,80,16,80,15.5,84,15.5,84,12.5,86.5,12.5,86.5,18,85.5,18,85.5,22.83333,88.25,22.83333,88.25,21.5,93.25,21.5,93.25,17.5,94.625,17.5,94.625,12,94.625,10,93.625,10,93.625,0,93.625,-4,87.5,-4,87.5,-11,76.25,-11,76.25,-4,70,-4,70,0,69.25,0] |
| 280 | + ] |
| 281 | + }); |
| 282 | + assert_equal(sky2.boundaries.length,2,"Provided boundaries are used") |
| 283 | + |
| 284 | + }); |
| 285 | + |
279 | 286 |
|
280 | 287 | });
|
281 | 288 |
|
|
0 commit comments