Adding get or post variables to a URL

christian.mercat shared this idea 3 years ago
Under Consideration

Hi there, it is cool to have GeoGebra resources that are acting like specific tools such as an ODE integrator, a Taylor polynomial plotter... But actually for every example you want to give, you have to duplicate the figure. It would be much better to have a figure that could read off its initial parameters from the URL variables. I do that for example

here

I just pass the function repeat(20,z=cos(z)+1/(A/3+B+C+(D*exp(i*time/8)/5)/5))in the URL as ?f=... and the program reads off the value. Then one can change it once again and generate the modified URL with a little inconspicuous button.


What do you guys think? Thanks again for your work! Best regards, Christian

Comments (5)

photo
1

Yesss! That's great! That's exactly the idea! Did you just implement that straightaway or was it there all the time?

But I guess putting everything in the URL is a bit too much, what I really need is to add some command on top of an existing resource. Is that possible?

Thanks, best regards, Christian

photo
1

It's been there for a long time ;)


If you want that you'll need to add some Global JavaScript to read the parameters yourself, eg https://www.geogebra.org/m/...

photo
1

Great, of course, I should have thought about it! I had used javascript in GGB long ago, thanks!

function ggbOnInit() {
    const queryString = window.location.search;
    const urlParams = new URLSearchParams(queryString);
    const command = urlParams.get("command");
    alert(command)
    ggbApplet.evalCommand('text = "' + command + '"');
    commands = command.split(";");
    for (var i = 0; i < commands.length; i++) {
        try {
            ggbApplet.evalCommand(commands[i]);
        } catch (e) {
            console.log(e, command);
        }

photo
1

Ok, it works nicely even in activities within a booklet!

https://www.geogebra.org/m/gnquj39f?command=f(x,y)=x*y;A=(-4,1);B=(-4,-1);ZoomIn(-4.5,-3,4.5,3)#material/zw6w9fkj


and of course as a standalone

https://www.geogebra.org/cl...

Thanks heap Michael!!

photo
© 2023 International GeoGebra Institute