掲示板

javascript ticker not working

thumbnail
15年前 に Amro A Ali によって更新されました。

javascript ticker not working

New Member 投稿: 2 参加年月日: 08/08/31 最新の投稿
I am trying to make use of a javascript ticker in liferay. Here is what I have thus far:

ticker.vm file in _diffs/template directory:

<div id="TICKER">
  TICKER CONTENT THAT SCROLLS!
</div>
<script language="JavaScript" type="text/javascript" src="$js_ticker_file"></script>


init_custom.vm in _diffs/template directory:


#set ($js_ticker_file = "$javascript_folder/webticker_lib.js?t=$theme_timestamp")


I parse ticker.vm in portal_normal.vm before the code that renders the navigation


#parse ("$full_templates_path/ticker.vm")


here is the listing for the javascript wbticker_lib.js I call (courtesy of mioplanet):



// WebTicker by Mioplanet
// www.mioplanet.com

TICKER_CONTENT = document.getElementById("TICKER").innerHTML;
 
TICKER_RIGHTTOLEFT = false;
TICKER_SPEED = 2;
TICKER_STYLE = "font-family:Arial; font-size:12px; color:#444444";
TICKER_PAUSED = false;

ticker_start();

function ticker_start() {
	var tickerSupported = false;
	TICKER_WIDTH = document.getElementById("TICKER").style.width;
	var img = "<img src="ticker_space.gif" width="+TICKER_WIDTH+" height="0">";

	// Firefox
	if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1) {
		document.getElementById("TICKER").innerHTML = "<table cellspacing="0" cellpadding="0" width="100%"><tbody><tr><td nowrap>"+img+"<span style="&quot;+TICKER_STYLE+&quot;" id="TICKER_BODY" width="100%">&nbsp;</span>"+img+"</td></tr></tbody></table>";
		tickerSupported = true;
	}
	// IE
	if (navigator.userAgent.indexOf("MSIE")!=-1 &amp;&amp; navigator.userAgent.indexOf("Opera")==-1) {
		document.getElementById("TICKER").innerHTML = "<div nowrap style="width:100%;">"+img+"<span style="&quot;+TICKER_STYLE+&quot;" id="TICKER_BODY" width="100%"></span>"+img+"</div>";
		tickerSupported = true;
	}
	if(!tickerSupported) document.getElementById("TICKER").outerHTML = ""; else {
		document.getElementById("TICKER").scrollLeft = TICKER_RIGHTTOLEFT ? document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth : 0;
		document.getElementById("TICKER_BODY").innerHTML = TICKER_CONTENT;
		document.getElementById("TICKER").style.display="block";
		TICKER_tick();
	}
}

function TICKER_tick() {
	if(!TICKER_PAUSED) document.getElementById("TICKER").scrollLeft += TICKER_SPEED * (TICKER_RIGHTTOLEFT ? -1 : 1);
	if(TICKER_RIGHTTOLEFT &amp;&amp; document.getElementById("TICKER").scrollLeft &lt;= 0) document.getElementById("TICKER").scrollLeft = document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth;
	if(!TICKER_RIGHTTOLEFT &amp;&amp; document.getElementById("TICKER").scrollLeft &gt;= document.getElementById("TICKER").scrollWidth - document.getElementById("TICKER").offsetWidth) document.getElementById("TICKER").scrollLeft = 0;
	window.setTimeout("TICKER_tick()", 30);
}



finally I have the ticker render using the following entry in custom.css in _diffs/css:
#TICKER {

	margin: 0 auto;
	overflow: hidden;

	width: 800px;
	/*background: blue;*/

}


I am not getting the ticker to work! The output comes out stationary on FireFox v3.0.3.

HELP!
thumbnail
15年前 に Amro A Ali によって更新されました。

RE: javascript ticker not working

New Member 投稿: 2 参加年月日: 08/08/31 最新の投稿
Well here is some good news and some bad news...

the good news is.. this way fo calling js functions is working.. bad news is window.setTimeout(TICKER_tick(),30) is not doing it's job.

I think it's got to do with Global Context method calling.. I have no idea how to get around it though.. so if you view this post and you've got any idea... I appreciate some feedback.. if you dont.. drop a hello emoticon
15年前 に Vaneet Sharma によって更新されました。

RE: javascript ticker not working

Regular Member 投稿: 195 参加年月日: 08/07/25 最新の投稿
Hi,

So were you able to get it working ?
12年前 に Abu Muhammad によって更新されました。

RE: javascript ticker not working

New Member 投稿: 9 参加年月日: 11/09/30 最新の投稿
Can you tell me, where it should place the js file?
thank you