bugfix
This commit is contained in:
parent
0a03b5c0d4
commit
cdfe924a65
@ -9,7 +9,7 @@ SOURCES=" page_data_loader.js factory.js uitypesdef.js utils.js uitype.js \
|
||||
binstreaming.js streaming_audio.js vadtext.js rtc.js docxviewer.js \
|
||||
llm_dialog.js llm.js websocket.js datarow.js tabular.js \
|
||||
line.js pie.js bar.js gobang.js period.js iconbarpage.js \
|
||||
keypress.js asr.js webspeech.js "
|
||||
keypress.js asr.js webspeech.js countdown.js progressbar.js "
|
||||
echo ${SOURCES}
|
||||
cat ${SOURCES} > ../dist/bricks.js
|
||||
# uglifyjs --compress --mangle -- ../dist/bricks.js > ../dist/bricks.min.js
|
||||
|
70
bricks/countdown.js
Normal file
70
bricks/countdown.js
Normal file
@ -0,0 +1,70 @@
|
||||
var bricks = window.bricks || {};
|
||||
|
||||
bricks.Countdown = class extends bricks.VBox {
|
||||
/*
|
||||
options:
|
||||
limit_time: 01:00:00
|
||||
text_rate:
|
||||
event:
|
||||
timeout
|
||||
*/
|
||||
constructor(opts){
|
||||
super(opts);
|
||||
var parts = opts.limit_time.split(':');
|
||||
var hours, minutes, seconds;
|
||||
switch(parts.length){
|
||||
case 0:
|
||||
hours = 0;
|
||||
minutes = 0;
|
||||
seconds = 0;
|
||||
break;
|
||||
case 1:
|
||||
hours = 0;
|
||||
minutes = 0;
|
||||
seconds = parseInt(parts[0])
|
||||
break;
|
||||
case 2:
|
||||
hours = 0;
|
||||
minutes = 0;
|
||||
seconds = parseInt(parts[0])
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
hours = parseInt(parts[0]);
|
||||
minutes = parseInt(parts[1]);
|
||||
seconds = parseInt(parts[2])
|
||||
break;
|
||||
}
|
||||
this.seconds = hours * 3600 + minutes * 60 + seconds;
|
||||
this.text_w = new bricks.Text({
|
||||
text:this.limit_time,
|
||||
rate:this.text_rate
|
||||
});
|
||||
this.add_widget(this.text_w);
|
||||
schedule_once(this.time_down_second.bind(this), 1)
|
||||
}
|
||||
formatTime(seconds) {
|
||||
let hrs = Math.floor(seconds / 3600);
|
||||
let mins = Math.floor((seconds % 3600) / 60);
|
||||
let secs = seconds % 60;
|
||||
|
||||
return [
|
||||
hrs.toString().padStart(2, '0'),
|
||||
mins.toString().padStart(2, '0'),
|
||||
secs.toString().padStart(2, '0')
|
||||
].join(':');
|
||||
}
|
||||
time_down_second(){
|
||||
if (this.seconds < 1){
|
||||
this.dispatch('timeout');
|
||||
return;
|
||||
}
|
||||
var h, m, s;
|
||||
this.seconds -= 1;
|
||||
var ts = formatTime(this.seconds);
|
||||
this.text_w.set_text(ts);
|
||||
schedule_once(this.time_down_second.bind(this), 1)
|
||||
}
|
||||
}
|
||||
|
||||
bricks.Factory.register('Countdown', bricks.Countdown);
|
@ -445,5 +445,19 @@ hr {
|
||||
.llm_title {
|
||||
background-color:#eeeeee;
|
||||
}
|
||||
|
||||
.progress-container {
|
||||
width: 80%;
|
||||
background-color: #ddd;
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.progress-bar {
|
||||
height: 30px;
|
||||
width: 0%;
|
||||
background-color: #4CAF50;
|
||||
text-align: center;
|
||||
color: white;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
|
24
bricks/progressbar.js
Normal file
24
bricks/progressbar.js
Normal file
@ -0,0 +1,24 @@
|
||||
var bricks = window.bricks || {};
|
||||
|
||||
bricks.ProgressBar = class extends bricks.HBox {
|
||||
/*
|
||||
options:
|
||||
total_value
|
||||
bar_cwidth
|
||||
event:
|
||||
*/
|
||||
constructor(opts){
|
||||
super(opts);
|
||||
this.set_css('progress-container');
|
||||
this.text_w = new bricks.Text({text:'0%', cheight:this.bar_cwidth||2});
|
||||
this.text_w.set_css('progress-bar')
|
||||
this.add_widget(this.text_w);
|
||||
}
|
||||
set_value(v){
|
||||
var pzt = (current / total) * 100;
|
||||
pzt = Math.max(0, Math.min(100, percentage));
|
||||
this.text_w.set_style('width', pzt + '%')
|
||||
}
|
||||
}
|
||||
bricks.Factory.register('ProgressBar', bricks.ProgressBar);
|
||||
|
@ -81,6 +81,8 @@ bricks.Video = class extends bricks.Layout {
|
||||
schedule_once(this._auto_play.bind(this), 0.8);
|
||||
}
|
||||
_auto_play(){
|
||||
this.set_url(this.opts.url);
|
||||
return;
|
||||
var play_btn = this.findVideoButtonByClass('vjs-big-play-button');
|
||||
if (!play_btn){
|
||||
console.log('vjs-big-play-button not found');
|
||||
@ -123,17 +125,22 @@ bricks.Video = class extends bricks.Layout {
|
||||
}
|
||||
}
|
||||
dispatch_mute(){
|
||||
var mute_btn = this.findVideoButtonByClass("vjs-mute-control");
|
||||
var mute_btn = this.findVideoButtonByClass("vjs-mute-control.vjs-control.vjs-button");
|
||||
if (!mute_btn){
|
||||
bricks.test_element = e;
|
||||
console.log(e, 'there is not mute button found')
|
||||
var isMute = this.player.muted();
|
||||
if (isMuted){
|
||||
this.player.muted(False);
|
||||
}
|
||||
bricks.test_element = this;
|
||||
console.log(this, 'there is not mute button found, isMuted=', isMuted);
|
||||
return;
|
||||
}
|
||||
var clickevent = new MouseEvent('click', {
|
||||
'bubbles': true, // 事件是否冒泡
|
||||
'cancelable': true // 事件是否可取消
|
||||
});
|
||||
if (this.player.muted && this.autounmute){
|
||||
var isMuted = this.player.muted();
|
||||
if (isMuted){
|
||||
mute_btn.dispatchEvent(clickevent);
|
||||
}
|
||||
}
|
||||
@ -172,8 +179,8 @@ bricks.Video = class extends bricks.Layout {
|
||||
}
|
||||
this.play_status = 'playok';
|
||||
console.log(this.cur_url, 'play ok');
|
||||
if (this.autounmute && this.player.muted){
|
||||
schedule_once(this.dispatch_mute.bind(this), 1.5);
|
||||
if (this.autounmute && this.player.muted()){
|
||||
schedule_once(this.dispatch_mute.bind(this), 2.5);
|
||||
console.log('mute btn clicked');
|
||||
} else {
|
||||
console.log(this.autounmute, 'player.muted=', this.player.muted);
|
||||
|
Loading…
Reference in New Issue
Block a user