BB FANS

UK Big Brother Forums






Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Any JavaScript programmers ?
PostPosted: 21 Oct 05, 22:06 
Offline
Big Brother
User avatar
 Profile

Joined: 24 Jan 03, 0:17
Posts: 3253
Location: Northamptonshire
Does anybody know how I can check the availability of a file (Image) from a list of websites before using the image on my weather website ?

Basically I'm using a satellite image but it's not always available from some of the sources due to server usage.
I have some Webcam script that I use to reload the image within the page without reloading the whole page. All I do is give it a delay after which it gets the image before reloading it on to the page.

It works well as I have three images on the page all different sources including my weather station (Uploaded every 10 minutes) with different delays. And I spotted the typo last night that has stopped the Rain Radar image from updating so I now have it as my desktop but it can also be viewed from

http://www.bigbrotherworldwide.com/liveweather.html

Any ideas ?

Also the Radar image works fine locally but not on-line ? Feel free to look at the source code. The webcam script isn't mine but is in use by a radio station for it's studio cam ,think some bits have been slightly modified.

_________________
ImageMy Cancer Research Fund Raising Website


Top
 
 Post subject:
PostPosted: 22 Oct 05, 23:16 
Offline
Big Brother
User avatar
 Profile

Joined: 24 Jan 03, 0:17
Posts: 3253
Location: Northamptonshire
I found an example that checks an image URL so have tried to modify it .But the main problem problem is that I'm a VisualBasic user rather than C and JavaScript is more like C.

I've give you the code I'm trying to get working ,both C and JavaScript users will be able to spot the errors.
The Functions worked ok and only the'testimage' function had a external variable passed to it. Not sure I've it'll work that way I'm trying .
The idea at this stage is to check six Image URLs and count the number of good links. What I'll try and do in the end is to use the first good URL as the one to provide the satellite image and then at each sheduled update to recheck. Putting them in order of preference so the colour images will be first and the black and white images towards the bottom of the list.

Here is the code

int lkgood[] = new int[7];
char iurl[] = new char[7];
iurl[1] = 'http://www.wetterzentrale.de/pics/D2u.jpg';
iurl[2] = 'http://meteocentre.com/sat_europe/latest_euir.gif';
iurl[3] = 'http://oiswww.eumetsat.org/~idds/images/out/latest/D2_07_1_latest.jpg';
iurl[4] = 'http://www.west-cheshire.ac.uk/weahter/images/weteosat/d2b.jpg';
iurl[5] = 'http://www.eurometeo.com/img-meteosat/D2.jpg';
iurl[6] = 'http://imkhp2.physik.uni-karlsruhe.de/~muehr/satpicsf/ulm/latir.jpg';
int good;
int x;

for (x=1; x<7; x++)
{
testimage (iurl[x], lkgood[x]);
}

for (x=1; x<7; x++)
{
good = good + lkgood[x];
}
alert (good + 'Links');


function testimage(URL,condx ,x) {
var tester=new Image();
tester.onload=isgood(condx, x);
tester.onerror=isbad(condx ,x);
tester.src=URL;
}

function isgood(condx,x) {
lkgood[x]=1;
}

function isbad(condx,x) {
lkgood[x]=0;
}


Unfortunatly I'm not a member of any programming forum and I guess there probably won't be any on here but you never know.

_________________
ImageMy Cancer Research Fund Raising Website


Top
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © phpBB Group. All trademarks and copyrights on this page are owned by their respective owners. Material breaching copyright laws should be reported to webmaster (-at-) bbfans.com. BBFans.com is in no way affilated with Channel4 or Endemol.