Commit 983ed655c8e12927d805b319e68bd233a6859ea4

Authored by ykxie
1 parent 9c098925

add host 127

server/app.js
@@ -57,7 +57,6 @@ io.on('connection', function(socket) { @@ -57,7 +57,6 @@ io.on('connection', function(socket) {
57 }); 57 });
58 58
59 socket.on('connect', function (msg) { 59 socket.on('connect', function (msg) {
60 - console.log('connect ---- ' + msg);  
61 }); 60 });
62 61
63 }); 62 });
src/live/js/student.js
1 $(function() { 1 $(function() {
2 var teacherId = document.getElementById('teacher'); 2 var teacherId = document.getElementById('teacher');
3 var studentId = document.getElementById('student'); 3 var studentId = document.getElementById('student');
4 - var socket = io('http://live-api.com:3306'); 4 + var socket = io('http://127.0.0.1:3306');
5 5
6 var teacher = CodeMirror.fromTextArea(teacherId, { 6 var teacher = CodeMirror.fromTextArea(teacherId, {
7 value: '输入HTML代码', 7 value: '输入HTML代码',
src/live/js/teacher.js
1 $(function(){ 1 $(function(){
2 var teacherId = document.getElementById('teacher'); 2 var teacherId = document.getElementById('teacher');
3 - var socket = io('http://live-api.com:3306'); 3 + var socket = io('http://127.0.0.1:3306');
4 4
5 // 初始化codemirror页面 5 // 初始化codemirror页面
6 var teacher = CodeMirror.fromTextArea(teacherId, { 6 var teacher = CodeMirror.fromTextArea(teacherId, {
@@ -88,10 +88,13 @@ $(function(){ @@ -88,10 +88,13 @@ $(function(){
88 88
89 // 禁止关闭浏览器 89 // 禁止关闭浏览器
90 window.onbeforeunload = function(){ 90 window.onbeforeunload = function(){
91 - // return ('你确定要结束教学吗?请确认保存内容');  
92 - $('#liveStart').hide(); 91 + alert('-0000');
  92 + console.log('-----======')
  93 + return ('你确定要结束教学吗?请确认保存内容');
93 } 94 }
94 95
  96 +
  97 +
95 LiveTeacher.init(); 98 LiveTeacher.init();
96 99
97 // 开始录制 100 // 开始录制
@@ -162,17 +165,22 @@ $(function(){ @@ -162,17 +165,22 @@ $(function(){
162 teacher.setValue(''); 165 teacher.setValue('');
163 console.log('programming.clear') 166 console.log('programming.clear')
164 167
165 - // socket.on('programming.clear', function(msg) {  
166 - // console.log('programming.clear ---- ');  
167 - // content = '';  
168 - // io.emit('programming.content', msg);  
169 - // }); 168 + socket.on('programming.clear', function(msg) {
  169 + console.log('programming.clear ---- ');
  170 + content = '';
  171 + io.emit('programming.content', msg);
  172 + });
170 173
171 174
172 // window.onbeforeunload = function(){ 175 // window.onbeforeunload = function(){
173 // return ('你确定要结束教学吗?') 176 // return ('你确定要结束教学吗?')
174 // } 177 // }
175 - window.close() 178 + // window.close()
  179 +
  180 + $(window).unbind('beforeunload', function(){
  181 + return '确认退出? 将不保存你的代码';
  182 + });
  183 + window.close();
176 } 184 }
177 185
178 186