LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 10-08-2012, 06:13 PM   #1
EODSteven
Member
 
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Ubuntu 14.04, Windows 8, Windows Server 2012. Ubuntu Server 14.04
Posts: 170

Rep: Reputation: 3
Need help with a script file


Why doesn't the swapFE function work?

Code:
 addEvent (window, "load", setUp, false);

function addEvent(object, evName, fnName, cap) {
   if (object.attachEvent)
       object.attachEvent("on" + evName, fnName); (Solution.....because of this "on".....)
   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); (Solution-change these to exclude on.)
		addEvent(newLI, "onmouseup", swapEF, false);  <--------("mousedown" & "mouseup")-----------
		olElem.appendChild (newLI);
		}
		transDoc.appendChild(olElem);
 }
function swapFE(e) {
	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(e) {
	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";
}

Last edited by EODSteven; 10-09-2012 at 04:47 AM. Reason: Added solution
 
Old 10-08-2012, 06:19 PM   #2
EODSteven
Member
 
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Ubuntu 14.04, Windows 8, Windows Server 2012. Ubuntu Server 14.04
Posts: 170

Original Poster
Rep: Reputation: 3
Portion of HTML it goes with...

Here's what the script is linked to....

Code:
 <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>
 
Old 10-08-2012, 06:22 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
I highly recommend you ask the Mods via the Report button to move this to the Programming forum.
The guys there will also ask what lang this is...
 
1 members found this post helpful.
Old 10-08-2012, 06:27 PM   #4
EODSteven
Member
 
Registered: Oct 2012
Location: Manchester, Tn
Distribution: Ubuntu 14.04, Windows 8, Windows Server 2012. Ubuntu Server 14.04
Posts: 170

Original Poster
Rep: Reputation: 3
Request sent...

Request has been sent to move this to programming forum...
 
Old 10-09-2012, 07:24 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,453

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply

Tags
script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to get name of file, delete original file, rename blank file chrisgti Linux - General 11 09-15-2012 02:49 AM
How to get full path to script file inside script itself? And in case of sym links? maggus Linux - Newbie 3 05-28-2009 08:40 AM
Need a script to search and replace text in file using shell script unixlearner Programming 14 06-21-2007 10:37 PM
Create a script to display file name, Inode, and size of any file. Has to be a script JaxsunApex Linux - Newbie 7 01-29-2007 08:15 PM
How to start a Tcl/Tk script by simply invoking the script file itself ? cyu021 Programming 2 10-10-2004 11:00 AM


All times are GMT -5. The time now is 09:08 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration