From my point of view, I like it to view the DEMO first: http://www.kulturwochenende.com (http://www.kulturwochenende.com)
This is the code for the block and the files you need for a real AJAX Chat.
So, your portal needs no more refreshes.
Things to do:
1. Create a new block (centered block and phpbox)
2. Fill this block with this code (and edit the "your-url/chat.js" line):
$chatuser=$context["user"]["name"];
echo "<input type=\"hidden\" id=\"chatnick\" name=\"chatnick\" value=\"$chatuser\">";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"99%\"><input id=\"chatmsg\" name=\"chatmsg\" type=\"text\" style=\"width:99%\" onkeyup=\"keyup(event.keyCode);\"></td><td width=\"1%\"><input type=\"button\" value=\"Chat\" onclick=\"submit_msg();\"></td></tr></table>";
echo "<div id=\"chatwindow\" style=\"margin-top:3px; width:100%; height:150px; overflow:scroll; border: 1px none #000000; background-color: #FFFFFF; layer-background-color: #FFFFFF;\"></div>";
echo "<script type=\"text/javascript\" src=\"http://your-url/chat.js\"></script>";
3. Download: http://www.janwerthmann.de/web/ajax_chat.zip (http://www.janwerthmann.de/web/ajax_chat.zip)
4. Search in the file chat.js for "www.kulturwochenende.com/forum/" and replace it with your URL.
5. Extract the folder and upload the single files to the folder where the index.php is.
6. Edit the w.php file. The comments are only in German, sorry. But when you're fit in php, you'll find it out. The nicknames between line 114 and 138 are nicks from my friends and when they submit a post, a special color will be posted.
7. But be careful... This was a quick work and take care of the security...
Please write me for security-updates or if you need support!
This work based on the scripts from chris (chris at linuxuser dot at)
most simple ajax chat script (www.linuxuser.at) (GPLv2)
Also be aware, that ajax stuff like this is pretty taxing on a server. Thanks for the share.
Looks cool! 8)
:up: Good job! I've been testing it and I've changed the parameter in .js which makes it to display last post on bottom instead of top, but when it reachs the number of posts which activates the scroll bars, the last post is written out of the window. Is there a way to automatically go to the last post in this way?
Thanks for this!
Quote from: IchBinâ„¢ on May 08, 2007, 03:39:29 AM
Also be aware, that ajax stuff like this is pretty taxing on a server.
Do you mean the amount of data per month to transfer?
Yes, the AJAX is using a lot of resources both BW and MEM CPU, so many shared hosting services can complain a lot about it and i have even heard and read of sites being closed down for some members.
not very private --> eh??
One more question: I'm using it on a spanish board and we use "special" characters like á é àñ and so more, I've seen that the script saves it on the chat.txt correctly but when they aere displayed this characters are replaced whith this other ?, anyone knows how to fix it?
Thanks.
Quote from: crip~ on May 09, 2007, 10:36:17 AM
not very private --> eh??
You can change this in the administation-center. For demonstration it's open for everyone at my website.
Quote from: tiochus on May 15, 2007, 06:46:48 PM
One more question: I'm using it on a spanish board and we use "special" characters like á é àñ and so more, I've seen that the script saves it on the chat.txt correctly but when they aere displayed this characters are replaced whith this other ?, anyone knows how to fix it?
Thanks.
Open the file w.php and search for this:
$out = str_replace("ä", "ä", $out);
$out = str_replace("ä", "Ä", $out);
$out = str_replace("ü", "ü", $out);
$out = str_replace("ÃÅ"", "Ü", $out);
$out = str_replace("ö", "ö", $out);
$out = str_replace("ö", "Ö", $out);
$out = str_replace("ß", "ß", $out);You can add here your own special characters.
This site (http://www.webmonkey.com/webmonkey/reference/special_characters/) gives you a survey of special characters.
For example, if you want to add the ñ, you have to add:
$out = str_replace("ñ", "ñ", $out);Greetz
Thank you very much. I've added the new characters and it works perfectly. :up:
I soupossed I have to make changes in this portion of code, but as I was not sure.... :smiley6600:
Thanks :coolsmiley:
very good mod!
So I've put it on my server, but it's a little broken. For whatever reason it only shows the last line that was typed, not everything (should show the last 20 lines according to the variable). Any ideas?
Send me the URL and I will have a look!
Is there an easy way to use any function which could regconize BBC codes like the shoutbox to display it in this mod?
I think shoutbox function to do this is tp_doUBBC. Could it be possible?
??? ???
Thanks.
Thanks :up:
I have placed it in a centre block, within a board which has restricted access. Good security that way.
Great script ;D
One problem for me - I need to be able to use norwegian letters (utf-8).
Do you know how I can fix this - I guess I need to add something in th .js file.
Yes, look here (http://www.tinyportal.net/index.php?topic=15772.msg132692#msg132692) ;)
There it is explained for spanish characters
Greetz
Lol, should have seen this fix.
Thanks.
My Chat shows the time 2 hours ahead, is there any way I can adjust the time by 2 hours?
Probably an easy fix but I am blind today. ;D
QuoteMy Chat shows the time 2 hours ahead, is there any way I can adjust the time by 2 hours?
Open the file w.php
Search for the line:
$uhrzeit = "[".date("H:i")."] ";Replace it with:
$twohoursback = time()-7200;
$uhrzeit = "[".date("H:i", $twohoursback)."] ";That should work :)
Yes it worked, Thank you. ;D
Is it possible to use any kind of smilies with this script?
Yes, sure... :)
An easy way to replace ":)" with a smiley is the following:
1. Open the file w.php
2. Insert the line:
$out = str_replace(":)", "<img src='http://www....your_webspace.../smile.gif' />", $out);
Feel free to program your own features.
For example you can add the smileys under the input-field and make them clickable.
Or you can add a checkbox for "Show smileys"
If I have time enough, I will code a more exclusiv Chat with more security and more features.
Besides I don't like it, that the chat reloads every time when you open a new page.
Perhaps I should make a ToDo-List :)
QuoteFor example you can add the smileys under the input-field and make them clickable.
Or you can add a checkbox for "Show smileys"
Do you know how to do this? I am still a newbie but I am trying to learn.
Great support on this forum. ;)
Yes, I know.
Showing the Smileys under the input-field should be no problem.
Then you have to write a javascript, which inserts automatically something like ":smile:" in the input-field when you click on it.
After that you have to insert:
$out = str_replace(":smile:", "<img src='http://www....your_webspace.../smile.gif' />", $out);
That's all
Ok, thanks.
I don't think that I will be able to write this javascript, but I understand for you are saying perfectly.
Is is a lot of code that will be needed in the .js, or is it just a few sentences?
Hello.
First of all, sorry for my English, iÃ,´m spanish ;D
I have the Ajax Chat in a center block, and all is ok, but if I added a block news before, in Internet Explorer only view one line of chat, but in Mozilla Firefox view all lines correctly. If the chat block is in the top of center blocks, all is ok.
Thanks.
Tomorrow I'm having an important presentation, but I promise, that I'll take care of it after that ;)
I have a center block over the center block which contains the AJAX Chat, and it works in all browsers for me. I understand that this is not helping, but which IE version do you have?
Quote from: katoona on June 08, 2007, 12:45:41 AM
I have a center block over the center block which contains the AJAX Chat, and it works in all browsers for me. I understand that this is not helping, but which IE version do you have?
IE 7, thanks
Quote from: Wantonio on June 08, 2007, 12:30:01 AM
Tomorrow I'm having an important presentation, but I promise, that I'll take care of it after that ;)
good luck with your presentation and thanks for help me
The only browser I do not have is IE7.0, so perhaps I have the same problem without knowing it.
Wantonio, any idea?
Thanks
Hi!
Sorry for not saying hello for the last days, anyway I didn't forget the topic...
I read (http://www.tinyportal.net/index.php?topic=14292.0), that we should better write in the Request-Child-Board for support.
So please open a new topic here (http://www.tinyportal.net/index.php?board=133.0) for further requests, with the subject: "AJAX Chat"!
But now, to espimans question. I tested your situation in my forum respectively portal and I got no errors with IE7. This must be a special problem, I suppose, but if you set up a guest-account for me in your portal or if you post a screenshot, this would be very helpful.
The next days I'm in Hamburg and Stuttgart, but I will do what I can ;) So please don't expect fast support from my side. You can also contact me via PM.
PS: By the way I have detected a very courious thing. My news - within a newsblock - are only visible for me as admin and not for others, but that's another problem...
For turkish characters use:
$out = str_replace("ü", "ü", $out);
$out = str_replace("ÃÅ"", "Ü", $out);
$out = str_replace("ö", "ö", $out);
$out = str_replace("ö", "Ö", $out);
$out = str_replace("Ã...ž", "Ş", $out);
$out = str_replace("ÅŸ", "ş", $out);
$out = str_replace("İ", "İ", $out);
$out = str_replace("ÄŸ", "ğ", $out);
$out = str_replace("Ã,,ž", "Ğ", $out);
$out = str_replace("ç", "Ç", $out);
$out = str_replace("Ç", "ç", $out);
in w.php
Anyone know how (if possible) I can make links clickable when writing a url with the Ajax Chat.
It refreshes so often that it is sometimes a little difficult to copy and paste a link. I know I can reduce refresh time, but dont want to.
From the example it appeared flawed as in I could easily fake the Admin's ID and the name was even red as if I were actually an admin.
Yours,
The one and only,
~Chanceler~