PDA

View Full Version : Pausing up-down message scroller language selection



Webnewbie
10-19-2007, 09:17 AM
1) CODE TITLE:
Pausing up-down message scroller
http://www.dynamicdrive.com/dynamicindex2/crosstick.htm

2) AUTHOR NAME/NOTES:
Dynamic drive

3) DESCRIPTION:
Multilanguage sql database linked to the "Pausing up-down message scroller"
I have developped a bilingual website and i have news in english and french. I've setup a language field in my sql database but i don't know how to ask only for the english content (en) for the english website and the french (fr) content for the french site, as i don't know what to modify in the code to determine this specific info. Can anybody help me on that one?

4) ATTACHED BELOW:
working on www.fiscon.com



<style type="text/css">

/*Example CSS for the two demo scrollers*/

#pscroller1{
width: 175px;
height: 130px;
padding-top: 1px;
padding-bottom: 0px;
padding-left: 7px;
padding-right: 7px;
text-align:justify;

}

.someclass{ /*background-image: url(sources/logodepeches2.jpg);
background-repeat: no-repeat;
height: 190px;
width: 197px;
position: fixe;
vertical-align: text-top;*/
}

</style>

<script type="text/javascript">

/*Example message arrays for the two demo scrollers*/

var pausecontent=new Array()
<?php



$cnx = connect_BD(MY_BASE);
$sql = "SELECT UNIX_TIMESTAMP(DATE) as ID, LANGUE, TITRE, TEXTE, LIENS, DATE, SOUSTITRE, DATE_FIN ";
$sql .= "FROM depeches ";
$sql .= "ORDER BY DATE ";


$qry = exec_SQL(MY_BASE,$sql) or die('Erreur SQL TADM!'.$sql.'<br />'.mysql_error());
$i = 0;
while($com = get_Array($qry))
{
$lines = file ('new2.html');
foreach($lines as $line)
{
$com['TEXTE'] =str_replace("'","\'",$com['TEXTE']);
$word = array("#TITRE#","#TEXTE#","#LIENS#","#DATE#","#SOUSTITRE#","#DATE_FIN#","#LANGUE#","#CONT#");
$remplace = array($com['TITRE'],$com['TEXTE'],$com['LIENS'],$com['DATE'],$com['SOUSTITRE'],$com['DATE_FIN'],$com['LANGUE'],$i);
$newline = str_replace($word, $remplace, $line);
echo $newline."\n";
if ($newline != "")
{
$i = $i + 1;
}
}
}

close_BD($cnx);

?>

</script>

<script type="text/javascript">

/***********************************************
* Pausing up-down scroller- Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

</script>

tech_support
10-19-2007, 09:30 AM
Have you read the banner?
http://www.dynamicdrive.com/forums/designfiles/submitlogo.gif
Not "DD Scripts Help"

//Thread moved.

Now, ugh

Webnewbie
10-19-2007, 09:56 AM
Sorry,
I just corrected the post.
Have a good one mate.

ddadmin
10-19-2007, 09:49 PM
Do you already have a mechanism in place for users to switch between the English and French versions of your site? Basically all that's involved is to use the same scheme, and dynamically output the array portion of the Pausing Scroller to the correct content at the very top.

I see you're already on the right path as far as using PHP to write out the actual JavaScript array elements (ie: pausecontent[0], pausecontent[1] etc). Unless you're running into a JavaScript syntax problem when doing this, only you know how the rest of your PHP code/ mySQL code works and fits together.

Webnewbie
10-23-2007, 05:18 PM
Actually, there is one home page per language. One in english the other one in french. The problem i have, is that I didn't develop the DB and is the script as i didn't know how to. The guy who developped it for me disappeared before ending the project.

Webnewbie
11-01-2007, 10:42 PM
here is the code of the news2.html file



pausecontent[#CONT#]="
<div style='font-size:12px;color:#FFFFFF;text-align:center; top:2px; font-weight:bolder '>
#TITRE#</div><br ><span style='font-size:12px; color:#4d0020; font-weight:bold;'>
#SOUSTITRE#</span><br /><span style='font-size:11px; color:#4d0020; text-align:justify;'>
#TEXTE#</span><br />
<a href='presse.php' style='font-size:12px; text-align:center;color:#4d0020'>Read more</a>"

Webnewbie
11-02-2007, 11:43 AM
Thanks to KURT of http://www.tutorialized.com/user/kurt

the solution is simple when you know how to ask a sql database :)
SELECT * FROM yourdatabasename WHERE LANGUE='EN'