jstreeAJAX.js 29 KB

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