Closed Thread Icon

Preserved Topic: Random quote generator (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=17850" title="Pages that link to Preserved Topic: Random quote  generator (Page 1 of 1)" rel="nofollow" >Preserved Topic: Random quote  generator <span class="small">(Page 1 of 1)</span>\

 
mahjqa
Maniac (V) Mad Scientist

From: The Demented Side of the Fence
Insane since: Aug 2000

posted posted 08-29-2000 00:39

I've been puzzling a lot of time on a javascript proggie that would show a quote on my page and change it, let's say, every 30 seconds. (for your convenience i've located all the quotes below) does anyone know if there exists such a program? (I've run into difficulties I can't solve by myself)

(BTW, I have flash 4 so mebbe that's an option...)

don't piss me off! I'm running out of places to hide the bodies.
I don't believe in miracles. I rely on them.
Next mood swing: 6 minutes.
I hate everybody, and you're next.
And your point is...
I used to be schizophrenic, but we're okay now.
I'm busy. You're ugly. Have a nice day.
Warning: I have an attitude and I know how to use it.
Remember my name - you'll be screaming it later.
Of course I don't look busy .. I did it right the first time.
Why do people with closed minds always open their mouths?
I'm multi-talented: I can talk and piss you off at the same time.
Do NOT start with me. You will NOT win.
You have the right to remain silent, so please SHUT UP.
All stressed out and no one to choke.
I'm on of those bad things that happens to good people.
How can I miss you if you won't go away?
Sorry if I look interested. I'm not.
If we are what eat, I'm fast, cheap and easy.
and your pathetic whiney-assed opinion would be...?
I don't suffer from insanity, I ENJOY EVERY MINUTE OF IT!!!!

and some sponsored ones for Docozone:

ozones.com- better than your future
ozones.com- the one-stop for your up-to-the-minute personal insults
ozones.com- the wonder of 1's and 0's
ozones.com- All this visitors and not a single toilet in sight
ozones.com- just when you thought it's safe again
ozones.com- ummm, did we mention that it's free?
ozones.com- We keep going and going and going and.......
ozones.com- If at first you don't succeed, hit 'Ctrl' & 'Alt' & 'Del'.
ozones.com- You must be over 18 months to enter this site
ozones.com- have it your way
ozones.com- Controlled Chaos at It's Best
ozones.com- low-technicolor
ozones.com- Now you know why there is a monitor in front of you.
ozones.com- Catch it while supplies last.
ozones.com- Don't say we didn't warn you.
ozones.com- Life sucks; we don't.
ozones.com- Finally! A reason for all those error messages.
ozones.com- Is like chinese food... twenty minutes later your hungry for more!
ozones.com- Think we're ugly? Just be glad you can't smell us!
ozones.com- Hax0r'5 p4r4d153.
ozones.com- Hallelujah!
ozones.com-Wecan'taffordanyspaces.Allourmoneyisgoingtoserveyoubetter.
ozones.com- And they said it was impossible.
ozones.com- I'm where? You're who?
ozones.com- Your worst nightmare.
ozones.com- The Matrix has you.
ozones.com- We know what you want, you want what we got!
ozones.com- Our msgboard works.
ozones.com- Resistance Is Futile
ozones.com- Are you as think as we drunk you are?
ozones.com- if yer reading this, you got too much time on your hands
ozones.com- batteries not included
ozones.com- testing, 1 2 3.. is this thing on?
ozones.com- Better than Life.
ozones.com- Just do it.
ozones.com- Use the force.
ozones.com- 42?? That's it??
ozones.com- Aren't the banners wonderful this time of the year?
ozones.com- Nothing Personal
ozones.com- All we need is a Blue Screen of Death wallpaper.
ozones.com- Drag "My Computer" to "Recycle Bin" -- it's fun.
ozones.com- what's this button do?
ozones.com- We are not secretly owned by Microsoft.
ozones.com- I think you get it.

: : M a h j q a : :

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-29-2000 01:09

What a coincidence - I've written such a script myself, and it's currently active on my front page (which, by the way, is down for the time being). Here's the code:

<script language="JavaScript">
function RandomText()
{
var RandNum = Math.random()*4;
if (RandNum <= 1) return "This is a quote.";
else if (RandNum <= 2) return "This is also a quote.";
else if (RandNum <= 3) return "More quotes can be added in the same way.";
else if (RandNum <= 4) return "<p>Even HTML can be used!</p>";
}
</script>

If you add more quotes, make sure you increment the number "4" in Math.random()*4, in the first line.
Then, in the source of the page somewhere, use this code to print the random quote:

<script language="JavaScript">
document.write(RandomText());
</script>

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-29-2000 01:12

Oh, yeah, as for changing it every thirty seconds... that's a lot more complicated, unless you refresh the page. In fact, I'm not even sure I know of a practical way that works universally.

little osh
Bipolar (III) Inmate

From: Wales, UK
Insane since: Jun 2000

posted posted 08-29-2000 09:12

Use the switch statement and a DIV tag. (The switch statememnt is a lot more efficient that a bunch of else ifs).


<HTML>
<HEAD>
<TITLE>Quote Generator</TITLE>

<SCRIPT language="JavaScript">
var IE = (document.all) ? 1:0;
var NN = 1 - IE;

var id, curr_quote =0;
var NUMOF_QUOTES=4;

if (IE)
{
doc = "document.all";
htm = "";
}
else if (NN)
{
doc = "document";
htm = ".document";
}


function getRandomQuote()
{
var new_quote = Math.floor(Math.random()*NUMOF_QUOTES);

if (new_quote == curr_quote)
if(++new_quote >= NUMOF_QUOTES)
new_quote = 0;

curr_quote = new_quote;

switch (new_quote) {
case 0: return "Quote number 1";
case 1: return "Quote number 2";
case 2: return "Quote number 3";
case 3: return "Quote number 4";
}
}


function setDivValue()
{
clearTimeout(id);

var status = eval(doc + "['quoteLay']" + htm);
var quote = getRandomQuote();

if (IE)
status.innerHTML = quote;
else if (NN)
{
status.open();
status.write(quote);
status.close();
}

id = window.setTimeout("setDivValue()",30000);
}

</SCRIPT>

</HEAD>
<BODY onLoad="setDivValue()">
<DIV id="quoteLay" style="position:absolute; left:200; top:200;">
Default Quote
</DIV>
</BODY>
</HTML>

Does somebody have a challange out there? I'm not getting any at work!!!

osh

mahjqa
Maniac (V) Mad Scientist

From: The Demented Side of the Fence
Insane since: Aug 2000

posted posted 08-29-2000 13:09

Thank you both... I decided to forget about the 30 minutes change.and keep the document.write one. Heck, I'm lazy. But thanks anyways!

: : M a h j q a : :

mbridge
Paranoid (IV) Mad Scientist

From:
Insane since: Jun 2000

posted posted 08-30-2000 00:54

30,000 is only a thirty second break, not a thirty minute break because it's in ms

timothymcnulty
Neurotic (0) Inmate
Newly admitted
posted posted 08-30-2000 01:44

heh, i think that minutes thing was a mistake, meant to say seconds.....
if you are creating random quotes every thirty minutes and expect people to be around to see it, i want to see your homepage.....
it has got to be *very* interesting.....

i don't think that i have stayed on one site for thirty minutes...well ever...

little osh
Bipolar (III) Inmate

From: Wales, UK
Insane since: Jun 2000

posted posted 08-30-2000 03:36

30 seconds is what the original post said!

Personally I think even that's too long. It depends of course on the length of the quote as to how long it should stay up there, but I'd think that 5s is a long enough pause for most things, for the exact reasons that timothy pointeed out.

osh

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-30-2000 03:40

Well, doesn't really matter now that he's decided not to do it.

You're right, Little Osh, I *should* have used the switch statement. Why don't I ever use that? I dunno.

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 08-30-2000 20:18

Just to offer an alternative, you could use the Perl script on Matt's Script Archive since you're not going to be refreshing it every 30 whatevers anymore. That way you wouldn't have to download the entire quote list with the page, which I suppose wouldn't be a big deal if it's a short list, but if it's going to get long...


Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 09-04-2000 14:40

Have you ever thought of adding some quotes from God like the one I have at the bottom of my signature, or others like:

If I'm so out of touch, how come I know what happens next?
Hope you don't have anything planned for this weekend.
or
Large, white and hairy...either I've just described me, or the abomanable snowman, which would YOU rather worship?

I got a gun for my wife...it was the best trade I ever made
I'm not a complete idiot, some parts got lost in the mail.




Don't make me come down there! - God

DocOzone
Maniac (V) Lord Mad Scientist
Sovereign of all the lands Ozone and just beyond that little green line over there...

From: Stockholm, Sweden
Insane since: Mar 1994

posted posted 09-04-2000 20:28

Thank you! I for one, saved that code, tested it, it works great in Netscape on the mac, and will probably work gresat on IE, and once I hack into it and trim it down to 4 lines it's going to show up *everywhere* on my newest pages! This is something I've wanted to figure out on my own, but haven't had the time yet, this rocks. (Neat coding style, too!)

"little osh" gets a front page link to the site of his choice for 7 days, let me know where and what you'd like me to link to, osh!

Your pal, -doc-

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-04-2000 20:50

Hmm, I have a related question. Math.random() returns a number between zero and one. BUT... is it possible for it to return exactly one? That could cause a problem with Math.floor(Math.random()*3) - it would be able to return 0, 1, 2, or 3. And it would barely ever call 3, but when it did, there would be errors.

SO... does anyone know if this is possible? That's why I used less-than-or-equal-tos in my script.

tea
Nervous Wreck (II) Inmate

From: Bern, Switzerland
Insane since: Aug 2000

posted posted 09-05-2000 00:14

Why not using an Array instead of Switch?
Like this:
var myMessages = new Array(
"<b>Sichtprüfung</b> : Ein glänzender und eleganter Wein",
"mit <i>goldgelbem</i>, relativ kräftigem Farbton.",
"Geruchsprobe : Intensives, volles Bukett.",
"Es entfaltet sich ein Duft von");

Get the message with direct access:
myMessages[messnr]

I used it in: http://www.tea.ch/javascript/fader/

cu, tea

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-05-2000 00:30

Good thinking.

By the way, on that page, you need to set the background color to white - white's not the default color on all systems, mine's a light green to reduce contrast with text, and your fading script doesn't completely work for me because of it. Nice page nonetheless!

tea
Nervous Wreck (II) Inmate

From: Bern, Switzerland
Insane since: Aug 2000

posted posted 09-05-2000 01:01

thanks, i just set the background color to white.
well it isn't that important, it's only a experimental page.

Doesn't randomnumber genrators return values 0 < x < 1 and
not 0 <= x <= 1 ?

And the following shouldn't provoke out of index errors:
myMessages[Math.floor(Math.random()*myMessages.length)]

cu, tea

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-05-2000 02:28

Yeah, I guess the generators return a number 0 <= x < 1. I'm not sure about zero, but i'm not going to rule it out.

If it *could* return 1, though, then that would be a problem:
myMessages[Math.floor(1*myMessages.length)] == myMessages[myMessages.length],
which doesn't exist.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-11-2000 23:20

The one I've used is from Matt's Script Archive. The cool thing about that one is that your quote line can be HTML. So it can randomize a picture, text, picture & text, formatting, etc...
The quotes are in a text file, which can then be called from other pages as well.

Pat Richard
Web weenie
http://www.gurusnetwork.com
ICQ 23113317

little osh
Bipolar (III) Inmate

From: Wales, UK
Insane since: Jun 2000

posted posted 09-12-2000 09:06

You can put HTML into the quotes of that code up there too!

But I don't know how to read from a text file in JavaScript. Could anyone tell me that, that would be cool for future reference!

You can't write to a file in JavaScript can you!? That's breaks the language's security code doesn't it?

osh

« BackwardsOnwards »

Show Forum Drop Down Menu