get-hierarchy.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Organization Chart Plugin</title>
  6. <link rel="icon" href="img/logo.png">
  7. <link rel="stylesheet" href="css/font-awesome.min.css">
  8. <link rel="stylesheet" href="css/jquery.orgchart.css">
  9. <link rel="stylesheet" href="css/style.css">
  10. <style type="text/css">
  11. #chart-container {
  12. display: inline-block;
  13. width: 50%;
  14. margin-left: 10px;
  15. }
  16. pre {
  17. display: inline-block;
  18. vertical-align: top;
  19. font-size: 16px;
  20. font-weight: bold;
  21. margin-left: 20px;
  22. }
  23. .home-link {
  24. position: absolute;
  25. bottom: 20px;
  26. right: 20px;
  27. display: block;
  28. width: 100%;
  29. text-align: right;
  30. }
  31. #btn-export-hier {
  32. display: inline-block;
  33. position: relative;
  34. top: -200px;
  35. left: 10px;
  36. padding: 6px 12px;
  37. margin-bottom: 0;
  38. font-size: 14px;
  39. font-weight: bold;
  40. line-height: 1.42857143;
  41. text-align: center;
  42. white-space: nowrap;
  43. vertical-align: middle;
  44. -ms-touch-action: manipulation;
  45. touch-action: manipulation;
  46. cursor: pointer;
  47. -webkit-user-select: none;
  48. -moz-user-select: none;
  49. -ms-user-select: none;
  50. user-select: none;
  51. color: #fff;
  52. background-color: #5cb85c;
  53. border: 1px solid transparent;
  54. border-color: #4cae4c;
  55. border-radius: 4px;
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <ul id="ul-data" style="display: none;">
  61. <li data-id="n1">Lao Lao
  62. <ul>
  63. <li data-id="n2">Bo Miao</li>
  64. <li data-id="n3">Su Miao
  65. <ul>
  66. <li data-id="n4">Tie Hua</li>
  67. <li data-id="n5">Hei Hei
  68. <ul>
  69. <li data-id="n6">Pang Pang</li>
  70. <li data-id="n7">Xiang Xiang</li>
  71. </ul>
  72. </li>
  73. </ul>
  74. </li>
  75. </ul>
  76. </li>
  77. </ul>
  78. <div id="chart-container"></div>
  79. <button id="btn-export-hier">Export Hierarchy</button>
  80. <script type="text/javascript" src="js/jquery.min.js"></script>
  81. <script type="text/javascript" src="js/jquery.orgchart.js"></script>
  82. <script type="text/javascript">
  83. $(function() {
  84. var oc = $('#chart-container').orgchart({
  85. 'data' : $('#ul-data')
  86. });
  87. $('#btn-export-hier').on('click', function() {
  88. if (!$('pre').length) {
  89. var hierarchy = oc.getHierarchy();
  90. $('#btn-export-hier').after('<pre>').next().append(JSON.stringify(hierarchy, null, 2));
  91. }
  92. });
  93. });
  94. </script>
  95. </body>
  96. </html>