[USED WORKAROUND] Cinnamon applet JS - calling functions between scripts

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
Drugwash
Level 5
Level 5
Posts: 734
Joined: Fri Jun 07, 2019 6:40 am
Location: Ploieşti, RO
Contact:

[USED WORKAROUND] Cinnamon applet JS - calling functions between scripts

Post by Drugwash »

Hi there. Been wandering around like an egg in a bucket and couldn't find a proper place to ask so here I am. Sorry if it's the wrong place.
What I'm trying to do is improve on a Cinnamon applet, out of curiosity and to keep myself busy. Maybe even learn something in the process.
Never learned JS so this may be extremely simple for somebody familiar with it.

So, the applet consists of a handful of JS scripts defined/included in the main applet.js. I can call functions residing in included scripts from the main script, but for the life of me couldn't find a way to call a function residing in the main script from one of the included scripts.
Actually there is a place - a class? - where this is possible but only because the main script's this - no idea what exactly represents - is being passed as a parameter to that class(?). However other classes that I'd need to be calling main functions from do not take any parameters and it may become complicated if I were to modify them to such extent - and if I knew how.

So far I only added a couple of my own functions in main applet.js, which have to be called from one of the included scripts; one functions works as it's called from the class that receives this as parameter, but the other doesn't since the call resides in a class without parameters.

My question would be: is it possible to make the main this available to the other class in the included script without changing class definitions? Hopefully without circular inclusions or other unwanted techniques?

EDIT: Nevermind, just used the workaround of passing this as parameter to the class in the other file. It works.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Locked

Return to “Scripts & Bash”