LIS 7008 - Information Technologies
Fall 2010 - Section 01
Assignment 6
This homework is due on your course Web site before the beginning of the next class session. Partial credit may be awarded.
If you do not have any previous programming experience,
it may take you long time to learn and you may feel frustrated. So we have a special
grading policy for this assignment. If your program works, you earn 100 points; if it partially works, you may earn a
grade between 90-95; if you have done some work but it does not work at all,
do not sweat, I will take a look at your program and assign a grade between 80-89. If you do nothing, that is 0,
but it would be appreciated if you could tell me that you did not do anything because it takes time for me to figure out
what you have done.
The purpose of the assignment is to give you the opportunity to learn how JavaScript can be used to create an interactive Web page,
not to train you to be a good JavaScript programmer. If you are serious about being a Web designer, you are advised to take LIS 7510
Website Design and Management, in which Dr. Ju will teach you a whole lot of JavaScript. It is not realistic to train a social scientist
or a humanity scholar to be a JavaScript programmer in one class session if she/he has no previous programming experience.
Explanation
The JavaScript program that we looked at
in the lecture notes
(i.e., selector.html) is a good start, but a real search tool selector would
probably need to provide more options and do more sophisticated
selection. It is therefore important that you learn how to modify
JavaScript that you find on the Web to suit your purposes. In this
assignment, you will modify selector.html in two ways, and post your
modified page on your Web site for the instructor to grade.
If you have not downloaded the page, please do so here:
shorthand version or
full version (with semicolons and complete braces)
What the program does
The purpose of the program is to direct users to a Web Search Engine and a Web Directory based on the user's age.
If the user is an adult (age >17 and <120), direct her to www.altavista.com if she
wants a Web Search Engine, or to dir.yahoo.com if she wants a Web Directory.
If the user is a kid (age ≤17
and >0), direct her to www.askkids.com if she wants a Web Search Engine, or to kids.yahoo.com if she wants a Web directory.
Your Task: Modify the Program
Task 1. The library board has decided that people aged 16 and over should be
treated as adults by the search tool selector. Change your copy of the
page to implement this new policy.
Task 2. Your library director has learned that a recent report published in
the Journal of Internet Stuff has revealed that people over 40 prefer
the AltaVista search engine (http://www.altavista.com), but that
adults aged 40 and under prefer Google (www.google.com). Change
your copy of the page to send adults to the search engine that they
are most likely to like based on their age (if they select a search
engine).
Save your work as hw6.html (or whatever filename you like), then link this from your 7008.html Web page,
which must be accessible from http://classes.slis.lsu.edu/wu/sp10/7008/your_folder/7008.html (where
where "your_folder" is your first initial followed by your last name, all in lower case).
Testing
You can (and I will) use the following age values to test your program to get the expected results:
Age |
Expected Seach Engine |
Expected Web Directory |
10 |
ask kids |
kids.yahoo |
16, 17, 40 |
Google |
dir.yahoo |
41, 50 |
Altavista |
dir.yahoo |
120 |
Invalid age 120 |
Invalid age 120 |
Common problems and solutions:
- Before revising the program, try to understand the logic of the program (those functions and if-else statements) first.
When adding/revising functions, make your logic clear. When making if-else statements, make mutually exclusive statements;
for example, in the statement if A go east else go west, "A and else (not-A)" are mutually exclusive. If you use
"if - else if - else" statements, please make those conditions clear.
- You cannot use statements like "(age>40)" or "(age > 15 && age < 40)" in the "function adult_jump()"
because that function does not have an "age" parameter and does not define an "age" variable; try to use
other functions [such as is_adult(age) or is_kid(age)] to replace those statements. Hint: you may want to
revise those smaller functions and/or write new ones to meet your needs.
- "I do not know what is wrong with my program; it simply does not work."
It is very common that right after changing anything in the program, it does not work.
In this case, please check whether you have lost any parentheses "()" and braces "{}"; check typos (such as functoin, retrun)
and inconsistent function names. Also, Internet Explorer has a Javascript debugger. Here is a
tutorial.
Reminder: debuggers check your syntax only; they do not check your semantics (logic).
Grading rubric:
Grade |
Program |
0 |
Program is not posted on your course Website before the due time. |
80 |
Only Task 1 is finished. |
85 |
Efforts were made to finish Task 2, but program does not work. |
90 |
Program does not work, but you are almost there. |
99 |
Program has very minor errors.
E.g., if age==40, user should be directed to Google rather than Alta Vista.
|
100 |
Program's behavior meets specification. |
These are the most common categories. You can actually grade your work by yourself.
Acknowledgement to Doug Oard, revised by Yejun Wu.