Skip to content
Snippets Groups Projects
Commit a34bb29f authored by Stahl, Merle's avatar Stahl, Merle
Browse files

Code aufgeräumt

parent 3eab582d
No related branches found
No related tags found
1 merge request!29Main
......@@ -125,7 +125,8 @@ var simulation = d3.forceSimulation()
}).strength(0.5))
.force("charge", d3.forceManyBody().strength(0.001))
.force("center", d3.forceCenter(width/2-20, height/2+20))
.force("yscale", d3.forceY().strength(function(d) {
.force("yscale", d3.forceY()
.strength(function(d) {
if (d.group == "Input") {return 300;}
else {return 200;}
}).y(function(d) {return y_scale(d.group)}))
......@@ -154,7 +155,7 @@ 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(check_if_json_changed, 5000)
var intervalId = window.setInterval(check_if_json_changed, 500)
function check_if_json_changed() {
d3.json("json_text.json").then(function(graph) {
newjson_string = JSON.stringify(graph)
......@@ -177,8 +178,7 @@ function update(links, nodes) {
update_links(links);
update_nodes(nodes);
simulation
.nodes(nodes)
simulation.nodes(nodes)
.on("tick", handle_tick);
simulation.force("link")
.links(links);
......@@ -513,7 +513,8 @@ function get_svg_string(svgNode) {
try {
if(!s.cssRules) continue;
} catch(e) {
}
catch(e) {
if(e.name !== 'SecurityError') throw e; // for Firefox
continue;
}
......@@ -524,14 +525,11 @@ function get_svg_string(svgNode) {
extractedCSSText += cssRules[r].cssText;
}
}
return extractedCSSText;
function contains(str,arr) {
return arr.indexOf(str) === -1 ? false : true;
}
}
function append_css(cssText, element) {
......@@ -571,8 +569,6 @@ function svg_string_to_image( svgString, width, height, format, callback ) {
var filesize = Math.round(blob.length/1024) + ' KB';
if (callback) callback(blob, filesize);
});
};
image.src = imgsrc;
}
\ No newline at end of file
......@@ -171,7 +171,7 @@ 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(check_if_json_changed, 5000)
var intervalId = window.setInterval(check_if_json_changed, 500)
function check_if_json_changed() {
d3.json("json_text.json").then(function(graph) {
newjson_string = JSON.stringify(graph)
......@@ -195,8 +195,7 @@ function update(links, nodes) {
update_links(links);
update_nodes(nodes);
simulation
.nodes(nodes)
simulation.nodes(nodes)
.on("tick", handle_tick);
simulation.force("link")
.links(links);
......@@ -298,7 +297,6 @@ function update_marker(color, target) {
* @param {object} node - node
*/
function click_node(node) {
d3.select(this.parentNode).raise();
fix_nodes(node);
if(to_remove){
......@@ -550,7 +548,8 @@ function get_svg_string(svgNode) {
try {
if(!s.cssRules) continue;
} catch(e) {
}
catch(e) {
if(e.name !== 'SecurityError') throw e; // for Firefox
continue;
}
......@@ -561,14 +560,11 @@ function get_svg_string(svgNode) {
extractedCSSText += cssRules[r].cssText;
}
}
return extractedCSSText;
function contains(str,arr) {
return arr.indexOf(str) === -1 ? false : true;
}
}
function append_css(cssText, element) {
......@@ -608,8 +604,6 @@ function svg_string_to_image( svgString, width, height, format, callback ) {
var filesize = Math.round(blob.length/1024) + ' KB';
if (callback) callback(blob, filesize);
});
};
image.src = imgsrc;
}
\ No newline at end of file
......@@ -88,9 +88,7 @@
</head>
<body>
<button id="change_graph" class="display" onclick="display()">Display Timeline</button>
<!-- graph 576-->
<!-- graph -->
<svg class="graph" width="680" height="560"></svg>
<p id="oldjson"></p>
......@@ -103,6 +101,7 @@
<button id="abstract" class="abstract" onclick='display_abstract(true), highlight_button("abstract")'>Abstract</button>
<!-- buttons -->
<button id="change_graph" class="display" onclick="display()">Display Timeline</button>
<button onclick="location.reload()">Reload Graph</button>
<button class="resetZoom" onclick="reset_view()">Reset View</button>
<button class="save" onclick="save_svg()">Save</button>
......@@ -114,9 +113,11 @@
<script src="https://cdn.rawgit.com/eligrey/canvas-toBlob.js/f1a01896135ab378aa5c0118eadd81da55e698d8/canvas-toBlob.js"></script>
<script src="https://cdn.rawgit.com/eligrey/FileSaver.js/e9d941381475b5df8b7d7691013401e171014e89/FileSaver.min.js"></script>
<!-- scripts to convert the content of a file into a hash value -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/md5.js"></script>
<!-- script to switch between default version and timeline version -->
<script type="text/javascript" >
if (window.location.hash=='#default') {
document.getElementById("change_graph").innerHTML = 'Display Timeline';
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment