Archive for the ‘A3’ Category

A3: Javascript

1/30, Wed.  7:05 pm

i thought i was done yesterday but wow, i took another look at it and realized that i was not 100% confident in what i had.

the biggest obstacle was when i realized that i only used one function to do the stylesheet switching when the assignment specified two.  i hadn’t considered the possibility that i needed to follow the directions exactly.  so a bit of panic creeped in.  but then, i took a look at the code i had, which originally was:

/*
function setActiveStyleSheet(title)
{
var i, a, main;
for(i=0; (a= document.getElementsByTagName(“link”)[i]); i++)
{
if(a.getAttribute(“rel”).indexOf(“style”) != -1 && a.getAttribute(“title”))
{
a.disabled = true;
if(a.getAttribute(“title”) == title) a.disabled = false;
}
}
}
*/

and i was able to figure it out pretty fast.  i just changed some things in the HTML, replacing all the files with the new code.  and it worked!  Firebug really helped speed it up by pinpointing what was wrong.

i felt very savvy.  hehe.. of course, this is after 3+ days of seriously working on it…  ahhh.

1/29, Tues. 

so i actually took advantage of that absolutely wondrous resource of a research university… the TA.

i went to office hours after class today and all my problems were solved within just ONE hour. it’s amazing how different the experience of programming is when one is floundering by oneself versus a guided learning process. truly, it was so ridiculously simple.

so Assignment 3 was using javascript in order to dynamically generate a navigation list and to add some cool buttons that pop up an alert notice and other buttons that change the stylesheets.

i discovered another use for firebug. it is really helpful to open up a window and then debug it by going through the html and seeing where there are errors or whether things went through. i used it mostly to check my progress in making the arrays and elements for the navigation links. it would show exactly where the code was lacking and that really helped me not to waste my time futilely changing other things.

in the future, i’m interested in doing some more fun and tasteful events such as mouseover to make the website look more sophisticated.

i have the link!

i found it! the problem that firebug popped up was:

a.getAttribute() has no properties

and so i googled that and up pops this site… http://www.webmasterworld.com/forum91/3524.htm.

i’m going to put this on the wiki as well. sooooo helpful!

yayyy!!!

monday (jan. 28)
9:56 am

i feel that incredible overwhelming of triumph as only succeeding after hours of programming can do.

i had attempted to start work on this program last week, even before the weekend because i knew i had a lot on my plate. but i had seriously hit a dead-end when it came to switching between stylesheets. i looked at the “A List Apart” stuff but the code just wouldn’t work. and i would get so confused about whether we need to insert our function “title” when the code said it…

so there was

function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}

and so i was so confused whether to insert my alternate stylesheet title which was “wild” into all the spots where it says ‘title’…

and the use i had for firebug was that it when i uploaded the window and tried clicking on the button to switch styles, a little red ‘x’ appears in the bottom corner. when i clicked on it, it kept saying that the “a.getAttribute” or some other line of code with the “a.whatever” had no properties. needless to say, i was completely flabbergasted. it seems like there’s no way to even start correcting because who knows what the magic words are? it’s so specific that one little thing off will ruin the entire program.

and so last week, i gave up in a huff, threw my hands up and stalked off. i tried to take a look at it periodically but there was no going forward.

but now, i think that website “A List Apart” was very misleading. i found another page that really helped. but sadly, i closed the window before recording its URL or else i would have posted it on the wiki. it was someone posting the exact same problem online and people replied with their suggestions. it was great because you could choose from the different solutions the one that matches the one that looks like yours…

so Firebug really helped me in locating my problem. i just typed in the error it kept showing up and someone else had already asked about it. i found the solution in about five tries. and it works perfectly.

so now, i’m trying to move on to the generating of the navigation list. once again, it was really easy to find how to load when the window opens because of other people’s questions. it’s really quite nice.