bug with space in end ligne (soluce)|tungstene|tungstene@free.fr|1362956115|tungstene|xx|0|88.167.184.18|[b]I find a new bug and a new solution  :)<br /><br />I explain :<br /><br />+ hello bot<br />- hello human<br /><br />it's ok<br /><br />but if i input hello bot ? <br />with space between bot and ? <br />or just hello bot with space <br />dont works ! <br />beacause the  space or multiple space caractere do the problem<br /><br />for soluce this bug : <br /><br />in chat.html<br /><br />replace &lt;form ....<br /><br /><br />by : [/b]<br /><br />&lt;form id=&quot;formAdmID&quot; method=&quot;post&quot; onSubmit=&quot;return sendMessage()&quot;&gt;<br /> &nbsp; &nbsp; &nbsp;&lt;fieldset&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;legend&gt;Send a Message&lt;/legend&gt;<br /><br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;table border=&quot;0&quot; cellspacing=&quot;4&quot; cellpadding=&quot;4&quot; width=&quot;100%&quot;&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;tr&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;td align=&quot;left&quot; valign=&quot;middle&quot;&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=&quot;text&quot; size=&quot;40&quot; name=&quot;message&quot; id=&quot;message&quot; autocomplete=&quot;on&quot; disabled placeholder=&quot;Please wait... loading...&quot;&gt;<br />                                &lt;input type=&quot;hidden&quot; name=&quot;input&quot; id=&quot;inputID&quot; /&gt; &lt;!-- input pour remplacer les accents --&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/td&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;td width=&quot;10&quot; align=&quot;center&quot; valign=&quot;middle&quot;&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=&quot;submit&quot; value=&quot;Send&quot;&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/td&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/tr&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/table&gt;<br /> &nbsp; &nbsp; &nbsp;&lt;/fieldset&gt;<br />&lt;/form&gt;<br /><br /><br />[b]and replace function sendMessage () &#123;code....<br /><br />by[/b]<br /><br />function sendMessage () <br /><br />&#123;<br />        // debut code remplacement accents <br />        newinput = document.forms['formAdmID'].elements['message'].value;<br /> &nbsp; &nbsp; &nbsp;newinput = newinput.replace(/[éèêë]/gi, &quot;e&quot;);<br /> &nbsp; &nbsp; &nbsp;newinput = newinput.replace(/[àâä]/gi, &quot;a&quot;);<br /> &nbsp; &nbsp; &nbsp;newinput = newinput.replace(/[ïî]/gi, &quot;i&quot;);<br /> &nbsp; &nbsp; &nbsp;newinput = newinput.replace(/[üûù]/gi, &quot;u&quot;);<br /> &nbsp; &nbsp; &nbsp;newinput = newinput.replace(/[öô]/gi, &quot;o&quot;);<br />        newinput = newinput.replace(/[ç]/gi, &quot;c&quot;);<br />        newinput = newinput.replace(/[']/gi, &quot; &quot;);<br />        newinput = newinput.replace(/[-]/gi, &quot; &quot;);<br />        newinput = newinput.replace(/[?]/gi, &quot; &quot;);<br />        newinput = newinput.replace(/[!]/gi, &quot; &quot;);<br /> &nbsp; &nbsp; &nbsp;  newinput = newinput.replace(/[\s]&#123;2,&#125;/g,&quot; &quot;); <br />        newinput = newinput.trim();<br />        var messageremplace = newinput;<br />        // on remplace les accents avec repalce<br /> &nbsp; &nbsp; &nbsp;  // Enlève les espaces doubles, triples, etc.<br />        // on suprime les espaces blanc en debut de ligne et en fin de ligne avec trim()<br />        <br /> &nbsp; &nbsp; &nbsp;//var text = $(&quot;#message&quot;).val(); // ligne d'origine du programe<br />        var text = messageremplace; // ligne a ajouter<br /> &nbsp; &nbsp; &nbsp;$(&quot;#message&quot;).val(&quot;&quot;);<br /> &nbsp; &nbsp; &nbsp;$(&quot;#dialogue&quot;).append(&quot;&lt;div&gt;&lt;span class='user'&gt;You:&lt;/span&gt; &quot; + text + &quot;&lt;/div&gt;&quot;);<br /> &nbsp; &nbsp; &nbsp;try &#123;<br /> &nbsp; &nbsp; &nbsp;var reply = rs.reply(&quot;soandso&quot;, text);<br /> &nbsp; &nbsp; &nbsp;reply = reply.replace(/\n/g, &quot;&lt;br&gt;&quot;);<br /> &nbsp; &nbsp; &nbsp;$(&quot;#dialogue&quot;).append(&quot;&lt;div&gt;&lt;span class='bot'&gt;Bot:&lt;/span&gt; &quot; + reply + &quot;&lt;/div&gt;&quot;);<br /> &nbsp; &nbsp; &nbsp;$(&quot;#dialogue&quot;).animate(&#123; scrollTop: $(&quot;#dialogue&quot;).height() &#125;, 1000);<br /> &nbsp; &nbsp; &nbsp;&#125; catch(e) &#123;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;window.alert(e.message + &quot;\n&quot; + e.line);<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.log(e);<br /> &nbsp; &nbsp; &nbsp;&#125;<br /><br /> &nbsp; &nbsp; &nbsp;return false;<br />&#125;<br /><br />[b]with replace soluce accent and point ? and !  problem<br />with trim() soluce space problem [/b]<br />it's good with firefox||1362959327|tungstene|
