Skip to content

Commit af4fda0

Browse files
committed
Bug Fix
Corrected a bug that was introduced by accident during the previous commit, which caused the script to produce no output. Also added code to the JSON interface to replace the user's raw input with it's spelling-corrected version.
1 parent c37a5df commit af4fda0

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

chatbot/conversation_start.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,5 @@
175175
runDebug(__FILE__, __FUNCTION__, __LINE__, "Closing Database", 2);
176176
db_close($con);
177177
//save_file(_DEBUG_PATH_ . 'function_list.txt', print_r(get_defined_functions()['user'], true));
178+
display_conversation($convoArr);
178179
$convoArr = handleDebug($convoArr); // Make sure this is the last line in the file, so that all debug entries are captured.
179-
display_conversation($display, $convoArr['conversation']['format']);

chatbot/core/conversation/display_conversation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ function get_xml($convoArr, $conversation)
190190
**/
191191
function display_conversation($convoArr)
192192
{
193+
$display = $convoArr['send_to_user'];
193194
$format =(isset($convoArr['conversation']['format'])) ? strtolower(trim($convoArr['conversation']['format'])) : 'html';
194195
switch ($format) {
195196
case 'html' :

gui/jquery/index.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
$bot_id = (isset($_COOKIE['bot_id'])) ? $_COOKIE['bot_id'] : 1;
1414
setcookie('bot_id', $bot_id);
1515
$display = 'Make sure that you edit this file to change the value of $url below to reflect the correct address, and to remove this message.' . PHP_EOL;
16+
$display = '';
1617
$url = 'http://www.example.com/programo/chatbot/conversation_start.php';
18+
$url = 'http://localhost/Program-O/Program-O/chatbot/conversation_start.php';
1719

1820
function get_convo_id()
1921
{
@@ -101,14 +103,17 @@ function get_convo_id()
101103
<script type="text/javascript" >
102104
$(document).ready(function() {
103105
// put all your jQuery goodness in here.
104-
$('#talkform').submit(function() {
106+
$('#talkform').submit(function(e) {
107+
e.preventDefault();
105108
user = $('#say').val();
106109
$('.usersay').text(user);
107110
formdata = $("#talkform").serialize();
108111
$('#say').val('')
109112
$('#say').focus();
110113
$.post('<?php echo $url ?>', formdata, function(data){
111114
var b = data.botsay;
115+
var usersay = data.usersay;
116+
if (user != usersay) $('.usersay').text(usersay);
112117
$('.botsay').html(b);
113118
}, 'json');
114119
return false;

0 commit comments

Comments
 (0)