Sha256: 4ba797f4a093dfe8927bc6f3bf152d12f9d28f216824de64b5bba7ec49367a2c

Contents?: true

Size: 1.94 KB

Versions: 3

Compression:

Stored size: 1.94 KB

Contents

<form id="script" class="clearfix script" method="post">
  <div class="form-group">
    <textarea name="script" id="editor" style="display: none;"></textarea>
  </div>
  <div class="pull-right">
    <select name="type" class="form-control" id="mode">
      <option value="ruby">Ruby</option>
      <option value="ruby_debug">Ruby (Debug Mode)</option>
      <option value="bash">Bash</option>
    </select>
    <button type="submit" class="btn btn-primary">Submit</button>
  </div>
</form>

<div id="content"></div>

<script type="text/javascript" src="javascripts/codemirror.js"></script>
<script type="text/javascript" src="javascripts/mode/ruby.js"></script>
<script type="text/javascript" src="javascripts/mode/shell.js"></script>
<link rel="stylesheet" type="text/css" href="stylesheets/codemirror.css">
<script type="text/javascript">
  var editor = CodeMirror.fromTextArea($("#editor")[0], {
    lineNumbers: true,
    extraKeys: {
      Tab: function(editor) {
        var spaces = Array(editor.getOption("indentUnit") + 1).join(" ");
        editor.replaceSelection(spaces);
      }
    }
  });

  ModeMap = {
    ruby: "ruby",
    ruby_debug: "ruby",
    bash: "shell"
  };

  $("#mode").change(function() {
    editor.setOption("mode", ModeMap[$(this).val()]);
  });


  var $content = $("#content");

  $('#script').ajaxForm({
    beforeSend: function() {
      $content
        .html('<hr/>')
        .append('<span class="text-info">Loading...</span>')
    },
    error: function() {
      $content
        .html('<hr/>')
        .append('<span class="text-danger">Oops! Something went wrong, please try again later!</span>')
    },
    success: function(json) {
      try {
        var data = JSON.parse(json);
        $content
          .html('<hr/>')
          .append('<span class="text-info">' + data.server_hostname + '</span>')
          .append(ansi_up.ansi_to_html(data.content));
      } catch (error) {
        console.log(error)
      }
    }
  });
</script>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tailog-0.5.1 app/views/script/index.erb
tailog-0.5.0 app/views/script/index.erb
tailog-0.4.8 app/views/script/index.erb