Skip to content

Commit

Permalink
Update index_m.html
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-blackson committed Jul 27, 2023
1 parent 95fff3e commit f4988f3
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<script type="text/javascript">
var setup = [];
var countdownData = [];
var originalNames = []
let _onChange;

// TEMP!!!
Expand All @@ -49,8 +50,29 @@
obj[$this.attr('id')] = $this.val();
}
});
updateSetup()
callback(obj);
}

function updateSetup(){
// check if countdown is still needed - otherwise delete it
for (var i = 0; i < originalNames.length; i++) {
var found = false
countdownData.map(function (countdownData) {
if (countdownData.countdownName == originalNames[i]){
found = true
}

})
console.log('Found ' + originalNames[i] + " :" + found)
if (!found){
sendTo(adapter + '.' + instance, 'send', {
"name": originalNames[i],
})
}
}

}

function load(settings, onChange) {
_onChange = onChange;
Expand All @@ -72,7 +94,6 @@
}
});
loadSetup()
console.log('Value of countdownData: ' + JSON.stringify(countdownData))

onChange(false);
if (M) M.updateTextFields();
Expand Down Expand Up @@ -117,13 +138,9 @@
*/
}
function loadSetup() {
console.log('LoadSetup1')

socket.emit('getObjectView', 'system', 'state', { startkey: 'countdown.' + instance + '.setup', endkey: 'countdown.' + instance + '.setup' + '.\u9999', include_docs: true }, function (err, _setup) {

//console.log('Return of all setups : ' + JSON.stringify(_setup));
console.log('LoadSetup2')

for (const i in _setup.rows) {
getState(_setup.rows[i].id , (err, state) => {
var countName = _setup.rows[i].id.replace('countdown.' + instance + '.setup.','');
Expand All @@ -144,7 +161,7 @@
repeatCycle = countdownDate.slice((SearchForCycle+1), countdownDate.length)
countdownDate = countdownDate.slice(0,SearchForCycle)
}

originalNames.push(countName)
countdownData.push(
{
countdownName: countName,
Expand Down

0 comments on commit f4988f3

Please sign in to comment.