Fossil SCM
Better NULL-protection against browsers which don't have "history" API
Commit
02b607a07a5ed13f92d06d5d8425ffb036f71635
Parent
f61958b183db741…
1 file changed
+7
-5
+7
-5
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -644,11 +644,13 @@ | ||
| 644 | 644 | @ } |
| 645 | 645 | @ |
| 646 | 646 | @ function toggleDir(ul, useInitValue){ |
| 647 | 647 | @ if( !useInitValue ){ |
| 648 | 648 | @ expandMap[ul.id] = !isExpanded(ul); |
| 649 | - @ history.replaceState(expandMap, ''); | |
| 649 | + @ if( history && history.replaceState ){ | |
| 650 | + @ history.replaceState(expandMap, ''); | |
| 651 | + @ } | |
| 650 | 652 | @ } |
| 651 | 653 | @ ul.style.display = expandMap[ul.id] ? 'block' : 'none'; |
| 652 | 654 | @ } |
| 653 | 655 | @ |
| 654 | 656 | @ function toggleAll(tree, useInitValue){ |
| @@ -660,28 +662,28 @@ | ||
| 660 | 662 | @ expand = false; /* Any already visible - make them all hidden */ |
| 661 | 663 | @ break; |
| 662 | 664 | @ } |
| 663 | 665 | @ } |
| 664 | 666 | @ expandMap = {'*': expand}; |
| 665 | - @ history.replaceState(expandMap, ''); | |
| 667 | + @ if( history && history.replaceState ){ | |
| 668 | + @ history.replaceState(expandMap, ''); | |
| 669 | + @ } | |
| 666 | 670 | @ } |
| 667 | 671 | @ var display = expandMap['*'] ? 'block' : 'none'; |
| 668 | 672 | @ for( var i=0; lists[i]; i++ ){ |
| 669 | 673 | @ lists[i].style.display = display; |
| 670 | 674 | @ } |
| 671 | 675 | @ } |
| 672 | 676 | @ |
| 673 | 677 | @ function checkState(){ |
| 674 | - @ expandMap = history.state || {}; | |
| 678 | + @ expandMap = (history && history.state) || {}; | |
| 675 | 679 | @ if( expandMap['*'] ) toggleAll(outer_ul, true); |
| 676 | 680 | @ for( var id in expandMap ){ |
| 677 | 681 | @ if( id!=='*' ) toggleDir(gebi(id), true); |
| 678 | 682 | @ } |
| 679 | 683 | @ } |
| 680 | 684 | @ |
| 681 | - @ /* No-op shim for IE9 */ | |
| 682 | - @ if( !history.replaceState ) history.replaceState = function(){}; | |
| 683 | 685 | @ var outer_ul = document.querySelector('.filetree > ul'); |
| 684 | 686 | @ var subdir = outer_ul.querySelector('.subdir'); |
| 685 | 687 | @ var expandMap = {}; |
| 686 | 688 | @ checkState(); |
| 687 | 689 | @ outer_ul.onclick = function(e){ |
| 688 | 690 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -644,11 +644,13 @@ | |
| 644 | @ } |
| 645 | @ |
| 646 | @ function toggleDir(ul, useInitValue){ |
| 647 | @ if( !useInitValue ){ |
| 648 | @ expandMap[ul.id] = !isExpanded(ul); |
| 649 | @ history.replaceState(expandMap, ''); |
| 650 | @ } |
| 651 | @ ul.style.display = expandMap[ul.id] ? 'block' : 'none'; |
| 652 | @ } |
| 653 | @ |
| 654 | @ function toggleAll(tree, useInitValue){ |
| @@ -660,28 +662,28 @@ | |
| 660 | @ expand = false; /* Any already visible - make them all hidden */ |
| 661 | @ break; |
| 662 | @ } |
| 663 | @ } |
| 664 | @ expandMap = {'*': expand}; |
| 665 | @ history.replaceState(expandMap, ''); |
| 666 | @ } |
| 667 | @ var display = expandMap['*'] ? 'block' : 'none'; |
| 668 | @ for( var i=0; lists[i]; i++ ){ |
| 669 | @ lists[i].style.display = display; |
| 670 | @ } |
| 671 | @ } |
| 672 | @ |
| 673 | @ function checkState(){ |
| 674 | @ expandMap = history.state || {}; |
| 675 | @ if( expandMap['*'] ) toggleAll(outer_ul, true); |
| 676 | @ for( var id in expandMap ){ |
| 677 | @ if( id!=='*' ) toggleDir(gebi(id), true); |
| 678 | @ } |
| 679 | @ } |
| 680 | @ |
| 681 | @ /* No-op shim for IE9 */ |
| 682 | @ if( !history.replaceState ) history.replaceState = function(){}; |
| 683 | @ var outer_ul = document.querySelector('.filetree > ul'); |
| 684 | @ var subdir = outer_ul.querySelector('.subdir'); |
| 685 | @ var expandMap = {}; |
| 686 | @ checkState(); |
| 687 | @ outer_ul.onclick = function(e){ |
| 688 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -644,11 +644,13 @@ | |
| 644 | @ } |
| 645 | @ |
| 646 | @ function toggleDir(ul, useInitValue){ |
| 647 | @ if( !useInitValue ){ |
| 648 | @ expandMap[ul.id] = !isExpanded(ul); |
| 649 | @ if( history && history.replaceState ){ |
| 650 | @ history.replaceState(expandMap, ''); |
| 651 | @ } |
| 652 | @ } |
| 653 | @ ul.style.display = expandMap[ul.id] ? 'block' : 'none'; |
| 654 | @ } |
| 655 | @ |
| 656 | @ function toggleAll(tree, useInitValue){ |
| @@ -660,28 +662,28 @@ | |
| 662 | @ expand = false; /* Any already visible - make them all hidden */ |
| 663 | @ break; |
| 664 | @ } |
| 665 | @ } |
| 666 | @ expandMap = {'*': expand}; |
| 667 | @ if( history && history.replaceState ){ |
| 668 | @ history.replaceState(expandMap, ''); |
| 669 | @ } |
| 670 | @ } |
| 671 | @ var display = expandMap['*'] ? 'block' : 'none'; |
| 672 | @ for( var i=0; lists[i]; i++ ){ |
| 673 | @ lists[i].style.display = display; |
| 674 | @ } |
| 675 | @ } |
| 676 | @ |
| 677 | @ function checkState(){ |
| 678 | @ expandMap = (history && history.state) || {}; |
| 679 | @ if( expandMap['*'] ) toggleAll(outer_ul, true); |
| 680 | @ for( var id in expandMap ){ |
| 681 | @ if( id!=='*' ) toggleDir(gebi(id), true); |
| 682 | @ } |
| 683 | @ } |
| 684 | @ |
| 685 | @ var outer_ul = document.querySelector('.filetree > ul'); |
| 686 | @ var subdir = outer_ul.querySelector('.subdir'); |
| 687 | @ var expandMap = {}; |
| 688 | @ checkState(); |
| 689 | @ outer_ul.onclick = function(e){ |
| 690 |