You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have wrapped VirtualSky into a library module for use with Google Web Toolkit (GWT).
My virtualsky object is created and displays in my webpage but virtualsky then attempts to download some extra files and these attempts all fail with a 404 file not found error.
VirtualSky is generating incorrect paths to these extra files.
And that seems to happen in virtualsky.js around lines 236 to 252:
// Identify the default base directory
this.setDir = function(){
var d = S('script[src*=virtualsky]').attr('src')[0].match(/^.//);
this.dir = d && d[0] || "";
return;
};
this.getDir = function(pattern){
if(typeof pattern!=="string") pattern = "virtualsky";
var d = S('script[src='+pattern+']').attr('src');
if(typeof d==="string") d = [d];
if(d.length < 1) d = [""];
d = d[0].match(/^.*//);
return d && d[0] || "";
};
this.q = S.query(); // Query string
this.setDir(); // Set the default base directory
this.dir = this.getDir(); // the JS file path
I think VirtualSky expects to find only a single <script> tag containing the text 'virtualsky' and extracts the 'current script path' from this tag.
But my webpage contains three <script> tags and VirtualSky parses the 'src' attribute of the first tag added to the page: http://hyperv-debian.lan:8080/VirtualSky/virtualskyhost/virtualskyhost.nocache.js
It concludes that the 'current script path' is 'virtualskyhost' and generates the paths to the extra files using this base path.
VirtualSky needs to instead parse the 'src' attribute of the <script> tag that loaded 'virtualsky.min.js'.
The text was updated successfully, but these errors were encountered:
Looking for virtualsky.min.js breaks if someone was not using the minified version of the script i.e. virtualsky.js. Obviously it isn't ideal. The quickest solution is for you to change the naming of your script path so that it doesn't match virtualsky.
Thanks for the reply.
I've taken a few days to consider a solution and came up with something that works perfectly and doesn't require a change to my webapp's script path...
I simply remove my webapp's <script> element from the document after my webapp has loaded but before injecting the VirtualSky <script> element into the document.
VirtualSky then correctly finds the <script> tag from which it was loaded and correctly builds the paths to the extras files.
I have wrapped VirtualSky into a library module for use with Google Web Toolkit (GWT).
My virtualsky object is created and displays in my webpage but virtualsky then attempts to download some extra files and these attempts all fail with a 404 file not found error.
My internal development link is: http://hyperv-debian.lan:8080/VirtualSky/
My web app's webpage contains a single <script> tag for it's javascript: http://hyperv-debian.lan:8080/VirtualSky/virtualskyhost/virtualskyhost.nocache.js
The web app javascript loads and eventually injects two <script> tags into my webpage and then creates the virtualsky object.
The two script tags are for:
https://slowe.github.io/VirtualSky/stuquery.min.js
https://slowe.github.io/VirtualSky/virtualsky.min.js
The 404 requests are for:
http://hyperv-debian.lan:8080/VirtualSky/virtualskyhost/lang/en.json
http://hyperv-debian.lan:8080/VirtualSky/virtualskyhost/virtualsky-planets.js
http://hyperv-debian.lan:8080/VirtualSky/virtualskyhost/lines_latin.json
http://hyperv-debian.lan:8080/VirtualSky/virtualskyhost/stars.json
VirtualSky is generating incorrect paths to these extra files.
And that seems to happen in virtualsky.js around lines 236 to 252:
// Identify the default base directory
this.setDir = function(){
var d = S('script[src*=virtualsky]').attr('src')[0].match(/^.//);
this.dir = d && d[0] || "";
return;
};
this.getDir = function(pattern){
if(typeof pattern!=="string") pattern = "virtualsky";
var d = S('script[src='+pattern+']').attr('src');
if(typeof d==="string") d = [d];
if(d.length < 1) d = [""];
d = d[0].match(/^.*//);
return d && d[0] || "";
};
this.q = S.query(); // Query string
this.setDir(); // Set the default base directory
this.dir = this.getDir(); // the JS file path
I think VirtualSky expects to find only a single <script> tag containing the text 'virtualsky' and extracts the 'current script path' from this tag.
But my webpage contains three <script> tags and VirtualSky parses the 'src' attribute of the first tag added to the page:
http://hyperv-debian.lan:8080/VirtualSky/virtualskyhost/virtualskyhost.nocache.js
It concludes that the 'current script path' is 'virtualskyhost' and generates the paths to the extra files using this base path.
VirtualSky needs to instead parse the 'src' attribute of the <script> tag that loaded 'virtualsky.min.js'.
The text was updated successfully, but these errors were encountered: