From 3eab582d37f2c5b20a9b656019b217e788021a0a Mon Sep 17 00:00:00 2001
From: Merle Stahl <merle.stahl@studium.uni-hamburg.de>
Date: Wed, 26 Jan 2022 15:30:46 +0100
Subject: [PATCH] Funktionsnamen angepasst

---
 assets/cn_default.js  | 23 ++++++++++++-----------
 assets/cn_timeline.js | 27 +++++++++++++--------------
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/assets/cn_default.js b/assets/cn_default.js
index 1a0361e..904b5ca 100644
--- a/assets/cn_default.js
+++ b/assets/cn_default.js
@@ -1,7 +1,7 @@
 /**
 * creates a new zoom behavior
 */
-var zoom = d3.zoom().on("zoom", handle_zoom);
+var zoom = d3.zoom().on("zoom", handle_transformation);
 
 /**
 * creates svg object and associated attributes
@@ -48,7 +48,7 @@ var rect = svg.append("rect")
     .attr("height", height)
     .attr("width", width)
     .style("fill", 'white')
-    .on('click', click_rect);
+    .on('click', click_background);
 
 /**
 * creates svg object (legend) with text, circles and arrows
@@ -143,7 +143,7 @@ var g = svg.append("g")
 * loads JSON data and calls the update function
 */
 d3.json("json_text.json").then(success,failure)
-function success(graph){
+function success(graph) {
     update(graph.links, graph.nodes);
 }
 function failure(graph) {
@@ -154,7 +154,8 @@ function failure(graph) {
 * checks at a fixed interval whether the contents of the JSON file have changed 
   and reloads the program if necessary
 */
-var intervalId=window.setInterval(function() {
+var intervalId=window.setInterval(check_if_json_changed, 5000)
+function check_if_json_changed() {
     d3.json("json_text.json").then(function(graph) {
         newjson_string=JSON.stringify(graph) 
         var newjson = CryptoJS.MD5(newjson_string).toString();
@@ -164,7 +165,7 @@ var intervalId=window.setInterval(function() {
             window.location.reload()
         }
     })
-},5000);
+}
 
 /**
 * calls update functions for links and nodes
@@ -213,8 +214,8 @@ function update_nodes(nodes) {
         .append("g")
         .attr("class", "node")
         .call(d3.drag()
-            .on("start", start_drag)
-            .on("drag", dragged)
+            .on("start", start_drag_node)
+            .on("drag", dragged_node)
         );
 
     node.append("circle")
@@ -277,7 +278,7 @@ function click_node(node) {
 /**
 * removes the highlights of the circles and their links
 */
-function click_rect() {
+function click_background() {
     fix_nodes(node);
     d3.selectAll(".circle").style("stroke", "none")
     d3.selectAll(".link")
@@ -389,7 +390,7 @@ function handle_tick() {
 * initializes dragging of the node
 * @param {object} node - node
 */
-function start_drag(node) {
+function start_drag_node(node) {
     d3.select(this).raise();
     if (!d3.event.active) 
         simulation.alphaTarget(0.3).restart()
@@ -402,7 +403,7 @@ function start_drag(node) {
 * applies dragging to the node
 * @param {object} node - node
 */
-function dragged(node) {
+function dragged_node(node) {
     node.fx = d3.event.x;
     node.fy = d3.event.y;
     fix_nodes(node);
@@ -424,7 +425,7 @@ function fix_nodes(this_node) {
 /**
 * applies the transformation (zooming or dragging) to the g element
 */
-function handle_zoom() {
+function handle_transformation() {
     d3.select('g').attr("transform", d3.event.transform);
 }
 
diff --git a/assets/cn_timeline.js b/assets/cn_timeline.js
index f7aa915..ae67d1c 100644
--- a/assets/cn_timeline.js
+++ b/assets/cn_timeline.js
@@ -1,7 +1,7 @@
 /**
 * creates a new zoom behavior
 */
-var zoom = d3.zoom().on("zoom", handle_zoom);
+var zoom = d3.zoom().on("zoom", handle_transformation);
 
 /**
 * creates svg object and associated attributes
@@ -48,7 +48,7 @@ var rect = svg.append("rect")
     .attr("height", height)
     .attr("width", width)
     .style("fill", 'white')
-    .on('click', click_rect);
+    .on('click', click_background);
 
 /**
 * creates svg object (legend) with text, circles and arrows
@@ -171,7 +171,8 @@ function failure(graph) {
 * checks at a fixed interval whether the contents of the JSON file have changed 
   and reloads the program if necessary
 */
-var intervalId=window.setInterval(function() {
+var intervalId=window.setInterval(check_if_json_changed, 5000)
+function check_if_json_changed() {
     d3.json("json_text.json").then(function(graph) {
         newjson_string=JSON.stringify(graph) 
         var newjson = CryptoJS.MD5(newjson_string).toString();
@@ -181,7 +182,7 @@ var intervalId=window.setInterval(function() {
             window.location.reload()
         }
     })
-},5000);
+}
 
 /**
 * calls update functions for links, nodes and x-axis
@@ -190,7 +191,7 @@ var intervalId=window.setInterval(function() {
 * @param {object} links - links
 */
 function update(links, nodes) {
-    updateXAxis(nodes);
+    update_xaxis(nodes);
     update_links(links);
     update_nodes(nodes);
     
@@ -208,7 +209,7 @@ function update(links, nodes) {
 * initializes and shows x-axis
 * @param {object} nodes - nodes
 */
-function updateXAxis(nodes) {
+function update_xaxis(nodes) {
     years = [];
     for (i = 0; i < nodes.length; i++) {
         years.push(parseInt(parseInt(/\d{4}\s*$/.exec(nodes[i]["year"]))));
@@ -249,8 +250,8 @@ function update_nodes(nodes) {
         .append("g")
         .attr("class", "node")
         .call(d3.drag()
-            .on("start", start_drag)
-            .on("drag", dragged)
+            .on("start", start_drag_node)
+            .on("drag", dragged_node)
         );
 
     node.append("circle")
@@ -314,7 +315,7 @@ function click_node(node) {
 /**
 * removes the highlights of the circles and their links
 */
-function click_rect() {
+function click_background() {
     fix_nodes(node);
     d3.selectAll(".circle").style("stroke", "none")
     d3.selectAll(".link")
@@ -426,11 +427,10 @@ function handle_tick() {
 * initializes the dragging of the node
 * @param {object} node - node
 */
-function start_drag(node) {
+function start_drag_node(node) {
     d3.select(this).raise();
     if (!d3.event.active) 
         simulation.alphaTarget(0.3).restart()
-    //node.fx = node.x;
     node.fy = node.y;
     fix_nodes(node);
 }
@@ -439,8 +439,7 @@ function start_drag(node) {
 * applies the dragging to the node
 * @param {object} node - node
 */
-function dragged(node) {
-    //node.fx = d3.event.x;
+function dragged_node(node) {
     node.fy = d3.event.y;
     fix_nodes(node);
 }
@@ -461,7 +460,7 @@ function fix_nodes(this_node) {
 /**
 * applies the transformation (zooming or dragging) to the g element
 */
-function handle_zoom() {
+function handle_transformation() {
     d3.select('g').attr("transform", d3.event.transform);
     var new_xScale = d3.event.transform.rescaleX(xscale)
     gX.call(xAxis.scale(new_xScale));
-- 
GitLab