@@ -5,11 +5,9 @@ function generateRegularUrl(hubUrl, urlPath, repoUrl, branch, compressed, source
55 var url = new URL ( hubUrl ) ;
66
77 url . searchParams . set ( 'repo' , repoUrl ) ;
8-
98 if ( compressed ) {
109 url . searchParams . set ( 'content_provider' , source ) ;
1110 }
12-
1311 if ( urlPath ) {
1412 url . searchParams . set ( 'urlpath' , urlPath ) ;
1513 }
@@ -19,7 +17,6 @@ function generateRegularUrl(hubUrl, urlPath, repoUrl, branch, compressed, source
1917 } else if ( source == "git" ) {
2018 url . searchParams . set ( 'branch' , "main" ) ;
2119 }
22-
2320 if ( ! url . pathname . endsWith ( '/' ) ) {
2421 url . pathname += '/'
2522 }
@@ -35,11 +32,9 @@ function generateCanvasUrl(hubUrl, urlPath, repoUrl, branch, compressed, source)
3532 var nextUrlParams = new URLSearchParams ( ) ;
3633
3734 nextUrlParams . append ( 'repo' , repoUrl ) ;
38-
3935 if ( compressed ) {
40- nextUrlParams . append ( 'content_provider' , source ) ;
36+ nextUrlParams . append ( 'content_provider' , source ) ;
4137 }
42-
4338 if ( urlPath ) {
4439 nextUrlParams . append ( 'urlpath' , urlPath ) ;
4540 }
@@ -71,9 +66,8 @@ function generateBinderUrl(hubUrl, userName, repoName, branch, urlPath,
7166 nextUrlParams . append ( 'repo' , contentRepoUrl ) ;
7267
7368 if ( compressed ) {
74- nextUrlParams . append ( 'content_provider' , source ) ;
69+ nextUrlParams . append ( 'content_provider' , source ) ;
7570 }
76-
7771 if ( urlPath ) {
7872 nextUrlParams . append ( 'urlpath' , urlPath ) ;
7973 }
@@ -132,17 +126,14 @@ function changeTab(div) {
132126 var env_repo = document . getElementById ( "env-repo" ) ;
133127 var id = div . id ;
134128 var form = document . getElementById ( 'linkgenerator' ) ;
135-
136129 clearLinks ( ) ;
137130 if ( id . includes ( "binder" ) ) {
138131 hub . placeholder = "https://mybinder.org" ;
139132 hub . value = "https://mybinder.org" ;
140133 hub_help_text . hidden = true ;
141134 hub . labels [ 0 ] . innerHTML = "BinderHub URL" ;
142-
143135 env_repo_group . style . display = '' ;
144136 env_repo . disabled = false ;
145-
146137 } else {
147138 hub . placeholder = "https://hub.example.com" ;
148139 hub . value = "" ;
@@ -164,37 +155,36 @@ function changeTab(div) {
164155 */
165156function generateCloneDirectoryName ( gitCloneUrl ) {
166157 if ( gitCloneUrl . slice ( - 1 ) == "/" )
167- gitCloneUrl = gitCloneUrl . slice ( 0 , - 1 ) ;
158+ gitCloneUrl = gitCloneUrl . slice ( 0 , - 1 ) ;
168159 var lastPart = gitCloneUrl . split ( '/' ) . slice ( - 1 ) [ 0 ] ;
169160 return lastPart . split ( ':' ) . slice ( - 1 ) [ 0 ] . replace ( / ( \. g i t | \. b u n d l e ) ? / , '' ) ;
170161}
171162
172163function handleSource ( args ) {
173- source = args [ "source" ] ;
174- branch = "" ;
175- compressed = true ;
176- sourceUrl = "" ;
177- if ( source == "git" ) {
178- sourceUrl = args [ "contentRepoUrl" ] ;
179- branch = args [ "contentRepoBranch" ] ;
180- compressed = false ;
181- } else if ( source == "googledrive" ) {
182- sourceUrl = args [ "driveUrl" ] ;
183- } else if ( source == "dropbox" ) {
184- sourceUrl = args [ "dropUrl" ] ;
185- } else if ( source == "generic_web" ) {
186- sourceUrl = args [ "webUrl" ] ;
187- }
188- return {
189- "branch" : branch ,
190- "sourceUrl" : sourceUrl ,
191- "compressed" : compressed
192- }
164+ source = args [ "source" ] ;
165+ branch = "" ;
166+ compressed = true ;
167+ sourceUrl = "" ;
168+ if ( source == "git" ) {
169+ sourceUrl = args [ "contentRepoUrl" ] ;
170+ branch = args [ "contentRepoBranch" ] ;
171+ compressed = false ;
172+ } else if ( source == "googledrive" ) {
173+ sourceUrl = args [ "driveUrl" ] ;
174+ } else if ( source == "dropbox" ) {
175+ sourceUrl = args [ "dropUrl" ] ;
176+ } else if ( source == "generic_web" ) {
177+ sourceUrl = args [ "webUrl" ] ;
178+ }
179+ return {
180+ "branch" : branch ,
181+ "sourceUrl" : sourceUrl ,
182+ "compressed" : compressed
183+ }
193184}
194185
195186function displayLink ( ) {
196187 var form = document . getElementById ( 'linkgenerator' ) ;
197-
198188 form . classList . add ( 'was-validated' ) ;
199189 if ( form . checkValidity ( ) ) {
200190 var hubUrl = document . getElementById ( 'hub' ) . value ;
@@ -209,13 +199,12 @@ function displayLink() {
209199 var appName = form . querySelector ( 'input[name="app"]:checked' ) . value ;
210200 var activeTab = document . querySelector ( ".nav-link.active" ) . id ;
211201 var source = form . querySelector ( 'input[name="source"]:checked' ) . value ;
212-
213202 if ( appName === 'custom' ) {
214203 var urlPath = document . getElementById ( 'urlpath' ) . value ;
215204 } else {
216205 var repoName = generateCloneDirectoryName ( contentRepoUrl ) ;
217206 if ( source !== "git" ) {
218- repoName = ""
207+ repoName = ""
219208 }
220209 var urlPath ;
221210 if ( activeTab === "tab-auth-binder" ) {
@@ -226,12 +215,12 @@ function displayLink() {
226215 }
227216 }
228217 args = {
229- "source" : source ,
230- "contentRepoUrl" : contentRepoUrl ,
231- "contentRepoBranch" : contentRepoBranch ,
232- "driveUrl" : driveUrl ,
233- "dropUrl" : dropUrl ,
234- "webUrl" : webUrl
218+ "source" : source ,
219+ "contentRepoUrl" : contentRepoUrl ,
220+ "contentRepoBranch" : contentRepoBranch ,
221+ "driveUrl" : driveUrl ,
222+ "dropUrl" : dropUrl ,
223+ "webUrl" : webUrl
235224 }
236225 config = handleSource ( args )
237226 if ( activeTab === "tab-auth-default" ) {
@@ -279,13 +268,13 @@ function populateFromQueryString() {
279268}
280269
281270function hideShowByClassName ( cls , hideShow ) {
282- [ ] . forEach . call ( document . querySelectorAll ( cls ) , function ( el ) {
283- el . style . display = hideShow ;
284- setDisabled = ( hideShow == 'none' )
285- $ ( el ) . find ( "input" ) . each ( function ( ) {
286- $ ( this ) . prop ( "disabled" , setDisabled ) ;
271+ [ ] . forEach . call ( document . querySelectorAll ( cls ) , function ( el ) {
272+ el . style . display = hideShow ;
273+ setDisabled = ( hideShow == 'none' )
274+ $ ( el ) . find ( "input" ) . each ( function ( ) {
275+ $ ( this ) . prop ( "disabled" , setDisabled ) ;
276+ } ) ;
287277 } ) ;
288- } ) ;
289278}
290279
291280
@@ -317,7 +306,6 @@ function render() {
317306 var form = document . getElementById ( 'linkgenerator' ) ;
318307 var appName = form . querySelector ( 'input[name="app"]:checked' ) . value ;
319308
320-
321309 if ( appName == 'custom' ) {
322310 document . getElementById ( 'urlpath' ) . disabled = false ;
323311 document . getElementById ( 'filepath' ) . disabled = true ;
@@ -354,7 +342,6 @@ function main() {
354342 ) ;
355343 }
356344 )
357-
358345 document . querySelectorAll ( '#linkgenerator input[type="text"], #linkgenerator input[type="url"]' ) . forEach (
359346 function ( element ) {
360347 element . addEventListener ( 'input' , render ) ;
@@ -373,7 +360,6 @@ function main() {
373360 }
374361 }
375362
376-
377363 // Do an initial render, to make sure our disabled / enabled properties are correctly set
378364 displaySource ( ) ;
379365 render ( ) ;
0 commit comments