@@ -375,16 +375,24 @@ function PlaygroundOutput(el) {
375
375
. join ( '/' ) ;
376
376
}
377
377
378
- var pushedPlay = window . location . pathname == '/play' ;
378
+ var pushedPlay = window . location . pathname == '/play/ ' ;
379
379
function inputChanged ( ) {
380
380
if ( pushedPlay ) {
381
381
return ;
382
382
}
383
383
pushedPlay = true ;
384
384
$ ( opts . shareURLEl ) . hide ( ) ;
385
+ $ ( opts . toysEl ) . show ( ) ;
385
386
var path = window . location . pathname ;
386
- var i = path . indexOf ( '/play' ) ;
387
- window . history . pushState ( null , '' , path . substr ( 0 , i + 5 ) ) ;
387
+ var i = path . indexOf ( '/play/' ) ;
388
+ var p = path . substr ( 0 , i + 6 ) ;
389
+ if ( opts . versionEl !== null ) {
390
+ var v = $ ( opts . versionEl ) . val ( ) ;
391
+ if ( v != '' ) {
392
+ p += '?v=' + v ;
393
+ }
394
+ }
395
+ window . history . pushState ( null , '' , p ) ;
388
396
}
389
397
function popState ( e ) {
390
398
if ( e === null ) {
@@ -515,8 +523,10 @@ function PlaygroundOutput(el) {
515
523
window . location = opts . shareRedirect + xhr . responseText ;
516
524
}
517
525
var path = '/play/p/' + xhr . responseText ;
526
+ if ( opts . versionEl !== null && $ ( opts . versionEl ) . val ( ) != "" ) {
527
+ path += "?v=" + $ ( opts . versionEl ) . val ( ) ;
528
+ }
518
529
var url = origin ( window . location ) + path ;
519
-
520
530
for ( var i = 0 ; i < shareCallbacks . length ; i ++ ) {
521
531
shareCallbacks [ i ] ( url ) ;
522
532
}
@@ -529,13 +539,11 @@ function PlaygroundOutput(el) {
529
539
. focus ( )
530
540
. select ( ) ;
531
541
532
- if ( opts . toysEl !== null ) {
533
- $ ( opts . toysEl ) . hide ( ) ;
534
- }
542
+ $ ( opts . toysEl ) . hide ( ) ;
535
543
if ( rewriteHistory ) {
536
544
var historyData = { code : sharingData } ;
537
545
window . history . pushState ( historyData , '' , path ) ;
538
- pushedEmpty = false ;
546
+ pushedPlay = false ;
539
547
}
540
548
}
541
549
} ,
@@ -595,15 +603,18 @@ function PlaygroundOutput(el) {
595
603
}
596
604
597
605
if ( opts . versionEl !== null ) {
606
+ var select = $ ( opts . versionEl ) ;
598
607
var v = ( new URL ( window . location ) ) . searchParams . get ( 'v' ) ;
599
608
if ( v !== null && v != "" ) {
600
- var select = $ ( opts . versionEl )
601
609
select . val ( v ) ;
602
610
if ( select . val ( ) != v ) {
603
611
select . append ( $ ( '<option>' , { value : v , text : 'Backend: ' + v } ) ) ;
604
612
select . val ( v ) ;
605
613
}
606
614
}
615
+ if ( opts . enableHistory ) {
616
+ select . bind ( 'change' , inputChanged ) ;
617
+ }
607
618
}
608
619
}
609
620
0 commit comments