Jump to content

infobar help


rupsen

Recommended Posts

i have a php script that generates a javascript code for a infobar

 

now i get a javascript syntaxiserror

 

it says it's in this line:

.prototype.setContent=function(data){

here is the actual javascript code:

 

<script type="text/javascript">
function (){
    this.displayfreq="always"
    this.content='<a href="javascript:.close()\"><img src="plugins/infobar/img/close.gif" style=\"width: 14px; height: 14px; float: right; border: 0; margin-right: 5px" /></a>'
}

.prototype.setContent=function(data){
    this.content=this.content+data
    document.write('<div id="" style="top: -500px">'+this.content+'</div>')
}

.prototype.animatetoview=function(){
    var barinstance=this
    if (parseInt(this.barref.style.top)<0){
        this.barref.style.top=parseInt(this.barref.style.top)+5+"px"
        setTimeout(function(){barinstance.animatetoview()}, 50)
    }
    else{
        if (document.all && !window.XMLHttpRequest)
        this.barref.style.setExpression("top", 'document.compatMode=="CSS1Compat"? document.documentElement.scrollTop+"px" : body.scrollTop+"px"')
    else
        this.barref.style.top=0
    }
}

.close=function(){
    document.getElementById("").style.display="none"
    if (this.displayfreq=="session")
        document.cookie="shown=1;path=/"
}

.prototype.setfrequency=function(type){
    this.displayfreq=type
}

.prototype.initialize=function(){
    if (this.displayfreq=="session" && document.cookie.indexOf("infobarshown")==-1 || this.displayfreq=="always"){
        this.barref=document.getElementById("")
        this.barheight=parseInt(this.barref.offsetHeight)
        this.barref.style.top=this.barheight*(-1)+"px"
        this.animatetoview()
    }
}

window.onunload=function(){
    this.barref=null
}

</script> 

 

and here is the php script:

$infobox_header .= '<script type="text/javascript">
function '.$event.'(){
    this.displayfreq="always"
    this.content=\'<a href="javascript:'.$event.'.close()\"><img src="plugins/infobar/img/close.gif" style=\"width: 14px; height: 14px; float: right; border: 0; margin-right: 5px" /></a>\'
}

'.$event.'.prototype.setContent=function(data){
    this.content=this.content+data
    document.write(\'<div id="'.$event.'" style="top: -500px">\'+this.content+\'</div>\')
}

'.$event.'.prototype.animatetoview=function(){
    var barinstance=this
    if (parseInt(this.barref.style.top)<0){
        this.barref.style.top=parseInt(this.barref.style.top)+5+"px"
        setTimeout(function(){barinstance.animatetoview()}, 50)
    }
    else{
        if (document.all && !window.XMLHttpRequest)
        this.barref.style.setExpression("top", \'document.compatMode=="CSS1Compat"? document.documentElement.scrollTop+"px" : body.scrollTop+"px"\')
    else
        this.barref.style.top=0
    }
}

'.$event.'.close=function(){
    document.getElementById("'.$event.'").style.display="none"
    if (this.displayfreq=="session")
        document.cookie="'.$event.'shown=1;path=/"
}

'.$event.'.prototype.setfrequency=function(type){
    this.displayfreq=type
}

'.$event.'.prototype.initialize=function(){
    if (this.displayfreq=="session" && document.cookie.indexOf("infobarshown")==-1 || this.displayfreq=="always"){
        this.barref=document.getElementById("'.$event.'")
        this.barheight=parseInt(this.barref.offsetHeight)
        this.barref.style.top=this.barheight*(-1)+"px"
        this.animatetoview()
    }
}

window.onunload=function(){
    this.barref=null
}

</script>
'; 

 

so if anybode knows what is wrong, and how to make it correct in the php code, that would be great :)

Link to comment
https://forums.phpfreaks.com/topic/127959-infobar-help/
Share on other sites

but still it's working, so what should i edit in the php script?

 

im very new to this so i dont understand the most terms :)

 

btw here is the complete php code:

 

require("plugins/infobar/lang/infobar.".$usr['lang'].".lang.php");

// Check if non-registered user
if ($usr['maingrp'] <= 0){
$event = "informationbar";
$infobox_body  .= '<script type="text/javascript">
				var infobar=new '.$event.'()
		infobar.setContent(\''.$L['member'].'<a href=\"users.php?m=register\">'.$L['member_click'].'</a>\')';

if ($cfg['plugin']['infobar']['sessionregister'] == "Yes"	){

	$infobox_body  .= '	
	infobar.setFrequency("session")
	infobar.initialize()
	</script>
';
}

else {
$infobox_body  .= '
infobar.initialize()
</script>
';	
}
}



// Check if user has new PM
if ($usr['newpm']){
$event = "informationbarpm"; 
$infobox_body  .= '<script type="text/javascript">
				var infobar=new '.$event.'()
			infobar.setContent(\''.$L['pm'].'<a href=\"pm.php\">'.$L['pm_click'].'</a>\')';

if ($cfg['plugin']['infobar']['sessionpm'] == "Yes"	){

	$infobox_body  .= '	
	infobar.setFrequency("session")
	infobar.initialize()
	</script>
';
}

else {
$infobox_body  .= '
infobar.initialize()
</script>
';	
}
}

// Feed out header javascript functions
$infobox_header .= '<script type="text/javascript">
function '.$event.'(){
this.displayfreq="always"
this.content=\'<a href="javascript:'.$event.'.close()\"><img src="plugins/infobar/img/close.gif" style=\"width: 14px; height: 14px; float: right; border: 0; margin-right: 5px" /></a>\'
}

'.$event.'.prototype.setContent=function(data){
this.content=this.content+data
document.write(\'<div id="'.$event.'" style="top: -500px">\'+this.content+\'</div>\')
}

'.$event.'.prototype.animatetoview=function(){
var barinstance=this
if (parseInt(this.barref.style.top)<0){
	this.barref.style.top=parseInt(this.barref.style.top)+5+"px"
	setTimeout(function(){barinstance.animatetoview()}, 50)
}
else{
	if (document.all && !window.XMLHttpRequest)
	this.barref.style.setExpression("top", \'document.compatMode=="CSS1Compat"? document.documentElement.scrollTop+"px" : body.scrollTop+"px"\')
else
	this.barref.style.top=0
}
}

'.$event.'.close=function(){
document.getElementById("'.$event.'").style.display="none"
if (this.displayfreq=="session")
	document.cookie="'.$event.'shown=1;path=/"
}

'.$event.'.prototype.setfrequency=function(type){
this.displayfreq=type
}

'.$event.'.prototype.initialize=function(){
if (this.displayfreq=="session" && document.cookie.indexOf("infobarshown")==-1 || this.displayfreq=="always"){
	this.barref=document.getElementById("'.$event.'")
	this.barheight=parseInt(this.barref.offsetHeight)
	this.barref.style.top=this.barheight*(-1)+"px"
	this.animatetoview()
}
}

window.onunload=function(){
this.barref=null
}

</script>
';


// And throw the stuff out
$t-> assign(array(
"INFOBOX_HEADER" => $infobox_header,
"INFOBOX_BODY" => $infobox_body,
"HEADER_METAS" => $out['metas'].'<link rel="stylesheet" href="./plugins/infobar/infobar.css" type="text/css" title="Information Bar" />',
));

?>

Link to comment
https://forums.phpfreaks.com/topic/127959-infobar-help/#findComment-662643
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.