jstreeAJAX.js 29 KB

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