|
Please help me with this code again sorry guys I just can't code JS :(
Can you help me with this code it's for a class, but a graduate class. The codes connects to another and I will explain. The book is New Perspectives JavaScript and Ajax, 2nd Edition; the exercise is Tutorial 7 Case Problem #1 page 433-434 if you want to read along. The file french5.htm connects to engfr.js and they are supposed to link together so french5htm shows a list of English and French and there's functions to switch back and for on the site, but my following code is incorrect and I wanted to know if someone can help me; please look thanks!
french5.htm (not code)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--
New Perspectives on JavaScript, 2nd Edition
Tutorial 7
Case Problem 1
French Phrases
Author: Franco Ferraiolo
Date: 1/29/13
Filename: french5.htm
Supporting files: engfr.js, french.js, styles.css
-->
<title>French Phrases Week 5</title>
<!-- links and functions for the site -->
<link href="styles.css" rel="stylesheet" type="text/css" />
<link href="engfr.js" rel="javascript" type="text/js" />
Var function.setUp
function[i]=setUp
Var link
link.setUp=(link href="engfr.js" rel="javascript" type="text/js" /)
Var transdoc
transdoc.setUp="engfr.js"
Var olElem
olElem.setUp="JavaScript"
Var newLI
newLI.setUp=list.js+"text/js"
<!-- functions for the site -->
function setUp(link,transdoc,newLI,olElem)
if (setUp.link)
<link href="engfr.js" rel="javascript" type="text/js" />("setUp" + link,transdoc,newLI,olElem)
else if (function.setUp)
function.setUp(link,transdoc,newLI,olElem)
<!-- swap function -->
Var swapFE()
Var pharse
event.pharse
swapFE.pharse.event=mousedown
Var pharseNum
event.pharseNum
swapFE.pharseNum.event=selected
events.pharse.pharseNum
link.english(link href="engfr.js" rel="javascript" type="text/js" /"english"
font.value.color=(155,102,102)
function=swapFE.pharse.pharseNum
function.swapFE(pharse.pharseNum)
Var swapEF
array[i]css.font.color=(#000000)
swapEF=css.font.color=(#000000)
</head>
<body>
<div id = "page">
<div id="head">
<div id = "rightHead">
<b>Prof. Eve Granger</b><br />
Office: 810 Linton Hall<br />
Hours: TR: 3:00-4:30
</div>
<div id = "leftHead">
<b>French 101</b><br />
MWF: 9:00-9:50<br />
Rm. 402 Linton Hall
</div>
</div>
<ul id="links">
<li class="newgroup"><a href="#">Home</a></li>
<li class="newgroup"><a href="#">Phrases</a></li>
<li><a href="#">Week 1 Phrases</a></li>
<li><a href="#">Week 2 Phrases</a></li>
<li><a href="#">Week 3 Phrases</a></li>
<li><a href="#">Week 4 Phrases</a></li>
<li><a href="#">Week 5 Phrases</a></li>
<li class="newgroup"><a href="#">Quizzes</a></li>
<li><a href="#">Chapter 1 Quiz</a></li>
<li><a href="#">Chapter 2 Quiz</a></li>
<li><a href="#">Chapter 3 Quiz</a></li>
<li class="newgroup"><a href="#">Dept. of French</a></li>
<li><a href="#">French 101</a></li>
<li><a href="#">French 135</a></li>
<li><a href="#">French 155</a></li>
<li><a href="#">French 201</a></li>
<li><a href="#">French 301</a></li>
<li class="newgroup"><a href="#">Staff</a></li>
<li><a href="#">Denise Abbot</a></li>
<li><a href="#">Viola Devreaux</a></li>
<li><a href="#">Eve Granger</a></li>
<li><a href="#">Cynthia Trudeau</a></li>
<li><a href="#">Gary Vironque</a></li>
</ul>
<div id = "doc">
<h1>Week 5 Phrases</h1>
<h2>Press down your mouse button on each phrase to translate</h2>
</div>
<address>
French-English Translation Page
</address>
</div>
</body>
</html>
connects to engfr.js (not code)
/*
New Perspectives on JavaScript, 2nd Edition
Tutorial 7
Case Problem 1
Author: Franco Ferraiolo
Date: 1/29/13
Filename: engfr.js
Function List:
addEvent(object, evName, fnName, cap)
Adds an event hander to object where evName is the name of the event,
fnName is the function assigned to the event, and cap indicates whether
event handler occurs during the capture phase (true) or bubbling
phase (false)
setUp()
Insert the current week's french phrases into document and set up
event handlers for the phrases.
swapFE(phrase, pnum)
Changes a French phrase to the English version of that phrase.
swapEF(phrase, pnum)
Changes an English phrase ot the Frech version of that phrase.
*/
<link href="www.french5.htm" rel="notepad" type="text/htm" />
function addEvent(object, evName, fnName, cap) {
if (object.attachEvent)
object.attachEvent("on" + evName, fnName);
else if (object.addEventListener)
object.addEventListener(evName, fnName, cap);
}
|