Installing an external javascript
- oblongintellect
- Novice


- Joined: Mar 23, 2004
- Posts: 28
- Status: Offline
I've got a script for a cell color transition I want to embed into my site could you tell me what I am doing wrong I keep getting script errors. This is the code I want to embed
It's name is table.js . I've been trying to embed it like this
Could someone please tell me what I'm doing wrong?
Code: [ Select ]
function makearray(n) {
this.length = n;
for(var i = 1; i <= n; i++)
this[i] = 0;
return this;
}
function hex(i) {
if (i < 0) return "00";
else if (i > 255) return "ff";
else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}
function hexnumtodec(hexchar) {
if (parseInt(hexchar) == hexchar) return Number(hexchar)
hexchar = hexchar.toUpperCase()
switch (hexchar) {
case 'A': return 10; break;
case 'B': return 11; break;
case 'C': return 12; break;
case 'D': return 13; break;
case 'E': return 14; break;
case 'F': return 15; break;
}
}
function hextodec(daHex) {
var daDec = Number((16 * hexnumtodec(daHex.substring(0,1))) + hexnumtodec(daHex.substring(1,2)))
return daDec
}
function setColor(r,g,b) {
var hr = hex(r); var hg = hex(g); var hb = hex(b);
var daColor = "#"+hr+hg+hb
daEl.style.backgroundColor = daColor
if (daColor == colorend.toLowerCase()) {
clearInterval(iId)
iId = null
timerRunning = false
}
}
function fade() {
i++
setColor(
Math.floor(sr * ((step-i)/step) + er * (i/step)),
Math.floor(sg * ((step-i)/step) + eg * (i/step)),
Math.floor(sb * ((step-i)/step) + eb * (i/step)));
}
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
var i
var iId = null
var sr, sg, sb
var er, eg, eb
var interval = 1
var step = 16
var colorstart
var colorend
var daEl
var timerRunning = false
function myfade(el,cs,ce,iv,st) {
daEl = el
colorstart = cs
colorend = ce
interval = iv
step = st
i = 0
if (timerRunning) {
clearInterval(iId)
iId = null
}
var myRe = /#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i
if (colorstart.match(myRe)) {
sr = hextodec(RegExp.$1)
sg = hextodec(RegExp.$2)
sb = hextodec(RegExp.$3)
}
if (colorend.match(myRe)) {
er = hextodec(RegExp.$1)
eg = hextodec(RegExp.$2)
eb = hextodec(RegExp.$3)
}
timerRunning = false;
iId = setInterval("fade()",interval)
timerRunning = true;
}
function cellover(table_cell) {
// play around with these values
// element, from_color, to_color, interval(milliseconds), transition steps
myfade(table_cell,'#B9D4E6','#eeeee0',20,32)
}
function cellout(table_cell) {
if (timerRunning) {
clearInterval(iId)
iId = null
}
table_cell.style.backgroundColor = '#B9D4E6'
}
this.length = n;
for(var i = 1; i <= n; i++)
this[i] = 0;
return this;
}
function hex(i) {
if (i < 0) return "00";
else if (i > 255) return "ff";
else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}
function hexnumtodec(hexchar) {
if (parseInt(hexchar) == hexchar) return Number(hexchar)
hexchar = hexchar.toUpperCase()
switch (hexchar) {
case 'A': return 10; break;
case 'B': return 11; break;
case 'C': return 12; break;
case 'D': return 13; break;
case 'E': return 14; break;
case 'F': return 15; break;
}
}
function hextodec(daHex) {
var daDec = Number((16 * hexnumtodec(daHex.substring(0,1))) + hexnumtodec(daHex.substring(1,2)))
return daDec
}
function setColor(r,g,b) {
var hr = hex(r); var hg = hex(g); var hb = hex(b);
var daColor = "#"+hr+hg+hb
daEl.style.backgroundColor = daColor
if (daColor == colorend.toLowerCase()) {
clearInterval(iId)
iId = null
timerRunning = false
}
}
function fade() {
i++
setColor(
Math.floor(sr * ((step-i)/step) + er * (i/step)),
Math.floor(sg * ((step-i)/step) + eg * (i/step)),
Math.floor(sb * ((step-i)/step) + eb * (i/step)));
}
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
var i
var iId = null
var sr, sg, sb
var er, eg, eb
var interval = 1
var step = 16
var colorstart
var colorend
var daEl
var timerRunning = false
function myfade(el,cs,ce,iv,st) {
daEl = el
colorstart = cs
colorend = ce
interval = iv
step = st
i = 0
if (timerRunning) {
clearInterval(iId)
iId = null
}
var myRe = /#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i
if (colorstart.match(myRe)) {
sr = hextodec(RegExp.$1)
sg = hextodec(RegExp.$2)
sb = hextodec(RegExp.$3)
}
if (colorend.match(myRe)) {
er = hextodec(RegExp.$1)
eg = hextodec(RegExp.$2)
eb = hextodec(RegExp.$3)
}
timerRunning = false;
iId = setInterval("fade()",interval)
timerRunning = true;
}
function cellover(table_cell) {
// play around with these values
// element, from_color, to_color, interval(milliseconds), transition steps
myfade(table_cell,'#B9D4E6','#eeeee0',20,32)
}
function cellout(table_cell) {
if (timerRunning) {
clearInterval(iId)
iId = null
}
table_cell.style.backgroundColor = '#B9D4E6'
}
- function makearray(n) {
- this.length = n;
- for(var i = 1; i <= n; i++)
- this[i] = 0;
- return this;
- }
- function hex(i) {
- if (i < 0) return "00";
- else if (i > 255) return "ff";
- else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
- }
- function hexnumtodec(hexchar) {
- if (parseInt(hexchar) == hexchar) return Number(hexchar)
- hexchar = hexchar.toUpperCase()
- switch (hexchar) {
- case 'A': return 10; break;
- case 'B': return 11; break;
- case 'C': return 12; break;
- case 'D': return 13; break;
- case 'E': return 14; break;
- case 'F': return 15; break;
- }
- }
- function hextodec(daHex) {
- var daDec = Number((16 * hexnumtodec(daHex.substring(0,1))) + hexnumtodec(daHex.substring(1,2)))
- return daDec
- }
- function setColor(r,g,b) {
- var hr = hex(r); var hg = hex(g); var hb = hex(b);
- var daColor = "#"+hr+hg+hb
- daEl.style.backgroundColor = daColor
- if (daColor == colorend.toLowerCase()) {
- clearInterval(iId)
- iId = null
- timerRunning = false
- }
- }
- function fade() {
- i++
- setColor(
- Math.floor(sr * ((step-i)/step) + er * (i/step)),
- Math.floor(sg * ((step-i)/step) + eg * (i/step)),
- Math.floor(sb * ((step-i)/step) + eb * (i/step)));
- }
- hexa = new makearray(16);
- for(var i = 0; i < 10; i++)
- hexa[i] = i;
- hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
- hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
- var i
- var iId = null
- var sr, sg, sb
- var er, eg, eb
- var interval = 1
- var step = 16
- var colorstart
- var colorend
- var daEl
- var timerRunning = false
- function myfade(el,cs,ce,iv,st) {
- daEl = el
- colorstart = cs
- colorend = ce
- interval = iv
- step = st
- i = 0
- if (timerRunning) {
- clearInterval(iId)
- iId = null
- }
- var myRe = /#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i
- if (colorstart.match(myRe)) {
- sr = hextodec(RegExp.$1)
- sg = hextodec(RegExp.$2)
- sb = hextodec(RegExp.$3)
- }
- if (colorend.match(myRe)) {
- er = hextodec(RegExp.$1)
- eg = hextodec(RegExp.$2)
- eb = hextodec(RegExp.$3)
- }
- timerRunning = false;
- iId = setInterval("fade()",interval)
- timerRunning = true;
- }
- function cellover(table_cell) {
- // play around with these values
- // element, from_color, to_color, interval(milliseconds), transition steps
- myfade(table_cell,'#B9D4E6','#eeeee0',20,32)
- }
- function cellout(table_cell) {
- if (timerRunning) {
- clearInterval(iId)
- iId = null
- }
- table_cell.style.backgroundColor = '#B9D4E6'
- }
Code: [ Select ]
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" type="text/css" href="../templates/test.css">
<script type="text/javascript" src="fader.js"></script>
<script type="text/javascript" src="jsfunctions.js"></script>
<script type="text/javascript" src="table.js"></script>
</head>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" type="text/css" href="../templates/test.css">
<script type="text/javascript" src="fader.js"></script>
<script type="text/javascript" src="jsfunctions.js"></script>
<script type="text/javascript" src="table.js"></script>
</head>
- <html>
- <head>
- <meta http-equiv="Content-Language" content="en-us">
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
- <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
- <meta name="ProgId" content="FrontPage.Editor.Document">
- <link rel="stylesheet" type="text/css" href="../templates/test.css">
- <script type="text/javascript" src="fader.js"></script>
- <script type="text/javascript" src="jsfunctions.js"></script>
- <script type="text/javascript" src="table.js"></script>
- </head>
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
March 27th, 2004, 7:44 pm
- _Leo_
- Proficient


- Joined: Feb 17, 2004
- Posts: 279
- Loc: Buenos Aires, Argentina
- Status: Offline
- oblongintellect
- Novice


- Joined: Mar 23, 2004
- Posts: 28
- Status: Offline
I tried but still no workie. This is what I now have.
Can you see anything else wrong?
Code: [ Select ]
function makearray(n) {
this.length = n;
for(var i = 1; i <= n; i++)
this[i] = 0;
return this;
}
function hex(i) {
if (i < 0) return "00";
else if (i > 255) return "ff";
else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}
function hexnumtodec(hexchar) {
if (parseInt(hexchar) == hexchar) return Number(hexchar)
hexchar = hexchar.toUpperCase()
switch (hexchar) {
case 'A': return 10; break;
case 'B': return 11; break;
case 'C': return 12; break;
case 'D': return 13; break;
case 'E': return 14; break;
case 'F': return 15; break;
}
}
function hextodec(daHex) {
var daDec = Number((16 * hexnumtodec(daHex.substring(0,1))) + hexnumtodec(daHex.substring(1,2)))
return daDec
}
function setColor(r,g,b) {
var hr = hex(r); var hg = hex(g); var hb = hex(b);
var daColor = "#"+hr+hg+hb;
daEl.style.backgroundColor = daColor;
if (daColor == colorend.toLowerCase()) {
clearInterval(iId)
iId = null;
timerRunning = false;
}
}
function fade() {
i++
setColor(
Math.floor(sr * ((step-i)/step) + er * (i/step)),
Math.floor(sg * ((step-i)/step) + eg * (i/step)),
Math.floor(sb * ((step-i)/step) + eb * (i/step)));
}
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
var i;
var iId = null;
var sr, sg, sb;
var er, eg, eb;
var interval = 1;
var step = 16;
var colorstart;
var colorend;
var daEl;
var timerRunning = false;
function myfade(el,cs,ce,iv,st) {
daEl = el;
colorstart = cs;
colorend = ce;
interval = iv;
step = st;
i = 0;
if (timerRunning) {
clearInterval(iId)
iId = null;
}
var myRe = /#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i;
if (colorstart.match(myRe)) {
sr = hextodec(RegExp.$1)
sg = hextodec(RegExp.$2)
sb = hextodec(RegExp.$3)
}
if (colorend.match(myRe)) {
er = hextodec(RegExp.$1)
eg = hextodec(RegExp.$2)
eb = hextodec(RegExp.$3)
}
timerRunning = false;
iId = setInterval("fade()",interval)
timerRunning = true;
}
function cellover(table_cell) {
// play around with these values
// element, from_color, to_color, interval(milliseconds), transition steps
myfade(table_cell,'#B9D4E6','#eeeee0',20,32)
}
function cellout(table_cell) {
if (timerRunning) {
clearInterval(iId)
iId = null;
}
table_cell.style.backgroundColor = '#B9D4E6'
}
this.length = n;
for(var i = 1; i <= n; i++)
this[i] = 0;
return this;
}
function hex(i) {
if (i < 0) return "00";
else if (i > 255) return "ff";
else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}
function hexnumtodec(hexchar) {
if (parseInt(hexchar) == hexchar) return Number(hexchar)
hexchar = hexchar.toUpperCase()
switch (hexchar) {
case 'A': return 10; break;
case 'B': return 11; break;
case 'C': return 12; break;
case 'D': return 13; break;
case 'E': return 14; break;
case 'F': return 15; break;
}
}
function hextodec(daHex) {
var daDec = Number((16 * hexnumtodec(daHex.substring(0,1))) + hexnumtodec(daHex.substring(1,2)))
return daDec
}
function setColor(r,g,b) {
var hr = hex(r); var hg = hex(g); var hb = hex(b);
var daColor = "#"+hr+hg+hb;
daEl.style.backgroundColor = daColor;
if (daColor == colorend.toLowerCase()) {
clearInterval(iId)
iId = null;
timerRunning = false;
}
}
function fade() {
i++
setColor(
Math.floor(sr * ((step-i)/step) + er * (i/step)),
Math.floor(sg * ((step-i)/step) + eg * (i/step)),
Math.floor(sb * ((step-i)/step) + eb * (i/step)));
}
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
var i;
var iId = null;
var sr, sg, sb;
var er, eg, eb;
var interval = 1;
var step = 16;
var colorstart;
var colorend;
var daEl;
var timerRunning = false;
function myfade(el,cs,ce,iv,st) {
daEl = el;
colorstart = cs;
colorend = ce;
interval = iv;
step = st;
i = 0;
if (timerRunning) {
clearInterval(iId)
iId = null;
}
var myRe = /#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i;
if (colorstart.match(myRe)) {
sr = hextodec(RegExp.$1)
sg = hextodec(RegExp.$2)
sb = hextodec(RegExp.$3)
}
if (colorend.match(myRe)) {
er = hextodec(RegExp.$1)
eg = hextodec(RegExp.$2)
eb = hextodec(RegExp.$3)
}
timerRunning = false;
iId = setInterval("fade()",interval)
timerRunning = true;
}
function cellover(table_cell) {
// play around with these values
// element, from_color, to_color, interval(milliseconds), transition steps
myfade(table_cell,'#B9D4E6','#eeeee0',20,32)
}
function cellout(table_cell) {
if (timerRunning) {
clearInterval(iId)
iId = null;
}
table_cell.style.backgroundColor = '#B9D4E6'
}
- function makearray(n) {
- this.length = n;
- for(var i = 1; i <= n; i++)
- this[i] = 0;
- return this;
- }
- function hex(i) {
- if (i < 0) return "00";
- else if (i > 255) return "ff";
- else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
- }
- function hexnumtodec(hexchar) {
- if (parseInt(hexchar) == hexchar) return Number(hexchar)
- hexchar = hexchar.toUpperCase()
- switch (hexchar) {
- case 'A': return 10; break;
- case 'B': return 11; break;
- case 'C': return 12; break;
- case 'D': return 13; break;
- case 'E': return 14; break;
- case 'F': return 15; break;
- }
- }
- function hextodec(daHex) {
- var daDec = Number((16 * hexnumtodec(daHex.substring(0,1))) + hexnumtodec(daHex.substring(1,2)))
- return daDec
- }
- function setColor(r,g,b) {
- var hr = hex(r); var hg = hex(g); var hb = hex(b);
- var daColor = "#"+hr+hg+hb;
- daEl.style.backgroundColor = daColor;
- if (daColor == colorend.toLowerCase()) {
- clearInterval(iId)
- iId = null;
- timerRunning = false;
- }
- }
- function fade() {
- i++
- setColor(
- Math.floor(sr * ((step-i)/step) + er * (i/step)),
- Math.floor(sg * ((step-i)/step) + eg * (i/step)),
- Math.floor(sb * ((step-i)/step) + eb * (i/step)));
- }
- hexa = new makearray(16);
- for(var i = 0; i < 10; i++)
- hexa[i] = i;
- hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
- hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
- var i;
- var iId = null;
- var sr, sg, sb;
- var er, eg, eb;
- var interval = 1;
- var step = 16;
- var colorstart;
- var colorend;
- var daEl;
- var timerRunning = false;
- function myfade(el,cs,ce,iv,st) {
- daEl = el;
- colorstart = cs;
- colorend = ce;
- interval = iv;
- step = st;
- i = 0;
- if (timerRunning) {
- clearInterval(iId)
- iId = null;
- }
- var myRe = /#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i;
- if (colorstart.match(myRe)) {
- sr = hextodec(RegExp.$1)
- sg = hextodec(RegExp.$2)
- sb = hextodec(RegExp.$3)
- }
- if (colorend.match(myRe)) {
- er = hextodec(RegExp.$1)
- eg = hextodec(RegExp.$2)
- eb = hextodec(RegExp.$3)
- }
- timerRunning = false;
- iId = setInterval("fade()",interval)
- timerRunning = true;
- }
- function cellover(table_cell) {
- // play around with these values
- // element, from_color, to_color, interval(milliseconds), transition steps
- myfade(table_cell,'#B9D4E6','#eeeee0',20,32)
- }
- function cellout(table_cell) {
- if (timerRunning) {
- clearInterval(iId)
- iId = null;
- }
- table_cell.style.backgroundColor = '#B9D4E6'
- }
- joebert
- Sledgehammer


- Joined: Feb 10, 2004
- Posts: 13455
- Loc: Florida
- Status: Offline
Let's see the page calling the scripts source, I just tried the above code, added cellover(this) and cellout(this) to a TD tag and It works like a charm.
EDIT: I just noticed that your using fader.js as well, I'd really like to know if you can get fader.js to work with this cell fader. I tinkered with trying to get fader and a cell fader to work together awhile ago with no success.
EDIT: I just noticed that your using fader.js as well, I'd really like to know if you can get fader.js to work with this cell fader. I tinkered with trying to get fader and a cell fader to work together awhile ago with no success.
Strong with this one, the sudo is.
- oblongintellect
- Novice


- Joined: Mar 23, 2004
- Posts: 28
- Status: Offline
- oblongintellect
- Novice


- Joined: Mar 23, 2004
- Posts: 28
- Status: Offline
Here's an example of the finished product. The colors will be reworked. This is only a working example. I still want to try and incorporate Nunzio's cellfader script but I gotta go to work soon and I'm currently still getting script errors.
http://www.ghosthacker.org/test.html
Thanks again for all the help.
-OI
http://www.ghosthacker.org/test.html
Thanks again for all the help.
-OI
- joebert
- Sledgehammer


- Joined: Feb 10, 2004
- Posts: 13455
- Loc: Florida
- Status: Offline
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 8 posts
- Users browsing this forum: No registered users and 180 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
