Skip to content

Commit

Permalink
Merge pull request #1610 from rern/UPDATE
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rern authored Feb 26, 2024
2 parents 8ab135c + 1be1f08 commit 22091c5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 41 deletions.
11 changes: 2 additions & 9 deletions srv/http/assets/js/camilla.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ var D0 = {
}
var Dlist = {
type : [ 'Type', 'select', [ 'AsyncSinc', 'AsyncPoly', 'Synchronous' ] ]
, profile : [ 'Profile', 'select', [ 'Accurate ', 'Balanced', 'Fast', 'VeryFast', 'Custom' ] ]
, profile : [ 'Profile', 'select', { kv: [ 'Accurate', 'Balanced', 'Fast', 'VeryFast', 'Custom' ], nosort: true } ]
, typeC : [ 'Type', 'select' ] // on 'GetSupportedDeviceTypes'
, typeP : [ 'Type', 'select' ] // ^
, deviceC : [ 'Device', 'select' ] // ^
Expand All @@ -270,7 +270,6 @@ var Dlist = {
, skip_bytes : [ 'Skip bytes', 'number' ]
, read_bytes : [ 'Read bytes', 'number' ]
, capture_samplerate : [ 'Capture samplerate', 'select' ] // ^
, custom : [ '<gr>Custom rate</gr>', 'number' ]
, exclusive : [ 'Exclusive', 'checkbox' ]
, loopback : [ 'Loopback', 'checkbox' ]
, change_format : [ 'Change format', 'checkbox' ]
Expand All @@ -283,7 +282,6 @@ var D1 = {
var D = {
main : [
[ 'Sample rate', 'select' ] // on 'GetSupportedDeviceTypes'
, Dlist.custom
, [ 'Chunk size', 'number' ]
, [ 'Queue limit', 'number' ]
, [ 'Silence Threshold', 'number' ]
Expand Down Expand Up @@ -750,7 +748,7 @@ var render = {
delete V.intervalvu;
$( '.peak, .rms' ).css( { 'transition-duration': '0s', width: 0 } );
$( '.peak' ).css( 'left', 0 );
$( '#divstate' ).find( '.buffer, .load, .capture, .rate' ).text( '·' );
$( '#divstate' ).find( '.buffer, .load, .capture, .rate' ).html( dots );
}
, vuLevel : ( rms, cpi, db ) => {
if ( db < -98 ) {
Expand Down Expand Up @@ -1087,7 +1085,6 @@ var render = {
var setting = {
filter : ( type, subtype, name ) => {
var list = subtype in F[ type ] ? F[ type ][ subtype ] : F[ type ];
console.log(type, subtype, name, list)
if ( type === 'Biquad' ) {
if ( [ 'Hig', 'Low' ].includes( subtype.slice( 0, 3 ) ) ) {
var vsubtype = subtype.replace( /High|Low/, '' );
Expand Down Expand Up @@ -1474,9 +1471,7 @@ var setting = {
var values = {};
D0.main.forEach( k => {
values[ k ] = DEV[ k ];
if ( k === 'samplerate' ) values.custom = DEV.samplerate; // force indexed after samplerate
} );
if ( ! D0.samplerate.includes( values.custom ) ) values.samplerate = 'Custom';
var title = common.tabTitle();
info( {
icon : V.tab
Expand All @@ -1488,8 +1483,6 @@ var setting = {
, checkchanged : true
, ok : () => {
var val = infoVal();
if ( val.samplerate === 'Custom' ) val.samplerate = val.custom;
delete val.custom;
$.each( val, ( k, v ) => DEV[ k ] = v );
setting.save( title, 'Change ...' );
render.devices();
Expand Down
55 changes: 26 additions & 29 deletions srv/http/assets/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ loader() local() selectSet()
var page = location.search.replace( '?p=', '' );
var dirbash = '/srv/http/bash/';
var dirsettings = '/srv/http/bash/settings/';
var dots = '·&ensp;·&ensp;·';
var iconwarning = ico( 'warning i-22 yl' ) +'&ensp;';
var localhost = [ 'localhost', '127.0.0.1' ].includes( location.hostname );
var orange = '#de810e';
Expand Down Expand Up @@ -146,14 +147,14 @@ $( '.col-r .switch' ).press( function( e ) {

// ----------------------------------------------------------------------
function banner( icon, title, message, delay ) {
clearTimeout( I.timeoutbanner );
clearTimeout( V.timeoutbanner );
var bottom = $( '#bar-bottom' ).is( '.transparent, :hidden' ) || ! $( '#loader' ).hasClass( 'hide' ) ? '10px' : '';
$( '#banner' )
.html( '<div id="bannerIcon">'+ ico( icon ) +'</div><div id="bannerTitle">'+ title +'</div>'
+'<div id="bannerMessage">'+ message +'</div>' )
.css( 'bottom', bottom )
.removeClass( 'hide' );
if ( delay !== -1 ) I.timeoutbanner = setTimeout( bannerHide, delay || 3000 );
if ( delay !== -1 ) V.timeoutbanner = setTimeout( bannerHide, delay || 3000 );
}
function bannerHide() {
if ( V.reboot || $( '#banner' ).hasClass( 'hide' ) || $( '#banner .i-warning' ).length ) return
Expand Down Expand Up @@ -275,6 +276,7 @@ select: [U] [D] - check
I = { active: false }

function info( json ) {
infoClearTimeout( 0, 8 );
local(); // flag for consecutive info
I = json;
if ( 'keyvalue' in I ) $.each( I.keyvalue, ( k, v ) => I[ k ] = v );
Expand Down Expand Up @@ -598,7 +600,7 @@ function info( json ) {
$( '#infoOk' ).toggleClass( 'disabled', I.blank || I.notip || I.short || I.nochange ); // initial check
infoCheckSet();
if ( I.range ) {
var timeout, val;
var val;
$( '.inforange input' ).on( 'input', function() {
var $this = $( this );
$this.siblings( '.value' ).text( +$this.val() );
Expand All @@ -611,14 +613,14 @@ function info( json ) {
.siblings( '.value' ).text( val );
}
$( '.inforange i' ).on( 'touchend mouseup keyup', function() { // increment up/dn
clearTimeout( timeout );
clearTimeout( V.timeout0 );
var $this = $( this );
if ( ! V.press ) rangeset( $this.siblings( 'input' ), $this.hasClass( 'up' ) );
} ).press( function( e ) {
var $this = $( e.target );
var $range = $this.siblings( 'input' )
var up = $this.hasClass( 'up' );
timeout = setInterval( () => rangeset( $range, up ), 100 );
V.timeout0 = setInterval( () => rangeset( $range, up ), 100 );
} );
}
if ( I.updn.length ) {
Expand All @@ -628,14 +630,10 @@ function info( json ) {
var $num = $td.prev().find( 'input' );
var step = el.step;
var v = 0;
var interval, timeout;
function numberset( up ) {
v = +$num.val();
v = up ? v + step : v - step;
if ( v === el.min || v === el.max ) {
clearInterval( interval );
clearTimeout( timeout );
}
if ( v === el.min || v === el.max ) infoClearTimeout( 1, 2 );
$num.val( v );
if ( I.checkchanged ) $num.trigger( 'input' );
updnToggle( v );
Expand All @@ -649,17 +647,16 @@ function info( json ) {
if ( ! V.press ) numberset( $( this ).hasClass( 'up' ) );
} ).press( function( e ) {
var up = $( e.target ).hasClass( 'up' );
interval = setInterval( () => numberset( up ), 100 );
timeout = setTimeout( () => { // @5 after 3s
clearInterval( interval );
V.timeout1 = setInterval( () => numberset( up ), 100 );
V.timeout2 = setTimeout( () => { // @5 after 3s
clearInterval( V.timeout1 );
step *= 5;
v = v > 0 ? v + ( step - v % step ) : v - ( step + v % step );
$num.val( v );
interval = setInterval( () => numberset( up ), 100 );
V.timeout3 = setInterval( () => numberset( up ), 100 );
}, 3000 );
} ).on( 'touchend mouseup keyup', function() {
clearInterval( interval );
clearTimeout( timeout );
infoClearTimeout( 1, 3 );
step = el.step;
} );
} );
Expand Down Expand Up @@ -702,8 +699,6 @@ function infoButtonWidth() {
if ( widest > 70 ) $( '.infobtn, .filebtn' ).css( 'min-width', widest );
}
function infoCheckBlank() {
if ( ! I.checkblank ) return // suppress error on repeating

I.blank = I.checkblank.some( i => $inputbox.eq( i ).val().trim() === '' );
}
function infoCheckIP() {
Expand Down Expand Up @@ -733,21 +728,23 @@ function infoCheckSet() {
if ( I.checkchanged || I.checkblank || I.checkip || I.checklength ) {
$( '#infoList' ).find( 'input, select, textarea' ).on( 'input', function() {
if ( I.checkchanged ) I.nochange = I.values.join( '' ) === infoVal( 'array' ).join( '' );
if ( I.checkblank ) setTimeout( infoCheckBlank, 0 ); // ios: wait for value
if ( I.checklength ) setTimeout( infoCheckLength, 25 );
if ( I.checkip ) setTimeout( infoCheckIP, 50 );
setTimeout( () => {
if ( ! $( '#infoList input' ).length ) return // suppress on repeating

if ( I.checkblank ) V.timeout4 = setTimeout( infoCheckBlank, 0 ); // #1
if ( I.checklength ) V.timeout5 = setTimeout( infoCheckLength, 25 ); // #2
if ( I.checkip ) V.timeout6 = setTimeout( infoCheckIP, 50 ); // #3
V.timeout7 = setTimeout( () => { // #4
$( '#infoOk' ).toggleClass( 'disabled', I.nochange || I.blank || I.notip || I.short );
}, 75 ); // ios: force after infoCheckLength
}, 75 );
} );
}
}
function infoClearTimeout( from, to ) { // ok for both timeout and interval
to++;
for ( i= from; i < to; i++ ) clearTimeout( V[ 'timeout'+ i ] );
}
function infoFileImage() {
delete I.infofilegif;
I.timeoutfile = setTimeout( () => banner( 'refresh blink', 'Change Image', 'Load ...', -1 ), 1000 );
I.rotate = 0;
V.timeout8 = setTimeout( () => banner( 'refresh blink', 'Change Image', 'Load ...', -1 ), 1000 );
I.rotate = 0;
$( '.infoimgname' ).addClass( 'hide' );
$( '.infoimgnew, .infoimgwh' ).remove();
if ( I.infofile.name.slice( -3 ) !== 'gif' ) {
Expand All @@ -768,7 +765,7 @@ function infoFileImage() {
var imgH = img.height;
var resize = infoFileImageResize( 'gif', imgW, imgH );
infoFileImageRender( img.src, imgW +' x '+ imgH, resize ? resize.wxh : '' );
clearTimeout( I.timeoutfile );
clearTimeout( V.timeout8 );
bannerHide();
}
} else {
Expand Down Expand Up @@ -805,7 +802,7 @@ function infoFileImageReader() {
} else {
infoFileImageRender( filecanvas.toDataURL( 'image/jpeg' ), imgW +' x '+ imgH );
}
clearTimeout( I.timeoutfile );
clearTimeout( V.timeout8 );
bannerHide();
}
}
Expand Down
1 change: 0 additions & 1 deletion srv/http/assets/js/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,6 @@ function setInfo() {
, Title : $( '#title' ).text()
, Album : $( '#album' ).text()
}
var dots = '·&ensp;·&ensp;·';
if ( S.webradio ) {
var url = S.file.replace( /#charset=.*/, '' );
if ( S.state !== 'play' ) {
Expand Down
5 changes: 3 additions & 2 deletions srv/http/settings/camilla.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
, 'config' => str_replace( 'mixers' , 'config', $btnmixers )
, 'control' => i( 'volume btn' ).i( 'inverted btn' ).i( 'linear btn' )
];
$dots = '·&ensp;·&ensp;·';
$help = [
'status' => <<< EOF
{$Fi( 'play btn' )}{$Fi( 'pause btn' )}{$Fi( 'stop btn' )} Playback control
Expand Down Expand Up @@ -70,8 +71,8 @@
<br>Sampling<span class="rateadjust"> · Adjust</span>
'
, 'values' => '
<a class="buffer">·</a> <gr>·</gr> <a class="load">·</a><span class="divclipped hide"> <gr>·</gr> <a class="clipped">·</a></span>
<br><a class="capture">·</a><span class="rateadjust"> <gr>·</gr> <a class="rate">·</a></span>
<a class="buffer">'.$dots.'</a> <gr>·</gr> <a class="load">'.$dots.'</a><span class="divclipped hide"> <gr>·</gr> <a class="clipped">'.$dots.'</a></span>
<br><a class="capture">'.$dots.'</a><span class="rateadjust"> <gr>·</gr> <a class="rate">'.$dots.'</a></span>
'
];
$tabs = [ 'filters', 'mixers', 'processors', 'pipeline', 'devices', 'config' ];
Expand Down

0 comments on commit 22091c5

Please sign in to comment.