Topic: How do I put this method in application.js?
I want to make the markup on the home page of http://Notipal.com valid XHTML strict, but I don't know how to move the inline javascript on the 'error_facts' (the scrolling div with links) in to the application.js. The javascript is included inline (grabbed it from a tutorial) underneath the div.
The following attempt threw errors on the scrollMe, apparently it 'isn't defined' - presumably this means the 'scrollMe' function needs handling or defining differently when this whole function is moved to a var in the application.js, like so;
$(document).observe('dom:loaded', function() {
setup_site_switch()
setup_error_facts()
})var setup_site_switch = function() {
.
.
.
}
var setup_error_facts = function() {
if($('error_facts')) {
var boxHeight = $('error_facts').style.height.replace('px','')
var repeatHeight = $('error_facts').scrollHeight //get the current height so we know when to wrap
$('error_facts').innerHTML = $('error_facts').innerHTML + $('error_facts').innerHTML //add a second copy so we can scroll down to the wrap point
var stopScroll = 0
var x
function scrollMe() {
clearTimeout(x)
if(stopScroll==1) {
return
}
$('error_facts').scrollTop=$('error_facts').scrollTop+1
if($('error_facts').scrollTop<=repeatHeight) {
// keep on scrolin'
x = setTimeout("scrollMe()",40)
}
else { //we have hit the wrap point
$('error_facts').scrollTop=0
x = setTimeout("scrollMe()",40)
}
}
x = setTimeout("scrollMe()",1000)
// start scrolling after one second
}
}
Does anyone know how I do this?