Arc Forumnew | comments | leaders | submit | Moon1ight's commentslogin

SOLVED.

I have defined attributes for iframe and the meta-tag in html.arc, after which it was easy to put the posts into an iframe and to set a meta-refresh on it.

Thanks to all of you, without your help I probably hadn't even thought about messing with html.arc and frames this hard. If someone wants I'll post the sourcecode of it, maybe it's useful.

-----


Thanks a lot for the quick answer, but:

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.

-----

2 points by thaddeus 5432 days ago | link

Here's an option:

  HTML Layout:

  <html>
  <head>
    <script type="text/javascript">
      (pr (get+xmlhttp (string "chatlog?room=" room "&max=" maxm))
          (checkif+xmlhttp (string "checkchat?room=" room))
    </script>
  </head>
  <body onLoad="javascript: GetData();">
     <div id='chatlog'  ....>
     </div>
   </body>
  <html>

  Services:
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.

-----

2 points by akkartik 5432 days ago | link

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...

-----

1 point by Moon1ight 5431 days ago | link

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...)?

-----