Skip to content

Commit

Permalink
Merge pull request #1787 from rern/UPDATE
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rern authored Oct 12, 2024
2 parents f2a2c9c + 8ef76b6 commit 3f5caf6
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 181 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Audio player for
- [Rotary encoder](https://github.com/rern/rAudio/raw/main/srv/http/assets/img/rotaryencoder.jpg)
- [Spectrum OLED](https://github.com/rern/rAudio/raw/main/srv/http/assets/img/mpdoled.jpg) (128x64)
- [TFT 3.5" LCD](https://github.com/rern/rAudio/raw/main/srv/http/assets/img/lcd.jpg) (320x420)
- VU LED (7 LEDs+Rs)
- VU LED (LEDs+Rs)
- Not applicable on Raspberry Pi `1` or `Zero`:
- GUI on local screen
- DSP
Expand Down
4 changes: 4 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ alias=r1

. /srv/http/bash/settings/addons.sh

# 20241011
file=$dirsystem/powerbutton.conf
[[ -e $file ]] && sed -i '/reserved/ d' $file

# 20240921
file=$dirsystem/relays.conf
if [[ -e $file ]] && ! grep -q timeron $file; then
Expand Down
4 changes: 2 additions & 2 deletions srv/http/assets/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ input.disabled + .switchlabel:after {
display: none;
color: var( --cw );
}
.gpio svg {
max-width: 100%;
.infomessage:has( svg ) {
width: 100%;
}
.gpiopins {
margin-top: 0;
Expand Down
106 changes: 53 additions & 53 deletions srv/http/assets/img/gpio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 64 additions & 17 deletions srv/http/assets/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,41 +545,71 @@ function info( json ) {
} );
}
if ( I.updn.length ) {
var max = [];
var min = [];
for ( i = 0; i < I.updn.length; i++ ) {
min.push( I.updn[ i ].min );
max.push( I.updn[ i ].max );
}
I.updn.forEach( ( el, i ) => {
var $td = $( '#infoList .updn' ).parent().eq( i );
var $updn = $td.find( '.updn' );
var $num = $td.prev().find( 'input' );
var step = el.step;
var v = 0;
function numberset( up ) {
v = +$num.val();
v = up ? v + step : v - step;
function numberset( $target ) {
var up = $target.hasClass( 'up' );
var v = +$num.val();
v = up ? v + step : v - step;
if ( v === el.min || v === el.max ) infoClearTimeout();
$num.val( v );
if ( I.checkchanged ) $num.trigger( 'input' );
updnToggle( v );
updnToggle( up );
}
function updnToggle( v ) {
$updn.eq( 0 ).toggleClass( 'disabled', v === el.min );
$updn.eq( 1 ).toggleClass( 'disabled', v === el.max );
function updnToggle( up ) {
var v = infoVal( 'array' );
if ( el.link && typeof up === 'boolean' ) {
if ( v[ 0 ] > v[ 1 ] ) {
var vlink = up ? v[ 0 ] : v[ 1 ];
v = [ vlink, vlink ];
$input.val( vlink );
}
}
if ( I.checkchanged ) $num.trigger( 'input' );
for ( i = 0; i < I.updn.length; i++ ) {
$( '#infoList .dn' ).eq( i ).toggleClass( 'disabled', v[ i ] === min[ i ] );
$( '#infoList .up' ).eq( i ).toggleClass( 'disabled', v[ i ] === max[ i ] );
}
}
updnToggle( +$num.val() );
updnToggle();
$updn.on( 'click', function() {
if ( ! V.press ) numberset( $( this ).hasClass( 'up' ) );
if ( ! V.press ) numberset( $( this ) );
} ).press( function( e ) {
var up = $( e.target ).hasClass( 'up' );
V.timeout.updni = setInterval( () => numberset( up ), 100 );
var $target = $( e.target );
V.timeout.updni = setInterval( () => numberset( $target ), 100 );
V.timeout.updnt = setTimeout( () => { // @5 after 3s
clearInterval( V.timeout.updni );
step *= 5;
v = v > 0 ? v + ( step - v % step ) : v - ( step + v % step );
step *= 5;
var v = +$num.val();
v = v > 0 ? v + ( step - v % step ) : v - ( step + v % step );
$num.val( v );
V.timeout.updni = setInterval( () => numberset( up ), 100 );
V.timeout.updni = setInterval( () => numberset( $target ), 100 );
}, 3000 );
} ).on( 'touchend mouseup keyup', function() {
infoClearTimeout();
step = el.step;
} );
if ( el.enable ) {
$input.on( 'blur', function() {
var $this = $( this );
var i = $this.parents( 'tr' ).index();
var v = { val: +$this.val(), min: min[ i ], max: max[ i ] }
if ( v.val < v.min ) {
$this.val( v.min );
} else if ( v.val > v.max ) {
$this.val( v.max );
}
updnToggle( i === 0 );
} );
}
} );
}
// custom function before show
Expand Down Expand Up @@ -791,7 +821,23 @@ function infoFileImageResize( ext, imgW, imgH ) {
function infoKey2array( key ) {
if ( ! Array.isArray( I[ key ] ) ) I[ key ] = [ I[ key ] ];
}
function infoListChange() {
function infoListAddRemove( callback ) {
$( '#infoList tr' ).append( '<td>'+ ico( 'remove edit' ) +'</td>' );
$( '#infoList td' ).eq( 2 ).html( ico( 'plus edit' ) );
$( '#infoList' ).on( 'click', '.edit', function() {
var $this = $( this );
if ( $this.hasClass( 'i-plus' ) ) {
$( '#infoList select' ).select2( 'destroy' );
var $tr = $( '#infoList tr' ).last();
$tr.after( $tr.clone() );
selectSet();
} else {
$this.parents( 'tr' ).remove();
}
infoListChange( callback );
} );
}
function infoListChange( callback ) {
$input = $( '#infoList' ).find( 'input, select' );
$inputbox = $( '#infoList input' );
if ( 'checkblank' in I ) {
Expand All @@ -800,6 +846,7 @@ function infoListChange() {
}
infoCheckSet();
$( '#infoList input' ).trigger( 'input' );
if ( callback ) callback();
}
function infoPrompt( message ) {
var $toggle = $( '#infoX, #infoTab, .infoheader, #infoList, .infofooter, .infoprompt' );
Expand Down
27 changes: 7 additions & 20 deletions srv/http/assets/js/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ $( '#setting-multiraudio' ).on( 'click', function() {
$tr.find( 'i' ).remove();
}
} );
var okToggle = () => $( '#infoOk' ).toggleClass( 'disabled', $( '#infoList input' ).length < 3 );
var okToggle = () => {
if ( ! S.multiraudio ) $( '#infoOk' ).toggleClass( 'disabled', $( '#infoList input' ).length < 3 );
}
okToggle();
$( '#infoList' ).on( 'click', 'i', function() {
var $this = $( this );
Expand All @@ -298,10 +300,9 @@ $( '#setting-multiraudio' ).on( 'click', function() {
$( '#infoList input' ).last().val( S.ipsub );
} else {
$this.parents( 'tr' ).remove();
if ( ! S.multiraudio ) setTimeout( okToggle, 150 );
}
I.checkip = checkIpList( $( '#infoList input' ).length );
infoListChange();
infoListChange( okToggle );
} );
}
, cancel : switchCancel
Expand Down Expand Up @@ -431,31 +432,17 @@ $( '#setting-stoptimer' ).on( 'click', function() {
} );
} );
$( '#setting-volumelimit' ).on( 'click', function() {
var param = { updn: { step: 1, min: 0, max: 100, enable: true, link: true } }
info( {
icon : SW.icon
, title : SW.title
, list : [
[ 'Startup default', 'number', { updn: { step: 1, min: 0, max: S.volumelimitconf.MAX } } ]
, [ 'Maximum limit', 'number', { updn: { step: 1, min: 0, max: 100 } } ]
[ 'Startup default', 'number', param ]
, [ 'Maximum limit', 'number', param ]
]
, boxwidth : 70
, values : S.volumelimitconf
, checkchanged : S.volumelimit
, beforeshow : () => {
var $input = $( '#infoList input' );
var $startup = $input.eq( 0 );
var $max = $input.eq( 1 );
var $up = $( '#infoList .up' ).eq( 0 );
$( '#infoList .up' ).eq( 1 ).on( 'click', function() {
var max = +$max.val();
if ( +$startup.val() > max ) {
$startup.val( max );
$up.addClass( 'disabled' );
} else {
$up.removeClass( 'disabled' );
}
} );
}
, cancel : switchCancel
, ok : switchEnable
, fileconf : true
Expand Down
4 changes: 2 additions & 2 deletions srv/http/assets/js/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -1213,12 +1213,12 @@ function renderLibraryList( data ) { // V.librarylist
var dir0 = dir[ 0 ];
var htmlpath = ico( V.mode );
if ( V.mode.slice( -5 ) === 'radio' ) htmlpath += '<a>'+ V.mode +' / </a>';
htmlpath += '<a>'+ dir0 +' <wh>/</wh> <span class="lidir">'+ dir0 +'</span></a>';
htmlpath += '<a>'+ dir0 +' / <span class="lidir">'+ dir0 +'</span></a>';
var lidir = dir0;
var iL = dir.length;
for ( i = 1; i < iL; i++ ) {
lidir += '/'+ dir[ i ];
htmlpath += '<a>'+ dir[ i ] +' <wh>/</wh> <span class="lidir">'+ lidir +'</span></a>';
htmlpath += '<a>'+ dir[ i ] +' / <span class="lidir">'+ lidir +'</span></a>';
}
}
if ( V.mode === 'webradio' ) {
Expand Down
Loading

0 comments on commit 3f5caf6

Please sign in to comment.