• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision8afedfb913f32e536b0cc14526f7f8f518d25e70 (tree)
Time2020-01-26 05:37:06
AuthorCapsia Tech <cmsuser3754@zoho...>
CommiterCapsia Tech

Log Message

Code Decluttering

Change Summary

Incremental Difference

diff -r 2f0a54c31d10 -r 8afedfb913f3 js/dataloader.js
--- a/js/dataloader.js Fri Jan 24 18:07:51 2020 +0100
+++ b/js/dataloader.js Sat Jan 25 21:37:06 2020 +0100
@@ -7,9 +7,8 @@
77 svg_block.style.width = width + "px";
88 svg_block.style.height = height + "px";
99 }
10- var posArr = [[0.08, 0.5],[0.16, 0.5], [0.24, 0.5], [0.32, 0.5], [0.40, 0.5], [0.48, 0.5], [0.56, 0.5]];
1110 sizing();
12- res = initSVG(posArr);
11+ res = initSVG();
1312 function runRes() {
1413 res(window.innerWidth, window.innerHeight);
1514 sizing();
diff -r 2f0a54c31d10 -r 8afedfb913f3 js/dataloader.js~
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/js/dataloader.js~ Sat Jan 25 21:37:06 2020 +0100
@@ -0,0 +1,18 @@
1+window.onload = setSizes;
2+function setSizes() {
3+ function sizing() {
4+ var height = window.innerHeight,
5+ width = window.innerWidth,
6+ svg_block = document.getElementById("svg");
7+ svg_block.style.width = width + "px";
8+ svg_block.style.height = height + "px";
9+ }
10+ var posArr = [[0.08, 0.5],[0.16, 0.5], [0.24, 0.5], [0.32, 0.5], [0.40, 0.5], [0.48, 0.5], [0.56, 0.5]];
11+ sizing();
12+ res = initSVG(posArr);
13+ function runRes() {
14+ res(window.innerWidth, window.innerHeight);
15+ sizing();
16+ }
17+ $(window).resize(runRes);
18+}
diff -r 2f0a54c31d10 -r 8afedfb913f3 js/svg-animator.js
--- a/js/svg-animator.js Fri Jan 24 18:07:51 2020 +0100
+++ b/js/svg-animator.js Sat Jan 25 21:37:06 2020 +0100
@@ -6,46 +6,41 @@
66 Riccardo Riccio
77 Simon Tomsič*/
88
9-function initSVG(posArr) { // Snap.SVG.JS needs to be started on load
9+function initSVG() { // Snap.SVG.JS needs to be started on load
1010 // Starting Snap SVG, basic objects and variables. To change discs positions use posArr.
1111 // Global setup
1212 document.getElementById("overlay").style.visibility = "hidden";
13+ window.nowFull = -1;
1314 var height = window.innerHeight,
1415 width = window.innerWidth,
16+ fontSize = parseFloat(getComputedStyle(document.body).fontSize)*0.6,
17+ dates = [2012, 2015, 2016, 2018, 2019],
18+ posArr = [],
19+
1520 s = Snap("#svg"), // set element to draw in
1621 // Start drawing
22+ dateLine = s.line(0, height/2, width, height/2),
1723 discs = s.group(), // group of all circles
18- nums = s.group(),
19- rect = s.rect(0,0,width,height);
20- if (width/height > 1.05) {
21- var bigCircle = s.circle(0, height/2, height/2);
22- } else {
23- var bigCircle = s.circle(0, width/3, width/3);
24+ nums = s.group();
25+
26+ for (i = 1; i <= dates.length; i++ ) {
27+ posArr.push([0.08*i, 0.5]);
2428 }
29+
2530 function SVGsizes(width, height) {
26- if (width/height > 1.05) {
27- bigCircle.attr({
28- r: height/2,
29- cy: height/2
30- });
31- } else {
32- bigCircle.attr({
33- r: width/3,
34- cy: width/3
35- });
36- }
37- rect.attr({
38- width: width,
39- height: height
31+ dateLine.attr({
32+ x2: width,
33+ y1: height / 2,
34+ y2: height / 2
4035 });
4136 for (i = 0; i < posArr.length; i++) {
42- discs.select("circle:nth-child(" + (i+1) + ")").attr({
37+ discs[i].attr({
4338 cx: width*posArr[i][0],
4439 cy: height*posArr[i][1]
4540 });
46- nums.select("text:nth-child(" + (i+1) + ")").attr({
47- x: (width*posArr[i][0])-7,
48- y: (height*posArr[i][1])+5
41+ nums[i].attr({
42+ x: (width*posArr[i][0])-32,
43+ y: (height*posArr[i][1])+50
4944 });
5045 }
5146 }
@@ -58,62 +53,45 @@
5853 }
5954 //console.log(initSVG.SVGsizes);
6055 // Setting default styles for rectangle and discs
61- rect.attr({
62- fill: " #383c4a",
63- visibility: "hidden",
64- opacity: 0
65- });
66- bigCircle.attr({
67- fill: "#4e9a06",
68- stroke: "#ca64ff",
69- strokeWidth: 20,
70- visibility: "hidden"
71- });
7256 discs.attr({
7357 fill: "#4e9a06",
7458 stroke: "#ca64ff",
7559 strokeWidth: 5
7660 });
61+ dateLine.attr({
62+ stroke: "#333",
63+ strokeWidth: 30
64+ });
7765 nums.attr({
78- pointerEvents: "none"
66+ fontSize: "1.8em",
67+ fontWeight: "bold"
68+// pointerEvents: "none"
7969 });
8070 // Initialize circles
8171 for (i = 0; i < posArr.length; i++) {
8272 discs.add(s.circle(width*posArr[i][0], height*posArr[i][1], 20)); // Create and add circles to discs.
83- nums.add(s.text((width*posArr[i][0])-7, (height*posArr[i][1])+5, addZyro(i)));
84- discs.select("circle:nth-child(" + (i+1) + ")").click( function() {
85-// console.log(this); //Enable this for debug
86- var save = [this.node.attributes.r.nodeValue, this.node.attributes.cx.nodeValue, this.node.attributes.cy.nodeValue],
87- reback = this; // Save elements for later
88-// displayInfo(posArr, save);
89- nums.attr({visibility: "hidden"});
90- this.animate({r: window.innerWidth, cy: (window.innerHeight / 2) , cx: (window.innerWidth / 2), strokeWidth: 50}, 1000); //Move circle
91- setTimeout(function(){ // Wait 1s function
73+ nums.add(s.text((width*posArr[i][0])-32, (height*posArr[i][1])+50, dates[i]));
74+ discs[i].click( function() {
75+ if (window.nowFull == -1) {
76+ for ( i = 0; i < posArr.length; i++ ) {
77+ if (discs[i].id == this.id) {
78+ window.nowFull = i;
79+ }
80+ }
81+ nums.attr({visibility: "hidden"});
9282 discs.attr({visibility: "hidden"}); // Hide discs to prevent ovelay viewing
93- bigCircle.attr({visibility: ""}); // Show big circle
94- rect.attr({visibility: ""}); //Show rectangle
95- rect.animate({opacity: 0.8}, 500); // Animate opacity
96- reback.animate({r: 20, cy: save[2], cx: save[1], strokeWidth: 5}, 1000); //Return circle to original position
97- document.getElementById("overlay").style.visibility = "";
98- }, 1000);
83+ this.attr({visibility: "visible"}); // Hide discs to prevent ovelay viewing
84+ this.animate({r: window.innerWidth, cy: (window.innerHeight / 2) , cx: (window.innerWidth / 2), strokeWidth: 50}, 1000); //Move circle
85+ document.getElementById("overlay").style.visibility = "";
86+ } else {
87+ discs[window.nowFull].animate({r: 20, cy: height*posArr[window.nowFull][1], cx: width*posArr[window.nowFull][0], strokeWidth: 5}, 1000); //Return circle to original position
88+ discs[window.nowFull].attr({visibility: ""});
89+ nums.attr({visibility: ""});
90+ discs.attr({visibility: ""}); // Unhide circles
91+ document.getElementById("overlay").style.visibility = "hidden";
92+ window.nowFull = -1;
93+ }
9994 });
10095 }
101-// Return function on bigCircle (click to return)
102- bigCircle.click(bConClick);
103- rect.click(bConClick);
104- function bConClick() {
105- nums.attr({visibility: ""});
106- discs.attr({visibility: ""}); // Unhide circles
107- bigCircle.attr({visibility: "hidden"}); // Hide big side circle
108- rect.attr({visibility: "hidden", opacity: "0"}); // Hide rectangle and set animation
109- document.getElementById("overlay").style.visibility = "hidden";
110- }
111- function addZyro(num) {
112- if (num < 9) {
113- return "0" + (num+1);
114- } else {
115- return (num+1);
116- }
117- }
11896 return SVGsizes;
11997 }
diff -r 2f0a54c31d10 -r 8afedfb913f3 js/svg-animator.js~
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/js/svg-animator.js~ Sat Jan 25 21:37:06 2020 +0100
@@ -0,0 +1,100 @@
1+// Welcome to SVG Virtual Map Animator by Capsia Tech
2+
3+/* Written by:
4+Desirée Schembri
5+Niccolò Celoro
6+Riccardo Riccio
7+Simon Tomsič*/
8+
9+function initSVG() { // Snap.SVG.JS needs to be started on load
10+// Starting Snap SVG, basic objects and variables. To change discs positions use posArr.
11+// Global setup
12+ document.getElementById("overlay").style.visibility = "hidden";
13+ window.nowFull = -1;
14+ var height = window.innerHeight,
15+ width = window.innerWidth,
16+ fontSize = parseFloat(getComputedStyle(document.body).fontSize)*0.6,
17+ dates = [2012, 2015, 2016, 2018, 2019],
18+ posArr = [],
19+
20+ s = Snap("#svg"), // set element to draw in
21+// Start drawing
22+ dateLine = s.line(0, height/2, width, height/2),
23+ discs = s.group(), // group of all circles
24+ nums = s.group();
25+
26+ for (i = 1; i <= dates.length; i++ ) {
27+ posArr.push([0.08*i, 0.5]);
28+ }
29+
30+ function SVGsizes(width, height) {
31+ dateLine.attr({
32+ x2: width,
33+ y1: height / 2,
34+ y2: height / 2
35+ });
36+ for (i = 0; i < posArr.length; i++) {
37+ discs[i].attr({
38+ cx: width*posArr[i][0],
39+ cy: height*posArr[i][1]
40+ });
41+ nums[i].attr({
42+ x: (width*posArr[i][0])-32,
43+ y: (height*posArr[i][1])+50
44+ });
45+ }
46+ }
47+ function WHforDiscs(width, height) {
48+ if (width/height > 1.05) {
49+ return height/2;
50+ } else {
51+ return width/3;
52+ }
53+ }
54+ //console.log(initSVG.SVGsizes);
55+// Setting default styles for rectangle and discs
56+ discs.attr({
57+ fill: "#4e9a06",
58+ stroke: "#ca64ff",
59+ strokeWidth: 5
60+ });
61+ dateLine.attr({
62+ stroke: "#333",
63+ strokeWidth: 30
64+ });
65+ nums.attr({
66+ fontSize: "1.8em",
67+ fontWeight: "bold"
68+// pointerEvents: "none"
69+ });
70+// Initialize circles
71+ for (i = 0; i < posArr.length; i++) {
72+ discs.add(s.circle(width*posArr[i][0], height*posArr[i][1], 20)); // Create and add circles to discs.
73+ nums.add(s.text((width*posArr[i][0])-32, (height*posArr[i][1])+50, dates[i]));
74+ discs[i].click( function() {
75+ if (window.nowFull == -1) {
76+ for ( i = 0; i < posArr.length; i++ ) {
77+ if (discs[i].id == this.id) {
78+ window.nowFull = i;
79+ }
80+ }
81+ nums.attr({visibility: "hidden"});
82+ discs.attr({visibility: "hidden"}); // Hide discs to prevent ovelay viewing
83+ this.attr({visibility: "visible"}); // Hide discs to prevent ovelay viewing
84+ this.animate({r: window.innerWidth, cy: (window.innerHeight / 2) , cx: (window.innerWidth / 2), strokeWidth: 50}, 1000); //Move circle
85+ rect.attr({visibility: ""}); //Show rectangle
86+ rect.animate({opacity: 0.8}, 500); // Animate opacity
87+ document.getElementById("overlay").style.visibility = "";
88+ } else {
89+ discs[window.nowFull].animate({r: 20, cy: height*posArr[window.nowFull][1], cx: width*posArr[window.nowFull][0], strokeWidth: 5}, 1000); //Return circle to original position
90+ discs[window.nowFull].attr({visibility: ""});
91+ nums.attr({visibility: ""});
92+ discs.attr({visibility: ""}); // Unhide circles
93+ rect.attr({visibility: "hidden", opacity: "0"}); // Hide rectangle and set animation
94+ document.getElementById("overlay").style.visibility = "hidden";
95+ window.nowFull = -1;
96+ }
97+ });
98+ }
99+ return SVGsizes;
100+}