@@ -57,6 +57,33 @@ function generateTrueFalseSelect(value)
5757 return returnText ;
5858}
5959
60+ function moveRowUp ( currentRow )
61+ {
62+ let currentRowDiffOne = currentRow - 1 ;
63+ let currentRowItem = moveBlock ( currentRowDiffOne , currentRow ) ;
64+ let moved = moveBlock ( currentRow , currentRowDiffOne ) ;
65+ document . getElementById ( "rowNumber" + currentRowDiffOne ) . outerHTML = moved ;
66+ document . getElementById ( "rowNumber" + currentRow ) . outerHTML = currentRowItem ;
67+ }
68+
69+ function moveRowDown ( currentRow )
70+ {
71+ let currentRowDiffOne = currentRow + 1 ;
72+ let currentRowItem = moveBlock ( currentRowDiffOne , currentRow ) ;
73+ let moved = moveBlock ( currentRow , currentRowDiffOne ) ;
74+ document . getElementById ( "rowNumber" + currentRowDiffOne ) . outerHTML = moved ;
75+ document . getElementById ( "rowNumber" + currentRow ) . outerHTML = currentRowItem ;
76+ }
77+
78+ function hideLastMoveDownButton ( )
79+ {
80+ for ( let i = 1 ; i < countOfWatchList ; i ++ )
81+ {
82+ document . getElementById ( "moveDown" + i ) . style . display = "block" ;
83+ }
84+ document . getElementById ( "moveDown" + countOfWatchList ) . style . display = "none" ;
85+ }
86+
6087function addRowFunction ( )
6188{
6289 countOfWatchList ++ ;
@@ -86,11 +113,13 @@ function addRowFunction()
86113 item = item . replace ( replaceString , "" ) ;
87114 }
88115 }
89- locationInsert = "newRowLocationForWatchList" + countOfClicks ;
90- item += "<div style=\"display: inline-block;\" id=\"" + locationInsert + "\"></div>" ;
116+ let newlocationInsert = "newRowLocationForWatchList" + countOfClicks ;
117+ item += "<div style=\"display: inline-block;\" id=\"" + newlocationInsert + "\"></div>" ;
91118 document . getElementById ( locationInsert ) . outerHTML += item ;
119+ locationInsert = newlocationInsert ;
92120 document . getElementById ( 'numberOfRows' ) . value = countOfWatchList ;
93121 countOfAddedFiles ++ ;
122+ hideLastMoveDownButton ( ) ;
94123}
95124
96125function deleteRowFunction ( currentRow , decreaseCountWatchListNum )
@@ -101,58 +130,61 @@ function deleteRowFunction(currentRow, decreaseCountWatchListNum)
101130 {
102131 return ;
103132 }
104- newValue = document . getElementById ( 'numberOfRows' ) . value ;
105- if ( currentRow < newValue )
133+ if ( currentRow < countOfWatchList )
106134 {
107135 //this wasn't the last folder deleted, update others
108- updateLaterFolders ( currentRow , newValue ) ;
136+ updateLaterFolders ( currentRow , countOfWatchList ) ;
109137 }
110- newValue -- ;
138+ countOfWatchList -- ;
111139 if ( countOfAddedFiles > 0 )
112140 {
113141 countOfAddedFiles -- ;
114- countOfWatchList -- ;
115142 }
116- document . getElementById ( 'numberOfRows' ) . value = newValue ;
143+ document . getElementById ( 'numberOfRows' ) . value = countOfWatchList ;
144+ hideLastMoveDownButton ( ) ;
117145}
118146
119147function updateLaterFolders ( currentRow , newValue )
120148{
121149 for ( var i = currentRow + 1 ; i <= newValue ; i ++ )
122150 {
123- var updateItoIMinusOne = i - 1 ;
124- var elementToUpdate = "rowNumber" + i ;
125- let item = $ ( "#hiddenWatchlistFormBlank" ) . html ( ) ;
126- item = item . replace ( / { { i} } / g, updateItoIMinusOne ) ;
127- let watchListKeyIdFind = "watchListKey" + i ;
128- let previousElementNumIdentifierForKey = document . getElementsByName ( watchListKeyIdFind ) [ 0 ] . value ;
129- item = item . replace ( / { { key} } / g, previousElementNumIdentifierForKey ) ;
130- for ( var j = 0 ; j < numberOfSubRows ; j ++ )
151+ let item = moveBlock ( i , i - 1 ) ;
152+ document . getElementById ( "rowNumber" + i ) . outerHTML = item ;
153+ }
154+ }
155+
156+ function moveBlock ( to , from )
157+ {
158+ let item = $ ( "#hiddenWatchlistFormBlank" ) . html ( ) ;
159+ item = item . replace ( / { { i} } / g, from ) ;
160+ let watchListKeyIdFind = "watchListKey" + to ;
161+ let previousElementNumIdentifierForKey = document . getElementsByName ( watchListKeyIdFind ) [ 0 ] . value ;
162+ item = item . replace ( / { { key} } / g, previousElementNumIdentifierForKey ) ;
163+ for ( var j = 0 ; j < numberOfSubRows ; j ++ )
164+ {
165+ let watchListItemIdFind = "watchListItem" + to + "-" + ( j + 1 ) ;
166+ let previousElementNumIdentifierForItem = document . getElementsByName ( watchListItemIdFind ) [ 0 ] . value ;
167+ let find = "{{" + from + "-" + ( j + 1 ) + "}}" ;
168+ let replaceString = new RegExp ( find , 'g' ) ;
169+
170+ if ( arrayOfKeysNonEnc [ j ] === "type" )
171+ {
172+ item = item . replace ( replaceString , generateTypeSelect ( previousElementNumIdentifierForItem ) ) ;
173+ }
174+ else if ( arrayOfKeysNonEnc [ j ] === "gitType" )
131175 {
132- let watchListItemIdFind = "watchListItem" + i + "-" + ( j + 1 ) ;
133- let previousElementNumIdentifierForItem = document . getElementsByName ( watchListItemIdFind ) [ 0 ] . value ;
134- let find = "{{" + updateItoIMinusOne + "-" + ( j + 1 ) + "}}" ;
135- let replaceString = new RegExp ( find , 'g' ) ;
136-
137- if ( arrayOfKeysNonEnc [ j ] === "type" )
138- {
139- item = item . replace ( replaceString , generateTypeSelect ( previousElementNumIdentifierForItem ) ) ;
140- }
141- else if ( arrayOfKeysNonEnc [ j ] === "gitType" )
142- {
143- item = item . replace ( replaceString , generateGitTypeSelect ( previousElementNumIdentifierForItem ) ) ;
144- }
145- else if ( arrayOfKeysNonEnc [ j ] === "Archive" )
146- {
147- item = item . replace ( replaceString , generateTrueFalseSelect ( previousElementNumIdentifierForItem ) ) ;
148- }
149- else
150- {
151- item = item . replace ( replaceString , previousElementNumIdentifierForItem ) ;
152- }
176+ item = item . replace ( replaceString , generateGitTypeSelect ( previousElementNumIdentifierForItem ) ) ;
177+ }
178+ else if ( arrayOfKeysNonEnc [ j ] === "Archive" )
179+ {
180+ item = item . replace ( replaceString , generateTrueFalseSelect ( previousElementNumIdentifierForItem ) ) ;
181+ }
182+ else
183+ {
184+ item = item . replace ( replaceString , previousElementNumIdentifierForItem ) ;
153185 }
154- document . getElementById ( elementToUpdate ) . outerHTML = item ;
155186 }
187+ return item ;
156188}
157189
158190function testConnection ( currentRowInformation )
@@ -215,4 +247,8 @@ function checkWebsiteStatus(sendUrlHere)
215247 document . getElementById ( "connectionCheckStatusRed" ) . style . display = "inline-block" ;
216248 }
217249 } ) ;
218- }
250+ }
251+
252+ $ ( document ) . ready ( function ( ) {
253+ hideLastMoveDownButton ( ) ;
254+ } ) ;
0 commit comments