Commits

Marcin Lulek committed 66595f8

jq basic demo works too now

  • Participants
  • Parent commits e4b6c87

Comments (0)

Files changed (2)

 Installation and Setup
 ======================
 
-Obtain source from github and do::
+Obtain source from bitbucket and do::
 
     python setup.py develop

gevent_cometd/static/jq_client.js

 
 // form submit event
 $('#msg_form').submit(function() {
-
     var form_array = $(this).serializeArray();
     var post = {};
     for ( var int = 0; int < form_array.length; int++) {
         post[form_array[int].name] = form_array[int].value;
     }
-
+    $('input[name=message]',this)[0].value = '';
     $.ajax({
         url : $(this).attr("action"),
         type : "POST",
         data : JSON.stringify(post),
         dataType : "json",
     }).done(function() {
-        $(this).addClass("done");
+
     });
     return false;
 });
 
+var messages_node = $('.messages')[0]
+var got_message = function(entry) {
+    $(messages_node).append(
+    '<li><strong>channel:' + entry.channel + '</strong> <strong>' + entry.user
+    + '</strong> <em>' + entry.message + '</em></li>');
+}
+
 var create_socket = function() {
     console.log('attempting to create socket');
     var socket_url = state.server_url + "/listen?conn_id=" + state.conn_id;
         var data = $.parseJSON(event.data);
         for ( var i = 0; i < data.length; i++) {
             console.log('publishing: ' + 'gevent_cometd/' + data[i].type);
+            got_message(data[i]);
         }
     };
     state.socket.onclose = function(event) {
 
 var demo_start = function(webapp_url, server_url, connection_request) {
     console.log('demo start');
-
     console.log('connecting to get UID of connection');
     state.connection_request = connection_request;
     state.webapp_url = webapp_url;