tweaks to events on hub start
This commit is contained in:
parent
4a67c41bf1
commit
98f1dbea6c
@ -8,6 +8,8 @@
|
||||
let $yourNameText = $('#your-name-text');
|
||||
let $yourColorText = $('#your-color-text');
|
||||
|
||||
let isTeacher = window.location.hash === '#4ELQcUq7UnFGghAZCVr4Chr9JmtncigfkGu5WSf9';
|
||||
|
||||
let isLive = false;
|
||||
|
||||
let isLiveMode = function () {
|
||||
@ -30,6 +32,16 @@
|
||||
connection.invoke('SaveName', $yourNameText.val(), color);
|
||||
};
|
||||
|
||||
let updateCode = function (editor, index) {
|
||||
|
||||
let user = $yourNameText.val();
|
||||
let code = editor.getValue();
|
||||
|
||||
connection.invoke('UpdateCode', user, index, code, isTeacher).catch(function (err) {
|
||||
return console.error(err.toString());
|
||||
});
|
||||
};
|
||||
|
||||
let setHeight = function () {
|
||||
|
||||
var editorHeight = $(window).height() - $('header').outerHeight() - $('footer').outerHeight();
|
||||
@ -45,8 +57,6 @@
|
||||
isLiveMode();
|
||||
setHeight();
|
||||
|
||||
let isTeacher = window.location.hash === '#4ELQcUq7UnFGghAZCVr4Chr9JmtncigfkGu5WSf9';
|
||||
|
||||
if (isTeacher) {
|
||||
$liveModeLink.hide();
|
||||
$liveModeStatus.hide();
|
||||
@ -56,21 +66,6 @@
|
||||
|
||||
let $editors = $('.ace_editor');
|
||||
|
||||
$editors.each(function (i, e) {
|
||||
|
||||
let editor = ace.edit(e);
|
||||
|
||||
editor.session.on('change', function () {
|
||||
|
||||
let user = $yourNameText.val();
|
||||
let code = editor.getValue();
|
||||
|
||||
connection.invoke('UpdateCode', user, i, code, isTeacher).catch(function (err) {
|
||||
return console.error(err.toString());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
connection.on('ReceiveCode', function (user, index, code) {
|
||||
|
||||
if (!isTeacher && isLive) {
|
||||
@ -97,6 +92,18 @@
|
||||
|
||||
sendName();
|
||||
|
||||
$editors.each(function (i, e) {
|
||||
|
||||
let editor = ace.edit(e);
|
||||
|
||||
editor.session.on('change', function () {
|
||||
updateCode(editor, i);
|
||||
});
|
||||
|
||||
// send initial code
|
||||
updateCode(editor, i);
|
||||
});
|
||||
|
||||
}).catch(function (err) {
|
||||
return console.error(err.toString());
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user