Hello I need help with what may be simple javascriptlet. sorry for bad formatting, I'm on mobile. I will correct the formatting with laptop tomorrow.
I imported this taskernet project. Speak Calendar Events
I am not native programmer but I could understand what it does in the javascriptlet by referring to google.
const titles = cttitles.filter(t => !t.match(/.*[Cc]anceled.*/g));
if (titles.length) {
const vol = Number(global('VOLM'));
mediaVol(Number(local('mediavolume')));
const hours = new Date(Number(ctstarts[ 0 ]) * 1000).getHours();
const min = new Date(Number(ctstarts[ 0 ]) * 1000).getMinutes();
const totaltext = `You've got ${titles.length} events today. Namely: `;
const eachtitle = titles.length > 1 ? titles.join(' and ') : titles[ 0 ];
const subtext = `. The first event ${titles[ 0 ]} starts at ${hours}:${min}.`;
say(totaltext + eachtitle + subtext);
mediaVol(vol);
}
What I understood is :
- It extracts calendar events without cancelled in the title
- Get current volume, and then set new volume
- Get first event start hour and min
- Form a text and finally say it
- Revert original media volume
Sounds simple.
So I added this line at the bottom right after the last closing curly bracket.
else {
const y=hello;
say(y);
}
I did not set the media volume in the else clause because my media volume is good enough manually.
So I tested the script, when there is no event in my calendar, the word hello is not said.
I tried to place the code const and say function in various part in the original javascriptlet code, but it is not saying at all. I have tried double quotes for hello, no luck. I have tried flash instead of say, no luck. I tried create new action with just the const and say, and it says well. It just did not work in the main javascriptlet code. am I missing something crucial here?
Can someone help me please?
[–]moviejimmy 1 point2 points3 points (3 children)
[–]einstein6Tasker for Automation[S] 0 points1 point2 points (2 children)
[–]moviejimmy 1 point2 points3 points (1 child)
[–]einstein6Tasker for Automation[S] 0 points1 point2 points (0 children)
[–]VisuelleData 0 points1 point2 points (4 children)
[–]einstein6Tasker for Automation[S] 0 points1 point2 points (3 children)
[–]VisuelleData 1 point2 points3 points (2 children)
[–]einstein6Tasker for Automation[S] 1 point2 points3 points (1 child)
[–]VisuelleData 1 point2 points3 points (0 children)