Sindbad~EG File Manager

Current Path : /home/beeson/public_html/WebMathXpert/
Upload File :
Current File : //home/beeson/public_html/WebMathXpert/AdjustToolbar.js

// Function to customize the toolbar based on problem number and graphtype
// graphtype is one of the values in mainchoi.h
// presently the code works with graphtype instead, but that needs to change.

let ORDINARY = 0;					/*  y=f(x) */
let COMPARE_SAME = 1				/* two graphs on the same axes */
let COMPARE_DIFFERENT = 2		/* two graphs on different axes */
let MC_INEQ = 3					/*  y < f(x) or f(x) < y < g(x) */
let MC_SET = 4          /*  arbitrary relation with shaded interior */
let PARAMETRIC = 5
let POLAR_CIRCULAR = 6  /* axes drawn as circles and radial lines */
let POLAR = 7           /* user specifies xmax and ymax */
let POLYROOT=  8        /* graph complex roots of a polynomial */
let ODE = 9             /* graph y' = f(x,y)                   */
                          /* we draw in both directions, and direction
                             fields work.  */
let ODE2 = 10           /* Two odes  y' = f(x,y) and x'= g(x,y)  */
                          /* Drawing is over a parameter interval, one
                             direction only, but direction fields work. */
let ODESYSTEM = 11       /* graphically solve an ode x'=f(t,x,y), y'= g(t,x,y) */
                          /* if t does not occur, mainchoice should be ODE2 instead */
                          /*  direction fields don't work */
let HDE = 12             /*  poly(derivs of y) = f(x,y), linear in highest y-deriv */
                          /*  draws in both directions, direction fields don't work */
let RELATION =  13        /* graph a relation */
let CONTOUR = 14        /* contour_plot */
let COMPLEX_CONTOUR = 15
let COMPAREDERIV = 16
let COMPAREDERIVS = 17
let RIEMANNSUMS = 18
let TRAPEZOIDRULE = 19
let SIMPSONSRULE = 20
let SPACECURVE = 21


function needsPointSlope(graphtype)
{	
	if (graphtype == ORDINARY || graphtype == COMPARE_SAME || graphtype == COMPARE_DIFFERENT)
		return true;
	return false;
}

function needs_circular_aspect(graphtype)
{	if(graphtype == POLAR_CIRCULAR ||  graphtype == MC_SET)
		return true;
	return false;
}

function needsDirectionField(graphtype)
{	if(graphtype == ODE || graphtype == ODE2)  // one or two ODEs that can have a direction field
		return true;
	return false;
}

function customizeToolbar(graphtype) {  // input is supposed to be an integer 
	console.log("in customizeToolbar with graphtype",  graphtype)
	// Logic to remove/hide buttons
	graphtype = Number(graphtype);
	// In case some idiot sends it a non-integer like "35",  change it to 35 and go on.
	if ( needsDirectionField(graphtype) == false){
		var directionFieldButton = document.getElementById('directionField');
		if (directionFieldButton) {
			console.log("directionFieldButton found and will be invisible ");
			directionFieldButton.style.display = 'none';
		}
	}
	if ( needsPointSlope(graphtype) == false){
		var pointSlopeButton = document.getElementById('pointSlopeButton');
		if (pointSlopeButton) {
			pointSlopeButton.style.display = 'none';
		}
	}
	 var commentary = document.getElementById("remarks");
	 if(!commentary)
		{
			// remove the Remarks button as there's no remark to display
			var remarkButton = document.getElementById("remarksButton");
			if (remarkButton){
				remarkButton.style.display = "none";
				// console.log("removed remarksButton");
			}
		}
	if(graphtype == ODE || graphtype == ODE2 || graphtype == HDE || graphtype == ODESYSTEM)
		{
			// don't show the Assumptions, Jumps, and Singularities buttons
			var assumptionsButton = document.getElementById("assumptionsButton");
			var singularitiesButton = document.getElementById("singularitiesButton");
			var jumpsButton = document.getElementById("jumpsButton");
			assumptionsButton.style.display = "none";
			jumpsButton.style.display = "none";
			singularitiesButton.style.display = "none";
			// console.log("removed assumptions, singularities, and jumps buttons");
		}
	if(needs_circular_aspect(graphtype))
		{
			// don't show hzoom, vzoom, or circularAspect buttons.
			var hzoominButton = document.getElementById("horizontalzoomin");
			var vzoominButton = document.getElementById("verticalzoomin");
			var hzoomoutButton = document.getElementById("horizontalzoomout");
			var vzoomoutButton = document.getElementById("verticalzoomout");
			var circularAspectButton = document.getElementById("circularAspectCopy");
			hzoominButton.style.display = "none";
			vzoominButton.style.display = "none";
			hzoomoutButton.style.display = "none";
			vzoomoutButton.style.display = "none";
			circularAspectButton.style.display = "none";
			console.log(circularAspectButton);
		}
}

document.addEventListener('DOMContentLoaded', function() {
	customizeToolbar(graphtypeNumber);  
	 // graphtypeNumber should be available in the document that included this file
});

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists