I'd approach this by using AJAX to replace the contents of the chat without refreshing the whole page. An iframe is a good approach too.
Once you get things working, it might be nice to switch to push techniques at some point: http://en.wikipedia.org/wiki/Comet_(programming) That way you don't have to reload the whole conversation every N seconds. This probably isn't important enough to lose sleep over, though. ^_^
Is the Arclanguage forum or HN (or something similiar) open-source?
Whatever you're using for Arc probably includes news.arc and app.arc, and those are released as specified in the "copyright" file:
This software is copyright (c) Paul Graham and Robert Morris. Permission
to use it is granted under the Perl Foundations's Artistic License 2.0.
In essence, it's a license that allows a lot of freedom but states that you can only distribute a modified version "provided that you clearly document how it differs from the Standard Version." I think the point is so that people who consider your modifications to be shoddy work or copyright infringement don't go complaining to Paul Graham or Robert Morris.
This is a very nice forum I have to say, great edititing and automatic code recognition! Never seen something as good as that.
You're one of the luckier ones, I guess. :) Complete editing instructions are at http://arclanguage.org/formatdoc in case you're interested.
I'd approach this by using AJAX to replace the contents of the chat without refreshing the whole page. An iframe is a good approach too.
Is that possible to do _in Arc_ (By something with tag ?) or do I need something else as well? I'm really not very expirienced and would have no idea how to combine my Arc-Sourcecode with something completely external... or how to implement these Comet-techniques.
Is it actually possible to make normal Frames or iFrames with the tag-macro?
Thanks for news.arc, I haven't seen it for some reason, seems like it's worth reading.
1. chatlog?room=1&max=20 , this service returns the conversation data you would like placed in your div having an id of 'chatlog'. The room is the id for a conversation and max is the number of items you want returned from the conversation history.
2. checkchat?room=1, this service checks to see if there's been an update in the chatlog since the last time the user checked. So you need to store the last time checked, and compare that to the timestamp of when the chatlog, for that room, was last updated. Comparing the two will return either Y or N. Y will trigger the update. There's javascript noted below that will auto check this for you.
Javascript:
(def get+xmlhttp (url)
(string
"function GetData(){
if (window.XMLHttpRequest){
var xmlHttp = new XMLHttpRequest ();}
if (window.ActiveXObject){
var xmlHttp = new ActiveXObject(\"Microsoft.XMLHTTP\");}
xmlHttp.open (\"GET\",\"" url "\", false);
xmlHttp.send (null);
var targetNode = document.getElementById (\"chatlog\");
targetNode.innerHTML = xmlHttp.responseText;};"))
(def checkif+xmlhttp (url)
(string
"function CheckChatLog(){
if (window.XMLHttpRequest){
var textHttp = new XMLHttpRequest ();}
if (window.ActiveXObject){
var textHttp = new ActiveXObject(\"Microsoft.XMLHTTP\");}
textHttp.open (\"GET\",\"" url "\", false);
textHttp.send (null);
if (textHttp.responseText == \"Y\") GetData();};
window.setInterval(\"CheckChatLog()\",5000);"))
The 'CheckChatLog' function checks the 'checkchat' service to see if there's been an update. If there has been, then 'GetData' is called which pushes the data into your 'chatlog' div.
Notice 'checkif+xmlhttp' has 'window.setInterval', so the js will periodically run 'CheckChatLog' for you - you may want to tweak the 5000 time interval.
I hope that's useful. I created one a year or so ago, which haven't touched it since, so if something doesn't make sense, ask away.
Doing an ajax get will require javascript. Look at votejs* in news.arc.
Frames and iframes can be rendered using tag but you'll need to update html.arc to recognize their html attributes. Surprisingly this isn't fixed in anarki, but see if you can figure out what to do at http://github.com/nex3/arc/blob/3201b34f3ed89e6305b0d99066e4...
On Frames: As the starttags <frameset attributes...> and <frame attbibutes...> aren't the same as the end tags, I'd have to do macros like (mac tab...), or ?
This should be possible... and then add the attributes, yeah. I will try it soon, thanks.
When I have a frame, how can I tell the code, to autorefresh it and only it?
And does a frame need a .html-file to read? or can scr="...", the attribute of a frame, be the name of a (defop xyz...)?