I have two Javascript functions. In my HTML I call the Setup function. I’m trying to call the Draw_Objects function from the Setup function. But every attempt I’ve made to call the Draw Objects function has failed. I hope someone can assist me.
function Setup () {
var URL = 'http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Diagonal_Line.json';
var Rectangle_Object;
var Rectangle_X_Coordinate;
var Rectangle_Y_Coordinate;
var Germanium_Object;
var Germanium_X_Radius;
var Germanium_Y_Radius;
var Germanium_X_Center;
var Germanium_Y_Center;
var Set_Attributes;
Set_Attributes = function Draw_Objects();
fetch(URL)
.then(res => res.json())
.then(data => {
console.log(data);
document.getElementById("Data_Text").value = data.Diagonal_Lines.Diagonal_Line_2.First_X1_Coordinate;
document.getElementById("Data_Text").value = data.Diagonal_Lines.Base_Rectangle.Rectangle_Y_Coordinate;
Rectangle_Object = document.getElementById('Base_Rectangle');
Germanium_Object = document.getElementById('Germanium_Ellipse');
Rectangle_X_Coordinate = JSON.stringify(data.Diagonal_Lines.Base_Rectangle.Rectangle_X_Coordinate);
Rectangle_Y_Coordinate = JSON.stringify(data.Diagonal_Lines.Base_Rectangle.Rectangle_Y_Coordinate);
Germanium_X_Radius = JSON.stringify(data.Diagonal_Lines.Germanium_Ellipse.Germanium_X_Radius);
Germanium_Y_Radius = JSON.stringify(data.Diagonal_Lines.Germanium_Ellipse.Germanium_Y_Radius);
Germanium_X_Center = JSON.stringify(data.Diagonal_Lines.Germanium_Ellipse.Germanium_X_Center);
Germanium_Y_Center = JSON.stringify(data.Diagonal_Lines.Germanium_Ellipse.Germanium_Y_Center);
function Draw_Objects(){}
});
}
function Draw_Objects(){
Rectangle_Object.setAttribute('x', Rectangle_X_Coordinate);
Rectangle_Object.setAttribute('y', Rectangle_Y_Coordinate);
Germanium_Object.setAttribute('rx', Germanium_X_Radius);
Germanium_Object.setAttribute('ry', Germanium_Y_Radius);
Germanium_Object.setAttribute('cx', Germanium_X_Center);
Germanium_Object.setAttribute('cy', Germanium_Y_Center);
Germanium_Object.style = "fill: #d5d5d7; stroke: black; stroke-width: 3;"
document.getElementById("Data_Text").value = "x1 = " + Rectangle_X_Coordinate;
}