bugfix
This commit is contained in:
parent
7a3e352284
commit
36d9572bea
@ -1,10 +1,10 @@
|
|||||||
bricks = window.bricks || {};
|
bricks = window.bricks || {};
|
||||||
|
|
||||||
bricks.QAFrame = class extends bricks.PopupWindow {
|
bricks.QAFrame = class extends bricks.VBox {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
ws_url:
|
ws_url:
|
||||||
ws_opts:
|
ws_params:
|
||||||
title:
|
title:
|
||||||
description:
|
description:
|
||||||
courseware:{
|
courseware:{
|
||||||
@ -30,15 +30,26 @@ bricks.QAFrame = class extends bricks.PopupWindow {
|
|||||||
this.add_widget(this.bottom_w);
|
this.add_widget(this.bottom_w);
|
||||||
var url = this.ws_url;
|
var url = this.ws_url;
|
||||||
if (this.ws_params){
|
if (this.ws_params){
|
||||||
url += '?' + URLSearchParams(this.ws_params).toString();
|
url += '?' + new URLSearchParams(this.ws_params).toString();
|
||||||
}
|
}
|
||||||
this.ws = new bricks.WebSocket(url);
|
this.ws = new bricks.WebSocket({
|
||||||
|
ws_url:url
|
||||||
|
});
|
||||||
|
this.ws.bind('onopen', this.start_question_answer.bind(this));
|
||||||
|
this.ws.bind('onquestion', this.show_question.bind(this));
|
||||||
|
this.ws.bind('oncourseware', this.show_courseware.bind(this));
|
||||||
if (this.courseware){
|
if (this.courseware){
|
||||||
this.play_course();
|
this.play_course();
|
||||||
} else {
|
} else {
|
||||||
this.show_conform();
|
this.show_conform();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
show_question(d){
|
||||||
|
console.log('show_question(), d=', d);
|
||||||
|
}
|
||||||
|
show_courseware(d){
|
||||||
|
console.log('show_courseware(), d=', d);
|
||||||
|
}
|
||||||
show_conform(){
|
show_conform(){
|
||||||
var btn = new bricks.Button({
|
var btn = new bricks.Button({
|
||||||
label: 'Start ?'
|
label: 'Start ?'
|
||||||
@ -58,7 +69,10 @@ bricks.QAFrame = class extends bricks.PopupWindow {
|
|||||||
this.main_w.clear_widgets();
|
this.main_w.clear_widgets();
|
||||||
var d = {
|
var d = {
|
||||||
'type': 'qa_start',
|
'type': 'qa_start',
|
||||||
'data': null
|
'data': {
|
||||||
|
d: 'test data',
|
||||||
|
v: 100
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this.ws.send(d)
|
this.ws.send(d)
|
||||||
}
|
}
|
||||||
|
@ -22,23 +22,27 @@ bricks.WebSocket = class extends bricks.VBox {
|
|||||||
} else {
|
} else {
|
||||||
this.ws = new WebSocket(this.ws_url);
|
this.ws = new WebSocket(this.ws_url);
|
||||||
}
|
}
|
||||||
this.ws.onopen = function(){
|
this.ws.onopen = this.on_open.bind(this);
|
||||||
this.dispatch('onopen');
|
this.ws.onmessage = this.on_message.bind(this);
|
||||||
console.log("open");
|
this.ws.onclose = this.on_close.bind(this);
|
||||||
}
|
this.ws.onerror = this.on_error.bind(this);
|
||||||
this.ws.onclose = function(e){
|
}
|
||||||
this.dispatch('onclose');
|
on_open(e){
|
||||||
console.log("close");
|
this.dispatch('onopen');
|
||||||
}
|
console.log("open");
|
||||||
this.ws.onerror = function(e){
|
}
|
||||||
this.dispatch('onerror');
|
on_close(e){
|
||||||
console.log(error);
|
this.dispatch('onclose');
|
||||||
}
|
console.log("close");
|
||||||
this.ws.onmessage = function(e){
|
}
|
||||||
var d = JSON.parse(e.data);
|
on_error(e){
|
||||||
var eventname = 'on' + d.type;
|
this.dispatch('onerror');
|
||||||
this.dispatch(eventname, d.data);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
on_message(e){
|
||||||
|
var d = JSON.parse(e.data);
|
||||||
|
var eventname = 'on' + d.type;
|
||||||
|
this.dispatch(eventname, d.data);
|
||||||
}
|
}
|
||||||
send_text(text){
|
send_text(text){
|
||||||
var d = {
|
var d = {
|
||||||
|
Loading…
Reference in New Issue
Block a user