rejetto forum
Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: ge2001 on August 17, 2010, 08:49:47 PM
-
Hi,
Maybe you can help me with this fragment:
<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
-
i think you should start changing all the {{. in {.
and .}} in .}
-
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 ?
-
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
-
@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
-
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
-
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 :D
;)
-
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 (http://en.wikipedia.org/wiki/Ajax_%28programming%29).
-
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
-
Hi,
Easy chat attached.
-
Hi,
Easy chat attached.
Thanks for sharing :)
It works, but it adds many entries to the log quickly.
Needs [.....|no log] added.