(cc) SMFPacks.com Javascript Alert

An annoying alert pops up time to time on the main page of this forum: “(cc) SMFPacks.com

http://www.peercointalk.org/Themes/default/shoutbox.js
Search for window.alert(’(’+‘c’+‘c’+’)’+’ ‘+‘S’+‘M’+‘F’+‘P’+‘a’+‘c’+‘k’+‘s’+’.’+‘c’ + ‘o’ + ‘m’);

This needs to be removed.

/u/ppctip 5 PPC

Hey that would be a cool feature to have this here :slight_smile:

hmm this seems to be because of an error loading the shoutbox. A hard refresh should resolve the issue and maybe I should change the message, just not 100% sure what would happen if i removed it but will investigate

Fuzzybear

This is not only happening to me but to other members as well. This happens maybe once every 2 weeks. Yesterday it happened twice. This is when the chatbox is being loaded.

Had this happen again. Getting it about every 3-4 days.

I’ll send you 15 ppc to just delete the window.alert line and see what happens :wink:

You game?

[quote=“emeth, post:6, topic:3350”]Had this happen again. Getting it about every 3-4 days.

I’ll send you 15 ppc to just delete the window.alert line and see what happens :wink:

You game?[/quote]
Many thanks for the offer but I think it best I do not take bribes like this! :stuck_out_tongue:

I have raised the issue on the support page for the mod here http://www.simplemachines.org/community/index.php?topic=269091.msg3794448#msg3794448 lets see what they come back with.

Fuzzybear

I just wanted to say that I don’t think this has anything to do with the theme change. I’ve been experiencing the error alert every so often for quite a while now. I just never reported it. It was last year sometime that it started happening I think.

Ok this useful feedback, I actually noticed we were on 1.0.4 shoutbox version, I have updated to 1.0.5 now so lets see if that resolves the issue

Fuzzybear

Every man has his price Fuzzy… what’s yours? :stuck_out_tongue:

Decision is totally yours, but if it helps…

Looking at the code after you updated:

http://www.peercointalk.org/Themes/default/shoutbox.js

[code]function Shoutbox_GetMsgs()
{
// bug? .-.
if (Shoutbox.posting || Shoutbox.loading)
return;

if (Shoutbox.first)
{
	// check this first :)
	var c = document.getElementById('s'+'h'+'o'+'u'+'t'+'b'+'o'+'x'+'_'+'b'+'a'+'r');
	if (!c)
		return window.alert('('+'c'+'c'+')'+' '+'S'+'M'+'F'+'P'+'a'+'c'+'k'+'s'+'.'+'c' + 'o' + 'm');

	var v = ' | <'+'a'+' '+'t'+'i'+'t'+'l'+'e'+'='+'"'+'S'+'M'+'F'+'P'+'a'+'c'+'k'+'s'+'.'+'c'+'o'+'m'+'"';
	v += ' '+'t'+'a'+'r'+'g'+'e'+'t'+'='+'"'+'_'+'b'+'l'+'a'+'n'+'k'+'"';
	v += ' '+'h'+'r'+'e'+'f'+'='+'"'+'h'+'t'+'t'+'p'+':'+'/'+'/';
	v += 'w'+'w'+'w'+'.'+'s'+'m'+'f'+'p'+'a'+'c'+'k'+'s'+'.'+'c'+'o'+'m'+'/';
	v += '"'+'>'+'&'+'c'+'o'+'p'+'y'+';'+' '+'S'+'M'+'F'+'P'+'a'+'c'+'k'+'s'+'<'+'/'+'a'+'>';
	setInnerHTML(c,v);
}

// show loading
if (Shoutbox.msgs !== false) window.clearTimeout(Shoutbox.msgs);
Shoutbox.loading = true;
document.getElementById("shoutbox_status").style.visibility = 'visible';

Shoutbox_getXML(smf_scripturl + "?action=shoutbox;sa=get;xml;row=" + Shoutbox.maxmsgs + (Shoutbox.first ? ';restart' : ''), Shoutbox_PutMsgs);

}[/code]

The first time the script checks for new messages, if, due to the race condition of html loading vs javascript loading, this code is being executed before the html for the shoutbox loads, it cancels the get_messages call and shows an alert instead. The get_messages call is then called again later after the html loads, and succeeds.

There will be absolutely 0 side-effects if you kill the line that says

return window.alert('('+'c'+'c'+')'+' '+'S'+'M'+'F'+'P'+'a'+'c'+'k'+'s'+'.'+'c' + 'o' + 'm');

and replace it with

return;

As both serve the exact same function, short-circuiting the get_messages function because the html isn’t present yet.

Totally understand if you want to wait and see what they come back with.

[quote=“emeth, post:10, topic:3350”]Every man has his price Fuzzy… what’s yours? :stuck_out_tongue:

Decision is totally yours, but if it helps…

Looking at the code after you updated:

http://www.peercointalk.org/Themes/default/shoutbox.js

[code]function Shoutbox_GetMsgs()
{
// bug? .-.
if (Shoutbox.posting || Shoutbox.loading)
return;

if (Shoutbox.first)
{
	// check this first :)
	var c = document.getElementById('s'+'h'+'o'+'u'+'t'+'b'+'o'+'x'+'_'+'b'+'a'+'r');
	if (!c)
		return window.alert('('+'c'+'c'+')'+' '+'S'+'M'+'F'+'P'+'a'+'c'+'k'+'s'+'.'+'c' + 'o' + 'm');

	var v = ' | <'+'a'+' '+'t'+'i'+'t'+'l'+'e'+'='+'"'+'S'+'M'+'F'+'P'+'a'+'c'+'k'+'s'+'.'+'c'+'o'+'m'+'"';
	v += ' '+'t'+'a'+'r'+'g'+'e'+'t'+'='+'"'+'_'+'b'+'l'+'a'+'n'+'k'+'"';
	v += ' '+'h'+'r'+'e'+'f'+'='+'"'+'h'+'t'+'t'+'p'+':'+'/'+'/';
	v += 'w'+'w'+'w'+'.'+'s'+'m'+'f'+'p'+'a'+'c'+'k'+'s'+'.'+'c'+'o'+'m'+'/';
	v += '"'+'>'+'&'+'c'+'o'+'p'+'y'+';'+' '+'S'+'M'+'F'+'P'+'a'+'c'+'k'+'s'+'<'+'/'+'a'+'>';
	setInnerHTML(c,v);
}

// show loading
if (Shoutbox.msgs !== false) window.clearTimeout(Shoutbox.msgs);
Shoutbox.loading = true;
document.getElementById("shoutbox_status").style.visibility = 'visible';

Shoutbox_getXML(smf_scripturl + "?action=shoutbox;sa=get;xml;row=" + Shoutbox.maxmsgs + (Shoutbox.first ? ';restart' : ''), Shoutbox_PutMsgs);

}[/code]

The first time the script checks for new messages, if, due to the race condition of html loading vs javascript loading, this code is being executed before the html for the shoutbox loads, it cancels the get_messages call and shows an alert instead. The get_messages call is then called again later after the html loads, and succeeds.

There will be absolutely 0 side-effects if you kill the line that says

return window.alert('('+'c'+'c'+')'+' '+'S'+'M'+'F'+'P'+'a'+'c'+'k'+'s'+'.'+'c' + 'o' + 'm');

and replace it with

return;

As both serve the exact same function, short-circuiting the get_messages function because the html isn’t present yet.

Totally understand if you want to wait and see what they come back with.[/quote]

Ok this is the explanation of the code I was hoping to have on the shoutbox thread but no one seems to want to respond like this :stuck_out_tongue: so hats off to you I am changing the code now.

Please let me kinow if this resolves the issue and if any other strange activity occurs.

Fuzzybear