@@ -91,27 +91,6 @@ function showMessageModal(modalType, message) {
91
91
show ( `${ modalType } -modal` ) ;
92
92
}
93
93
94
- async function getRequest ( url , parameters = { } , loading = true ) {
95
- try {
96
- if ( loading ) {
97
- showLoading ( ) ;
98
- }
99
- let responsePromise = await fetch ( url , { method : 'GET' , headers : parameters } ) ;
100
- if ( ! responsePromise . ok ) {
101
- if ( loading ) {
102
- hideLoading ( ) ;
103
- }
104
- throw new Error ( responsePromise . status ) ;
105
- }
106
- if ( loading ) {
107
- hideLoading ( ) ;
108
- }
109
- return await responsePromise . json ( ) ;
110
- } catch ( error ) {
111
- return error ;
112
- }
113
- }
114
-
115
94
function setFocusTo ( selector ) {
116
95
getElement ( selector ) . focus ( ) ;
117
96
}
@@ -145,7 +124,7 @@ function addInputFieldAfter(selector, attributes) {
145
124
146
125
function addInputFieldBefore ( selector , attributes ) {
147
126
let element = createInput ( attributes ) ;
148
- getElement ( selector ) . after ( element ) ;
127
+ getElement ( selector ) . before ( element ) ;
149
128
}
150
129
151
130
@@ -160,6 +139,15 @@ function cloneInput(selector) {
160
139
element . after ( clone ) ;
161
140
}
162
141
142
+ function cloneElement ( selector ) {
143
+ let element = getElement ( selector ) ;
144
+ let clone = element . cloneNode ( ) ;
145
+ if ( element . id !== undefined ) {
146
+ clone . id = element . id + Date . now ( ) ;
147
+ }
148
+ element . after ( clone ) ;
149
+ }
150
+
163
151
async function postRequest ( url , parameters = { } , loading = true ) {
164
152
try {
165
153
if ( loading ) {
@@ -186,3 +174,24 @@ async function postRequest(url, parameters = {}, loading = true) {
186
174
return error ;
187
175
}
188
176
}
177
+
178
+ async function getRequest ( url , parameters = { } , loading = true ) {
179
+ try {
180
+ if ( loading ) {
181
+ showLoading ( ) ;
182
+ }
183
+ let responsePromise = await fetch ( url , { method : 'GET' , headers : parameters } ) ;
184
+ if ( ! responsePromise . ok ) {
185
+ if ( loading ) {
186
+ hideLoading ( ) ;
187
+ }
188
+ throw new Error ( responsePromise . status ) ;
189
+ }
190
+ if ( loading ) {
191
+ hideLoading ( ) ;
192
+ }
193
+ return await responsePromise . json ( ) ;
194
+ } catch ( error ) {
195
+ return error ;
196
+ }
197
+ }
0 commit comments