app/views/script/index.erb in tailog-0.5.6 vs app/views/script/index.erb in tailog-0.5.7
- old
+ new
@@ -6,19 +6,38 @@
<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 id="broadcast-button" type="submit" class="btn btn-danger">Broadcast</button>
<button id="submit-button" type="submit" class="btn btn-primary">Submit</button>
</div>
<div>
Press <kbd><kbd>Ctrl</kbd> + <kbd>Enter</kbd></kbd> to submit code
</div>
</form>
<div id="content"></div>
+<div class="modal fade" tabindex="-1" role="dialog" id="broadcast-modal">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
+ <h4 class="modal-title">Modal title</h4>
+ </div>
+ <div class="modal-body">
+ <p>One fine body…</p>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ <button type="button" class="btn btn-primary">Save changes</button>
+ </div>
+ </div><!-- /.modal-content -->
+ </div><!-- /.modal-dialog -->
+</div><!-- /.modal -->
+
<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">
@@ -26,11 +45,11 @@
CodeMirror.keyMap.default["Tab"] = function(editor) {
var spaces = Array(editor.getOption("indentUnit") + 1).join(" ");
editor.replaceSelection(spaces);
};
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Enter"] = function(editor) {
- $("#submit-button").trigger('click');
+ $("#submit-button").trigger("click");
};
var editor = CodeMirror.fromTextArea($("#editor")[0], {
lineNumbers: true
});
@@ -46,29 +65,38 @@
});
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);
+ $("#broadcast-button").click(function(event) {
+ event.preventDefault();
+ $("#broadcast-modal").addClass("in");
+ });
+
+ $("#submit-button").click(function(event) {
+ event.preventDefault();
+ $("#script").ajaxSubmit({
+ beforeSend: function() {
$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)
+ .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>