api-detail.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <?php
  2. include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_right.php");
  3. ?>
  4. <!doctype html>
  5. <html class="fixed sidebar-left-collapsed">
  6. <head>
  7. <!-- jstree CSS -->
  8. <link rel="stylesheet" href="/Common/assets/vendor/jstree/themes/default/style.css" />
  9. <link href="https://vjs.zencdn.net/7.17.0/video-js.css" rel="stylesheet">
  10. <?php include("bim-support-header.html"); ?>
  11. <script src="./script/js/global.js"></script>
  12. <style>
  13. th {
  14. width: 10%;
  15. text-align: center;
  16. }
  17. </style>
  18. <script type="application/javascript">
  19. var i = 0;
  20. var api = [];
  21. var fileName;
  22. var folder;
  23. var software;
  24. var userName = "<?php echo $_SESSION['name'] ?>";
  25. var role = "<?php echo ($groupName); ?>";
  26. var right = <?php echo ($right); ?>;
  27. var webLink;
  28. var source;
  29. var searchURL = window.location.search;
  30. searchURL = searchURL.substring(1, searchURL.length);
  31. object = decodeURIComponent(searchURL.split("&")[0].split("=")[1]);
  32. if (object == 'undefined') {
  33. window.location.href = "./api-list.php";
  34. }
  35. $.ajax({
  36. url: "./script/php/api_group_detail.php",
  37. type: "GET",
  38. async: false,
  39. data: {
  40. object: object,
  41. },
  42. contentType: "application/json",
  43. dataType: "json"
  44. }).done(function(data) {
  45. if (data.APIID == null)
  46. data.APIID = '';
  47. folder = data.software + '/' + data.APIID + data.APIName;
  48. data[1] = data[1] == "Dynamo" ? data.software + " " + data.dynamoVersion : data.software + " " + data.revitVersion;
  49. for (i = 0; i < 6; i++) {
  50. if (data[i] != null)
  51. table.push(data[i]);
  52. else
  53. table.push("空");
  54. }
  55. webLink = data.webLink;
  56. source = data.source;
  57. }).error(function(error) {
  58. console.log(error);
  59. });
  60. $.ajax({
  61. url: "./script/php/update_popularity.php",
  62. type: "GET",
  63. async: false,
  64. data: {
  65. api_id: object,
  66. update_type: "viewTimes",
  67. },
  68. contentType: "application/json",
  69. dataType: "json"
  70. });
  71. pageHeader = "BIM程式庫";
  72. </script>
  73. </head>
  74. <body>
  75. <canvas id="c"></canvas>
  76. <section class="body">
  77. <!-- start: header -->
  78. <header-menu></header-menu>
  79. <!-- end: header -->
  80. <div class="inner-wrapper">
  81. <!-- start: sidebar -->
  82. <side-bar></side-bar>
  83. <!-- end: sidebar -->
  84. <section role="main" class="content-body">
  85. <header class="page-header">
  86. <h2>{{pageHeader}}</h2>
  87. </header>
  88. <!-- start: page -->
  89. <section class="content-with-menu content-with-menu-has-toolbar media-gallery">
  90. <div class="content-with-menu-container">
  91. <inner-menu>
  92. <template v-slot:inner-equipment>
  93. <api-list></api-list>
  94. </template>
  95. </inner-menu>
  96. <div class="inner-body mg-main">
  97. <div class="inner-toolbar">
  98. <ul>
  99. <li class="right">
  100. <a href="#" onclick="window.history.go(-1); return false;"><i class="fa fa-undo"></i> 返回</a>
  101. </li>
  102. </ul>
  103. </div>
  104. <div class="row">
  105. <div class="col-md-8">
  106. <section class="panel">
  107. <div class="panel-body">
  108. <h2 style="color: black;font-weight: bold;">{{table[0]}}</h2>
  109. <br>
  110. <h4 style="color: black;">{{table[2]}}</h2>
  111. <div class="table-responsive">
  112. <table class="table table-bordered mb-none">
  113. <tbody>
  114. <tr>
  115. <th>開發版本</th>
  116. <td>{{table[1]}}</td>
  117. </tr>
  118. <tr>
  119. <th>操作方式</th>
  120. <td>{{table[3]}}</td>
  121. </tr>
  122. <tr>
  123. <th width="5%">開發者</th>
  124. <td id="webLink"></td>
  125. </tr>
  126. <tr>
  127. <th>備註</th>
  128. <td>{{table[5]}}</td>
  129. </tr>
  130. </tbody>
  131. </table>
  132. </div>
  133. </div>
  134. </section>
  135. </div>
  136. <div class="col-md-4">
  137. <section class="panel">
  138. <div class="panel-body">
  139. <img id="thumbnail" style="width:100%;" src="/Common/assets/images/not-found-image.png" alt="成果縮圖">
  140. </div>
  141. </section>
  142. </div>
  143. </div>
  144. <div class="row">
  145. <div class="col-md-5">
  146. <section class="panel">
  147. <div class="panel-body">
  148. <h4 style="color: black;font-weight: bold;">操作影片</h4>
  149. <video style="width:100%;height:320px;" id="my-video" class="video-js" autoplay preload="auto" data-setup="{}">
  150. <source id="video-src" src='/Common/assets/images/not-found-video.mp4'>
  151. </video>
  152. </div>
  153. </section>
  154. </div>
  155. <div class="col-md-7">
  156. <section class="panel">
  157. <div class="panel-body">
  158. <img v-if="table[1].includes('ynamo')" src="/Common/assets/images/dynamo-icon.png" style="height:80px; display: inline-block; vertical-align: top;"></img>
  159. <img v-else-if="table[1].includes('Revit')" src="/Common/assets/images/revit-icon.png" style="height:80px; display: inline-block; vertical-align: top;"></img>
  160. <div class="summary" style="display: inline-block;">
  161. <div class="title"><strong>程式下載</strong></div>
  162. <div class="info" id="apiList">
  163. </div>
  164. </div>
  165. </div>
  166. </section>
  167. <section class="panel">
  168. <div class="panel-body">
  169. <h5 class="text-semibold text-dark text-uppercase">參考檔案下載</h5>
  170. <div id="treeAjaxHTML"></div>
  171. </div>
  172. </section>
  173. <button type="button" class="mb-xs mt-xs mr-xs btn btn-info col-md-offset-11" onclick="window.history.go(-1); return false;">返回</button>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. </section>
  179. <!-- end: page -->
  180. </section>
  181. </div>
  182. </section>
  183. <script>
  184. /*Vue */
  185. vm.mount('.body');
  186. addUserImage(userName.charAt(0),role);
  187. const downloads = ["dll", "dyn", "exe", "msi"];
  188. const videos = ["mp4", "m3u8", "ts", "avi"];
  189. const hidden = ["png"];
  190. if (webLink != null) {
  191. $("#webLink").append("<a href='" + webLink + "' target='_blank'>" + source + "</a>");
  192. } else if (webLink == null) {
  193. $("#webLink").append("<span>" + source + "</span>");
  194. }
  195. $(document).ready(function() {
  196. $("#apiList a").on("click", function() {
  197. $.ajax({
  198. url: "./script/php/update_popularity.php",
  199. type: "GET",
  200. async: false,
  201. data: {
  202. api_id: object,
  203. update_type: "downloadTimes",
  204. },
  205. contentType: "application/json",
  206. dataType: "json"
  207. });
  208. });
  209. $('#treeAjaxHTML').jstree({
  210. 'core': {
  211. 'themes': {
  212. 'responsive': false
  213. },
  214. 'check_callback': true,
  215. 'data': {
  216. 'url': './script/php/getTree.php?folder=' + folder,
  217. }
  218. },
  219. 'types': {
  220. 'default': {
  221. 'icon': 'fa fa-folder'
  222. },
  223. 'file': {
  224. 'icon': 'fa fa-file'
  225. }
  226. },
  227. 'plugins': ['types']
  228. }).on("ready.jstree", function(e, data) {
  229. var jsonNodes = $('#treeAjaxHTML').jstree(true).get_json('#', {
  230. flat: true
  231. });
  232. $.each(jsonNodes, function(i, val) {
  233. var treeNode = document.getElementById($(val).attr('id'));
  234. var nodeText = $(val).attr('text');
  235. var video = videojs("my-video");
  236. let href = $(val).attr('a_attr').href;
  237. let exts = href.split('.');
  238. let ext = exts[exts.length - 1]
  239. if (downloads.includes(ext)) {
  240. $("#apiList").append("<a download href='" + href + "' id='api" + 1 + "'>" + nodeText + "</a><br>");
  241. }
  242. if (ext.toLowerCase().includes('m3u8')) {
  243. video.src({
  244. src: href,
  245. });
  246. }
  247. if (ext.toLowerCase().includes('png')) {
  248. $("#thumbnail").attr("src", href);
  249. }
  250. if (videos.includes(ext.toLowerCase()) || downloads.includes(ext.toLowerCase()) || hidden.includes(ext.toLowerCase())) {
  251. $(treeNode).hide();
  252. }
  253. })
  254. }).on('select_node.jstree', function(event, data) {
  255. data.instance.toggle_node(data.node);
  256. if (data.node.text.includes(".")) {
  257. console.log(data.node);
  258. var link = document.createElement("a");
  259. link.download = data.node.text;
  260. link.href = data.node.a_attr.href;
  261. document.body.appendChild(link);
  262. link.click();
  263. document.body.removeChild(link);
  264. }
  265. });
  266. });
  267. </script>
  268. <script src="/Common/assets/vendor/jstree/jstree.js"></script>
  269. <!-- <script src="assets/javascripts/ui-elements/examples.treeview.js"></script> -->
  270. <?php include("bim-support-body.html"); ?>
  271. <script src="https://vjs.zencdn.net/7.17.0/video.min.js"></script>
  272. </body>
  273. </html>