jstreeAJAX.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. /*
  2. 0:自動編號 SN項次
  3. 1:類別 圖名
  4. 2:X 關鍵字
  5. 3:X 版次
  6. 4:檔案數 X
  7. 5:計畫編號-計畫名稱 計畫編號
  8. 6:類別ID 計畫名稱
  9. 7:X 類別ID
  10. 8:X 工程類別
  11. 9:X 上一層資料夾
  12. 10:X 檔案路徑
  13. */
  14. $(document).ready(function () {
  15. //const types = ["工程概要", "工程計算書", "設計圖", "數量計算書", "工程預算書", "施工規範&特定條款", "設計報告書"];
  16. var types = [];
  17. var path = '';
  18. var category = '';
  19. var project_id = '';
  20. var project_name = '';
  21. var project = '';
  22. var blueprint_SN = '';
  23. var blueprint_path = '';
  24. var notes = [];
  25. var tempTable = [];
  26. var tempTable2 = [];
  27. var tree_data; //save getTree ajax data
  28. var start = true;
  29. var folderPath = "";
  30. var fileNums = [];
  31. var is_blueprint2 = false;
  32. PDFObject.embed("./assets/null.pdf", "#pdfFile");
  33. addUserImage(userName.charAt(0), role);
  34. var table = $('#datatable-ajax').DataTable({
  35. bProcessing: true,
  36. responsive: true,
  37. "pagingType": "full_numbers",
  38. "bLengthChange": true,
  39. "lengthMenu": [
  40. [7, 10, 25, -1],
  41. [7, 10, 25, "全部"]
  42. ],
  43. "searching": false,
  44. "pageLength": 7,
  45. "language": {
  46. "processing": "處理中...",
  47. "loadingRecords": "載入中...",
  48. "lengthMenu": "顯示 _MENU_ 項結果",
  49. "zeroRecords": "沒有符合的結果或是沒有資料",
  50. "info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
  51. "infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
  52. "infoFiltered": "(從 _MAX_ 項結果中過濾)",
  53. "infoPostFix": "",
  54. "search": "搜尋:",
  55. "paginate": {
  56. "first": '<i class="fa fa-step-backward"></i>',
  57. "previous": '<i class="fa fa-backward"></i>',
  58. "next": '<i class="fa fa-forward"></i>',
  59. "last": '<i class="fa fa-step-forward"></i>'
  60. },
  61. "aria": {
  62. "sortAscending": ": 升冪排列",
  63. "sortDescending": ": 降冪排列"
  64. }
  65. },
  66. "columns": [{
  67. "width": "5%"
  68. },
  69. null,
  70. null,
  71. {
  72. "width": "5%"
  73. }, {
  74. "width": "5%"
  75. },
  76. ],
  77. data: [
  78. [
  79. " ", "", "", "", "",
  80. ],
  81. [
  82. " ", "", "", "", "",
  83. ],
  84. [
  85. " ", "", "", "", "",
  86. ],
  87. [
  88. " ", "", "", "", "",
  89. ],
  90. [
  91. " ", "", "", "", "",
  92. ],
  93. [
  94. " ", "", "", "", "",
  95. ],
  96. [
  97. " ", "", "", "", "",
  98. ]
  99. ],
  100. drawCallback: function () {
  101. if (!start) {
  102. var api = this.api();
  103. var rowCount = api.rows({
  104. page: 'current'
  105. }).count();
  106. /*for (var i = 0; i < api.page.len() - (rowCount === 0 ? 1 : rowCount); i++) {
  107. $('#datatable-ajax tbody').append($("<tr><td>&nbsp;</td><td></td><td></td><td></td></tr>"));
  108. }*/
  109. }
  110. start = false;
  111. },
  112. });
  113. $("#datatable-ajax_length").append($("#reset"))
  114. $.ajax({
  115. url: "./script/php/getTree.php",
  116. contentType: "application/json",
  117. dataType: "json",
  118. type: "GET",
  119. async: false
  120. })
  121. .success(function (response) {
  122. tree_data = response;
  123. }).error(function (error) {
  124. console.log(error);
  125. });
  126. displayDetail(false, true);
  127. $('#treeAjaxHTML').jstree({
  128. 'core': {
  129. 'themes': {
  130. variant: 'large'
  131. },
  132. 'data': tree_data,
  133. 'multiple': false,
  134. 'animation': 40,
  135. 'expand_selected_onload': true
  136. },
  137. 'types': {
  138. 'default': {
  139. 'icon': 'fa fa-folder'
  140. },
  141. 'file': {
  142. 'icon': 'fa fa-file'
  143. }
  144. },
  145. 'plugins': ['types', 'search', 'wholerow']
  146. }).bind("loaded.jstree", function (event, data) {
  147. var url_href = window.location.href;
  148. var url = new URL(url_href);
  149. var projectId = url.searchParams.get("projectId");
  150. if (projectId != null) {
  151. $(this).jstree("open_all");
  152. }
  153. $('.jstree-anchor').each(function () {
  154. $(this).children().css("color",color[$(this).text()]);
  155. })
  156. }).on(
  157. 'select_node.jstree',
  158. function (event, data) {
  159. if (data.node.text.includes("-")) {
  160. $("#reset").prop("disabled", false);
  161. $("#header").empty();
  162. displayDetail(false, true);
  163. project_id = data.node.text.split("-")[0];
  164. project_name = data.node.text.split("-")[1];
  165. project = data.node.text;
  166. $("#project-id").val(project_id)
  167. $("#header").empty();
  168. category = $('#treeAjaxHTML').jstree(true).get_node(data.node.parents[0]).text;
  169. countFiles(project_id, "false");
  170. var span = $('<span>' + project + ' > </span>');
  171. span.on("click", function (e) {
  172. countFiles(project_id, "false");
  173. displayDetail(false, true);
  174. is_blueprint2 = false;
  175. for (var k = folderPath.length - 1; k > 0; k--) {
  176. $("#header").children().eq(k).remove();
  177. folderPath.pop();
  178. }
  179. let i = 1;
  180. table.clear().draw();
  181. tempTable = [];
  182. types.forEach(function (element) {
  183. if (fileNums[i - 1] == null) {
  184. total = 0;
  185. } else {
  186. total = fileNums[i - 1].total;
  187. }
  188. let temp = [
  189. i,
  190. element.type_name,
  191. category,
  192. '',
  193. total,
  194. project,
  195. element.type_id
  196. ];
  197. table.row.add(temp).draw();
  198. tempTable.push(temp);
  199. i++;
  200. });
  201. $("#tableDetail td").empty();
  202. });
  203. $("#header").append(span);
  204. let i = 1;
  205. table.clear().draw();
  206. tempTable = [];
  207. types.forEach(function (element) {
  208. if (fileNums[i - 1] == null) {
  209. total = 0;
  210. } else {
  211. total = fileNums[i - 1].total;
  212. }
  213. let temp = [
  214. i,
  215. element.type_name,
  216. category,
  217. '',
  218. total,
  219. project,
  220. element.type_id
  221. ];
  222. table.row.add(temp).draw();
  223. tempTable.push(temp);
  224. i++;
  225. });
  226. $("#tableDetail td").empty();
  227. } else {
  228. data.instance.toggle_node(data.node);
  229. }
  230. displayDetail(false, true);
  231. });
  232. $('#btn-search').click(function () {
  233. $("#reset").prop("disabled", true);
  234. $("#header").empty();
  235. $("#header").append("<span>搜尋結果</span>");
  236. $.ajax({
  237. url: "./script/php/search.php",
  238. data: {
  239. search: $("#search").val(),
  240. },
  241. async: false,
  242. contentType: "application/json",
  243. dataType: "json",
  244. type: "GET",
  245. })
  246. .success(function (response) {
  247. displayDetail(true, true);
  248. table.clear().draw();
  249. $("#tableDetail td").empty();
  250. response.forEach(function (data) {
  251. let temp = [
  252. data["SN"],
  253. data["original_name"],
  254. data["keyword"],
  255. '1.0.0',
  256. data["project_id"],
  257. data["project_name"],
  258. data["type_id"],
  259. data["category_name"],
  260. data["notes"],
  261. data["filename"],
  262. ];
  263. table.row.add(temp).draw();
  264. i++;
  265. });
  266. })
  267. .error(function (error) {
  268. console.log(error);
  269. })
  270. .complete(function () {});
  271. });
  272. $('#search').keyup(function (e) {
  273. if (e.keyCode == 13) {
  274. $('#btn-search').click();
  275. }
  276. });
  277. $('#reset').click(function () {
  278. if (folderPath.length != 1) {
  279. folderPath.pop();
  280. let index = folderPath.length;
  281. $("#header").children().eq(index).remove();
  282. table.clear().draw();
  283. if (is_blueprint2) {
  284. tempTable2.forEach(function (data) {
  285. table.row.add(data).draw();
  286. });
  287. is_blueprint2 = false;
  288. } else {
  289. tempTable.forEach(function (data) {
  290. table.row.add(data).draw();
  291. });
  292. }
  293. $("#tableDetail td").empty();
  294. displayDetail(false, true);
  295. }
  296. });
  297. $('#datatable-ajax tbody').on('click', 'tr', function () {
  298. $("#reset").prop("disabled", false);
  299. $(this).parent().find("tr").css('background-color', '');
  300. $(this).css("background-color", "#cccccc");
  301. $("#tableDetail td").empty();
  302. var data = table.row(this).data();
  303. console.log(data)
  304. if (data == null) {
  305. data = ["", "", "null", "", "", "", "", "", "", ""];
  306. }
  307. let project_id = data[5].split("-")[0];
  308. let SN = data[6] != null ? data[6] : 0;
  309. let is_blueprint = data[1] == "設計圖" || data[1] == "成果圖" ? true : false;
  310. let note = notes.includes(data[1]) ? data[1] : '';
  311. if (data[2] == 'null') {
  312. $("#tableDetail td").empty();
  313. } else if (data[3] == '') {
  314. path = data[1];
  315. $.ajax({
  316. url: "./script/php/getDetail.php",
  317. data: {
  318. project_id: project_id,
  319. type_id: SN,
  320. is_blueprint: is_blueprint,
  321. note: note
  322. },
  323. async: false,
  324. contentType: "application/json",
  325. dataType: "json",
  326. type: "GET",
  327. })
  328. .success(function (response) {
  329. var span = $('<span>' + data[1] + ' > </span>');
  330. span.on("click", function (e) {
  331. let clicked = $(e.target).text().split(" > ")[0];
  332. let index = folderPath.indexOf(clicked);
  333. for (k = index + 1; k < folderPath.length; k++) {
  334. $("#header").children().eq(k).remove();
  335. folderPath.pop();
  336. }
  337. addTable(data, notes, response, SN, path);
  338. is_blueprint2 = false;
  339. });
  340. $("#header").append(span);
  341. folderPath = $("#header").text().split(" > ");
  342. folderPath.pop();
  343. addTable(data, notes, response, SN, path);
  344. })
  345. .error(function (error) {
  346. console.log(error);
  347. })
  348. .complete(function () {});
  349. } else {
  350. let type = types[parseInt(data[7]) - 1];
  351. let path = '';
  352. //let category = data[8];
  353. path = data[8] + "/" + data[5] + "-" + data[6] + data[10];
  354. $("#plan_code").text(data[5]);
  355. $("#plan_name").text(data[6]);
  356. $("#version").text(data[3]);
  357. $("#fileName").text(data[1]);
  358. if (path.toLowerCase().includes("pdf")) {
  359. PDFObject.embed("./assets/建置資料/" + path, "#pdfFile");
  360. $("#download").append('<img src="./assets/images/' + 'pdf-icon.png" style="height: 30px; display: inline-block;"> ');
  361. } else {
  362. PDFObject.embed("./assets/notPDF.pdf", "#pdfFile");
  363. if (path.toLowerCase().includes("doc")) {
  364. $("#download").append('<img src="./assets/images/' + 'word-icon.png" style="height: 30px; display: inline-block;"> ');
  365. } else if (path.toLowerCase().includes("xls")) {
  366. $("#download").append('<img src="./assets/images/' + 'excel-icon.png" style="height: 30px; display: inline-block;"> ');
  367. }
  368. }
  369. console.log(data[10]);
  370. let fileNames = data[10].split('/');
  371. let fileName = fileNames[fileNames.length - 1];
  372. $("#download").append('<a target="_blank" href="./assets/建置資料/' + path + '">' + fileName + '</a>');
  373. }
  374. });
  375. function displayDetail(isFile, isBlueprint) {
  376. table.column(0).visible(isBlueprint);
  377. table.column(2).visible(isFile);
  378. table.column(3).visible(isFile);
  379. table.column(4).visible(!isFile);
  380. if (isFile) {
  381. $(".table-responsive").show();
  382. $("#SN").text("圖號");
  383. $("#name").text("圖名");
  384. $('.nav-tabs a[href="#pdfTab"]').tab('show');
  385. test = table;
  386. if (table.rows().count() > 10) {
  387. table.page.len(10).draw();
  388. } else {
  389. table.page.len(-1).draw();
  390. }
  391. } else {
  392. $(".table-responsive").hide();
  393. $("#SN").text("項次");
  394. $("#name").text("類別");
  395. if (isBlueprint) {
  396. table.page.len(-1).draw();
  397. } else {
  398. table.page.len(7).draw();
  399. }
  400. $('.nav-tabs a[href="#arcgisTab"]').tab('show');
  401. }
  402. }
  403. function countFiles(project_id, is_blueprint) {
  404. $.ajax({
  405. url: "./script/php/get_file_count.php",
  406. data: {
  407. project_id: project_id,
  408. is_blueprint: is_blueprint,
  409. },
  410. async: false,
  411. //contentType: "application/json",
  412. dataType: "json",
  413. type: "POST",
  414. })
  415. .success(function (response) {
  416. console.log(response);
  417. fileNums = response;
  418. types = [];
  419. response.forEach(function (element) {
  420. types.push({
  421. type_id: element.type_id,
  422. type_name: element.type_name
  423. })
  424. });
  425. })
  426. .error(function (error) {
  427. console.log(error);
  428. })
  429. .complete(function () {});
  430. }
  431. function addTable(data, notes, response, SN, path) {
  432. table.clear().draw();
  433. if (data[1] != "設計圖" && data[1] != "成果圖") {
  434. for (i = 0; i < response.length; i++) {
  435. table.row.add([
  436. response[i]["SN"],
  437. response[i]["original_name"],
  438. response[i]["keyword"],
  439. '1.0.0',
  440. '',
  441. response[i]["project_id"],
  442. response[i]["project_name"],
  443. response[i]["type_id"],
  444. response[i]["category_name"],
  445. response[i]["notes"],
  446. response[i]["filename"],
  447. ])
  448. table.draw();
  449. }
  450. if (notes.includes(data[1])) {
  451. is_blueprint2 = true;
  452. displayDetail(true, true);
  453. } else {
  454. displayDetail(true, false);
  455. }
  456. } else {
  457. displayDetail(false, true);
  458. blueprint_SN = SN;
  459. blueprint_path = path;
  460. tempTable2 = [];
  461. countFiles(project_id, "true");
  462. for (i = 0; i < response.length; i++) {
  463. notes[i] = response[i]['notes'];
  464. if (fileNums[i] == null) {
  465. total = 0;
  466. } else {
  467. total = fileNums[i].total;
  468. }
  469. let temp = [
  470. i + 1,
  471. response[i]['notes'],
  472. '',
  473. '',
  474. total,
  475. data[5],
  476. ];
  477. table.row.add(temp);
  478. tempTable2.push(temp);
  479. }
  480. table.draw();
  481. }
  482. }
  483. var search_output = {};
  484. var search_word = ""
  485. $("#keep-search-button").on("click", function (e) {
  486. show_progress_bar(true);
  487. update_progress_bar();
  488. $.ajax({
  489. url: "./script/php/get_search_list.php",
  490. data: {
  491. project_id: [''].concat(search_data["project"]),
  492. type_id: [''].concat(search_data["type"]),
  493. notes_name: [''].concat(search_data["notes"].filter(element => {
  494. return element !== undefined;
  495. })),
  496. search: $("#search-word").val(),
  497. },
  498. type: "GET",
  499. dataType: "json",
  500. contentType: "application/json",
  501. async: false
  502. }).success(function (response) {
  503. displayDetail(true);
  504. search_output = response;
  505. search_word = $("#search-word").val();
  506. filter_base_data = search_data;
  507. }).error(function (error) {
  508. console.log(error);
  509. });
  510. setTimeout(() => {
  511. draw_datatable(search_output);
  512. e.preventDefault();
  513. $.magnificPopup.close();
  514. if ($("#search-filter").css("display") != "none") {
  515. $("#search-filter").slideUp(200);
  516. $("#filter-slide").toggleClass("fa-sort-desc fa-sort-up");
  517. }
  518. $("#search-filter-panel .btn-default").toggleClass("btn-primary btn-default");
  519. show_filter(filter_base_data);
  520. show_progress_bar(false);
  521. $("#keep-search-button").css("display", "none");
  522. $("#warning-text").css("display", "none");
  523. $("#advanced-search-button").css("display", "inline-block");
  524. $("#search-filter-panel").css("display", "block");
  525. }, 0);
  526. });
  527. $("#advanced-search-button").on("click", function (e) {
  528. count = {};
  529. $.ajax({
  530. url: "./script/php/sql_search_count.php",
  531. data: {
  532. project_id: [''].concat(search_data["project"]),
  533. type_id: [''].concat(search_data["type"]),
  534. notes_name: [''].concat(search_data["notes"].filter(element => {
  535. return element !== undefined;
  536. })),
  537. search: $("#search-word").val(),
  538. },
  539. type: "GET",
  540. dataType: "json",
  541. contentType: "application/json",
  542. async: false
  543. }).success(function (response) {
  544. displayDetail(true);
  545. count = response;
  546. }).error(function (error) {
  547. console.log(error);
  548. });
  549. search_total_count = count[0]["total"] + count[1]["total"];
  550. if (search_total_count > 1000) {
  551. $("#keep-search-button").css("display", "inline-block");
  552. $("#warning-text").css("display", "inline-block");
  553. $("#advanced-search-button").css("display", "none");
  554. } else {
  555. show_progress_bar(true);
  556. update_progress_bar();
  557. $.ajax({
  558. url: "./script/php/get_search_list.php",
  559. data: {
  560. project_id: [''].concat(search_data["project"]),
  561. type_id: [''].concat(search_data["type"]),
  562. notes_name: [''].concat(search_data["notes"].filter(element => {
  563. return element !== undefined;
  564. })),
  565. search: $("#search-word").val(),
  566. },
  567. type: "GET",
  568. dataType: "json",
  569. contentType: "application/json",
  570. async: false
  571. }).success(function (response) {
  572. displayDetail(true);
  573. search_output = response;
  574. search_word = $("#search-word").val();
  575. filter_base_data = search_data;
  576. }).error(function (error) {
  577. console.log(error);
  578. });
  579. setTimeout(() => {
  580. draw_datatable(search_output);
  581. e.preventDefault();
  582. $.magnificPopup.close();
  583. if ($("#search-filter").css("display") != "none") {
  584. $("#search-filter").slideUp(200);
  585. $("#filter-slide").toggleClass("fa-sort-desc fa-sort-up");
  586. }
  587. $("#search-filter-panel .btn-default").toggleClass("btn-primary btn-default");
  588. show_filter(filter_base_data);
  589. show_progress_bar(false);
  590. $("#search-filter-panel").css("display", "block");
  591. }, 0);
  592. }
  593. });
  594. $("#advancedSearch .panel-body input").on("change", function () {
  595. $("#keep-search-button").css("display", "none");
  596. $("#warning-text").css("display", "none");
  597. $("#advanced-search-button").css("display", "inline-block");
  598. });
  599. function draw_datatable(search_output) {
  600. table.clear().draw();
  601. for (i = 0; i < search_output.length; i++) {
  602. table.row.add([
  603. search_output[i]["SN"],
  604. search_output[i]["original_name"],
  605. search_output[i]["keyword"],
  606. '1.0.0',
  607. '',
  608. search_output[i]["project_id"],
  609. search_output[i]["project_name"],
  610. search_output[i]["type_id"],
  611. search_output[i]["category_name"],
  612. search_output[i]["notes"],
  613. search_output[i]["filename"],
  614. ])
  615. table.draw();
  616. // progress_bar_value = (i/search_output.length)*100
  617. // update_progress_bar();
  618. }
  619. }
  620. function reset_filter_search_output() {
  621. output_data = [];
  622. click_option = get_filter_click("btn-primary");
  623. $.ajax({
  624. url: "./script/php/get_search_list.php",
  625. data: {
  626. project_id: [''].concat(click_option["project"]),
  627. type_id: [''].concat(click_option["type"]),
  628. notes_name: [''].concat(click_option["notes"]),
  629. search: search_word
  630. },
  631. type: "GET",
  632. dataType: "json",
  633. contentType: "application/json",
  634. async: false
  635. }).success(function (response) {
  636. displayDetail(true);
  637. search_output = response;
  638. }).error(function (error) {
  639. console.log(error);
  640. });
  641. draw_datatable(search_output);
  642. }
  643. function get_filter_click(click_class) {
  644. click_id_list = {
  645. "category": [],
  646. "project": [],
  647. "type": [],
  648. "notes": []
  649. };
  650. check_notes = false;
  651. $("#f-category ." + click_class).each(function () {
  652. if ($(this).css("display") == "inline-block") {
  653. click_id_list["category"].push($(this).attr("id").replace("f-c", ""));
  654. }
  655. });
  656. $("#f-project ." + click_class).each(function () {
  657. if ($(this).css("display") == "inline-block") {
  658. click_id_list["project"].push($(this).attr("id").replace("f-p", ""));
  659. }
  660. });
  661. $("#f-type ." + click_class).each(function () {
  662. if ($(this).css("display") == "inline-block") {
  663. click_id_list["type"].push($(this).attr("id").replace("f-t", ""));
  664. if ($(this).attr("id").replace("f-t", "") == "3") {
  665. check_notes = true;
  666. }
  667. }
  668. });
  669. if (check_notes) {
  670. $("#f-notes ." + click_class).each(function () {
  671. if ($(this).css("display") == "inline-block") {
  672. click_id_list["notes"].push($(this).text());
  673. }
  674. });
  675. }
  676. return click_id_list;
  677. }
  678. function show_filter(filter_base_data) {
  679. show_notes = false;
  680. $("#search-filter button").css("display", "none");
  681. filter_base_data["category"].forEach(element => {
  682. id = "f-c" + element;
  683. $("#" + id).css("display", "inline-block");
  684. });
  685. filter_base_data["project"].forEach(element => {
  686. id = "f-p" + element;
  687. $("#" + id).css("display", "inline-block");
  688. });
  689. filter_base_data["type"].forEach(element => {
  690. id = "f-t" + element;
  691. $("#" + id).css("display", "inline-block");
  692. if (element == "3") {
  693. show_notes = true;
  694. }
  695. });
  696. if (show_notes) {
  697. $("#filter_notes").css("display", "block");
  698. filter_base_data["notes"].forEach(element => {
  699. $("#f-notes button").each(function () {
  700. if ($(this).text() == element) {
  701. $(this).css("display", "inline-block");
  702. }
  703. });
  704. });
  705. } else {
  706. $("#filter_notes").css("display", "none");
  707. }
  708. }
  709. var progress_bar_value = 0;
  710. function update_progress_bar() {
  711. var i = 0;
  712. if (i == 0) {
  713. i = 1;
  714. var id = setInterval(frame, 10);
  715. function frame() {
  716. if (progress_bar_value >= 100) {
  717. clearInterval(id);
  718. i = 0;
  719. } else {
  720. $("#progress-bars").css("width", progress_bar_value + "%");
  721. }
  722. }
  723. }
  724. }
  725. function show_progress_bar(show) {
  726. if (show) {
  727. $("#advanced-search-button-group").css("display", "none");
  728. $("#loading").css("display", "block");
  729. // $("#progress-bars").parent().css("display", "block");
  730. } else {
  731. $("#advanced-search-button-group").css("display", "block");
  732. $("#loading").css("display", "none");
  733. // $("#progress-bars").parent().css("display", "none");
  734. }
  735. }
  736. $("#search-filter-panel").hoverIntent({
  737. sensitivity: 50,
  738. interval: 200,
  739. over: function (e) {
  740. $("#search-filter").slideDown(200);
  741. $("#filter-slide").toggleClass("fa-sort-desc fa-sort-up")
  742. },
  743. timeout: 200,
  744. out: function (e) {
  745. $("#search-filter").slideUp(200);
  746. $("#filter-slide").toggleClass("fa-sort-desc fa-sort-up")
  747. }
  748. });
  749. $("#search-filter-panel button").on("click", function (e) {
  750. $(this).toggleClass("btn-primary btn-default");
  751. click_option = get_filter_click("btn-primary");
  752. if (click_option["category"].length > 0 && click_option["project"].length > 0 && click_option["type"].length > 0) {
  753. reset_filter_search_output();
  754. } else {
  755. table.clear().draw();
  756. }
  757. });
  758. $("#f-category button").on("click", function () {
  759. c_id = $(this).attr("id").replace("f-c", "");
  760. sub_project_list = [];
  761. db_table["project"].forEach(element => {
  762. if (element["category_id"] == c_id) {
  763. sub_project_list.push(element["project_id"]);
  764. }
  765. });
  766. sub_project_list.forEach(element => {
  767. if ($(this).hasClass("btn-primary")) {
  768. if ($("#f-p" + element).hasClass("btn-default")) {
  769. $("#f-p" + element).toggleClass("btn-primary btn-default");
  770. }
  771. } else {
  772. if ($("#f-p" + element).hasClass("btn-primary")) {
  773. $("#f-p" + element).toggleClass("btn-primary btn-default");
  774. }
  775. }
  776. click_option = get_filter_click("btn-primary");
  777. if (click_option["category"].length == 0) {
  778. table.clear().draw();
  779. }
  780. });
  781. reset_filter_search_output();
  782. });
  783. $("#f-type button").on("click", function () {
  784. t_id = $(this).attr("id").replace("f-t", "");
  785. if (t_id == "3") {
  786. if ($(this).hasClass("btn-default")) {
  787. $("#filter_notes").css("display", "none");
  788. $("#f-notes .btn-default").toggleClass("btn-primary btn-default");
  789. } else {
  790. $("#filter_notes").css("display", "block");
  791. }
  792. }
  793. });
  794. });