Sha256: 5099437b36784b46d2e79a4a5786b37eee20063a842f9afbbdb67146d50f0170

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

$().ready( function() {
  client = Stomp.client( "ws://localhost:8675" )

  var display_message = function( message ) {
      elem = $("#console .content")
      line = message.body
      line = line.replace("<", "&lt;")
      line = line.replace(">", "&gt;")
      if (message.headers['prompt']) {
        $("#console .prompt").html( line )
      } else {
        elem.append( ansispan(line) + "\n" )
        /*elem.append( line + "\n" )*/
      }
      $(window).scrollTop($("body").height())
      $("#console input").focus();
  }

  var send_message = function( message ) {
      var input = $("#console input").attr( "value" ) + "\n"
      $("#console .content").append( $("#console .prompt").text() )
      $("#console .content").append( input )
      $("#console input").attr( "value", "" )
      client.send( "/stomplet/console", {}, input )
      return false;
  }

  var toggle_theme = function() {
    if ($("body").hasClass("light")) {
      $("body").removeClass("light");
      $("body").addClass("dark");
    } else {
      $("body").addClass("light");
      $("body").removeClass("dark");
    }
  }

  $(window).unload( function() { client.disconnect() });

  $( '#input-form' ).bind( "submit", send_message );
  $( '.button' ).bind( "click", toggle_theme );

  client.connect( null, null, function() {
      client.subscribe("/stomplet/console", display_message)
  } );
} )

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
torquebox-console-0.1.4 public/console.js
torquebox-console-0.1.3 public/console.js
torquebox-console-0.1.2 public/console.js