0

timer component

asked 2008-07-16 16:00:16 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai,

i need to change font color from white to a red. i would like to use i timer to achieve that.

the problem : how to use a timer if i create a page a manual ?,

Is there anyone use a timer component because i need to discussion ?


TIA,

andy susanto

delete flag offensive retag edit

13 Replies

Sort by ยป oldest newest

answered 2008-07-17 14:09:25 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai,

maybe my previous post does not clear enough. How create a label of button likely blinking.

usually if i would to do that i create a javascript using setTimeout and that replace style of button from black font to red font and red font to black font.

so can i implement that with a Timer Component ?


TIA,

andy susanto

link publish delete flag offensive edit

answered 2008-07-18 05:38:57 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

The Timer component is majorly used for periodic server request. I will not suggest using Timer component in your use case. ZK lives well with customized javascript, why not just follow your original implementation?

You can use Clients.evalJavaScript to call your javascript code.

link publish delete flag offensive edit

answered 2008-07-20 08:39:40 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai Henri,

is there any an example because i do not know how to start ?

can you teach me ?


TIA,


andy susanto

link publish delete flag offensive edit

answered 2008-07-20 09:59:27 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Write your JavaScript code that will blink your button and then I tell you how to trigger it from ZK event.

/henri

link publish delete flag offensive edit

answered 2008-07-21 12:20:36 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai Henri,

first i create a blink tag <blink> after that in my javascript i find that tag and use a display to set Visible and hidden. and in body tag i put
setInterval('blinkit()',1000)

this my javascript:
function blinkit(){
if (!document.all) return;
else{
for(i=0;i<document.all.tags('blink').length;i++){
s = document.all.tags('blink');
s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
}
}
}

TIA,

andy susanto

link publish delete flag offensive edit

answered 2008-07-22 02:04:53 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Please just provide a testing code that will work with your javascript implementation such that I can simply deploy it and test it. Then I will refactor it to work with ZK event.

link publish delete flag offensive edit

answered 2008-07-22 11:43:24 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai henri,

this my code before i use a zk framework

<HTML>
<HEAD>

<SCRIPT>function blinkit(){
  if (!document.all) return;
  else{
    for(i=0;i<document.all.tags('blink').length;i++){
      s = document.all.tags('blink')<i >;
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
    }
  }
}
function auto(){ 
  location.reload(true);
} 

</SCRIPT><SCRIPT LANGUAGE='JavaScript' SRC='/hotel/js/blockkey.js' ></SCRIPT>
</HEAD>
<BODY ONLOAD = "setInterval('blinkit()',1000)" BGCOLOR="#A9D4F2">
	<TABLE>
<TR HEIGHT=26><TD><FONT COLOR='RED'><BLINK>18:28:58</BLINK></FONT></TD><TD><FONT COLOR='RED'><BLINK>19:58:58</BLINK></FONT></TD><TD> </TD></TR>

</TABLE></BODY>
</HTML>

link publish delete flag offensive edit

answered 2008-07-24 06:13:04 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Your html does not work on IE (javascript error).
The FF does not care the javascript. I remove all JavaScript and it still blink. Looks FF knows <blink> tags.
However, I refactored your code. When you press "Start Blink" in IE (FF will blink with or without JavaScript code so don't test this on FF), it start running the JavaScript function blinkit().

<zk>
<script type="text/javascript"><![CDATA[
function blinkit(){
  if (!document.all) return;
  else{
    for(i=0;i<document.all.tags('blink').length;i++){
      s = document.all.tags('blink')<i >;
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
    }
  }
}
function auto(){ 
  location.reload(true);
} 
]]></script>
<html><![CDATA[
	<TABLE>
<TR HEIGHT=26><TD><FONT COLOR='RED'><BLINK>18:28:58</BLINK></FONT></TD><TD><FONT
COLOR='RED'><BLINK>19:58:58</BLINK></FONT></TD><TD> </TD></TR>

</TABLE>
]]></html>
<button label="Start Blink">
<attribute name="onClick">
	Clients.evalJavaScript("setInterval('blinkit()',1000)");
</attribute>
</button>
</zk>

link publish delete flag offensive edit

answered 2008-07-24 11:38:41 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai Henri,
just change <i > to (i)


or this the right javascript

<HTML>
<HEAD>

<SCRIPT>function blinkit(){
  if (!document.all) return;
  else{ 
    for(i=0;i<document.all.tags('blink').length;i++){
      s = document.all.tags('blink')(i);
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
    }
  }
}
function auto(){ 
  location.reload(true);
} 

</SCRIPT>
</HEAD>
<BODY  ONLOAD = setInterval('blinkit()',1000) BGCOLOR="#A9D4F2">
	<TABLE>
<TR HEIGHT=26><TD><FONT COLOR='RED'><BLINK>18:28:58</BLINK></FONT></TD><TD><FONT COLOR='RED'><BLINK>19:58:58</BLINK></FONT></TD><TD> </TD></TR>

</TABLE></BODY>
</HTML>

but Henri i need javascript running when a document finish to display. in your example the blink will start after click a button

and btw can an example use only a zul file. What i mean is zul component only. because i do not want use

<html><![CDATA[
	<TABLE>
<TR HEIGHT=26><TD><FONT COLOR='RED'><BLINK>18:28:58</BLINK></FONT></TD><TD><FONT
COLOR='RED'><BLINK>19:58:58</BLINK></FONT></TD><TD> </TD></TR>

</TABLE>
]]></html>

because i would like to blink the caption of table or just a button for the easy way to blink

TIA,

andy susanto

link publish delete flag offensive edit

answered 2008-07-24 12:55:26 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Andy,

Just put the Clients.evalJavaScript in onCreate of your loading page then it will be called when the page is loaded.

As for the zul file, the example has show you the concept. You shall be able to design it yourself per your own request.

/henri

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-07-16 16:00:16 +0800

Seen: 608 times

Last updated: Aug 07 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More