이것은 jsfiddle 특정 문제입니다. 기능 doIt
의 선언이
doIt = function(){
//redefine function f according to the current text field value
eval("function f(x){ return "+document.getElementById("eingabe").value+";}");
//change the Y attribute of the graph to the new function
graph.Y = function(x){ return f(x); };
//update the graph
graph.updateCurve();
//update the whole board
board.update();
};
대신
function doIt() {
...
}
로 변경되는 경우의 예를 실행합니다.
그러나 나를 JSXGraph 대신 자바 스크립트 구문의 일반적인 수학 구문의 입력을 할 수 있습니다 그 자체 파서 JessieCode (https://github.com/jsxgraph/JessieCode 참조)와 함께 제공하는 한편을 강조 할 수 있습니다. 즉 Math.sin(x)
대신에 sin(x)
을 입력하면됩니다. 또한 전원 연산자 ^
이 있습니다. 즉 Math.pow(x,2)
대신 x^2
을 입력 할 수 있습니다.
함수 플로팅 JessieCode를 사용하여 최소한의 예는 다음과 같이 참조 보이는 https://jsfiddle.net/eLs83cs6/
board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 12, 8, -6], axis: true});
doPlot = function() {
var txtraw = document.getElementById('input').value, // Read user input
f = board.jc.snippet(txtraw, true, 'x', true), // Parse input with JessieCode
curve;
board.removeObject('f'); // Remove element with name f
curve = board.create('functiongraph', [f, -10, 10], {name:'f'});
};
doPlot();
앤 추가적인 부작용 JessieCode와 수학 구문 분석이 쉽게 될 XSS 공격을 방지한다는 것이다 사용자가 임의의 JavaScript 코드를 입력으로 제공 할 수있는 경우 가능합니다.