|
189 | 189 | overflow-y: auto; |
190 | 190 | } |
191 | 191 |
|
192 | | - |
193 | 192 | </style> |
194 | 193 | <style id="Org_Chart_Layout_Magic"> |
195 | 194 | /* OrgChart CSS Base: Reference https://www.cssscript.com/responsive-hierarchical-organization-chart-pure-css/ */ |
|
2209 | 2208 | let sNotes = getCookie( 'notes' ) || '/config/notes.html'; |
2210 | 2209 | let sMeetingLink = getCookie( 'meetingLink' ) || 'Add YOUR Zoom URL to your OrgChart settings so it will appear here!'; |
2211 | 2210 | let aAllSearchTypes; |
| 2211 | + |
2212 | 2212 | function getAncestors( oPerson ) |
2213 | 2213 | { |
2214 | | - let aAncestors = [oPerson.id]; // include self in ancestry |
| 2214 | + let aAncestors = [ oPerson.id ]; // include self in ancestry |
2215 | 2215 | let oAncestor = oPerson; |
2216 | 2216 | while( oAncestor.manager ) |
2217 | 2217 | { |
|
2228 | 2228 | } |
2229 | 2229 | return aAncestors; |
2230 | 2230 | } |
| 2231 | + |
2231 | 2232 | function mapData( data ) |
2232 | 2233 | { |
2233 | 2234 | for( const chump in data ) |
|
2298 | 2299 | document.getElementById( 'searchText' ).focus(); |
2299 | 2300 |
|
2300 | 2301 |
|
2301 | | - document.body.addEventListener('keydown', function(e) { |
2302 | | - if (e.key === "Escape") { |
| 2302 | + document.body.addEventListener( 'keydown', function( e ) |
| 2303 | + { |
| 2304 | + if( e.key === 'Escape' ) |
| 2305 | + { |
2303 | 2306 | cancelSearch(); |
2304 | 2307 | } |
2305 | | - }); |
| 2308 | + } ); |
2306 | 2309 | } |
2307 | 2310 |
|
2308 | 2311 | function cancelSearch() |
|
2311 | 2314 | document.getElementById( 'searchResults' ).innerHTML = ''; |
2312 | 2315 | document.getElementById( 'searchResults' ).style.display = 'none'; |
2313 | 2316 | document.getElementById( 'searchText' ).focus(); |
2314 | | - loadPerson( sCurrentPersonId); |
| 2317 | + loadPerson( sCurrentPersonId ); |
2315 | 2318 | } |
2316 | 2319 |
|
2317 | 2320 | function getAllSearchTypes() |
|
2320 | 2323 | let aSearchTypes = [ ...oSearchTypesSelect.options ].map( o => o.value ); |
2321 | 2324 | const aSortedSearchTypes = aSearchTypes.sort(); |
2322 | 2325 | aSortedSearchTypes.unshift( 'name' ); // |
2323 | | - return aSortedSearchTypes |
| 2326 | + return aSortedSearchTypes; |
2324 | 2327 | } |
2325 | 2328 |
|
2326 | 2329 | function setCookie( sCookieName, sValue ) |
|
2616 | 2619 | } |
2617 | 2620 | </script> |
2618 | 2621 | <style> |
2619 | | - .searchDistanceUp |
2620 | | - { |
2621 | | - color:blue; |
| 2622 | + .searchDistanceUp { |
| 2623 | + color: blue; |
2622 | 2624 | } |
2623 | | - .searchDistanceDown |
2624 | | - { |
2625 | | - color:green; |
| 2625 | + |
| 2626 | + .searchDistanceDown { |
| 2627 | + color: green; |
2626 | 2628 | } |
2627 | | - .searchCommonAncestor |
2628 | | - { |
| 2629 | + |
| 2630 | + .searchCommonAncestor { |
2629 | 2631 | color: black; |
2630 | 2632 | font-weight: normal; |
2631 | 2633 | font-style: italic; |
2632 | 2634 | } |
2633 | | - .searchDistance |
2634 | | - { |
| 2635 | + |
| 2636 | + .searchDistance { |
2635 | 2637 | font-size: 80%; |
2636 | 2638 | } |
| 2639 | + |
2637 | 2640 | .searchDistanceUpIcon, |
2638 | | - .searchDistanceDownIcon |
2639 | | - { |
| 2641 | + .searchDistanceDownIcon { |
2640 | 2642 | font-size: 120%; |
2641 | 2643 | font-weight: bold; |
2642 | 2644 | } |
2643 | | - .defaultTopAncestor |
2644 | | - { |
| 2645 | + |
| 2646 | + .defaultTopAncestor { |
2645 | 2647 | color: gray; |
2646 | 2648 | } |
2647 | 2649 | </style> |
|
2661 | 2663 | <strong>${ getFullName( person.id ) }</strong> |
2662 | 2664 |
|
2663 | 2665 | <span class="searchDistance"> |
2664 | | - <span class="searchDistanceUp">${ person.lastMatchUp }</span><span class="searchDistanceUpIcon">↑</span> |
2665 | | - <span class="searchCommonAncestor">${ person.lastMatchCommonAncestor ? person.lastMatchCommonAncestor : '' }</span> |
2666 | | - <span class="searchCommonAncestor">${ !person.lastMatchCommonAncestor ? '<span class="defaultTopAncestor">' + sDefaultPersonId + '</span>' : '' }</span> |
2667 | | - <span class="searchDistanceDown">${ person.lastMatchDown }</span><span class="searchDistanceDownIcon">↓</span> |
| 2666 | + <span class="searchDistanceUp">${ person.lastMatchUp }</span><span class="searchDistanceUpIcon">↑</span> |
| 2667 | + <span class="searchCommonAncestor">${ person.lastMatchCommonAncestor ? person.lastMatchCommonAncestor : '' }</span> |
| 2668 | + <span class="searchCommonAncestor">${ !person.lastMatchCommonAncestor ? '<span class="defaultTopAncestor">' + sDefaultPersonId + '</span>' : '' }</span> |
| 2669 | + <span class="searchDistanceDown">${ person.lastMatchDown }</span><span class="searchDistanceDownIcon">↓</span> |
2668 | 2670 | </span> |
2669 | 2671 |
|
2670 | 2672 | <br/> |
|
3538 | 3540 | break; |
3539 | 3541 | } |
3540 | 3542 | } |
3541 | | - document.getElementById( 'searchResults' ).innerHTML += sSearchResultsHtml |
| 3543 | + document.getElementById( 'searchResults' ).innerHTML += sSearchResultsHtml; |
3542 | 3544 |
|
3543 | 3545 | function sortSearchResultsByDistance( oMatches ) |
3544 | 3546 | { |
3545 | 3547 |
|
3546 | 3548 | let oReferencePerson = data[ sCurrentPersonId ]; |
3547 | 3549 | if( sCurrentPersonId === sDefaultPersonId ) |
3548 | 3550 | { |
3549 | | - oReferencePerson = data[ sMe ] || data[sDefaultPersonId]; |
| 3551 | + oReferencePerson = data[ sMe ] || data[ sDefaultPersonId ]; |
3550 | 3552 | } |
3551 | 3553 |
|
3552 | 3554 | for( let sPersonId in oMatches ) |
3553 | 3555 | { |
3554 | 3556 | const oSearchResultPerson = oMatches[ sPersonId ]; |
3555 | 3557 | findCommonAncestor( oReferencePerson, oSearchResultPerson ); |
3556 | 3558 | } |
3557 | | - let aMatches = sortObjectByProperty( oMatches, "lastMatchDown" ); // the secondary sort goes first |
3558 | | - aMatches = sortArrayOfObjectsByProperty( aMatches, "lastMatchUp" ); // primary property goes second - stable sort to preserve previous order |
| 3559 | + let aMatches = sortObjectByProperty( oMatches, 'lastMatchDown' ); // the secondary sort goes first |
| 3560 | + aMatches = sortArrayOfObjectsByProperty( aMatches, 'lastMatchUp' ); // primary property goes second - stable sort to preserve previous order |
3559 | 3561 | return aMatches; |
3560 | 3562 |
|
3561 | 3563 | function sortObjectByProperty( oObject, sProperty ) |
3562 | 3564 | { |
3563 | | - const aSortedArray = Object.keys( oObject ).map( key => ({ |
| 3565 | + const aSortedArray = Object.keys( oObject ).map( key => ( { |
3564 | 3566 | personId: key, |
3565 | 3567 | ...oObject[ key ] |
3566 | | - })); |
| 3568 | + } ) ); |
3567 | 3569 | aSortedArray.sort( ( a, b ) => a[ sProperty ] - b[ sProperty ] ); |
3568 | 3570 | return aSortedArray; |
3569 | 3571 | } |
|
3581 | 3583 | let aSearchResultPersonAncestors = oSearchResultPerson.ancestors;// || getAncestors( oSearchResultPerson ); |
3582 | 3584 | oSearchResultPerson.lastMatchUp = 99; |
3583 | 3585 | oSearchResultPerson.lastMatchDown = 99; |
3584 | | - oSearchResultPerson.lastMatchDistance = 99 ; |
| 3586 | + oSearchResultPerson.lastMatchDistance = 99; |
3585 | 3587 | oSearchResultPerson.lastMatchCommonAncestor = oReferencePerson.id; |
3586 | 3588 | for( let iStepsUp = 0; iStepsUp < aReferencePersonAncestors.length; iStepsUp++ ) |
3587 | 3589 | { |
|
3590 | 3592 | if( aReferencePersonAncestors[ iStepsUp ] === aSearchResultPersonAncestors[ iStepsDown ] ) |
3591 | 3593 | { |
3592 | 3594 | sCommonAncestorId = aReferencePersonAncestors[ iStepsUp ]; |
3593 | | - oSearchResultPerson.lastMatchUp = iStepsUp +""; |
3594 | | - oSearchResultPerson.lastMatchDown = iStepsDown+""; |
3595 | | - oSearchResultPerson.lastMatchDistance = iStepsDown + iStepsUp +"" ; |
| 3595 | + oSearchResultPerson.lastMatchUp = iStepsUp + ''; |
| 3596 | + oSearchResultPerson.lastMatchDown = iStepsDown + ''; |
| 3597 | + oSearchResultPerson.lastMatchDistance = iStepsDown + iStepsUp + ''; |
3596 | 3598 | oSearchResultPerson.lastMatchCommonAncestor = sCommonAncestorId; |
3597 | 3599 | break; |
3598 | 3600 | } |
|
3711 | 3713 | function exportSearchResults() |
3712 | 3714 | { |
3713 | 3715 | // const aDataFields = [ 'email', 'phone', 'mobile', 'slack', 'skype', 'twitter', 'linkedin', 'github', 'website' ]; |
3714 | | - const aDataFields = [ "name", 'email', "title" ]; |
3715 | | - const sEmailAddresses = getDataElements( oSearchResults, aDataFields, "," ); |
| 3716 | + const aDataFields = [ 'name', 'email', 'title' ]; |
| 3717 | + const sEmailAddresses = getDataElements( oSearchResults, aDataFields, ',' ); |
3716 | 3718 | navigator.clipboard.writeText( sEmailAddresses ); |
3717 | 3719 | } |
3718 | 3720 |
|
|
3749 | 3751 | } |
3750 | 3752 | }, 2000 ); |
3751 | 3753 | } |
| 3754 | + |
3752 | 3755 | return sData; |
3753 | 3756 | } |
3754 | 3757 | </script> |
|
3866 | 3869 | </button> |
3867 | 3870 | </div> |
3868 | 3871 | </div> |
3869 | | - <div id="searchArea" onclick="showSearchResults()"> |
| 3872 | + <div id="searchArea" onclick="showSearchResults()" ondblclick="exportSearchResults()"> |
3870 | 3873 | <form name="SearchForm" class="touchTargets"> |
3871 | 3874 | <label aria-label="State"> |
3872 | 3875 | <select name="type" id="searchType" |
|
3935 | 3938 | </label> |
3936 | 3939 |
|
3937 | 3940 | <button id="AndSearchButton" onclick="andSearch(); return false;" style="visibility: hidden"></button> |
3938 | | - <div id="searchResults" ondblclick="exportSearchResults()"> |
| 3941 | + <div id="searchResults"> |
3939 | 3942 | <div></div> |
3940 | 3943 | </div> |
3941 | 3944 | </form> |
|
0 commit comments