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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.