code:
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage){
if (sMessage.charAt(0) != '/' && sMessage.substr(0, 4) != 'www.' && sMessage.substr(0, 7) != 'http://') {
}
return punctuate(sMessage);
}
function punctuate(s)
{
var sentences = s.split(" ");
for (var i = 0; i < sentences.length; i++)
{
if (sentences[i].charAt(0) == "/")
{
return sentences.join(" ");
}
else{
if (i == sentences.length - 1 && isin(sentences[i].charAt(sentences[i].length - 1), "abcdefghijklmnopqrstuvwxyz0123456789"))
{
sentences[i] = sentences[i] + ".";
}
if (i == 0)
{
sentences[i] = sentences[i].charAt(0).toUpperCase() + sentences[i].substr(1);
}
else
{
if (isin(sentences[i-1].charAt(sentences[i-1].length - 1), ".?!"))
{
sentences[i] = sentences[i].charAt(0).toUpperCase() + sentences[i].substr(1);
}
}
}
}
return sentences.join(" ");
}
function isin(needle, haystack)
{
for (var i = 0; i < haystack.length; i++)
if (haystack.charAt(i) == needle)
return true;
return false;
I think someone should make it so it adds " ' " 's into the right spots
or I could just replace all the theyre with they're and so on