Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
10-08-2012, 09:00 PM
|
#16
|
|
Member
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Lisa, Windows 7
Posts: 153
Original Poster
Rep:
|
1st Java file
1st Java file...
Code:
/*
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.
*/
addEvent (window, "load", setUp, false);
function addEvent(object, evName, fnName, cap) {
if (object.attachEvent)
object.attachEvent("on" + evName, fnName);
else if (object.addEventListener)
object.addEventListener(evName, fnName, cap);
}
function setUp() {
var transDoc = document.getElementById("doc");
var olElem = document.createElement("ol");
for (var i = 0; i < french.length; i++){
var newLI = document.createElement("li");
newLI.innerHTML = french[i];
newLI.id = i + "phrase";
newLI.style.cursor = "pointer";
addEvent(newLI, "onmousedown", swapFE, false);
addEvent(newLI, "onmouseup", swapEF, false);
olElem.appendChild (newLI);
}
transDoc.appendChild(olElem);
}
function swapFE(event) {
var phrase = event.target || event.srcElement;
if (phrase.nodeName == "#text")
phrase = phrase.parentNode;
var phraseNum = parseInt(phrase.id);
phrase.innerHTML = english[phraseNum];
phrase.style.color = "rgb(155,102,102)";
phrase.style.fontstyle = "italic";
}
function swapEF(event) {
var phrase = event.target || event.srcElement;
if (phrase.nodeName == "#text")
phrase = phrase.parentNode;
var phraseNum = parseInt(phrase.id);
phrase.innerHTML = french[phraseNum];
phrase.style.color = "rgb(0,0,0)";
phrase.style.fontstyle = "normal";
}
|
|
|
|
10-08-2012, 09:01 PM
|
#17
|
|
Member
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Lisa, Windows 7
Posts: 153
Original Poster
Rep:
|
2nd Java file
second java file....
Code:
/*
Filename: french5.js
Variable List:
french
Contains an array of 10 english phrases
english
Contains an array of 10 French translations
*/
var english=new Array();
english[0]="This hotel isn't far from the Eiffel Tower.";
english[1]="What time does the train arrive?";
english[2]="We have been waiting for the bus for one half-hour.";
english[3]="This meal is delicious";
english[4]="What day is she going to arrive?";
english[5]="We have eleven minutes before the train leaves!";
english[6]="Living in a foreign country is a good experience.";
english[7]="Excuse me! I'm late!";
english[8]="Is this taxi free?";
english[9]="Be careful when you go down the steps.";
var french=new Array();
french[0]="Cet hôtel n'est pas loin de la Tour Eiffel.";
french[1]="A quelle heure arrive le train?";
french[2]="Nous attendons l'autobus depuis une demi-heure.";
french[3]="Ce repas est délicieux";
french[4]="Quel jour va-t-elle arriver?";
french[5]="Nous avons onze minutes avant le départ du train!";
french[6]="Habiter dans un pays étranger est une bonne expérience.";
french[7]="Excusez-moi! Je suis en retard!";
french[8]="Est-ce que ce taxi est libre?";
french[9]="Faites attention quand vous descendez l'escalier.";
|
|
|
|
10-08-2012, 09:03 PM
|
#18
|
|
Member
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Lisa, Windows 7
Posts: 153
Original Poster
Rep:
|
CSS
Style Sheet.....
Code:
* {margin: 0px; padding: 0px}
#page {width: 700px; border: 1px solid rgb(155, 102, 102)}
#head {width: 700px; color: white; font-size: 14px;
font-family: Arial, Helvetica, sans-serif;
background-color: rgb(155, 102, 102);
padding: 10px 0px}
#rightHead {float: right; margin-right: 10px}
#leftHead {margin-left: 10px}
#links {clear: both; width: 120px; float: left;
border-right: 1px solid rgb(155, 102, 102);
list-style-type: none; margin-left: 15px;
font-size: 12px; padding-bottom: 10px}
#links a {display: block; text-decoration: none; width: 100%;
color: black}
#links a:hover {background-color: rgb(155, 102, 102); color: white}
#links .newgroup {margin-top: 5px; margin-left: -10px}
#doc {float: left}
#doc ol {margin-left: 45px; margin-top: 15px}
h1, h2 {font-family: Arial, Helvetica, sans-serif;
padding: 0px 10px}
p {padding: 0px 10px; margin: 2px}
.pnum {margin-right: 5px; text-align: right; width: 30px;
border: 1px solid rgb(155,102,102); padding-right: 2px;
color: white; background-color: rgb(155,102,102)}
.phrase {font-style: italic; cursor: pointer}
h1 {font-size: 18px; margin: 20px 0px 5px 0px}
h2 {font-size: 12px; font-weight: normal; margin: 5px}
address {clear: left; text-align: center; font-style: normal;
background-color: rgb(155, 102, 102); color: white;
font-family: Arial, Helvetica, sans-serif}
|
|
|
|
10-08-2012, 09:05 PM
|
#19
|
|
Member
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Lisa, Windows 7
Posts: 153
Original Poster
Rep:
|
Ok!
That's all of them!
|
|
|
|
10-08-2012, 11:11 PM
|
#20
|
|
Senior Member
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 3,692
|
Fixed it.
setUp() in engfr.js should be this:
Code:
function setUp() {
var transDoc = document.getElementById("doc");
var olElem = document.createElement("ol");
for (var i = 0; i < french.length; i++){
var newLI = document.createElement("li");
newLI.innerHTML = french[i];
newLI.id = i + "phrase";
newLI.style.cursor = "pointer";
addEvent(newLI, "mousedown", swapFE, false);
addEvent(newLI, "mouseup", swapEF, false);
olElem.appendChild (newLI);
}
transDoc.appendChild(olElem);
}
The difference is that the event names are now "mousedown" and "mouseup", not "onmousedown and "onmouseup". The reason is that this is what you have in addEvent:
Code:
function addEvent(object, evName, fnName, cap) {
if (object.attachEvent)
object.attachEvent("on" + evName, fnName);
else if (object.addEventListener)
object.addEventListener(evName, fnName, cap);
}
addEvent already prepends "on" to "evName", so you ended up adding event listeners to "ononmouseup" and "ononmousedown". That's why it wasn't working.
BTW, that's a sweet idea for a language quiz.
Last edited by dugan; 10-08-2012 at 11:46 PM.
|
|
|
1 members found this post helpful.
|
10-09-2012, 04:31 AM
|
#21
|
|
Member
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Lisa, Windows 7
Posts: 153
Original Poster
Rep:
|
Sorry I went to bed...Thank you!!!!!
Here's the page out of my book...That's ridiculous that they expect students to figure that out.
Code:
Core Events
The general event attributes are part of the specifications for HTML and XHTML. They
apply to almost all page elements.
Attribute Description HTML XHTML
onclick The mouse button is clicked. 4.0 1.0
ondblclick The mouse button is double-clicked. 4.0 1.0
onkeydown A key is pressed down. 4.0 1.0
onkeypress A key is initially pressed. 4.0 1.0
onkeyup A key is released. 4.0 1.0
onmousedown The mouse button is pressed down. 4.0 1.0
onmousemove The mouse pointer is moved within the element’s boundaries. 4.0 1.0
onmouseout The mouse pointer is moved out of the element’s boundaries. 4.0 1.0
onmouseover The mouse pointer hovers over the element. 4.0 1.0
onmouseup The mouse button is released. 4.0 1.0
I'm glad the world has smarter folks than the one who wrote my book!
Gonna try to take out the "on" and see if that works.......Nope....it will only work the way you wrote it!
Last edited by EODSteven; 10-09-2012 at 04:37 AM.
Reason: additional info
|
|
|
|
10-09-2012, 09:23 AM
|
#22
|
|
Senior Member
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 3,692
|
If isn't for a course, and you're allowed to choose your book, then you should look for a different one. The "on" event properties are deprecated. They only became common because they were the only option in some old versions of Internet Explorer. The W3C standard way to do it is with addEventListner("mouseup"), which also works in current version of Internet Explorer.
|
|
|
|
10-09-2012, 09:48 AM
|
#23
|
|
Member
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Lisa, Windows 7
Posts: 153
Original Poster
Rep:
|
Last Tutorial
My Book was the 4th edition and I have seen that they are already in the 7th edition. That was my last tutorial anyway so I'm moving on to A+ Guide to managing and maintaining your PC...CompTia certification course!. I'm looking forward to the "nuts & bolts" of the PC, something I'm much well suited for. I was a Robotic tech for years till I had to get a defibrillator installed and had to move away from strong magnetic feilds. Again Dugan, thank you very much and it was so nice to meet a "nice" Canadian!  . Take care! P.S. How do you install the cool Tags at the end of your Posts?
Last edited by EODSteven; 10-09-2012 at 09:53 AM.
Reason: Question
|
|
|
|
10-09-2012, 10:05 AM
|
#24
|
|
Member
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Lisa, Windows 7
Posts: 153
Original Poster
Rep:
|
Signature...
I think I found it...Signature.....Gonna edit that...
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:09 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|