Sha256: 0681c36cf1fdebf06f87355beb94695abf3775a81bd7e77ddde6df6f613aef0e
Contents?: true
Size: 1.93 KB
Versions: 6
Compression:
Stored size: 1.93 KB
Contents
# Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescript.org/ $ -> window.wrapUp = -> console.log('done') convoForm.show() convoForm.submit() $('#convo-form-enter').prop('disabled', true) doc = $('body') convoForm = $('#convo-form') convoForm.hide() doc.append(""" <div class="convo-window"> <ol class="convo-chat-history"> </ol> <input id="input-box" class="input-box" placeholder="Type your answer here ..."> <button id="convo-form-enter">Next</button> </div> """ ) inputIds = []; $('.convo input[name]').each -> inputIds.push($(this).attr('id')) endIndex = inputIds.length - 1 sequenceIndex = 0 item = inputIds[sequenceIndex] inputBox = $('#input-box') openDialog = -> item = inputIds[sequenceIndex] $('.convo-window .convo-chat-history').append(' <li class="other"> <div class="msg"> <p>Please enter your ' + item + '</p> </div> </li> ') $('.convo-window .convo-chat-history').scrollTop($('.convo-window .convo-chat-history')[0].scrollHeight); $('#convo-form-enter').click -> if sequenceIndex <= endIndex submitted = inputBox.val() inputBox.val(null) $('#' + item).val(submitted) $('.convo-window .convo-chat-history').append(' <li class="self"> <div class="msg"> <p>' + submitted + '</p> </div> </li> ') $('.convo-window .convo-chat-history').scrollTop($('.convo-window .convo-chat-history')[0].scrollHeight); sequenceIndex++ if sequenceIndex == endIndex $('#convo-form-enter').html 'submit' if sequenceIndex > endIndex wrapUp() else openDialog() inputBox.keyup (e) -> if e.which is 13 $('#convo-form-enter').click() openDialog(inputIds)
Version data entries
6 entries across 6 versions & 1 rubygems