News:

SMF 2.0.19 has been released! Please update. Read more.

Main Menu

nneonneo's Shoutbox

Started by nneonneo, December 26, 2006, 06:58:11 PM

Previous topic - Next topic

tyhgdgh

I have Simple Portal installed, I get this error

8: Undefined variable: scripturl
File: /home/virtual/site69/fst/var/www/html/forum/Themes/default/languages/MGallery.english.php (eval?) BLOCK
Line: 4

Can i fix it?

Marcus Forsberg

Fantastic mod! :D

Can you make it so that it says like "NAME has just joined the conversation" when someone joins, and "NAME has quit" when they leave?
Maybe even a list of active users?

tyhgdgh

Quote from: Nascar on December 14, 2008, 08:03:58 AM
Fantastic mod! :D

Can you make it so that it says like "NAME has just joined the conversation" when someone joins, and "NAME has quit" when they leave?
Maybe even a list of active users?

there might be a glitch, go to different page

Marcus Forsberg

I know, but I hva placed the shoutbox on a custom page instead of the header, so for me it would be perfect :)

tyhgdgh


nneonneo

@Nascar: There's a potential lag issue with IE: if you try to fire off an event when someone leaves a page, IE does some weird things and lags the page a lot. I have no idea why.

That said, it's not hard to do this: in initShoutbox(), add a call to makeShout() which says "/me has joined the chat" to the shoutbox. Then, add another action, for $_GET['signoff'] or similar, to makeShout('/me has left the chat'). Then, finally, you can just add an onunload event which fires off an AJAX call to yshout_php+'&signoff'.

@Nintendofanthr33: Try adding global $scripturl; above the offending line.

@Nequil: You can't really block /me because it is built-in to SMF, for example:
Quote/me tests /me
yields
* nneonneo tests /me
You could try replacing /me in the shout, e.g. add
$text=preg_replace('/^\/me /i','',$text) before
preparsecode($text);
and see if that blocks /me.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

Marcus Forsberg

I made it this way:

1. Added this function:

function hasJoined($text,$user=false) {
global $maxLines,$chatPath,$historyPath,$ip;

if($user===false)
global $user;

$emTitle=time()." | $ip";
$banID=isGuest($user)?$ip:$user['id'];
$timestamp="<span class=\"shout-timestamp\" title=\"$emTitle\"><timeval=".time()."></span>";
writeLine("<p class=\"shout\"><font color=\"green\">$timestamp&nbsp;$text</font></p>\n",$chatPath);
truncateChat($maxLines,$chatPath,$historyPath);
}


Then, added this to initShoutbox()
if($user===false)
global $user;
$text = cleanupShout($text.' ');

$a_style = "";
global $user_profile;
if(loadMemberData(Array($user['id']),false,'profile')!==false)
{
$profile=$user_profile[$user['id']];
$a_style = ' class="userclass" style="color: '.(empty($profile['member_group_color']) ? $profile['post_group_color'] : $profile['member_group_color']).'"';
}

$shoutName=$user['name'];
$userID=$user['id'];
if(isGuest($user))
$writeText=$shoutName;
else
$writeText="<a$a_style href=\"index.php?action=profile;u=$userID\">$shoutName</a>";
$writeText.=" har kommit in i chatten.";
hasJoined($writeText,$user);


That works when someone joins, but it also displays the text when you click the sound button etc.

nneonneo

#4727
Ah, yes...that would be because pressing those buttons causes the init to be run again.

Maybe the best solution is to have a new JavaScript function called setStatus or similar, that looks like this (yshout/js/yshout.js):
function setStatus(status) {
new ajax (yshout_php, {
postBody: 'reqtype=status&status=' + status + '&file=' + shoutFile
});
}

Then, in yshout.php, after
case "autoshout":
if(isMod())
processCommand($_POST["shout"]);
break;

add
case "status":
if($_POST['status'] == 'on')
hasJoined('Online');
else
hasJoined('Offline');
break;

or similar. In index.template.php, change
window.onload=function(){loadChat();};
to
window.onload=function(){setStatus("on");loadChat();};
Finally, in yshout.js, change
function unloadChat() {
to
offline=false;
function unloadChat() {
if(!offline) { setStatus("off"); offline=true; }

Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

Marcus Forsberg

That removed the chat :S
Maybe I did something wrong..

nneonneo

Try shift+refresh. Also, my instructions had a slight bug (wouldn't have prevented the chat from working AFAIK) relating to the "offline" status, so I've edited the post.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

Marcus Forsberg

The chat returned, but when I logged out and in from SMF, it disappeared

nneonneo

Funny, it's working fine for me on my test board...you did do shift+refresh, and tried the new code?
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

Marcus Forsberg

Shoutbox is working (Reinstalled it).
But now, the message isn't displayed when someone join/quit :P

tyhgdgh

PHP syntax error

at line 4: $scripturlparsed = parse_url($scripturl);

[unplugged]

Hey nneonneo, I have an update on the Google Chrome issue. My co-admin just noticed that Chrome posts fine when used in the popup window. I have no idea how useful that actually is for you, but I know he is happy again. ;)
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »



nneonneo

@SunKing: It is because on the popup window, the shoutbox forces UTF-8. The bug in Chrome does not appear with UTF-8.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

[unplugged]

And here I thought I was onto something.  :P
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »



nneonneo

I've already asked Sleepy to take a look at it. Hopefully this gets resolved, one way or another. I have a feeling the WebKit team won't budge on this issue (after all, it is technically the correct behaviour...) so some changes will probably be made. Chrome, after all, is gaining popularity, as is Safari.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

fext

#4738
Hi Neonneo,

Got a quick question... I think the shoutbox is not letting my site validate.

I have this code which is used on my SimplePortal:

   // YSHOUT HERE - shoutbox code
   global $txt,$context,$boarddir;
   if(allowedTo('yshout_view'))
   {
      echo '<div id="yshout">';
      include_once($boarddir.'/yshout/yshout.php');
      echo '</div><div class="smalltext" style="padding:5px 0 0 5px;"><a href="javascript:collapse1.slidedown()">Open Smileys</a> | <a href="javascript:collapse1.slideup()">Close Smileys</a>';
                     require('mymod/smiley.php');
                     loadSmileys();
                  echo '
                     <div id="smiley_pic">';
                        printSmileys('shout_form','shout_text');
                  echo '
                     </div>
                     <script type="text/javascript">
                     //Syntax: var uniquevar=new animatedcollapse("DIV_id", animatetime_milisec, enablepersist(true/fase), [initialstate] )
                     var collapse1=new animatedcollapse("smiley_pic", 1000, false)
                     </script>
                  </div>';
   }
   elseif($context['user']['is_guest'])
      echo $txt['yshout_no_guests'];
   // YSHOUT END - shoutbox code


You will notice that it also incorporates the smileys add on.

Now when I view the source of my site I have noticed that a name repeats twice (name="shout_form" name="shout_form"):

<form id="shout-form" name="shout_form" name="shout_form" action="#" onsubmit="doSend();return false;">

<fieldset>
<input id="forum-name" type="text" maxlength="25" value="Youngie" disabled="disabled" />
<input id="shout-text" name="shout_text" type="text" maxlength="150" value="" />
<input id="shout-button" type="submit" value="Shout!" />
</fieldset>
</form>


When validating the page it returns one error which is that there is a closed form tag

QuoteError  Line 363, Column 6: end tag for element "form" which is not open.

</form></div>

The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.

Now I suspect this to be due to the repeated name call as I checked this (view source > downloaded > edited) and it validated when I removed one of the repeated name calls (not sure if it would work when the name call is removed) only thing is I am not sure in what file I need to look for this repeat and if it is the correct thing to remove?

Could you clarify and also could you let me know if this is a mod issue or something I may have done?

Also just so you know I have modified the Shoutbox so:
- No timestamp appears
- No namebox appears

Not sure if these would cause the issue?




Also on the point regarding validation I also noticed that the smiley.php files was causing validation errors for me as the doctype area was being repeated - this returned 4 validation errors.

I have attached the file that I edited and put live on my site.

Cheers.

nneonneo

The name attribute is in yshout.php. It is likely that you accidentally duplicated it while adding smileys (a common, if mostly harmless mistake). If you want smiley.php to validate, just remove the DOCTYPE and html tags from it. That should fix the duplicate errors.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

Advertisement: