component-detail.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. session_start();
  3. //Can't come in without logged in
  4. if (!isset($_SESSION['loggedin'])) {
  5. header('Location: pages-signin.html');
  6. exit;
  7. }
  8. ?>
  9. <!doctype html>
  10. <html class="fixed">
  11. <head>
  12. <?php include("bim-support-header.html"); ?>
  13. <script src="./script/js/global.js"></script>
  14. <script>
  15. var isFavorite = false;
  16. var revitVersion = "";
  17. var searchURL = window.location.search;
  18. searchURL = searchURL.substring(1, searchURL.length);
  19. var name = decodeURIComponent(searchURL.split("&")[0].split("=")[1]);
  20. var type = searchURL.split("&")[1].split("=")[1];
  21. var userName = '<?php echo $_SESSION['name']; ?>';
  22. var header = [];
  23. var value = [];
  24. pageHeader = "元件庫";
  25. </script>
  26. </head>
  27. <body>
  28. <canvas id="c"></canvas>
  29. <section class="body">
  30. <!-- start: header -->
  31. <header-menu></header-menu>
  32. <!-- end: header -->
  33. <div class="inner-wrapper">
  34. <!-- start: sidebar -->
  35. <side-bar></side-bar>
  36. <!-- end: sidebar -->
  37. <section role="main" class="content-body">
  38. <header class="page-header">
  39. <h2>{{pageHeader}}</h2>
  40. </header>
  41. <!-- start: page -->
  42. <section class="content-with-menu content-with-menu-has-toolbar media-gallery">
  43. <div class="content-with-menu-container">
  44. <inner-menu>
  45. <template v-slot:inner-upload>
  46. <upload-component></upload-component>
  47. <hr class="separator" />
  48. </template>
  49. <template v-slot:inner-equipment>
  50. <equipment-list></equipment-list>
  51. </template>
  52. </inner-menu>
  53. <div class="inner-body mg-main">
  54. <div class="inner-toolbar">
  55. <ul>
  56. <li class="right">
  57. <a href="#" onclick="window.history.go(-2); return false;"><i class="fa fa-undo"></i> 返回</a>
  58. </li>
  59. <li class="right">
  60. <a href="#" onclick="AddFavorite();"><i id="heart" class="fa fa-heart"></i><span id="favorite"> 加入清單</span></a>
  61. </li>
  62. </ul>
  63. </div>
  64. <div class="row">
  65. <div class="col-md-6" id="content" style="width:500px; position: relative; padding: 0 0 0;">
  66. </div>
  67. <div class="col-md-offset-1 col-md-6">
  68. <section class="panel">
  69. <div class="panel-body" style="padding: 0px;">
  70. <div class="table-responsive">
  71. <table class="table table-bordered mb-none">
  72. <tbody id="table">
  73. </tbody>
  74. </table>
  75. </div>
  76. </div>
  77. </section>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </section>
  83. <!-- end: page -->
  84. </section>
  85. </div>
  86. </section>
  87. <script>
  88. /*Vue */
  89. vm.mount('.body');
  90. </script>
  91. <?php include("bim-support-body.html"); ?>
  92. <script>
  93. $(document).ready(function() {
  94. $.ajax({
  95. url: "./script/php/equipment_group_detail.php",
  96. type: "GET",
  97. data: {
  98. type: type,
  99. object: name,
  100. },
  101. contentType: "application/json",
  102. dataType: "json"
  103. }).done(function(data) {
  104. header = data.header;
  105. value = data.value;
  106. for (var i = 0; i < header.length; i++) {
  107. if (value[i] == null)
  108. value[i] = "";
  109. if (header[i] == "元件版本")
  110. revitVersion = value[i];
  111. $('#table').append("<tr><td>" + data.header[i] + "</td><td>" + data.value[i] + "</td></tr>");
  112. }
  113. }).error(function(error) {
  114. console.log(error.responseText);
  115. });
  116. $.ajax({
  117. url: "./script/php/addFavorite.php",
  118. type: "GET",
  119. data: {
  120. type: type,
  121. object: name,
  122. },
  123. contentType: "application/json",
  124. dataType: "json"
  125. }).done(function(data) {
  126. isFavorite = data;
  127. if (isFavorite) {
  128. $("#heart").css("color", "Tomato");
  129. $("#favorite").html('移出清單');
  130. } else {
  131. $("#heart").css("color", "white");
  132. $("#favorite").html('加入清單');
  133. }
  134. }).error(function(error) {
  135. console.log(error.responseText);
  136. });
  137. });
  138. function AddFavorite() {
  139. var stack_bar_top = {
  140. "dir1": "down",
  141. "dir2": "right",
  142. "push": "top",
  143. "spacing1": 0,
  144. "spacing2": 0
  145. };
  146. if (isFavorite) {
  147. $.ajax({
  148. url: "./script/php/addFavorite.php",
  149. type: "POST",
  150. data: {
  151. DelFavorite: type + "/" + name,
  152. username: userName
  153. }
  154. }).done(function(data) {
  155. var notice = new PNotify({
  156. title: '通知',
  157. text: '移出清單成功!',
  158. type: 'success',
  159. addclass: 'stack-bar-top',
  160. stack: stack_bar_top,
  161. width: "100%"
  162. });
  163. isFavorite = false;
  164. $("#heart").css("color", "white");
  165. $("#favorite").html('加入清單');
  166. }).error(function(error) {
  167. var notice = new PNotify({
  168. title: '通知',
  169. text: '移出清單失敗!',
  170. type: 'error',
  171. addclass: 'stack-bar-top',
  172. stack: stack_bar_top,
  173. width: "100%"
  174. });
  175. console.log(error);
  176. });
  177. } else {
  178. $.ajax({
  179. url: "./script/php/addFavorite.php",
  180. type: "POST",
  181. data: {
  182. AddFavorite: type + "/" + name,
  183. username: userName,
  184. revitVersion: revitVersion
  185. }
  186. }).done(function(data) {
  187. var notice = new PNotify({
  188. title: '通知',
  189. text: '加入清單成功!',
  190. type: 'success',
  191. addclass: 'stack-bar-top',
  192. stack: stack_bar_top,
  193. width: "100%"
  194. });
  195. isFavorite = true;
  196. $("#heart").css("color", "Tomato");
  197. $("#favorite").html('移出清單');
  198. }).error(function() {
  199. var notice = new PNotify({
  200. title: '通知',
  201. text: '加入清單失敗!',
  202. type: 'error',
  203. addclass: 'stack-bar-top',
  204. stack: stack_bar_top,
  205. width: "100%"
  206. });
  207. });
  208. }
  209. }
  210. </script>
  211. <!-- Vendor -->
  212. <script src="script/js/3Dpic-detail.js" type="module" async></script>
  213. </body>
  214. </html>