@@ -15,6 +15,14 @@ const movingObjProjection1 = document.querySelector('#moving-obj-prj-1');
15
15
const oneClickGoBtn = document . querySelector ( '.obj-manage .objs-oneclick-go' ) ;
16
16
const oneClickResetBtn = document . querySelector ( '.obj-manage .objs-oneclick-reset' ) ;
17
17
const oneClickBtnsSeparator = document . querySelector ( '.obj-manage br' ) ;
18
+ oneClickGoBtn . style . display = 'none' ;
19
+ oneClickResetBtn . style . display = 'none' ;
20
+ oneClickBtnsSeparator . style . display = 'none' ;
21
+
22
+ var prevObjSelect = new Array ( ) ;
23
+ var nextObjSelect = new Array ( ) ;
24
+ // var prevBtnHandlers = too lazy do not want to do it is not needed
25
+ var nextBtnHandlers = new Array ( ) ;
18
26
19
27
var circular1 = new BlockInMotion ( '1' ) ;
20
28
@@ -29,7 +37,8 @@ document.querySelector('.obj-manage .append-objs').addEventListener('click', (e)
29
37
// create nodes
30
38
var clonedInfoContainer = infoContainer1 . cloneNode ( true ) ;
31
39
clonedInfoContainer . id = `info-container-${ CircularsCount } ` ;
32
- clonedInfoContainer . children [ 0 ] . innerText = `Block ${ CircularsCount } ` ;
40
+ clonedInfoContainer . children [ 0 ] . children [ 1 ] . innerText = `Block ${ CircularsCount } ` ;
41
+ clonedInfoContainer . style . display = 'none' ;
33
42
grandContainer . insertBefore ( clonedInfoContainer , container ) ;
34
43
35
44
var clonedMovingObj = movingObj1 . cloneNode ( true ) ;
@@ -54,10 +63,24 @@ document.querySelector('.obj-manage .append-objs').addEventListener('click', (e)
54
63
Circulars . push ( bl ) ;
55
64
56
65
// displays the multi-ball control buttons
57
- oneClickGoBtn . style . display = 'unset' ;
58
- oneClickResetBtn . style . display = 'unset' ;
59
- oneClickBtnsSeparator . style . display = 'unset' ;
60
- window . scrollBy ( 0 , 299 ) ;
66
+ if ( CircularsCount == 2 ) {
67
+ oneClickGoBtn . style . display = '' ;
68
+ oneClickResetBtn . style . display = '' ;
69
+ oneClickBtnsSeparator . style . display = '' ;
70
+ }
71
+ //window.scrollBy(0, 299);
72
+
73
+ // activates the switch-previous-next buttons
74
+ const cc = CircularsCount
75
+ document . querySelector ( `#info-container-${ cc } .switch-obj-prev` ) . addEventListener ( 'click' , ( e ) => {
76
+ document . querySelector ( `#info-container-${ cc } ` ) . style . display = 'none' ;
77
+ document . querySelector ( `#info-container-${ cc - 1 } ` ) . style . display = 'grid' ;
78
+ } ) ;
79
+ nextBtnHandlers . push ( ( e ) => {
80
+ document . querySelector ( `#info-container-${ cc - 1 } ` ) . style . display = 'none' ;
81
+ document . querySelector ( `#info-container-${ cc } ` ) . style . display = 'grid' ;
82
+ } ) ;
83
+ document . querySelector ( `#info-container-${ cc - 1 } .switch-obj-next` ) . addEventListener ( 'click' , nextBtnHandlers [ cc - 2 ] ) ;
61
84
} ) ;
62
85
63
86
document . querySelector ( '.obj-manage .delete-objs' ) . addEventListener ( 'click' , ( e ) => {
@@ -66,19 +89,28 @@ document.querySelector('.obj-manage .delete-objs').addEventListener('click', (e)
66
89
delete Circulars [ Circulars . length - 1 ] ;
67
90
Circulars . pop ( ) ;
68
91
92
+ const infoBox = document . querySelector ( `#info-container-${ CircularsCount } ` ) ;
93
+ const prevInfoBox = document . querySelector ( `#info-container-${ CircularsCount - 1 } ` ) ;
94
+ const amIAtThisPage = infoBox . style . display != 'none' ;
95
+
69
96
// remove nodes
70
- document . querySelector ( `#info-container- ${ CircularsCount } ` ) . remove ( ) ;
97
+ infoBox . remove ( ) ;
71
98
document . querySelector ( `#moving-obj-${ CircularsCount } ` ) . remove ( ) ;
72
99
document . querySelector ( `#moving-obj-trajectory-${ CircularsCount } ` ) . remove ( ) ;
73
- document . querySelector ( `#moving-obj-prj-${ CircularsCount } ` ) . parentNode . remove ( )
100
+ document . querySelector ( `#moving-obj-prj-${ CircularsCount } ` ) . parentNode . remove ( ) ;
101
+
102
+ // unbind the next-button event for the previous one
103
+ document . querySelector ( `#info-container-${ CircularsCount - 1 } .switch-obj-next` ) . removeEventListener ( 'click' , nextBtnHandlers . pop ( ) ) ;
104
+ // if user is now at this page, move to the previous page
105
+ if ( amIAtThisPage ) prevInfoBox . style . display = 'grid' ;
74
106
75
107
if ( -- CircularsCount == 1 ) {
76
108
// hides the multi-ball control buttons
77
109
oneClickGoBtn . style . display = 'none' ;
78
110
oneClickResetBtn . style . display = 'none' ;
79
111
oneClickBtnsSeparator . style . display = 'none' ;
80
112
}
81
- window . scrollBy ( 0 , - 299 ) ;
113
+ // window.scrollBy(0, -299);
82
114
} ) ;
83
115
84
116
document . querySelector ( '.obj-manage .objs-oneclick-go' ) . addEventListener ( 'click' , ( e ) => {
0 commit comments