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