Skip to content

Commit

Permalink
Better data init
Browse files Browse the repository at this point in the history
  • Loading branch information
toggledbits committed Jul 19, 2020
1 parent 5fa3cf1 commit 3827c05
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/J_Switchboard1_UI7.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ var Switchboard1_UI7 = (function(api, $) {
break;

default:
console("handleIconClick() unhandled action " + String(act));
console.log("handleIconClick() unhandled action " + String(act));
}
}

Expand Down Expand Up @@ -225,12 +225,18 @@ var Switchboard1_UI7 = (function(api, $) {
row.append( el );
row.append( jQuery( '<div class="vsname col-xs-11 col-md-5" />' ).text( obj.name + ' (#' + obj.id + ')' ).attr( 'title', 'Click to change name' ) );
el = jQuery( '<div class="col-xs-4 col-md-2" />' );
el.append( '<i class="swbd-vis material-icons md-btn" title="Toggle visibility">visibility</i>' );
jQuery( '<i class="swbd-vis material-icons md-btn" title="Toggle visibility">visibility</i>' )
.data( 'swbd-action', 'visibility' )
.appendTo( el );
if ( false !== ( childBehavior[behavior] || {} ).timer ) {
el.append( '<i class="swbd-impulse material-icons md-btn" title="Set auto-reset timer">timer_off</i>' );
jQuery( '<i class="swbd-impulse material-icons md-btn" title="Set auto-reset timer">timer_off</i>' )
.data('swbd-action', 'impulse')
.appendTo( el );
}
if ( isOpenLuup ) {
el.append( '<i class="swbd-repeat material-icons md-btn" title="Trigger only if status changes">repeat_one</i>' );
jQuery( '<i class="swbd-repeat material-icons md-btn" title="Trigger only if status changes">repeat_one</i>' )
.data('swbd-action', 'repeat')
.appendTo( el );
}
row.append( el );

Expand All @@ -249,16 +255,16 @@ var Switchboard1_UI7 = (function(api, $) {
container.append( row );

if ( ( obj.invisible || "0" ) != "0" ) {
jQuery( 'i.swbd-vis', row ).text( 'visibility_off' ).data('swbd-action', 'visibility');
jQuery( 'i.swbd-vis', row ).text( 'visibility_off' );
}
st = parseInt( api.getDeviceState( obj.id, serviceId, "ImpulseTime" ) || 0 );
if ( ! isNaN( st ) && st > 0 ) {
jQuery( 'i.swbd-impulse', row ).text( 'timer' ).data('swbd-action', 'impulse')
jQuery( 'i.swbd-impulse', row ).text( 'timer' )
.attr( 'title', 'Auto-reset ' + st + ' seconds; click to modify or clear' );
}
st = 0 !== parseInt( api.getDeviceState( obj.id, serviceId, "AlwaysUpdateStatus" ) || 0 );
if ( st ) {
jQuery( 'i.swbd-repeat', row ).text( 'repeat' ).data('swbd-action', 'repeat');
jQuery( 'i.swbd-repeat', row ).text( 'repeat' );
}

jQuery( 'img.swbd-state', row ).on( 'click.switchboard', handleStateClick );
Expand Down

0 comments on commit 3827c05

Please sign in to comment.