rejetto forum
February 09, 2012, 04:16:58 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: file changed macro in combination with javascript  (Read 785 times)
0 Members and 1 Guest are viewing this topic.
ge2001
Guest


Email
« on: August 17, 2010, 03:49:47 PM »

Hi,
Maybe you can help me with this fragment:

Code:
<script language="JavaScript" type="text/javascript">
<!--
var active;
function f_ChatUpdate()
{
{{.if|{{.file changed|ge2001\chat\chat.txt.}}|
{:
Dummy=String(Math.random());parent.frames[1].location.replace("chat.txt"+'?'+Dummy);
:}
.}}
}
-->
</script>

</head>
<body onload="aktiv=window.setInterval('f_ChatUpdate()',3000);" onunload="window.clearInterval(aktiv);">

The chat updates always, even if the file isn't changed. That is the problem.

Thanks
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« Reply #1 on: August 17, 2010, 04:55:49 PM »

i think you should start changing all the {{. in {.
and .}} in .}
Logged
ge2001
Guest


Email
« Reply #2 on: August 18, 2010, 05:58:13 AM »

Hi,
thank you for the help, code corrected.
Maybe i don't understand the file changed macro.
If i edit the file chat.txt manualy with a text editor and save it no update occurs.

I remove the macros, only using the javascript:

Dummy=String(Math.random());parent.frames[1].location.replace("chat.txt"+'?'+Dummy);

Now again editing the file chat.txt manualy with a text editor and saving it the update works fine.

So, what is wrong in my way of thinking ?
Logged
ge2001
Regular poster
**
Offline Offline

Germany Germany

Posts: 28


What


View Profile WWW
« Reply #3 on: August 20, 2010, 04:40:28 AM »

Hi,
the main question for me is how to use macros inside a javascript function.
Is it possible ? Can somebody supply an example ?

That is what i like to do:

function f_ChatUpdate()
{
macros here ?
Dummy=String(Math.random());parent.frames[1].location.replace("chat.txt"+'?'+Dummy);
}


Thanks
Logged
Mars
Operator
Insane poster
*****
Offline Offline

France France

Posts: 1468



View Profile WWW
« Reply #4 on: August 20, 2010, 01:45:52 PM »

@ge2001
The macros are as variables, they are estimated and replaced before sending to the browser, they do not appear any more in sources of the web page, the macro are the equivalent diverted from the php
Logged
ge2001
Regular poster
**
Offline Offline

Germany Germany

Posts: 28


What


View Profile WWW
« Reply #5 on: August 20, 2010, 02:54:37 PM »

Hi,
o.k, thank you Mars.

But why do the code in my first post don't work ?
Please read also my second post, simulating the change of the file chat.txt with a text editor.
It works only if i remove the macros.

Do you have an idea ?

Thank you
Logged
rejetto forum
« Reply #5 on: August 20, 2010, 02:54:37 PM »

Do you like this software? Consider even $2
 Logged
Mars
Operator
Insane poster
*****
Offline Offline

France France

Posts: 1468



View Profile WWW
« Reply #6 on: August 20, 2010, 03:34:43 PM »

In the ideal, it would be necessary to use a flow rss to update only what is modified in the file txt, but it is outside my field of expertise.

On the other hand, the macro of the first comment does not still exist, that's why it cannot work Cheesy

 Wink
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« Reply #7 on: August 25, 2010, 06:25:43 PM »

problem is: you are mixing server-side and client-side scripting.
server-side is run just ONCE, and before the browser downloads the page.
so you wrote your script expecting at every javascript interval to get the {.file changed.} while it is actually executed ONCE, before any interval is initiated.
if you need to read the {.file changed.} value through javascript you'll have to use AJAX.

Follow members gave a thank to your post:

ge2001

For this post, 1 member gave a thank you!
Logged
ge2001
Regular poster
**
Offline Offline

Germany Germany

Posts: 28


What


View Profile WWW
« Reply #8 on: August 26, 2010, 04:41:52 PM »

Ouh,
thank you very much for the information.
I'm wondering that that several macros in a javascript interval do not work like expected.
Yes it works once, that was just confusing me completly ...

Your statement is very usefull for me and maybe also for other.


Thanks rejetto
Logged
ge2001
Regular poster
**
Offline Offline

Germany Germany

Posts: 28


What


View Profile WWW
« Reply #9 on: August 28, 2010, 08:45:24 AM »

Hi,
Easy chat attached.

* EasyChat.zip (2.39 KB - downloaded 40 times.)
Logged
r][m
Insane poster
*****
Offline Offline

United States United States

Posts: 339


View Profile
« Reply #10 on: August 28, 2010, 04:22:27 PM »

Hi,
Easy chat attached.
Thanks for sharing  Smiley
It works, but it adds many entries to the log quickly.
Needs [.....|no log] added.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page February 06, 2012, 04:43:58 PM