Click here to Skip to main content
15,888,461 members
Home / Discussions / JavaScript
   

JavaScript

 
Questionunexpected identifier: quick question Pin
shoysmTP19-Sep-16 1:59
shoysmTP19-Sep-16 1:59 
AnswerRe: unexpected identifier: quick question Pin
Richard Deeming19-Sep-16 2:20
mveRichard Deeming19-Sep-16 2:20 
GeneralRe: unexpected identifier: quick question Pin
shoysmTP19-Sep-16 3:56
shoysmTP19-Sep-16 3:56 
Questionjavascript message on web app Pin
dcof16-Sep-16 15:07
dcof16-Sep-16 15:07 
AnswerRe: javascript message on web app Pin
Nathan Minier19-Sep-16 1:39
professionalNathan Minier19-Sep-16 1:39 
QuestionAdding New Button using java script Pin
Member 1274349616-Sep-16 1:29
Member 1274349616-Sep-16 1:29 
AnswerRe: Adding New Button using java script Pin
Nathan Minier16-Sep-16 1:49
professionalNathan Minier16-Sep-16 1:49 
QuestionChatbot js code Pin
SolidSnake71-Sep-16 7:26
SolidSnake71-Sep-16 7:26 
Hey everyone and sorry for my bad English. I give my best. Smile | :)
I want to create a offline chatbot and I want that he answer in multiple for special words. (answer must be random)

Here An Exemple:

Me: Hey
Bot: hey

Me:hey
Bot: hi

Here the js code: (what is wrong?)
Java
var $messages = $('.messages-content'),
    d, h, m,
    i = 0;

$(window).load(function() {
  $messages.mCustomScrollbar();
  setTimeout(function() {
    fakeMessage();
  }, 100);
});

function updateScrollbar() {
  $messages.mCustomScrollbar("update").mCustomScrollbar('scrollTo', 'bottom', {
    scrollInertia: 10,
    timeout: 0
  });
}

function setDate(){
  d = new Date()
  if (m != d.getMinutes()) {
    m = d.getMinutes();
    $('<div class="timestamp">' + d.getHours() + ':' + m + '</div>').appendTo($('.message:last'));
  }
}

function insertMessage() {
  msg = $('.message-input').val();
  if ($.trim(msg) == '') {
    return false;
  }
  $('<div class="message message-personal">' + msg + '</div>').appendTo($('.mCSB_container')).addClass('new');
  setDate();
  $('.message-input').val(null);
  updateScrollbar();
  setTimeout(function() {
    fakeMessage(msg);
  }, 1000 + (Math.random() * 20) * 100);
}

$('.message-submit').click(function() {
  insertMessage();
});

$(window).on('keydown', function(e) {
  if (e.which == 13) {
    insertMessage();
    return false;
  }
})

var Fake = {
"Hi": ['Hi', 6000]
"Hi": ['Hey', 6000]
"Hey": ['Hey', 6000]
"Hey": ['Hi', 6000]
}

function fakeMessage(msg) {
  if (msg == '') {
    return false;
  }
  
  var resp = Fake[msg][0];
  console.log(msg, resp);

AnswerRe: Chatbot js code Pin
Dominic Burford6-Sep-16 2:51
professionalDominic Burford6-Sep-16 2:51 
AnswerRe: Chatbot js code Pin
ZurdoDev6-Sep-16 6:06
professionalZurdoDev6-Sep-16 6:06 
QuestionHTML and javascript dashboard Pin
Member 1271309731-Aug-16 3:21
Member 1271309731-Aug-16 3:21 
SuggestionRe: HTML and javascript dashboard Pin
Nathan Minier31-Aug-16 8:12
professionalNathan Minier31-Aug-16 8:12 
AnswerRe: HTML and javascript dashboard Pin
W Balboos, GHB14-Sep-16 4:48
W Balboos, GHB14-Sep-16 4:48 
SuggestionRe: HTML and javascript dashboard Pin
Harpreet05Kaur26-Sep-16 1:50
Harpreet05Kaur26-Sep-16 1:50 
AnswerRe: HTML and javascript dashboard Pin
Harpreet05Kaur26-Sep-16 1:24
Harpreet05Kaur26-Sep-16 1:24 
QuestionHow can I swap only body element between HTML pages? Pin
lino_7630-Aug-16 8:08
lino_7630-Aug-16 8:08 
AnswerRe: How can I swap only body element between HTML pages? Pin
Richard Deeming30-Aug-16 8:34
mveRichard Deeming30-Aug-16 8:34 
AnswerRe: How can I swap only body element between HTML pages? Pin
Nathan Minier31-Aug-16 1:55
professionalNathan Minier31-Aug-16 1:55 
QuestionCollect text and images from image pdf using JS or AngularJS Pin
Member 1270857628-Aug-16 22:47
Member 1270857628-Aug-16 22:47 
AnswerRe: Collect text and images from image pdf using JS or AngularJS Pin
Richard MacCutchan28-Aug-16 23:00
mveRichard MacCutchan28-Aug-16 23:00 
GeneralRe: Collect text and images from image pdf using JS or AngularJS Pin
Member 1270857629-Aug-16 0:18
Member 1270857629-Aug-16 0:18 
QuestionJavascript reverse help Pin
313help23-Aug-16 3:29
313help23-Aug-16 3:29 
AnswerRe: Javascript reverse help Pin
Richard Deeming23-Aug-16 4:35
mveRichard Deeming23-Aug-16 4:35 
GeneralRe: Javascript reverse help Pin
313help23-Aug-16 4:59
313help23-Aug-16 4:59 
Questionangular http post doesnt work on IIS Pin
Member 1103130422-Aug-16 19:34
Member 1103130422-Aug-16 19:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.