Fossil SCM
Add ID attribute to subdirectory lists.
Commit
24fa1e680288cfaa07b9950e0db792ab23a54927
Parent
434e4538bc95f42…
1 file changed
+13
-11
+13
-11
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -418,10 +418,11 @@ | ||
| 418 | 418 | FileTreeNode *p; /* One line of the tree */ |
| 419 | 419 | FileTree sTree; /* The complete tree of files */ |
| 420 | 420 | HQuery sURI; /* Hyperlink */ |
| 421 | 421 | int startExpanded; /* True to start out with the tree expanded */ |
| 422 | 422 | int showDirOnly; /* Show directories only. Omit files */ |
| 423 | + int nDir = 0; /* Number of directories. Used for ID attributes */ | |
| 423 | 424 | char *zProjectName = db_get("project-name", 0); |
| 424 | 425 | |
| 425 | 426 | if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; } |
| 426 | 427 | memset(&sTree, 0, sizeof(sTree)); |
| 427 | 428 | login_check_credentials(); |
| @@ -602,23 +603,24 @@ | ||
| 602 | 603 | }else{ |
| 603 | 604 | @ <li class="dir subdir"> |
| 604 | 605 | } |
| 605 | 606 | @ %z(href("%s",url_render(&sURI,"name",0,0,0)))%h(zProjectName)</a> |
| 606 | 607 | @ <ul> |
| 607 | - for(p=sTree.pFirst; p; p=p->pNext){ | |
| 608 | + for(p=sTree.pFirst, nDir=0; p; p=p->pNext){ | |
| 608 | 609 | if( p->isDir ){ |
| 609 | 610 | if( p->nFullName==nD-1 ){ |
| 610 | 611 | @ <li class="dir subdir"> |
| 611 | 612 | }else{ |
| 612 | 613 | @ <li class="dir"> |
| 613 | 614 | } |
| 614 | 615 | @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a> |
| 615 | 616 | if( startExpanded || p->nFullName<=nD ){ |
| 616 | - @ <ul> | |
| 617 | + @ <ul id="dir%d(nDir)"> | |
| 617 | 618 | }else{ |
| 618 | - @ <ul style='display:none;'> | |
| 619 | + @ <ul id="dir%d(nDir)" style='display:none;'> | |
| 619 | 620 | } |
| 621 | + nDir++; | |
| 620 | 622 | }else if( !showDirOnly ){ |
| 621 | 623 | char *zLink; |
| 622 | 624 | if( zCI ){ |
| 623 | 625 | zLink = href("%R/artifact/%S",p->zUuid); |
| 624 | 626 | }else{ |
| @@ -639,20 +641,16 @@ | ||
| 639 | 641 | @ function isExpanded(ul){ |
| 640 | 642 | @ var display = window.getComputedStyle(ul).getPropertyValue('display'); |
| 641 | 643 | @ return display!='none'; |
| 642 | 644 | @ } |
| 643 | 645 | @ |
| 644 | - @ function toggleDir(a, useInitValue){ | |
| 645 | - @ var ul = a.nextSibling; | |
| 646 | - @ while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling; | |
| 647 | - @ if( !ul ) return false; /* This is a file link, not a directory */ | |
| 646 | + @ function toggleDir(ul, useInitValue){ | |
| 648 | 647 | @ if( !useInitValue ){ |
| 649 | - @ expandMap[a.id] = !isExpanded(ul); | |
| 648 | + @ expandMap[ul.id] = !isExpanded(ul); | |
| 650 | 649 | @ history.replaceState(expandMap, ''); |
| 651 | 650 | @ } |
| 652 | - @ ul.style.display = expandMap[a.id] ? 'block' : 'none'; | |
| 653 | - @ return true; | |
| 651 | + @ ul.style.display = expandMap[ul.id] ? 'block' : 'none'; | |
| 654 | 652 | @ } |
| 655 | 653 | @ |
| 656 | 654 | @ function toggleAll(tree, useInitValue){ |
| 657 | 655 | @ var lists = tree.querySelectorAll('.subdir > ul > li ul'); |
| 658 | 656 | @ if( !useInitValue ){ |
| @@ -692,11 +690,15 @@ | ||
| 692 | 690 | @ if( a.parentNode==subdir ){ |
| 693 | 691 | @ toggleAll(outer_ul); |
| 694 | 692 | @ return false; |
| 695 | 693 | @ } |
| 696 | 694 | @ if( !subdir.contains(a) ) return true; |
| 697 | - @ return !toggleDir(a); | |
| 695 | + @ var ul = a.nextSibling; | |
| 696 | + @ while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling; | |
| 697 | + @ if( !ul ) return true; /* This is a file link, not a directory */ | |
| 698 | + @ toggleDir(ul); | |
| 699 | + @ return false; | |
| 698 | 700 | @ } |
| 699 | 701 | @ }())</script> |
| 700 | 702 | style_footer(); |
| 701 | 703 | |
| 702 | 704 | /* We could free memory used by sTree here if we needed to. But |
| 703 | 705 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -418,10 +418,11 @@ | |
| 418 | FileTreeNode *p; /* One line of the tree */ |
| 419 | FileTree sTree; /* The complete tree of files */ |
| 420 | HQuery sURI; /* Hyperlink */ |
| 421 | int startExpanded; /* True to start out with the tree expanded */ |
| 422 | int showDirOnly; /* Show directories only. Omit files */ |
| 423 | char *zProjectName = db_get("project-name", 0); |
| 424 | |
| 425 | if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; } |
| 426 | memset(&sTree, 0, sizeof(sTree)); |
| 427 | login_check_credentials(); |
| @@ -602,23 +603,24 @@ | |
| 602 | }else{ |
| 603 | @ <li class="dir subdir"> |
| 604 | } |
| 605 | @ %z(href("%s",url_render(&sURI,"name",0,0,0)))%h(zProjectName)</a> |
| 606 | @ <ul> |
| 607 | for(p=sTree.pFirst; p; p=p->pNext){ |
| 608 | if( p->isDir ){ |
| 609 | if( p->nFullName==nD-1 ){ |
| 610 | @ <li class="dir subdir"> |
| 611 | }else{ |
| 612 | @ <li class="dir"> |
| 613 | } |
| 614 | @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a> |
| 615 | if( startExpanded || p->nFullName<=nD ){ |
| 616 | @ <ul> |
| 617 | }else{ |
| 618 | @ <ul style='display:none;'> |
| 619 | } |
| 620 | }else if( !showDirOnly ){ |
| 621 | char *zLink; |
| 622 | if( zCI ){ |
| 623 | zLink = href("%R/artifact/%S",p->zUuid); |
| 624 | }else{ |
| @@ -639,20 +641,16 @@ | |
| 639 | @ function isExpanded(ul){ |
| 640 | @ var display = window.getComputedStyle(ul).getPropertyValue('display'); |
| 641 | @ return display!='none'; |
| 642 | @ } |
| 643 | @ |
| 644 | @ function toggleDir(a, useInitValue){ |
| 645 | @ var ul = a.nextSibling; |
| 646 | @ while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling; |
| 647 | @ if( !ul ) return false; /* This is a file link, not a directory */ |
| 648 | @ if( !useInitValue ){ |
| 649 | @ expandMap[a.id] = !isExpanded(ul); |
| 650 | @ history.replaceState(expandMap, ''); |
| 651 | @ } |
| 652 | @ ul.style.display = expandMap[a.id] ? 'block' : 'none'; |
| 653 | @ return true; |
| 654 | @ } |
| 655 | @ |
| 656 | @ function toggleAll(tree, useInitValue){ |
| 657 | @ var lists = tree.querySelectorAll('.subdir > ul > li ul'); |
| 658 | @ if( !useInitValue ){ |
| @@ -692,11 +690,15 @@ | |
| 692 | @ if( a.parentNode==subdir ){ |
| 693 | @ toggleAll(outer_ul); |
| 694 | @ return false; |
| 695 | @ } |
| 696 | @ if( !subdir.contains(a) ) return true; |
| 697 | @ return !toggleDir(a); |
| 698 | @ } |
| 699 | @ }())</script> |
| 700 | style_footer(); |
| 701 | |
| 702 | /* We could free memory used by sTree here if we needed to. But |
| 703 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -418,10 +418,11 @@ | |
| 418 | FileTreeNode *p; /* One line of the tree */ |
| 419 | FileTree sTree; /* The complete tree of files */ |
| 420 | HQuery sURI; /* Hyperlink */ |
| 421 | int startExpanded; /* True to start out with the tree expanded */ |
| 422 | int showDirOnly; /* Show directories only. Omit files */ |
| 423 | int nDir = 0; /* Number of directories. Used for ID attributes */ |
| 424 | char *zProjectName = db_get("project-name", 0); |
| 425 | |
| 426 | if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; } |
| 427 | memset(&sTree, 0, sizeof(sTree)); |
| 428 | login_check_credentials(); |
| @@ -602,23 +603,24 @@ | |
| 603 | }else{ |
| 604 | @ <li class="dir subdir"> |
| 605 | } |
| 606 | @ %z(href("%s",url_render(&sURI,"name",0,0,0)))%h(zProjectName)</a> |
| 607 | @ <ul> |
| 608 | for(p=sTree.pFirst, nDir=0; p; p=p->pNext){ |
| 609 | if( p->isDir ){ |
| 610 | if( p->nFullName==nD-1 ){ |
| 611 | @ <li class="dir subdir"> |
| 612 | }else{ |
| 613 | @ <li class="dir"> |
| 614 | } |
| 615 | @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a> |
| 616 | if( startExpanded || p->nFullName<=nD ){ |
| 617 | @ <ul id="dir%d(nDir)"> |
| 618 | }else{ |
| 619 | @ <ul id="dir%d(nDir)" style='display:none;'> |
| 620 | } |
| 621 | nDir++; |
| 622 | }else if( !showDirOnly ){ |
| 623 | char *zLink; |
| 624 | if( zCI ){ |
| 625 | zLink = href("%R/artifact/%S",p->zUuid); |
| 626 | }else{ |
| @@ -639,20 +641,16 @@ | |
| 641 | @ function isExpanded(ul){ |
| 642 | @ var display = window.getComputedStyle(ul).getPropertyValue('display'); |
| 643 | @ return display!='none'; |
| 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){ |
| 655 | @ var lists = tree.querySelectorAll('.subdir > ul > li ul'); |
| 656 | @ if( !useInitValue ){ |
| @@ -692,11 +690,15 @@ | |
| 690 | @ if( a.parentNode==subdir ){ |
| 691 | @ toggleAll(outer_ul); |
| 692 | @ return false; |
| 693 | @ } |
| 694 | @ if( !subdir.contains(a) ) return true; |
| 695 | @ var ul = a.nextSibling; |
| 696 | @ while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling; |
| 697 | @ if( !ul ) return true; /* This is a file link, not a directory */ |
| 698 | @ toggleDir(ul); |
| 699 | @ return false; |
| 700 | @ } |
| 701 | @ }())</script> |
| 702 | style_footer(); |
| 703 | |
| 704 | /* We could free memory used by sTree here if we needed to. But |
| 705 |