Commit 7869a1781a0517b613c851af90609390b5bb804c
1 parent
042bc469
add teacher and student page
Showing
4 changed files
with
510 additions
and
66 deletions
src/live/review.html
0 → 100644
src/live/student.html
| @@ -3,46 +3,179 @@ | @@ -3,46 +3,179 @@ | ||
| 3 | <head> | 3 | <head> |
| 4 | <meta charset="UTF-8"> | 4 | <meta charset="UTF-8"> |
| 5 | <title>学生端</title> | 5 | <title>学生端</title> |
| 6 | + <link href="../css/reset.css" rel="stylesheet"> | ||
| 7 | + <link rel="stylesheet" href="../css/responsive/css/bootstrap.min.css"> | ||
| 6 | <link rel="stylesheet" href="../js/codemirror-5.25.0/lib/codemirror.css"> | 8 | <link rel="stylesheet" href="../js/codemirror-5.25.0/lib/codemirror.css"> |
| 9 | + <link rel="stylesheet" href="style/main.css"> | ||
| 10 | +<style> | ||
| 11 | + | ||
| 12 | + .teacher-live, .student-work{ | ||
| 13 | + position: absolute; | ||
| 14 | + width: 50%; | ||
| 15 | + height: 100%; | ||
| 16 | + } | ||
| 17 | + .teacher-live{ | ||
| 18 | + left: 0; | ||
| 19 | + border-right: 1px solid #999; | ||
| 20 | + } | ||
| 21 | + .student-work{ | ||
| 22 | + right: 0; | ||
| 23 | + } | ||
| 24 | +</style> | ||
| 7 | </head> | 25 | </head> |
| 8 | <body> | 26 | <body> |
| 9 | - <h1>学生端</h1> | ||
| 10 | - <ul id="messages"></ul> | ||
| 11 | - <textarea id="student" title="HTML"></textarea> | 27 | +<div class="student"> |
| 28 | + <div class="teacher-live"> | ||
| 29 | + <div class="live-wrap"> | ||
| 30 | + <!-- 头部信息 --> | ||
| 31 | + <div class="header"> | ||
| 32 | + <h1>老师端</h1> | ||
| 33 | + </div> | ||
| 34 | + | ||
| 35 | + <!-- 录制区域 --> | ||
| 36 | + <div class="live-code"> | ||
| 37 | + <textarea id="teacher" title="HTML"></textarea> | ||
| 38 | + </div> | ||
| 39 | + | ||
| 40 | + <!-- 编译操作区 --> | ||
| 41 | + <!-- 运行结果区 --> | ||
| 42 | + <div class="live-console-wrap"> | ||
| 43 | + <div id="toolbar"> | ||
| 44 | + <!-- Nav tabs --> | ||
| 45 | + <ul class="nav nav-tabs result-tabs need-compile" role="tablist" id="cmprun-tabs"> | ||
| 46 | + <li class="active"><a href="#stdin" role="tab" data-toggle="tab" class="text">标准</a></li> | ||
| 47 | + <li><a href="#cmpinfo" role="tab" data-toggle="tab" class="text">编译</a></li> | ||
| 48 | + <li><a href="#stderr" role="tab" data-toggle="tab" class="text">错误</a></li> | ||
| 49 | + <li><a href="#output" role="tab" data-toggle="tab" class="text">结果</a></li> | ||
| 50 | + </ul> | ||
| 51 | + <div class="pull-right func"> | ||
| 52 | + <button class="btn compile-btn" id="CompileBtn"> | ||
| 53 | + <span class="ladda-label">编译运行</span> | ||
| 54 | + </button> | ||
| 55 | + <a id="full-screen" class="fb"> | ||
| 56 | + <img src="../img/full-screen-icon.svg" alt=""> | ||
| 57 | + </a> | ||
| 58 | + <a id="back-screen" class="fb" style="display: none;"> | ||
| 59 | + <img src="../img/full-screen-icon.svg" alt=""> | ||
| 60 | + </a> | ||
| 61 | + </div> | ||
| 62 | + </div> | ||
| 63 | + | ||
| 64 | + <!-- Tab panes --> | ||
| 65 | + <div id="resultoutput" class="tab-content need-compile"> | ||
| 66 | + <div class="tab-pane active padall15" id="stdin"> | ||
| 67 | + <div class="stdin-wrap"> | ||
| 68 | + <input class="effect-2" id="runtimeArgus" type="text" placeholder="标准输入"> | ||
| 69 | + <span class="focus-border"></span> | ||
| 70 | + </div> | ||
| 71 | + </div> | ||
| 72 | + <div class="tab-pane padall15" id="cmpinfo"></div> | ||
| 73 | + <div class="tab-pane padall15" id="stderr"></div> | ||
| 74 | + <div class="tab-pane padall15" id="output"></div> | ||
| 75 | + </div> | ||
| 76 | + <div class="panel-body no-compile" id="ifrcontainer"> | ||
| 77 | + <iframe id="resultiframe" frameBorder="0" width="100%"></iframe> | ||
| 78 | + </div> | ||
| 79 | + </div> | ||
| 80 | + | ||
| 81 | + <!-- 录制控制区 --> | ||
| 82 | + <div class="live-ctrl"> | ||
| 83 | + | ||
| 84 | + </div> | ||
| 85 | + </div> | ||
| 86 | + </div> | ||
| 87 | + <div class="student-work"> | ||
| 88 | + <div class="live-wrap"> | ||
| 89 | + <!-- 头部信息 --> | ||
| 90 | + <div class="header"> | ||
| 91 | + <h1>学生端</h1> | ||
| 92 | + </div> | ||
| 93 | + | ||
| 94 | + <!-- 录制区域 --> | ||
| 95 | + <div class="live-code"> | ||
| 96 | + <textarea id="student" title="HTML"></textarea> | ||
| 97 | + </div> | ||
| 98 | + | ||
| 99 | + <!-- 编译操作区 --> | ||
| 100 | + <!-- 运行结果区 --> | ||
| 101 | + <div class="live-console-wrap"> | ||
| 102 | + <div id="toolbar"> | ||
| 103 | + <!-- Nav tabs --> | ||
| 104 | + <ul class="nav nav-tabs result-tabs need-compile" role="tablist" id="cmprun-tabs"> | ||
| 105 | + <li class="active"><a href="#stdin" role="tab" data-toggle="tab" class="text">标准</a></li> | ||
| 106 | + <li><a href="#cmpinfo" role="tab" data-toggle="tab" class="text">编译</a></li> | ||
| 107 | + <li><a href="#stderr" role="tab" data-toggle="tab" class="text">错误</a></li> | ||
| 108 | + <li><a href="#output" role="tab" data-toggle="tab" class="text">结果</a></li> | ||
| 109 | + </ul> | ||
| 110 | + <div class="pull-right func"> | ||
| 111 | + <button class="btn compile-btn" id="CompileBtn"> | ||
| 112 | + <span class="ladda-label">编译运行</span> | ||
| 113 | + </button> | ||
| 114 | + <a id="full-screen" class="fb"> | ||
| 115 | + <img src="../img/full-screen-icon.svg" alt=""> | ||
| 116 | + </a> | ||
| 117 | + <a id="back-screen" class="fb" style="display: none;"> | ||
| 118 | + <img src="../img/full-screen-icon.svg" alt=""> | ||
| 119 | + </a> | ||
| 120 | + </div> | ||
| 121 | + </div> | ||
| 122 | + | ||
| 123 | + <!-- Tab panes --> | ||
| 124 | + <div id="resultoutput" class="tab-content need-compile"> | ||
| 125 | + <div class="tab-pane active padall15" id="stdin"> | ||
| 126 | + <div class="stdin-wrap"> | ||
| 127 | + <input class="effect-2" id="runtimeArgus" type="text" placeholder="标准输入"> | ||
| 128 | + <span class="focus-border"></span> | ||
| 129 | + </div> | ||
| 130 | + </div> | ||
| 131 | + <div class="tab-pane padall15" id="cmpinfo"></div> | ||
| 132 | + <div class="tab-pane padall15" id="stderr"></div> | ||
| 133 | + <div class="tab-pane padall15" id="output"></div> | ||
| 134 | + </div> | ||
| 135 | + <div class="panel-body no-compile" id="ifrcontainer"> | ||
| 136 | + <iframe id="resultiframe" frameBorder="0" width="100%"></iframe> | ||
| 137 | + </div> | ||
| 138 | + </div> | ||
| 139 | + | ||
| 140 | + <!-- 录制控制区 --> | ||
| 141 | + <div class="live-ctrl"> | ||
| 142 | + | ||
| 143 | + </div> | ||
| 144 | + </div> | ||
| 145 | + </div> | ||
| 146 | +</div> | ||
| 147 | + | ||
| 12 | 148 | ||
| 13 | <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script> | 149 | <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script> |
| 14 | <script src="https://code.jquery.com/jquery-1.11.1.js"></script> | 150 | <script src="https://code.jquery.com/jquery-1.11.1.js"></script> |
| 15 | <script src="../js/codemirror-5.25.0/lib/codemirror.js"></script> | 151 | <script src="../js/codemirror-5.25.0/lib/codemirror.js"></script> |
| 152 | +<script src="../js/bootstrap.js"></script> | ||
| 16 | <script> | 153 | <script> |
| 17 | $(function() { | 154 | $(function() { |
| 155 | + var teacherId = document.getElementById('teacher'); | ||
| 18 | var studentId = document.getElementById('student'); | 156 | var studentId = document.getElementById('student'); |
| 19 | var socket = io('http://localhost:3000'); | 157 | var socket = io('http://localhost:3000'); |
| 20 | 158 | ||
| 21 | - var student = CodeMirror.fromTextArea(studentId, { | 159 | + var teacher = CodeMirror.fromTextArea(teacherId, { |
| 22 | value: '输入HTML代码', | 160 | value: '输入HTML代码', |
| 23 | mode: 'text/javascript', | 161 | mode: 'text/javascript', |
| 24 | lineNumbers: true, | 162 | lineNumbers: true, |
| 25 | smartIndent: false | 163 | smartIndent: false |
| 26 | }); | 164 | }); |
| 27 | 165 | ||
| 28 | - // CodeMirror.on(student, "change", function(instance, changeObj) { | ||
| 29 | - // console.log(instance); | ||
| 30 | - // console.log(changeObj); | ||
| 31 | - // }); | 166 | + var student = CodeMirror.fromTextArea(studentId, { |
| 167 | + value: '输入HTML代码', | ||
| 168 | + mode: 'text/javascript', | ||
| 169 | + lineNumbers: true, | ||
| 170 | + smartIndent: false | ||
| 171 | + }); | ||
| 32 | 172 | ||
| 33 | - socket.on('connect', function () { | ||
| 34 | - socket.on('programming.content', function(msg) { | ||
| 35 | - console.log('programming.content ---- ' + msg); | ||
| 36 | - student.setValue(msg); | ||
| 37 | - }); | ||
| 38 | - }); | ||
| 39 | 173 | ||
| 40 | - socket.on('chat message', function(msg) { | 174 | + socket.on('teacher.programming', function(msg) { |
| 41 | console.log(msg); | 175 | console.log(msg); |
| 42 | var msgObj = JSON.parse(msg) | 176 | var msgObj = JSON.parse(msg) |
| 43 | // student.setValue(msg) | 177 | // student.setValue(msg) |
| 44 | - | ||
| 45 | - processChangeObject(student, msgObj); | 178 | + processChangeObject(teacher, msgObj); |
| 46 | 179 | ||
| 47 | $('#messages').append($('<li>').text(msg)); | 180 | $('#messages').append($('<li>').text(msg)); |
| 48 | window.scrollTo(0, document.body.scrollHeight); | 181 | window.scrollTo(0, document.body.scrollHeight); |
src/live/style/main.css
0 → 100644
| 1 | +* { | ||
| 2 | + box-sizing: border-box; | ||
| 3 | +} | ||
| 4 | + | ||
| 5 | +body { | ||
| 6 | + font: 13px Helvetica, Arial; | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +.live-wrap { | ||
| 10 | + position: absolute; | ||
| 11 | + width: 100%; | ||
| 12 | + height: 100%; | ||
| 13 | + overflow: hidden; | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +.header { | ||
| 17 | + text-align: center; | ||
| 18 | + border-bottom: 1px solid #c1c1c1; | ||
| 19 | + padding: 8px 0; | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +.header h1 { | ||
| 23 | + font-size: 18px; | ||
| 24 | + margin: 0; | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +.live-code { | ||
| 28 | + position: relative; | ||
| 29 | + width: 100%; | ||
| 30 | + height: 100%; | ||
| 31 | + padding-bottom: 296px; | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +.live-code .CodeMirror { | ||
| 35 | + height: 100%; | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +.live-console-wrap { | ||
| 39 | + width: 100%; | ||
| 40 | + background-color: #FFF; | ||
| 41 | + height: 200px; | ||
| 42 | + position: absolute; | ||
| 43 | + bottom: 60px; | ||
| 44 | + z-index: 999; | ||
| 45 | + overflow: hidden; | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +#toolbar { | ||
| 49 | + width: 100%; | ||
| 50 | + height: 40px; | ||
| 51 | + overflow: hidden; | ||
| 52 | + background-color: #F4F6F9; | ||
| 53 | + padding: 0 36px; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +.result-tabs { | ||
| 57 | + overflow: hidden; | ||
| 58 | + margin: 5px 10px; | ||
| 59 | + color: #fff; | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +.text { | ||
| 63 | + color: #1FB6FF; | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +.result-tabs>li.active>a, | ||
| 67 | +.result-tabs>li.active>a:hover, | ||
| 68 | +.result-tabs>li>a:hover, | ||
| 69 | +.result-tabs>li.active>a:focus { | ||
| 70 | + color: #FFF; | ||
| 71 | + background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%); | ||
| 72 | + background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); | ||
| 73 | + -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important; | ||
| 74 | + transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important; | ||
| 75 | + box-shadow: 0px 0px 2px 0px #B3E5FF; | ||
| 76 | + border: none; | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +.result-tabs>li>a, | ||
| 80 | +.result-tabs>li.active>a:hover { | ||
| 81 | + padding: 4px 21px; | ||
| 82 | + border: none; | ||
| 83 | + margin: 1px; | ||
| 84 | + border-radius: 15px; | ||
| 85 | + font-size: 14px; | ||
| 86 | + transition: all 0.1s ease; | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +.func { | ||
| 90 | + height: 36px; | ||
| 91 | + padding-top: 5px; | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +.stdin-wrap { | ||
| 95 | + margin: 0 48px; | ||
| 96 | + position: relative; | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +#stdin { | ||
| 100 | + position: absolute; | ||
| 101 | + width: 100%; | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +#stdin:focus { | ||
| 105 | + outline: none; | ||
| 106 | +} | ||
| 107 | + | ||
| 108 | +#stdin input[type="text"] { | ||
| 109 | + font: 15px/24px "Lato", Arial, sans-serif; | ||
| 110 | + color: #333; | ||
| 111 | + width: 100%; | ||
| 112 | + box-sizing: border-box; | ||
| 113 | + letter-spacing: 1px; | ||
| 114 | + padding-left: 12px; | ||
| 115 | + outline: none; | ||
| 116 | +} | ||
| 117 | + | ||
| 118 | +#stdin .effect-2 { | ||
| 119 | + border: 0; | ||
| 120 | + padding: 12px 0 1px; | ||
| 121 | + border-bottom: 1px solid #ccc; | ||
| 122 | +} | ||
| 123 | + | ||
| 124 | +#stdin .effect-2 ~ .focus-border { | ||
| 125 | + position: absolute; | ||
| 126 | + bottom: 0; | ||
| 127 | + left: 50%; | ||
| 128 | + width: 0; | ||
| 129 | + height: 2px; | ||
| 130 | + background-color: #62DCF5; | ||
| 131 | + transition: 1s; | ||
| 132 | +} | ||
| 133 | + | ||
| 134 | +#stdin .effect-2:focus ~ .focus-border { | ||
| 135 | + width: 100%; | ||
| 136 | + transition: 1s; | ||
| 137 | + left: 0; | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +.nav-tabs { | ||
| 141 | + border: none; | ||
| 142 | + float: left; | ||
| 143 | + border-bottom: 0; | ||
| 144 | +} | ||
| 145 | + | ||
| 146 | +.panel-body { | ||
| 147 | + padding: 0; | ||
| 148 | +} | ||
| 149 | + | ||
| 150 | +.compile-btn { | ||
| 151 | + background: #FFF; | ||
| 152 | + border: 1px solid #3ad5f5; | ||
| 153 | + color: #1FB6FF; | ||
| 154 | + border-radius: 24px; | ||
| 155 | +} | ||
| 156 | + | ||
| 157 | +.btn { | ||
| 158 | + padding: 3px 18px; | ||
| 159 | +} | ||
| 160 | + | ||
| 161 | +.fb { | ||
| 162 | + float: right; | ||
| 163 | + margin: 0 16px; | ||
| 164 | + cursor: pointer; | ||
| 165 | +} | ||
| 166 | + | ||
| 167 | +.fb img { | ||
| 168 | + width: 32px; | ||
| 169 | +} | ||
| 170 | + | ||
| 171 | +.live-ctrl { | ||
| 172 | + width: 100%; | ||
| 173 | + height: 60px; | ||
| 174 | + position: absolute; | ||
| 175 | + bottom: 0; | ||
| 176 | + z-index: 999; | ||
| 177 | + padding: 0 136px; | ||
| 178 | + background-color: #23383f; | ||
| 179 | + box-sizing: border-box; | ||
| 180 | +} |
src/live/teacher.html
| @@ -4,6 +4,8 @@ | @@ -4,6 +4,8 @@ | ||
| 4 | <head> | 4 | <head> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> |
| 6 | <title>老师端</title> | 6 | <title>老师端</title> |
| 7 | + <link href="../css/reset.css" rel="stylesheet"> | ||
| 8 | + <link rel="stylesheet" href="../css/responsive/css/bootstrap.min.css"> | ||
| 7 | <link rel="stylesheet" href="../js/codemirror-5.25.0/lib/codemirror.css"> | 9 | <link rel="stylesheet" href="../js/codemirror-5.25.0/lib/codemirror.css"> |
| 8 | 10 | ||
| 9 | <style> | 11 | <style> |
| @@ -16,68 +18,201 @@ | @@ -16,68 +18,201 @@ | ||
| 16 | body { | 18 | body { |
| 17 | font: 13px Helvetica, Arial; | 19 | font: 13px Helvetica, Arial; |
| 18 | } | 20 | } |
| 19 | - | ||
| 20 | - form { | ||
| 21 | - background: #000; | ||
| 22 | - padding: 3px; | ||
| 23 | - position: fixed; | 21 | + .live-wrap{ |
| 22 | + position: absolute; | ||
| 24 | width: 100%; | 23 | width: 100%; |
| 24 | + height: 100%; | ||
| 25 | + overflow: hidden; | ||
| 25 | } | 26 | } |
| 26 | - | ||
| 27 | - form input { | ||
| 28 | - border: 0; | ||
| 29 | - padding: 10px; | ||
| 30 | - width: 80%; | ||
| 31 | - margin-right: .5%; | 27 | + .header{ |
| 28 | + text-align: center; | ||
| 29 | + border-bottom: 1px solid #c1c1c1; | ||
| 30 | + padding: 8px 0; | ||
| 32 | } | 31 | } |
| 33 | - | ||
| 34 | - form button { | ||
| 35 | - width: 19%; | ||
| 36 | - background: rgb(130, 224, 255); | 32 | + .header h1{ |
| 33 | + font-size: 18px; | ||
| 34 | + margin: 0; | ||
| 35 | + } | ||
| 36 | + .live-code{ | ||
| 37 | + position: relative; | ||
| 38 | + width: 100%; | ||
| 39 | + height: 100%; | ||
| 40 | + padding-bottom: 296px; | ||
| 41 | + } | ||
| 42 | + .live-code .CodeMirror{ | ||
| 43 | + height: 100%; | ||
| 44 | + } | ||
| 45 | + .live-console-wrap{ | ||
| 46 | + width: 100%; | ||
| 47 | + background-color: #FFF; | ||
| 48 | + height: 200px; | ||
| 49 | + position: absolute; | ||
| 50 | + bottom: 60px; | ||
| 51 | + z-index: 999; | ||
| 52 | + overflow: hidden; | ||
| 53 | + } | ||
| 54 | + #toolbar{ | ||
| 55 | + width: 100%; | ||
| 56 | + height: 40px; | ||
| 57 | + overflow: hidden; | ||
| 58 | + background-color: #F4F6F9; | ||
| 59 | + padding: 0 36px; | ||
| 60 | + } | ||
| 61 | + .result-tabs{ | ||
| 62 | + overflow: hidden; | ||
| 63 | + margin: 5px 10px; | ||
| 64 | + color: #fff; | ||
| 65 | + } | ||
| 66 | + .text{ | ||
| 67 | + color: #1FB6FF; | ||
| 68 | + } | ||
| 69 | + .result-tabs>li.active>a, .result-tabs>li.active>a:hover, .result-tabs>li>a:hover, .result-tabs>li.active>a:focus{ | ||
| 70 | + color: #FFF; | ||
| 71 | + background-image: -webkit-linear-gradient(left, #1FB6FF 0%, #62DCF5 100%); | ||
| 72 | + background-image: linear-gradient(to right, #1FB6FF 0%, #62DCF5 100%); | ||
| 73 | + -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important; | ||
| 74 | + transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important; | ||
| 75 | + box-shadow: 0px 0px 2px 0px #B3E5FF; | ||
| 37 | border: none; | 76 | border: none; |
| 38 | - padding: 10px; | ||
| 39 | } | 77 | } |
| 40 | - | ||
| 41 | - #messages { | ||
| 42 | - list-style-type: none; | ||
| 43 | - margin: 0; | 78 | + .result-tabs>li>a, .result-tabs>li.active>a:hover{ |
| 79 | + padding: 4px 21px; | ||
| 80 | + border: none; | ||
| 81 | + margin: 1px; | ||
| 82 | + border-radius: 15px; | ||
| 83 | + font-size: 14px; | ||
| 84 | + transition: all 0.1s ease; | ||
| 85 | + } | ||
| 86 | + .func{ | ||
| 87 | + height: 36px; | ||
| 88 | + padding-top: 5px; | ||
| 89 | + } | ||
| 90 | + .stdin-wrap { | ||
| 91 | + margin: 0 48px; | ||
| 92 | + position: relative; | ||
| 93 | + } | ||
| 94 | + #stdin { | ||
| 95 | + position: absolute; | ||
| 96 | + width: 100%; | ||
| 97 | + } | ||
| 98 | + #stdin :focus{outline: none;} | ||
| 99 | + | ||
| 100 | + #stdin input[type="text"]{font: 15px/24px "Lato", Arial, sans-serif; color: #333; width: 100%; box-sizing: border-box; letter-spacing: 1px;padding-left: 12px;} | ||
| 101 | + | ||
| 102 | + #stdin .effect-2{border: 0; padding: 12px 0 1px; border-bottom: 1px solid #ccc;} | ||
| 103 | + #stdin .effect-2 ~ .focus-border{position: absolute; bottom: 0; left: 50%; width: 0; height: 2px; background-color: #62DCF5; transition: 1s;} | ||
| 104 | + #stdin .effect-2:focus ~ .focus-border{width: 100%; transition: 1s; left: 0;} | ||
| 105 | + .nav-tabs { | ||
| 106 | + border: none; | ||
| 107 | + float: left; | ||
| 108 | + border-bottom: 0; | ||
| 109 | + } | ||
| 110 | + .panel-body{ | ||
| 44 | padding: 0; | 111 | padding: 0; |
| 45 | } | 112 | } |
| 46 | - | ||
| 47 | - #messages li { | ||
| 48 | - padding: 5px 10px; | 113 | + |
| 114 | + .compile-btn { | ||
| 115 | + background: #FFF; | ||
| 116 | + border: 1px solid #3ad5f5; | ||
| 117 | + color: #1FB6FF; | ||
| 118 | + border-radius: 24px; | ||
| 49 | } | 119 | } |
| 50 | - | ||
| 51 | - #messages li:nth-child(odd) { | ||
| 52 | - background: #eee; | 120 | + .btn { |
| 121 | + padding: 3px 18px; | ||
| 53 | } | 122 | } |
| 54 | - | ||
| 55 | - #messages { | ||
| 56 | - margin-bottom: 40px | 123 | + .fb { |
| 124 | + float: right; | ||
| 125 | + margin: 0 16px; | ||
| 126 | + cursor: pointer; | ||
| 127 | + } | ||
| 128 | + .fb img { | ||
| 129 | + width: 32px; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + .live-ctrl{ | ||
| 133 | + width: 100%; | ||
| 134 | + height: 60px; | ||
| 135 | + position: absolute; | ||
| 136 | + bottom: 0; | ||
| 137 | + z-index: 999; | ||
| 138 | + padding: 0 136px; | ||
| 139 | + background-color: #23383f; | ||
| 140 | + box-sizing: border-box; | ||
| 57 | } | 141 | } |
| 58 | </style> | 142 | </style> |
| 59 | </head> | 143 | </head> |
| 60 | 144 | ||
| 61 | <body> | 145 | <body> |
| 62 | - <h1>老师端</h1> | ||
| 63 | - <ul id="messages"></ul> | ||
| 64 | - <textarea id="teacher" title="HTML"></textarea> | ||
| 65 | 146 | ||
| 66 | - | ||
| 67 | - <form action=""> | ||
| 68 | - <input id="" autocomplete="off" /> | ||
| 69 | - <button>Send</button> | ||
| 70 | - </form> | 147 | +<div class="live-wrap"> |
| 148 | + <!-- 头部信息 --> | ||
| 149 | + <div class="header"> | ||
| 150 | + <h1>老师端</h1> | ||
| 151 | + </div> | ||
| 152 | + | ||
| 153 | + <!-- 录制区域 --> | ||
| 154 | + <div class="live-code"> | ||
| 155 | + <textarea id="teacher" title="HTML"></textarea> | ||
| 156 | + </div> | ||
| 157 | + | ||
| 158 | + <!-- 编译操作区 --> | ||
| 159 | + <!-- 运行结果区 --> | ||
| 160 | + <div class="live-console-wrap"> | ||
| 161 | + <div id="toolbar"> | ||
| 162 | + <!-- Nav tabs --> | ||
| 163 | + <ul class="nav nav-tabs result-tabs need-compile" role="tablist" id="cmprun-tabs"> | ||
| 164 | + <li class="active"><a href="#stdin" role="tab" data-toggle="tab" class="text">标准</a></li> | ||
| 165 | + <li><a href="#cmpinfo" role="tab" data-toggle="tab" class="text">编译</a></li> | ||
| 166 | + <li><a href="#stderr" role="tab" data-toggle="tab" class="text">错误</a></li> | ||
| 167 | + <li><a href="#output" role="tab" data-toggle="tab" class="text">结果</a></li> | ||
| 168 | + </ul> | ||
| 169 | + <div class="pull-right func"> | ||
| 170 | + <button class="btn compile-btn" id="CompileBtn"> | ||
| 171 | + <span class="ladda-label">编译运行</span> | ||
| 172 | + </button> | ||
| 173 | + <a id="full-screen" class="fb"> | ||
| 174 | + <img src="../img/full-screen-icon.svg" alt=""> | ||
| 175 | + </a> | ||
| 176 | + <a id="back-screen" class="fb" style="display: none;"> | ||
| 177 | + <img src="../img/full-screen-icon.svg" alt=""> | ||
| 178 | + </a> | ||
| 179 | + </div> | ||
| 180 | + </div> | ||
| 181 | + | ||
| 182 | + <!-- Tab panes --> | ||
| 183 | + <div id="resultoutput" class="tab-content need-compile"> | ||
| 184 | + <div class="tab-pane active padall15" id="stdin"> | ||
| 185 | + <div class="stdin-wrap"> | ||
| 186 | + <input class="effect-2" id="runtimeArgus" type="text" placeholder="标准输入"> | ||
| 187 | + <span class="focus-border"></span> | ||
| 188 | + </div> | ||
| 189 | + </div> | ||
| 190 | + <div class="tab-pane padall15" id="cmpinfo"></div> | ||
| 191 | + <div class="tab-pane padall15" id="stderr"></div> | ||
| 192 | + <div class="tab-pane padall15" id="output"></div> | ||
| 193 | + </div> | ||
| 194 | + <div class="panel-body no-compile" id="ifrcontainer"> | ||
| 195 | + <iframe id="resultiframe" frameBorder="0" width="100%"></iframe> | ||
| 196 | + </div> | ||
| 197 | + </div> | ||
| 198 | + | ||
| 199 | + <!-- 录制控制区 --> | ||
| 200 | + <div class="live-ctrl"> | ||
| 201 | + | ||
| 202 | + </div> | ||
| 203 | +</div> | ||
| 71 | 204 | ||
| 72 | 205 | ||
| 73 | <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script> | 206 | <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script> |
| 74 | <script src="https://code.jquery.com/jquery-1.11.1.js"></script> | 207 | <script src="https://code.jquery.com/jquery-1.11.1.js"></script> |
| 75 | <script src="../js/codemirror-5.25.0/lib/codemirror.js"></script> | 208 | <script src="../js/codemirror-5.25.0/lib/codemirror.js"></script> |
| 209 | +<script src="../js/bootstrap.js"></script> | ||
| 76 | <script> | 210 | <script> |
| 77 | $(function() { | 211 | $(function() { |
| 78 | var teacherId = document.getElementById('teacher'); | 212 | var teacherId = document.getElementById('teacher'); |
| 79 | var socket = io('http://localhost:3000'); | 213 | var socket = io('http://localhost:3000'); |
| 80 | 214 | ||
| 215 | + // 初始化codemirror页面 | ||
| 81 | var teacher = CodeMirror.fromTextArea(teacherId, { | 216 | var teacher = CodeMirror.fromTextArea(teacherId, { |
| 82 | value: '输入HTML代码', | 217 | value: '输入HTML代码', |
| 83 | mode: 'text/javascript', | 218 | mode: 'text/javascript', |
| @@ -85,28 +220,24 @@ | @@ -85,28 +220,24 @@ | ||
| 85 | smartIndent: false | 220 | smartIndent: false |
| 86 | }); | 221 | }); |
| 87 | 222 | ||
| 223 | + // 记录每次操作的变化 | ||
| 88 | CodeMirror.on(teacher,"change", function(instance, changeObj) { | 224 | CodeMirror.on(teacher,"change", function(instance, changeObj) { |
| 89 | console.log(instance); | 225 | console.log(instance); |
| 90 | console.log(changeObj); | 226 | console.log(changeObj); |
| 91 | var changeObjStr = JSON.stringify(changeObj); | 227 | var changeObjStr = JSON.stringify(changeObj); |
| 92 | 228 | ||
| 93 | - socket.emit('chat message', changeObjStr); | 229 | + socket.emit('teacher.programming', changeObjStr); |
| 94 | 230 | ||
| 95 | socket.emit('programming.content', teacher.getValue()); | 231 | socket.emit('programming.content', teacher.getValue()); |
| 96 | 232 | ||
| 97 | }); | 233 | }); |
| 98 | 234 | ||
| 99 | - | ||
| 100 | - // $('form').submit(function() { | ||
| 101 | - // socket.emit('chat message', $('#m').val()); | ||
| 102 | - // $('#m').val(''); | ||
| 103 | - // return false; | ||
| 104 | - // }); | ||
| 105 | - // socket.on('chat message', function(msg) { | ||
| 106 | - // console.log(msg); | ||
| 107 | - // $('#messages').append($('<li>').text(msg)); | ||
| 108 | - // window.scrollTo(0, document.body.scrollHeight); | ||
| 109 | - // }); | 235 | + // 链接时执行初始化代码 |
| 236 | + socket.on('programming.content', function(msg) { | ||
| 237 | + console.log('programming.content ---- ' + msg); | ||
| 238 | + teacher.setValue(msg); | ||
| 239 | + }); | ||
| 240 | + | ||
| 110 | }); | 241 | }); |
| 111 | </script> | 242 | </script> |
| 112 | </body> | 243 | </body> |