Connecting Tech Pros Worldwide Forums | Help | Site Map

Help - easier way to load different pics ie er.jpg del.gif?

David. E. Goble
Guest
 
Posts: n/a
#1: Jul 23 '05
Hi all;

I have the following code;

var picssigs = new Array(
"sigs/finished1.jpg",
"sigs/foghorn.jpg",
"sigs/motto.jpg",
"sigs/sig.jpg",
"sigs/SWAT.jpg",
"sigs/title.gif"
);
var pictsigs = Math.round(Math.random()*(picssigs.length-1));
for (var i=0; i<picssigs.length; i++)
{
var imgsigs = new Image();
imgsigs.src = picssigs[i];
}

If I rename all the files as numbers ie 1.jpg, 2.jpeg, 3.gif. Can I
then some how load these.

Or would I first need to make sure they have the same extension.
Regards David. E. Goble
http://degoble.customer.netspace.net.au
degoble[AT]netspace.net.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223



Random
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Help - easier way to load different pics ie er.jpg del.gif?


Same extension, man.



David. E. Goble wrote:[color=blue]
> Hi all;
>
> I have the following code;
>
> var picssigs = new Array(
> "sigs/finished1.jpg",
> "sigs/foghorn.jpg",
> "sigs/motto.jpg",
> "sigs/sig.jpg",
> "sigs/SWAT.jpg",
> "sigs/title.gif"
> );
> var pictsigs = Math.round(Math.random()*(picssigs.length-1));
> for (var i=0; i<picssigs.length; i++)
> {
> var imgsigs = new Image();
> imgsigs.src = picssigs[i];
> }
>
> If I rename all the files as numbers ie 1.jpg, 2.jpeg, 3.gif. Can I
> then some how load these.
>
> Or would I first need to make sure they have the same extension.
> Regards David. E. Goble
> http://degoble.customer.netspace.net.au
> degoble[AT]netspace.net.au
> Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223[/color]

David. E. Goble
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Help - easier way to load different pics ie er.jpg del.gif?


Well thats a bugger as some of the pics are smaller in gif format,
while others look better in jpg.

On 24 May 2005 03:34:11 -0700, "Random" <randomiez@gmail.com> wrote:[color=blue]
>Same extension, man.
>
>
>
>David. E. Goble wrote:[color=green]
>> Hi all;
>>
>> I have the following code;
>>
>> var picssigs = new Array(
>> "sigs/finished1.jpg",
>> "sigs/foghorn.jpg",
>> "sigs/motto.jpg",
>> "sigs/sig.jpg",
>> "sigs/SWAT.jpg",
>> "sigs/title.gif"
>> );
>> var pictsigs = Math.round(Math.random()*(picssigs.length-1));
>> for (var i=0; i<picssigs.length; i++)
>> {
>> var imgsigs = new Image();
>> imgsigs.src = picssigs[i];
>> }
>>
>> If I rename all the files as numbers ie 1.jpg, 2.jpeg, 3.gif. Can I
>> then some how load these.
>>
>> Or would I first need to make sure they have the same extension.
>> Regards David. E. Goble
>> http://degoble.customer.netspace.net.au
>> degoble[AT]netspace.net.au
>> Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223[/color][/color]

Regards David. E. Goble
http://degoble.customer.netspace.net.au
degoble[AT]netspace.net.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223


Random
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Help - easier way to load different pics ie er.jpg del.gif?


Well, if you have a lot of them, you might consider building the Images
in two loops. Use one loop for *.jpg and one for *.gif.

Otherwise... it's only a few lines of code. I'd say leave it be.


David. E. Goble wrote:[color=blue]
> Well thats a bugger as some of the pics are smaller in gif format,
> while others look better in jpg.
>
> On 24 May 2005 03:34:11 -0700, "Random" <randomiez@gmail.com> wrote:[color=green]
> >Same extension, man.
> >
> >
> >
> >David. E. Goble wrote:[color=darkred]
> >> Hi all;
> >>
> >> I have the following code;
> >>
> >> var picssigs = new Array(
> >> "sigs/finished1.jpg",
> >> "sigs/foghorn.jpg",
> >> "sigs/motto.jpg",
> >> "sigs/sig.jpg",
> >> "sigs/SWAT.jpg",
> >> "sigs/title.gif"
> >> );
> >> var pictsigs = Math.round(Math.random()*(picssigs.length-1));
> >> for (var i=0; i<picssigs.length; i++)
> >> {
> >> var imgsigs = new Image();
> >> imgsigs.src = picssigs[i];
> >> }
> >>
> >> If I rename all the files as numbers ie 1.jpg, 2.jpeg, 3.gif. Can[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> >> then some how load these.
> >>
> >> Or would I first need to make sure they have the same extension.
> >> Regards David. E. Goble
> >> http://degoble.customer.netspace.net.au
> >> degoble[AT]netspace.net.au
> >> Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223[/color][/color]
>
> Regards David. E. Goble
> http://degoble.customer.netspace.net.au
> degoble[AT]netspace.net.au
> Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223[/color]

David. E. Goble
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Help - easier way to load different pics ie er.jpg del.gif?


Ok well here is a link to my page;

http://bow.foggy.home.insightbb.com/test.htm

Any way of improving it. Either for readability and/or performance
wise?
Regards David. E. Goble
http://degoble.customer.netspace.net.au
degoble[AT]netspace.net.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223


Random
Guest
 
Posts: n/a
#6: Jul 23 '05

re: Help - easier way to load different pics ie er.jpg del.gif?


1. Don't try to cache all of the images at once. Most people are still
not on broadband. Instead, try caching them two or three at a time.

2. Give the option of displaying a certain number of any one set of
images-- but only one set at a time, and only a fixed number. Don't
default to showing fifty animated gifs in one shot. Not only is it
irritating, but it plays hell on slower systems with older video cards
and has been known to aid in the diagnosis of elipesy at inopportune
times.

3. Display the images in an area of fixed size, so that clicking
'Next', 'Previous', et cetera don't cause the buttons to move.

4. Account for double-clicks on the buttons.

5. Try to compact it all so it fits on a single screen. It takes a
little more organisation, but it does a lot for the 'user experience'.



David. E. Goble wrote:[color=blue]
> Ok well here is a link to my page;
>
> http://bow.foggy.home.insightbb.com/test.htm
>
> Any way of improving it. Either for readability and/or performance
> wise?
> Regards David. E. Goble
> http://degoble.customer.netspace.net.au
> degoble[AT]netspace.net.au
> Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223[/color]

McKirahan
Guest
 
Posts: n/a
#7: Jul 23 '05

re: Help - easier way to load different pics ie er.jpg del.gif?


"David. E. Goble" <degoble@gtech.computing> wrote in message
news:8p66911io46d66tsfs4btug02548hi5l9g@4ax.com...[color=blue]
> Ok well here is a link to my page;
>
> http://bow.foggy.home.insightbb.com/test.htm
>
> Any way of improving it. Either for readability and/or performance
> wise?
> Regards David. E. Goble
> http://degoble.customer.netspace.net.au
> degoble[AT]netspace.net.au
> Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
>
>[/color]


Change the varying shaped button sizes to:

<input type="button" value="<<" title="First"
<input type="button" value="<" title="Previous"
<input type="button" value=">" title="Next"
<input type="button" value=">>" title="Last"

Or use CSS to assign a fixed width:

<input type="button" style="width:50px" value="<<" title="First"
<input type="button" style="width:50px" value="<" title="Previous"
<input type="button" style="width:50px" value=">" title="Next"
<input type="button" style="width:50px" value=">>" title="Last"

Or use CSS to fancy it up; (the first part goes above the </head> tag:

<style type="text/css">
..buttons {
background-color:#FFFFFF;
font-family:Arial,Helvetica;
width:50px;
}
</style>

<input type="button" class="buttons" value="<<" title="First"
<input type="button" class="buttons" value="<" title="Previous"
<input type="button" class="buttons" value=">" title="Next"
<input type="button" class="buttons" value=">>" title="Last"

Or use images instead of text.


What's with the questions that start with
"If you have a ..."
and don't even end with a question mark?

Also, it would be helpful to describe the page's purpose.


David. E. Goble
Guest
 
Posts: n/a
#8: Jul 23 '05

re: Help - easier way to load different pics ie er.jpg del.gif?


One problem is that if you click on reload or refresh the top part
does not reload the the pics.

On Tue, 24 May 2005 21:59:43 +0930, David. E. Goble
<degoble@gtech.computing> wrote:
[color=blue]
>Ok well here is a link to my page;
>
>http://bow.foggy.home.insightbb.com/test.htm
>
>Any way of improving it. Either for readability and/or performance
>wise?
>Regards David. E. Goble
> http://degoble.customer.netspace.net.au
> degoble[AT]netspace.net.au
> Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
>[/color]

Regards David. E. Goble
http://degoble.customer.netspace.net.au
degoble[AT]netspace.net.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223


Dr John Stockton
Guest
 
Posts: n/a
#9: Jul 23 '05

re: Help - easier way to load different pics ie er.jpg del.gif?


JRS: In article <n6v591p1abbveam1n4p4332k7hpcn3fjvn@4ax.com>, dated
Tue, 24 May 2005 19:55:36, seen in news:comp.lang.javascript, David. E.
Goble <degoble@gtech.computing> posted :
[color=blue]
>var picssigs = new Array(
>"sigs/finished1.jpg",
>"sigs/foghorn.jpg",
>"sigs/motto.jpg",
>"sigs/sig.jpg",
>"sigs/SWAT.jpg",
>"sigs/title.gif"
>);
>var pictsigs = Math.round(Math.random()*(picssigs.length-1));[/color]

Note that your pictsigs is not evenly distributed over the valid
indices; see clj FAQ 4.22.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Closed Thread