Minor bug fixes and code formatting, and limit-years style modified a little bit
diff --git a/js/circle-mode.js b/js/circle-mode.js
index d5ecff3..492c6c6 100644
--- a/js/circle-mode.js
+++ b/js/circle-mode.js
@@ -1,52 +1,48 @@
// *********** HERE STARTS circle-mode.js *************
-window.addEventListener("load", initCircleMode);
-
circleMode = false;
function initCircleMode() {
- document.querySelector("#circle-mode").addEventListener('click', function() {
- if(circleMode) {
- circleMode = false;
- document.querySelector("#circle-mode i").innerText = "trip_origin";
+ document.querySelector("#circle-mode").addEventListener('click', function() {
+ if(circleMode) {
+ circleMode = false;
+ document.querySelector("#circle-mode i").innerText = "trip_origin";
- s.graph.nodes().forEach(function(n) {
- n.x = n.originalX;
- n.y = n.originalY;
- n.size = 10;
- });
-
- s.refresh();
-
- }
- else {
- circleMode = true;
- document.querySelector("#circle-mode i").innerText = "shuffle";
-
- s.graph.nodes().forEach(function(n) {
- n.x = n.circleX;
- n.y = n.circleY;
- });
-
- s.refresh();
- }
- });
+ s.graph.nodes().forEach(function(n) {
+ n.x = n.originalX;
+ n.y = n.originalY;
+ n.size = 10;
+ });
+
+ s.refresh();
+ } else {
+ circleMode = true;
+ document.querySelector("#circle-mode i").innerText = "scatter_plot";
+
+ s.graph.nodes().forEach(function(n) {
+ n.x = n.circleX;
+ n.y = n.circleY;
+ });
+
+ s.refresh();
+ }
+ });
}
-function isInRect (x, y, rect) {
- if (x < -10000 || x > 10000) return true;
- if (y < -10000 || y > 10000) return true;
-
- var ans = true;
- var c = crossProd (rect[0], rect[1], x, y);
-
- for(var i=1; i<4; i++) {
- var temp = crossProd (rect[i], rect[(i+1)%4], x, y);
- if (c*temp < 0) ans = false;
- }
- return ans;
+function isInRect(x, y, rect) {
+ if (x < -10000 || x > 10000) return true;
+ if (y < -10000 || y > 10000) return true;
+
+ var ans = true;
+ var c = crossProd (rect[0], rect[1], x, y);
+
+ for(var i = 1; i < 4; i++) {
+ var temp = crossProd (rect[i], rect[(i+1)%4], x, y);
+ if (c*temp < 0) ans = false;
+ }
+ return ans;
}
function crossProd(r1, r2, x, y) {
- return r1[0]*r2[1] + r2[0]*y + x*r1[1] - r1[0]*y - r2[0]*r1[1] - x*r2[1];
-}
\ No newline at end of file
+ return r1[0]*r2[1] + r2[0]*y + x*r1[1] - r1[0]*y - r2[0]*r1[1] - x*r2[1];
+}