Author Topic: I am dumb, I need help  (Read 4152 times)

WMD

  • Global Moderator
  • Member
  • ***
  • Posts: 2,525
  • Kudos: 391
    • http://www.dognoodle99.cjb.net
Re: I am dumb, I need help
« Reply #15 on: 24 July 2006, 08:53 »
Java and JavaScript have nothing to do with each other.
My BSOD gallery
"Yes there's nothing wrong with going around being rude and selfish, killing people and fucking married women, but being childish is a cardinal sin around these parts." -Aloone_Jonez

H_TeXMeX_H

  • Member
  • **
  • Posts: 1,988
  • Kudos: 494
    • http://draconishinobi.50webs.com/
Re: I am dumb, I need help
« Reply #16 on: 24 July 2006, 20:32 »
Don't they ? Actually I've never used java so I wouldn't know ...

WMD

  • Global Moderator
  • Member
  • ***
  • Posts: 2,525
  • Kudos: 391
    • http://www.dognoodle99.cjb.net
Re: I am dumb, I need help
« Reply #17 on: 24 July 2006, 20:43 »
Java was created by Sun.  javaScript was created by, I think, Netscape.  They just called it that to capitalize on the Java craze.  I have no idea how they got away with it.
My BSOD gallery
"Yes there's nothing wrong with going around being rude and selfish, killing people and fucking married women, but being childish is a cardinal sin around these parts." -Aloone_Jonez

worker201

  • Global Moderator
  • Member
  • ***
  • Posts: 2,810
  • Kudos: 703
    • http://www.triple-bypass.net
Re: I am dumb, I need help
« Reply #18 on: 24 July 2006, 21:12 »
Quote from: wikipedia
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

So there you go.  No mystery at all.  Sun maintains the brand integrity of all things Java.

worker201

  • Global Moderator
  • Member
  • ***
  • Posts: 2,810
  • Kudos: 703
    • http://www.triple-bypass.net
Re: I am dumb, I need help
« Reply #19 on: 24 July 2006, 22:05 »
btw, xylon, here's an example of what the JavaScript does (working okay now):
http://www.triple-bypass.net/brickpics/pimpmech/pimp.htm

Would your replacement script do the same thing?

xyle_one

  • VIP
  • Member
  • ***
  • Posts: 2,213
  • Kudos: 135
Re: I am dumb, I need help
« Reply #20 on: 24 July 2006, 22:18 »
Quote from: worker201
btw, xylon, here's an example of what the JavaScript does (working okay now):
http://www.triple-bypass.net/brickpics/pimpmech/pimp.htm

Would your replacement script do the same thing?
Yes.

worker201

  • Global Moderator
  • Member
  • ***
  • Posts: 2,810
  • Kudos: 703
    • http://www.triple-bypass.net
Re: I am dumb, I need help
« Reply #21 on: 24 July 2006, 23:40 »
With what modifications?  When/where does the text array get filled?

xyle_one

  • VIP
  • Member
  • ***
  • Posts: 2,213
  • Kudos: 135
Re: I am dumb, I need help
« Reply #22 on: 25 July 2006, 01:04 »
Will you be on aim later? It would be easier to do this when I am not at work.

worker201

  • Global Moderator
  • Member
  • ***
  • Posts: 2,810
  • Kudos: 703
    • http://www.triple-bypass.net
Re: I am dumb, I need help
« Reply #23 on: 25 July 2006, 01:09 »
No.  No internet connection at home.

I'd say "fuck it", but I really want to learn how your design works, and what, if anything, about it is better than the one I already have.  For educational purposes, if nothing else.

piratePenguin

  • VIP
  • Member
  • ***
  • Posts: 3,027
  • Kudos: 775
    • http://piratepenguin.is-a-geek.com/~declan/
Re: I am dumb, I need help
« Reply #24 on: 25 July 2006, 01:20 »
Code: [Select]

"thumb

You know you could just use onclick on the img elements.
"What you share with the world is what it keeps of you."
 - Noah And The Whale: Give a little love



a poem by my computer, Macintosh Vigilante
Macintosh amends a damned around the requested typewriter. Macintosh urges a scarce design. Macintosh postulates an autobiography. Macintosh tolls the solo variant. Why does a winter audience delay macintosh? The maker tosses macintosh. Beneath female suffers a double scum. How will a rat cube the heavier cricket? Macintosh calls a method. Can macintosh nest opposite the headache? Macintosh ties the wrong fairy. When can macintosh stem the land gang? Female aborts underneath macintosh. Inside macintosh waffles female. Next to macintosh worries a well.

xyle_one

  • VIP
  • Member
  • ***
  • Posts: 2,213
  • Kudos: 135
Re: I am dumb, I need help
« Reply #25 on: 25 July 2006, 01:53 »
Quote from: worker201
No.  No internet connection at home.

I'd say "fuck it", but I really want to learn how your design works, and what, if anything, about it is better than the one I already have.  For educational purposes, if nothing else.


Ok. Check back tomorrow and you will have answers. You only need to slightly adjust your markup. You will need to add title attributes to your anchors.


EDIT: Updated with code examples.
The benefit in doing it "my" way is that your javascript is completely separated from the markup. I am using the DOM to hook into the markup to give it its behavior.

I did adjust your markup, but only to remove the onclick event handlers and the unordered list of descriptions. The descriptions are now apart of the anchor title for each thumbnail. I suppose I could have added them to the img alt description, or just left them alone and wrote something to handle it. Perhaps you can take what I have started and customize it for your needs.

imageGallery.js
Code: [Select]
function ChangeImageAndText(pic)
{
if(!document.getElementById) return false;

var source = pic.getAttribute("href");
var mainimg = document.getElementById("mainimg");
mainimg.setAttribute("src",source);

if (pic.getAttribute("title")) {
  var text = pic.getAttribute("title");
} else {
var text = "";
}
var description = document.getElementById("text");
if (description.firstChild.nodeType == 3) {
description.firstChild.nodeValue = text;
}
return false;
}

function prepareImageLinks()
{
if(!document.getElementById) return false;
var humpics = document.getElementById("wrapper");
var links = humpics.getElementsByTagName("a");
for( var i=0; i < links.length; i++ )
{
links[i].onclick = function()
{
return ChangeImageAndText(this);
}
links[i].onkeypress = links[i].onclick;
}
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
window.onload = func;
  } else {
window.onload = function() {
 oldonload();
 func();
}
  }
}

addLoadEvent(prepareImageLinks);

The first function, showPic, handles the image & text swapping. prepareGallery() dynamically adds an onclick event handler to all links within "wrapper". addLoadEvent() is used to load the prepareGallery function when the page is finished loading.

The changes to your markup:

Code: [Select]


Here is where image text will be



If you disable javascript, or are using a crappy browser, then the links simply open the image in the current window. With javascript enabled, the image placeholder is swapped for the value in the href attribute of the anchor.

This could be improved for sure. But it's a start.

The goal would be a complete separation of your behaviors, styles, and markup, so that at is rawest, most simple presentation, the site is still usable.

piratePenguin

  • VIP
  • Member
  • ***
  • Posts: 3,027
  • Kudos: 775
    • http://piratepenguin.is-a-geek.com/~declan/
Re: I am dumb, I need help
« Reply #26 on: 26 July 2006, 02:24 »
Quote from: worker201
btw, xylon, here's an example of what the JavaScript does (working okay now):
http://www.triple-bypass.net/brickpics/pimpmech/pimp.htm

Would your replacement script do the same thing?
Wanna see what your page looks like when it's sent as application/xhtml+xml?

http://piratepenguin.is-a-geek.com/~declan/crap/worker/pimp.xhtml

Hehe

See - in it's current state, no browser is treating the page as XHTML. If they were, they'd throw that error, since it aint well-formed XML ;)
"What you share with the world is what it keeps of you."
 - Noah And The Whale: Give a little love



a poem by my computer, Macintosh Vigilante
Macintosh amends a damned around the requested typewriter. Macintosh urges a scarce design. Macintosh postulates an autobiography. Macintosh tolls the solo variant. Why does a winter audience delay macintosh? The maker tosses macintosh. Beneath female suffers a double scum. How will a rat cube the heavier cricket? Macintosh calls a method. Can macintosh nest opposite the headache? Macintosh ties the wrong fairy. When can macintosh stem the land gang? Female aborts underneath macintosh. Inside macintosh waffles female. Next to macintosh worries a well.

worker201

  • Global Moderator
  • Member
  • ***
  • Posts: 2,810
  • Kudos: 703
    • http://www.triple-bypass.net
Re: I am dumb, I need help
« Reply #27 on: 26 July 2006, 02:36 »
Quote from: piratePenguin
Wanna see what your page looks like when it's sent as application/xhtml+xml?

http://piratepenguin.is-a-geek.com/~declan/crap/worker/pimp.xhtml

Hehe

See - in it's current state, no browser is treating the page as XHTML. If they were, they'd throw that error, since it aint well-formed XML ;)
I just went there and asked Firefox (1.0.8, fyi) to show me the source.  All the self-close slashes were missing for some reason.  Meaning, it gave this:
Code: [Select]
instead of this:
Code: [Select]
Also the XML opening tag was missing:
Code: [Select]
So what happened, eh?  The page is in fact well-formed, according to W3C guidelines.  I think what happened is that you did a "save webpage" thing or something, and it pulled the page down as HTML, which is how the browser interpreted it.  Check my source and you will see that the code is well-formed, and validates flawlessly.

piratePenguin

  • VIP
  • Member
  • ***
  • Posts: 3,027
  • Kudos: 775
    • http://piratepenguin.is-a-geek.com/~declan/
Re: I am dumb, I need help
« Reply #28 on: 26 July 2006, 02:58 »
Quote from: worker201
I just went there and asked Firefox (1.0.8, fyi) to show me the source.  All the self-close slashes were missing for some reason.  Meaning, it gave this:
Code: [Select]

instead of this:
Code: [Select]

Also the XML opening tag was missing:
Code: [Select]

So what happened, eh?  The page is in fact well-formed, according to W3C guidelines.  I think what happened is that you did a "save webpage" thing or something, and it pulled the page down as HTML, which is how the browser interpreted it.  Check my source and you will see that the code is well-formed, and validates flawlessly.
Bah, didn't recall that save page as fucked everything up.

But anyhow when I wget'ed the page it rendered the same as XHTML.

Lucky there's no background colour set ;)

(then it would be this versus this)

btw one of the selling points of XHTML is that you don't have to go to the W3C validator to catch well-formedness errors ;)
"What you share with the world is what it keeps of you."
 - Noah And The Whale: Give a little love



a poem by my computer, Macintosh Vigilante
Macintosh amends a damned around the requested typewriter. Macintosh urges a scarce design. Macintosh postulates an autobiography. Macintosh tolls the solo variant. Why does a winter audience delay macintosh? The maker tosses macintosh. Beneath female suffers a double scum. How will a rat cube the heavier cricket? Macintosh calls a method. Can macintosh nest opposite the headache? Macintosh ties the wrong fairy. When can macintosh stem the land gang? Female aborts underneath macintosh. Inside macintosh waffles female. Next to macintosh worries a well.

xyle_one

  • VIP
  • Member
  • ***
  • Posts: 2,213
  • Kudos: 135
Re: I am dumb, I need help
« Reply #29 on: 26 July 2006, 03:36 »
Why does it matter? Not all browsers support the proper mime type to serve an XHTML1.1 Strict page anyways.