bugfix
This commit is contained in:
parent
3c3c1e1050
commit
9900fbfa35
@ -86,7 +86,7 @@ bricks.Camera = class extends bricks.Popup {
|
|||||||
this.video.srcObject = this.stream;
|
this.video.srcObject = this.stream;
|
||||||
this.video.play();
|
this.video.play();
|
||||||
this.show_cnt = 1;
|
this.show_cnt = 1;
|
||||||
this.task = schedule_once(this.show_picture.bind(this), this.task_period);
|
this.task = schedule_interval(this.show_picture.bind(this), this.task_period);
|
||||||
}
|
}
|
||||||
show_picture(){
|
show_picture(){
|
||||||
if (this.task_period == 0){
|
if (this.task_period == 0){
|
||||||
@ -99,7 +99,6 @@ bricks.Camera = class extends bricks.Popup {
|
|||||||
context.drawImage(this.video, 0, 0);
|
context.drawImage(this.video, 0, 0);
|
||||||
this.dataurl = canvas.toDataURL('image/jpeg', 0.95);
|
this.dataurl = canvas.toDataURL('image/jpeg', 0.95);
|
||||||
this.imgw.set_url(this.dataurl);
|
this.imgw.set_url(this.dataurl);
|
||||||
this.task = schedule_once(this.show_picture.bind(this), this.task_period);
|
|
||||||
this.show_cnt += 1;
|
this.show_cnt += 1;
|
||||||
}
|
}
|
||||||
switch_recording(){
|
switch_recording(){
|
||||||
@ -141,7 +140,7 @@ bricks.Camera = class extends bricks.Popup {
|
|||||||
take_picture(event){
|
take_picture(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (this.task){
|
if (this.task){
|
||||||
task.cancel();
|
clearInterval(this.task);
|
||||||
this.task = null;
|
this.task = null;
|
||||||
}
|
}
|
||||||
this.task_period = 0;
|
this.task_period = 0;
|
||||||
|
|||||||
@ -17,13 +17,13 @@ bricks.TimePassed = class extends bricks.VBox {
|
|||||||
this.seconds = 0;
|
this.seconds = 0;
|
||||||
var t = bricks.formatTime(this.seconds);
|
var t = bricks.formatTime(this.seconds);
|
||||||
this.text_w = new bricks.Text({
|
this.text_w = new bricks.Text({
|
||||||
text:this.t,
|
text:t,
|
||||||
rate:this.text_rate
|
rate:this.text_rate
|
||||||
});
|
});
|
||||||
this.add_widget(this.text_w);
|
this.add_widget(this.text_w);
|
||||||
}
|
}
|
||||||
start(){
|
start(){
|
||||||
this.task = schedule_once(this.add_one_second.bind(this), 1);
|
this.task = schedule_interval(this.add_one_second.bind(this), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_one_second(){
|
add_one_second(){
|
||||||
@ -33,7 +33,7 @@ bricks.TimePassed = class extends bricks.VBox {
|
|||||||
this.task = schedule_once(this.add_one_second.bind(this), 1);
|
this.task = schedule_once(this.add_one_second.bind(this), 1);
|
||||||
}
|
}
|
||||||
stop(){
|
stop(){
|
||||||
this.task.cancel();
|
clearInterval(this.task);
|
||||||
this.task = null;
|
this.task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,18 +84,23 @@ bricks.Countdown = class extends bricks.VBox {
|
|||||||
this.add_widget(this.text_w);
|
this.add_widget(this.text_w);
|
||||||
}
|
}
|
||||||
start(){
|
start(){
|
||||||
schedule_once(this.time_down_second.bind(this), 1)
|
this.task = schedule_interval(this.time_down_second.bind(this), 1)
|
||||||
|
}
|
||||||
|
stop(){
|
||||||
|
if (this.task){
|
||||||
|
clearInterval(this.task);
|
||||||
|
}
|
||||||
|
this.task = null;
|
||||||
}
|
}
|
||||||
time_down_second(){
|
time_down_second(){
|
||||||
if (this.seconds < 1){
|
|
||||||
this.dispatch('timeout');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var h, m, s;
|
var h, m, s;
|
||||||
this.seconds -= 1;
|
this.seconds -= 1;
|
||||||
var ts = bricks.formatTime(this.seconds);
|
var ts = bricks.formatTime(this.seconds);
|
||||||
this.text_w.set_text(ts);
|
this.text_w.set_text(ts);
|
||||||
schedule_once(this.time_down_second.bind(this), 1)
|
if (this.seconds < 1){
|
||||||
|
stop();
|
||||||
|
this.dispatch('timeout');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@ bricks.BaseModal = class extends bricks.Layout {
|
|||||||
if (this.parent){
|
if (this.parent){
|
||||||
this.set_css('display', 'none');
|
this.set_css('display', 'none');
|
||||||
if (this.timeout_task){
|
if (this.timeout_task){
|
||||||
this.timeout_task.cancel();
|
clearTimeout(this.timeout_task);
|
||||||
this.timeout_task = null;
|
this.timeout_task = null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -32,10 +32,9 @@ bricks.MediaRecorder = class extends bricks.Popup {
|
|||||||
this.record_status = 'standby';
|
this.record_status = 'standby';
|
||||||
this.toggle_record.bind('click', this.switch_record.bind(this));
|
this.toggle_record.bind('click', this.switch_record.bind(this));
|
||||||
this.toggle_record.disabled(true);
|
this.toggle_record.disabled(true);
|
||||||
schedule_once(this.open_recorder.bind(this), 0.1);
|
this.task = schedule_interval(this.open_recorder.bind(this), 0.1);
|
||||||
}
|
}
|
||||||
tick_task(){
|
tick_task(){
|
||||||
this.task = schedule_once(this.tick_task.bind(this), this.task_period);
|
|
||||||
this.timepass.set_text(bricks.timeDiff(this.start_time));
|
this.timepass.set_text(bricks.timeDiff(this.start_time));
|
||||||
}
|
}
|
||||||
async switch_record(){
|
async switch_record(){
|
||||||
@ -96,7 +95,7 @@ bricks.MediaRecorder = class extends bricks.Popup {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.start_time = Date.now();
|
this.start_time = Date.now();
|
||||||
this.task = schedule_once(this.tick_task.bind(this), this.task_period);
|
this.task = schedule_interval(this.tick_task.bind(this), this.task_period);
|
||||||
this.mediaRecorder.start();
|
this.mediaRecorder.start();
|
||||||
this.dispatch('record_started')
|
this.dispatch('record_started')
|
||||||
console.log("Recording started...");
|
console.log("Recording started...");
|
||||||
@ -116,7 +115,7 @@ bricks.MediaRecorder = class extends bricks.Popup {
|
|||||||
|
|
||||||
close_recorder(){
|
close_recorder(){
|
||||||
if (this.task){
|
if (this.task){
|
||||||
this.task.cancel();
|
clearInterval(this.task);
|
||||||
this.task = null;
|
this.task = null;
|
||||||
}
|
}
|
||||||
if (this.stream){
|
if (this.stream){
|
||||||
@ -242,7 +241,7 @@ bricks.SysVideoRecorder = class extends bricks.MediaRecorder {
|
|||||||
this.imgw = new bricks.Image({width: '100%'});
|
this.imgw = new bricks.Image({width: '100%'});
|
||||||
this.preview.add_widget(this.imgw);
|
this.preview.add_widget(this.imgw);
|
||||||
this.toggle_record.disabled(false);
|
this.toggle_record.disabled(false);
|
||||||
this.pic_task = schedule_once(this.show_picture.bind(this), this.task_period);
|
this.pic_task = schedule_interval(this.show_picture.bind(this), this.task_period);
|
||||||
}
|
}
|
||||||
async show_picture(){
|
async show_picture(){
|
||||||
if (this.task_period == 0){
|
if (this.task_period == 0){
|
||||||
@ -254,13 +253,11 @@ bricks.SysVideoRecorder = class extends bricks.MediaRecorder {
|
|||||||
'image.jpg',
|
'image.jpg',
|
||||||
{ type: 'image/jpeg' });
|
{ type: 'image/jpeg' });
|
||||||
this.imgw.set_url(this.dataurl);
|
this.imgw.set_url(this.dataurl);
|
||||||
this.pic_task = schedule_once(this.show_picture.bind(this),
|
|
||||||
this.task_period);
|
|
||||||
}
|
}
|
||||||
close_recorder(){
|
close_recorder(){
|
||||||
super.close_recorder();
|
super.close_recorder();
|
||||||
if (this.pic_task){
|
if (this.pic_task){
|
||||||
this.pic_task.cancel();
|
clearInterval(this.pic_task);
|
||||||
this.pic_task = null;
|
this.pic_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,7 +267,7 @@ bricks.SysCamera= class extends bricks.SysVideoRecorder {
|
|||||||
console.log('shot it ............');
|
console.log('shot it ............');
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (this.task){
|
if (this.task){
|
||||||
task.cancel();
|
clearInterval(this.task);
|
||||||
this.task = null;
|
this.task = null;
|
||||||
}
|
}
|
||||||
this.task_period = 0;
|
this.task_period = 0;
|
||||||
|
|||||||
@ -140,7 +140,6 @@ bricks.Signaling = class {
|
|||||||
this.send_data(d);
|
this.send_data(d);
|
||||||
if (this.heartbeat_period > 0){
|
if (this.heartbeat_period > 0){
|
||||||
console.log('call login again in', this.heartbeat_period, ' seconds');
|
console.log('call login again in', this.heartbeat_period, ' seconds');
|
||||||
this.hb_task = schedule_once(this.login.bind(this), this.heartbeat_period);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,18 +23,17 @@ bricks.BaseRunning = class extends bricks.FHBox {
|
|||||||
this.time_start = new Date().getTime();
|
this.time_start = new Date().getTime();
|
||||||
this.add_widget(this.icon_w);
|
this.add_widget(this.icon_w);
|
||||||
this.add_widget(this.time_w);
|
this.add_widget(this.time_w);
|
||||||
this.showtime_task = schedule_once(this.show_timepass.bind(this), 0.05);
|
this.showtime_task = schedule_interval(this.show_timepass.bind(this), 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
show_timepass(){
|
show_timepass(){
|
||||||
var t = new Date().getTime() - this.time_start;
|
var t = new Date().getTime() - this.time_start;
|
||||||
var txt = bricks.formatMs(t, 1);
|
var txt = bricks.formatMs(t, 1);
|
||||||
this.time_w.set_text(txt);
|
this.time_w.set_text(txt);
|
||||||
this.showtime_task = schedule_once(this.show_timepass.bind(this), 0.05);
|
|
||||||
}
|
}
|
||||||
stop_timepass(){
|
stop_timepass(){
|
||||||
if (this.showtime_task){
|
if (this.showtime_task){
|
||||||
this.showtime_task.cancel();
|
clearInterval(this.showtime_task);
|
||||||
this.showtime_task = null;
|
this.showtime_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,18 +57,17 @@ bricks.Svg = class extends bricks.VBox {
|
|||||||
this.dom_element.innerHTML = this.svg_text;
|
this.dom_element.innerHTML = this.svg_text;
|
||||||
else
|
else
|
||||||
this.dom_element.innerHTML = ''
|
this.dom_element.innerHTML = ''
|
||||||
this.blink_task = schedule_once(this._blink.bind(this),
|
|
||||||
this.blinktime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start_blink(){
|
start_blink(){
|
||||||
if (!this.blink_task){
|
if (!this.blink_task){
|
||||||
this._blink();
|
this.blink_task = schedule_interval(this._blink.bind(this),
|
||||||
|
this.blinktime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end_blink(){
|
end_blink(){
|
||||||
if (this.blink_task)
|
if (this.blink_task)
|
||||||
this.blink_task.cancel();
|
clearInterval(this.blink_task);
|
||||||
this.blink_task = null;
|
this.blink_task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -358,12 +358,8 @@ var schedule_once = function(f, t){
|
|||||||
}
|
}
|
||||||
|
|
||||||
var schedule_interval = function(f, t){
|
var schedule_interval = function(f, t){
|
||||||
var mf = function(func, t){
|
t = t * 1000
|
||||||
console.log('arguments:', func, t);
|
return window.setInterval(f, t);
|
||||||
func();
|
|
||||||
schedule_once(mf.bind(func, t), t);
|
|
||||||
}
|
|
||||||
schedule_once(mf.bind(f,t), t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var debug = function(){
|
var debug = function(){
|
||||||
|
|||||||
@ -551,7 +551,7 @@ bricks.Tooltip = class extends bricks.Text {
|
|||||||
hide(){
|
hide(){
|
||||||
try {
|
try {
|
||||||
if (this.auto_task){
|
if (this.auto_task){
|
||||||
this.auto_task.cancel();
|
clearTimeout(this.auto_task);
|
||||||
this.auto_task = null;
|
this.auto_task = null;
|
||||||
}
|
}
|
||||||
} catch(e){
|
} catch(e){
|
||||||
|
|||||||
@ -45,10 +45,6 @@ bricks.Wterm = class extends bricks.JsWidget {
|
|||||||
destroy(){
|
destroy(){
|
||||||
console.debug('------domoff event, destory this widget');
|
console.debug('------domoff event, destory this widget');
|
||||||
try {
|
try {
|
||||||
if (this.heartbeat_task){
|
|
||||||
this.heartbeat_task.cancel();
|
|
||||||
this.heartbeat_task = null;
|
|
||||||
}
|
|
||||||
this.unbind('element_resize', this.term_resize.bind(this))
|
this.unbind('element_resize', this.term_resize.bind(this))
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log('error ', e);
|
console.log('error ', e);
|
||||||
@ -83,16 +79,6 @@ bricks.Wterm = class extends bricks.JsWidget {
|
|||||||
send_data(d){
|
send_data(d){
|
||||||
this.socket.send(JSON.stringify({type: "input", "data":d}));
|
this.socket.send(JSON.stringify({type: "input", "data":d}));
|
||||||
}
|
}
|
||||||
send_heartbeat(){
|
|
||||||
this.socket.send(JSON.stringify({ type: "heartbeat" }));
|
|
||||||
|
|
||||||
}
|
|
||||||
heartbeat(){
|
|
||||||
if (this.socket.readyState != 1) return;
|
|
||||||
this.send_heartbeat();
|
|
||||||
this.heartbeat_task = schedule_once(this.heartbeat.bind(this),
|
|
||||||
this.ping_timeout);
|
|
||||||
}
|
|
||||||
async open(){
|
async open(){
|
||||||
var term_options = bricks.extend({width: "100%", height: "100%"}, this.term_options);
|
var term_options = bricks.extend({width: "100%", height: "100%"}, this.term_options);
|
||||||
var term = new Terminal(term_options);
|
var term = new Terminal(term_options);
|
||||||
@ -120,16 +106,10 @@ bricks.Wterm = class extends bricks.JsWidget {
|
|||||||
};
|
};
|
||||||
ws.onclose = (event) => {
|
ws.onclose = (event) => {
|
||||||
console.log('websocket closed:', event.code, '--', event.reason);
|
console.log('websocket closed:', event.code, '--', event.reason);
|
||||||
if (this.heartbeat_task) {
|
|
||||||
this.heartbeat_task.cancel();
|
|
||||||
this.heartbeat_task = null;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
this.send_term_size();
|
this.send_term_size();
|
||||||
this.bind('element_resize', this.term_resize.bind(this))
|
this.bind('element_resize', this.term_resize.bind(this))
|
||||||
this.heartbeat_task = schedule_once(this.heartbeat.bind(this),
|
|
||||||
this.ping_timeout);
|
|
||||||
};
|
};
|
||||||
term.onData((key) => {
|
term.onData((key) => {
|
||||||
console.log('key=', key);
|
console.log('key=', key);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user