HelpMe!!! ¿Cómo usar los guiones globales de javascript?

Rafael shared this question 1 week ago

Necesito poder escribir guiones Javascript en la parte gobal, pero no encuentro como hacerlo. he podido crear botones con javascript al clic y también algunas cosas con javascript al actualizar... pero no consigo como hacer por ejemplo que el programa desde el inicio haga que todas las líneas y puntos sean de un tamaño determinado y color. o cosas por el estilo. se algo de variables funciones, arreglos, y ciclos en Javascript... pero no encuentro el modo de manejarme con la zona de funciones globales.-gracias

Comments (1)


Basically, Global JS is always inside a function. This Global-JS function can be called from JS which is placed somewhere. Either from the JS in onUpdate or onClick in the objects. Or from the so-called "listener calls" from the kernel of GGB itself.

"Listener calls can be established anywhere in the JS-code by specifying the name of the function to be call in global JS on a GGB-specific (non-object related) event. Usually this "listener-calls" are established within the function ggbOnInit(), which is called by the GGB kernel when an applet is started. Listeners are a very powerful concept, it is worth using JS for this.

The documentation is quite sparse and it is recommended to do several experiments before starting a concrete project. You should always have this documentation at hand. The best way to answer questions is to create and adapt experiments and draw conclusions. GGB-5 and GGB-6 has some (small) differences (I don't know which, because I always use GGB-5).

Most objects and their properties can be accessed via the interface "ggbApplet.<interface>(<parameters>)" (see link above). Some properties must be read and written via XML. Cumbersome conversion procedures are required to access GGB lists.

If there are errors in the global JS, no error message appears and the JS is aborted silently. It is therefore recommended to test a JS function within a buttons onClick before it is established in global-JS.

Larger codings should be created outside the GGB internal code-editor and then copied with Ctrl-C and Ctrl-V into the code-editor.

The alert() command is available for testing (nothing more).

JS is useful in very few situations and is overestimated at the beginning. Usually the disadvantages outweigh the benefits.

Many hours of desperation await you. Have fun.


attached a sample with listener

© 2020 International GeoGebra Institute