lib.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. const CheckDecimal = x => {
  2. const realStringObj = obj && obj.toString();
  3. if (!jQuery.isArray(obj) && (realStringObj - parseFloat(realStringObj) + 1) >= 0) return false;
  4. const parts = x.toString().split(".");
  5. parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  6. return parts.join(".");
  7. }
  8. const CheckMail = email => {
  9. const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  10. const result = re.test(String(email).toLowerCase());
  11. // !result && alert('Email is invalid !!!', 'error');
  12. return result;
  13. }
  14. const CheckNum = input => !isNaN(input);
  15. const LenCheck = (input, length) => {
  16. return input.length <= length;
  17. }
  18. const CheckMinMax = (elm, min, max) => {
  19. const length = $(elm).val().length;
  20. if (length < min || length > max) {
  21. $(elm).empty();
  22. $(elm).focus();
  23. }
  24. }
  25. function setCookie(cookieName, value, expirationDate) {
  26. var cookieValue = escape(value) + ((expirationDate == null) ? '' : '; expires=' + expirationDate.toUTCString()) + ';path=/';
  27. document.cookie = cookieName + '=' + cookieValue;
  28. }
  29. function getCookie(cookieName) {
  30. var name = cookieName + '=';
  31. var decodedCookie = decodeURIComponent(document.cookie);
  32. var cookieArray = decodedCookie.split(';');
  33. for (var i = 0; i < cookieArray.length; i++) {
  34. var cookie = cookieArray[i];
  35. while (cookie.charAt(0) == ' ') {
  36. cookie = cookie.substring(1);
  37. }
  38. if (cookie.indexOf(name) == 0) {
  39. return cookie.substring(name.length, cookie.length);
  40. }
  41. }
  42. return '';
  43. }
  44. function makeTwoDigit(number) {
  45. return number < 10 ? '0' + number : number.toString();
  46. }
  47. function isEmptyArr(arr) {
  48. if(Array.isArray(arr) && arr.length === 0) {
  49. return true;
  50. }
  51. return false;
  52. }
  53. const CheckSSN = ssn => {
  54. const ssnPattern = /^[0-9]{3}\-?[0-9]{2}\-?[0-9]{4}$/;
  55. return ssnPattern.test(ssn);
  56. }
  57. const CheckRequired = inputList => {
  58. inputList.forEach(item => {
  59. const value = item.val();
  60. if (value == null || value == '' || value == undefined) {
  61. alert(`${item.data('name')} is required !!!`, 'error');
  62. return false;
  63. }
  64. })
  65. };
  66. const ComfirmPasswd = (pass, confirmPass) => pass === confirmPass;
  67. const DisableInput = elm => $(elm).prop('disabled', function (i, v) {
  68. return !v;
  69. });
  70. const BlinkObject = elm => {
  71. $(elm).fadeOut('slow', function () {
  72. $(this).fadeIn('slow', function () {
  73. BlinkObject(this);
  74. });
  75. });
  76. }
  77. const InitCheckBox = (data, name) => {
  78. let html = '';
  79. data.forEach(item => {
  80. html += `<input type="checkbox" name="${name}" value="${item}"> ${item}`;
  81. });
  82. return html;
  83. }
  84. const InitRadio = (data, name) => {
  85. let html = '';
  86. data.forEach(item => {
  87. html += `<input type="radio" name="${name}" value="${item}"> ${item}`;
  88. });
  89. return html;
  90. }
  91. const InitSelect = (data, name) => `<select name="${name}">${ArrayToOption(data)}</select>`;
  92. const ArrayToOption = array => {
  93. let html = '';
  94. array.forEach(item => {
  95. html += `<option value="${item}">${item}</option>`
  96. });
  97. return html;
  98. }
  99. function commaCheck($this) {
  100. $($this).val(function (index, value) {
  101. value = value.replace(/,/g, '');
  102. return numberWithCommas(value);
  103. });
  104. }
  105. function minusComma(value) {
  106. let formNumber = "" + trim(value);
  107. // 문자제거
  108. // value = formNumber.toString().replace(/[^\d]+/g, "");
  109. // 콤마제거
  110. value = formNumber.toString().replace(/,/g, "");
  111. return value;
  112. }
  113. function rand(min, max) {
  114. return Math.floor(Math.random() * (max - min)) + min;
  115. }
  116. function format_decimal(val, number) {
  117. let format = decimal_convert(number);
  118. // 소수점 버린다.
  119. return numeral(Math.floor(val).toFixed(number)).format(format);
  120. // 소수점 반올림.
  121. return numeral(parseFloat(val).toFixed(number)).format(format);
  122. }
  123. function fill_zero(width, str) {
  124. return (str.length && width > 0) ? str + '.' + new Array(width + 1).join('0') : str;
  125. }
  126. function decimal_convert(point_name) {
  127. return fill_zero(parseInt(point_name), '0,0')
  128. }
  129. function remove_tag( html ) {
  130. return html.replace(/(<([^>]+)>)/gi, "");
  131. }
  132. function formatDateString(inputString) {
  133. // Split the input string into an array of substrings with two characters each
  134. const chunks = inputString.match(/.{1,2}/g) || [];
  135. // Initialize an empty result string
  136. let result = '';
  137. // Iterate through the chunks and process accordingly
  138. for (const chunk of chunks) {
  139. // Check if the chunk is "00"
  140. if (chunk === "00") {
  141. // If it is, break out of the loop
  142. break;
  143. }
  144. // Otherwise, add the chunk to the result string
  145. result += chunk;
  146. }
  147. return result;
  148. }
  149. function is_localhost() {
  150. if (location.hostname === 'localhost' || location.hostname === '127.0.0.1') {
  151. return true
  152. }
  153. return false
  154. }
  155. function get_clusterize_rows_in_block() {
  156. return 10
  157. // return is_localhost() ? 10 : 10
  158. }
  159. function remove_comma_and_arithmetic(a, b, type) {
  160. switch (type) {
  161. case 'plus':
  162. return Number(minusComma(a)) + Number(minusComma(b))
  163. case 'minus':
  164. return Number(minusComma(a)) - Number(minusComma(b))
  165. }
  166. }
  167. function unixtimeFormatDate(data) {
  168. moment.locale('ko')
  169. return moment(new Date(data * 1000)).format('YYYY-MM-DD HH:mm:ss (dd)')
  170. }
  171. function format_result(data, format, display_vars = undefined) {
  172. let result = data
  173. switch (format) {
  174. case 'YYYY-MM-DD': case 'YYYY.MM.DD': case 'YYYYMMDD':
  175. case 'YY-MM-DD': case 'YY.MM.DD': case 'YYMMDD':
  176. case 'yy-mm-dd': case 'yy.mm.dd': case 'yymmdd':
  177. result = isEmpty(data) ? '' : moment(data).format(format.toUpperCase());
  178. break;
  179. case 'unixtime':
  180. result = isEmpty(data) ? '' : moment(new Date(data * 1000)).format('YY-MM-DD HH:mm:ss');
  181. break;
  182. case 'unix-yy.mm.dd':
  183. result = isEmpty(data) ? '' : moment(new Date(data * 1000)).format('YY-MM-DD');
  184. break;
  185. case '$_ThumbNail':
  186. const w = display_vars['ListWidth'] === 0 ? '100%' : display_vars['ListWidth'] + 'px';
  187. const h = display_vars['ListHeight'] === 0 ? '100%' : display_vars['ListHeight'] + 'px';
  188. result = `
  189. <div class="thumb-nail-title" style="height: ${h};">
  190. <div class="thumb-nail-img-div">
  191. <img src="${window.env['MEDIA_URL'] + data}" style="max-width:${w}; max-height:${h};"
  192. class="thumb-nail-img" onerror="this.src='/images/folder.jpg'">
  193. </div>
  194. </div>
  195. `;
  196. // <div class="m-auto" style="width: 100px; height: 100px; overflow: hidden; margin:0 auto;">
  197. // <img src="${window.env['MEDIA_URL'] + data}" style="width: 100%; height: 100%; object-fit: cover;" onerror="this.src='/images/folder.jpg'"
  198. // </div>
  199. break;
  200. case '$_FileName':
  201. let path_list = data.split('/')
  202. result = path_list[path_list.length - 1];
  203. break;
  204. case 'check':
  205. if (data == 1 || data == true) {
  206. result = '✓';
  207. } else {
  208. result = '';
  209. }
  210. break;
  211. case 'unique':
  212. result = data.split("'").join('');
  213. break;
  214. case 'date_month':
  215. result = isEmpty(data) ? '' : moment(data).format('YY.MM');
  216. break;
  217. case 'date_week':
  218. result = isEmpty(data) ? '' : `${moment(data).format('YY.MM')}-${moment(data).isoWeek()}`;
  219. break;
  220. case 'remove_tag':
  221. result = remove_tag(data);
  222. break;
  223. default:
  224. if (! isEmpty(format) && format.match(/[A-Za-z]+\s*\(\s*'(.*?)\'\s*\)\s*/)) {
  225. const func_name = format.replace(')', `, '${data}')`);
  226. try {
  227. result = eval(`format_func_${func_name}`);
  228. } catch (err) {
  229. result = 'Invalid';
  230. }
  231. }
  232. break;
  233. }
  234. return result;
  235. }
  236. function format_conver_for(data, format, display_vars = undefined, is_split_column = false) {
  237. if (is_split_column) {
  238. if (format.includes('|')) {
  239. let data_list = data.split('|||');
  240. let format_list = format.split('|');
  241. let result_list = [];
  242. format_list.forEach(function (format, index) {
  243. if (format.startsWith("^")) {
  244. format = format.substring(1);
  245. }
  246. result_list.push(format_result(data_list[index], format, display_vars))
  247. });
  248. let r = '';
  249. result_list.forEach(function (result, index) {
  250. if (index >= result_list.length -1) {
  251. r += result
  252. } else {
  253. if (format_list[index + 1].includes('^')) {
  254. r += result + '<br/>'
  255. } else {
  256. r += result + ' | '
  257. }
  258. }
  259. })
  260. return r
  261. }
  262. }
  263. return format_result(data, format, display_vars)
  264. }
  265. function format_func_decimal(...argv) {
  266. const format = capitalize(camelCase(argv[0])) + 'Point';
  267. let data;
  268. if (window.User[format] == undefined) {
  269. return 'Invalid';
  270. }
  271. switch (argv.length) {
  272. case 2:
  273. data = format_decimal(argv[1], window.User[format]);
  274. break;
  275. case 3:
  276. data = format_decimal(argv[2], window.User[format])
  277. if (argv[1] === 'nz' && (isEmpty(data) || data == 0)) { data = 0; }
  278. else if (argv[1] === 'zn' && (isEmpty(data) || data == 0)) { data = ''; }
  279. break;
  280. }
  281. if (argv[1] === '') {
  282. return ''
  283. }
  284. return data;
  285. }
  286. function format_func_status_update(value, data) {
  287. return { Field: 'Status', Value: format_func_status_rev(value, data), };
  288. }
  289. function format_func_status_code_update(value, data) {
  290. return { Field: 'Status', Value: data, };
  291. }
  292. function format_func_status_rev(value, data) {
  293. const status = Object.values(window.CodeTitle['status'][value]).filter(status => status.Title == data)
  294. if (isEmptyArr(status)) { return data; }
  295. return _.first(status)['Code'];
  296. }
  297. function format_func_status(value, data) {
  298. if (window.CodeTitle['status'] && window.CodeTitle['status'][value][data]) {
  299. return window.CodeTitle['status'][value][data]['Title'];
  300. }
  301. return 'Invalid';
  302. }
  303. function format_func_sort_update(value, data) {
  304. return { Field: 'Sort', Value: format_func_sort_rev(value, data), };
  305. }
  306. function format_func_sort_code_update(value, data) {
  307. return { Field: 'Sort', Value: data, };
  308. }
  309. function format_func_sort_rev(value, data) {
  310. const sort = Object.values(window.CodeTitle['sort'][value]).filter(sort => sort.Title == data)
  311. if (isEmptyArr(sort)) { return data; }
  312. return _.first(sort)['Code'];
  313. }
  314. function format_func_sort(value, data) {
  315. if (window.CodeTitle['sort'] && window.CodeTitle['sort'][value][data]) {
  316. return window.CodeTitle['sort'][value][data]['Title'];
  317. }
  318. return 'Invalid';
  319. }
  320. function format_func_deal_type_update(value, data) {
  321. return { Field: 'DealType', Value: format_func_deal_type_rev(value, data), };
  322. }
  323. function format_func_deal_type_rev(value, data) {
  324. const deal_type = Object.values(window.CodeTitle['deal-type'][value]).filter(deal_type => deal_type.Title == data)
  325. if (isEmptyArr(deal_type)) { return data; }
  326. return _.first(deal_type)['Code'];
  327. }
  328. function format_func_deal_type(value, data) {
  329. if (window.CodeTitle['deal-type'] && window.CodeTitle['deal-type'][value][data]) {
  330. return window.CodeTitle['deal-type'][value][data]['Title'];
  331. }
  332. return 'Invalid';
  333. }
  334. function format_func_paymethod_rev(value, data) {
  335. const paymethod = Object.values(window.CodeTitle['paymethod'][value]).filter(paymethod => paymethod.Title == data)
  336. if (isEmptyArr(paymethod)) { return data; }
  337. return _.first(paymethod)['Code'];
  338. }
  339. function format_func_paymethod(value, data) {
  340. if (window.CodeTitle['paymethod'] && window.CodeTitle['paymethod'][value][data]) {
  341. return window.CodeTitle['paymethod'][value][data]['Title'];
  342. }
  343. return 'Invalid';
  344. }
  345. function format_func_situation_rev(value, data) {
  346. const situation = Object.values(window.CodeTitle['situation'][value]).filter(situation => situation.Title == data)
  347. if (isEmptyArr(situation)) { return data; }
  348. return _.first(situation)['Code'];
  349. }
  350. function format_func_situation(value, data) {
  351. if (window.CodeTitle['situation'] && window.CodeTitle['situation'][value][data]) {
  352. return window.CodeTitle['situation'][value][data]['Title'];
  353. }
  354. return 'Invalid';
  355. }
  356. function format_func_bill_type_update(value, data) {
  357. return { Field: 'BillType', Value: format_func_deal_type_rev(value, data), };
  358. }
  359. function format_func_bill_type_rev(value, data) {
  360. const bill_type = Object.values(window.CodeTitle['bill-type'][value]).filter(bill_type => bill_type.Title == data)
  361. if (isEmptyArr(bill_type)) { return data; }
  362. return _.first(bill_type)['Code'];
  363. }
  364. function format_func_bill_type(value, data) {
  365. if (window.CodeTitle['bill-type'] && window.CodeTitle['bill-type'][value][data]) {
  366. return window.CodeTitle['bill-type'][value][data]['Title'];
  367. }
  368. return 'Invalid';
  369. }
  370. function format_func_setup_code_update(value, data) {
  371. return { Field: 'SetupCode', Value: format_func_setup_code_rev(value, data), };
  372. }
  373. function format_func_setup_code_rev(value, data) {
  374. const setup_code = Object.values(window.CodeTitle['setup-code'][value]).filter(setup_code => setup_code.Title == data)
  375. if (isEmptyArr(setup_code)) { return data; }
  376. return _.first(setup_code)['Code'];
  377. }
  378. function format_func_setup_code(value, data) {
  379. if (window.CodeTitle['setup-code'] && window.CodeTitle['setup-code'][value][data]) {
  380. return window.CodeTitle['setup-code'][value][data]['Title'];
  381. }
  382. return 'Invalid';
  383. }
  384. function format_func_expose_type_update(value, data) {
  385. return { Field: 'ExposeType', Value: format_func_expose_type_rev(value, data), };
  386. }
  387. function format_func_expose_type_rev(value, data) {
  388. const expose_type = Object.values(window.CodeTitle['expose-type'][value]).filter(expose_type => expose_type.Title == data)
  389. if (isEmptyArr(expose_type)) { return data; }
  390. return _.first(expose_type)['Code'];
  391. }
  392. function format_func_expose_type(value, data) {
  393. if (window.CodeTitle['expose-type'] && window.CodeTitle['expose-type'][value][data]) {
  394. return window.CodeTitle['expose-type'][value][data]['Title'];
  395. }
  396. return 'Invalid';
  397. }
  398. function format_func_ship_type_update(value, data) {
  399. return { Field: 'ShipType', Value: format_func_ship_type_rev(value, data), };
  400. }
  401. function format_func_ship_type_rev(value, data) {
  402. const ship_type = Object.values(window.CodeTitle['ship-type'][value]).filter(ship_type => ship_type.Title == data)
  403. if (isEmptyArr(ship_type)) { return data; }
  404. return _.first(ship_type)['Code'];
  405. }
  406. function format_func_ship_type(value, data) {
  407. if (window.CodeTitle['ship-type'] && window.CodeTitle['ship-type'][value][data]) {
  408. return window.CodeTitle['ship-type'][value][data]['Title'];
  409. }
  410. return 'Invalid';
  411. }
  412. function format_func_delay_type_update(value, data) {
  413. return { Field: 'DelayType', Value: format_func_delay_type_rev(value, data), };
  414. }
  415. function format_func_delay_type_rev(value, data) {
  416. const delay_type = Object.values(window.CodeTitle['delay-type'][value]).filter(delay_type => delay_type.Title == data)
  417. if (isEmptyArr(delay_type)) { return data; }
  418. return _.first(delay_type)['Code'];
  419. }
  420. function format_func_delay_type(value, data) {
  421. if (window.CodeTitle['delay-type'] && window.CodeTitle['delay-type'][value][data]) {
  422. return window.CodeTitle['delay-type'][value][data]['Title'];
  423. }
  424. return 'Invalid';
  425. }
  426. function format_func_cargo_type_update(value, data) {
  427. return { Field: 'CargoType', Value: format_func_cargo_type_rev(value, data), };
  428. }
  429. function format_func_cargo_type_rev(value, data) {
  430. const cargo_type = Object.values(window.CodeTitle['cargo-type'][value]).filter(cargo_type => cargo_type.Title == data)
  431. if (isEmptyArr(cargo_type)) { return data; }
  432. return _.first(cargo_type)['Code'];
  433. }
  434. function format_func_cargo_type(value, data) {
  435. if (window.CodeTitle['cargo-type'] && window.CodeTitle['cargo-type'][value][data]) {
  436. return window.CodeTitle['cargo-type'][value][data]['Title'];
  437. }
  438. return 'Invalid';
  439. }
  440. function format_func_condition_type_update(value, data) {
  441. return { Field: 'ConditionType', Value: format_func_condition_type_rev(value, data), };
  442. }
  443. function format_func_condition_type_rev(value, data) {
  444. const condition_type = Object.values(window.CodeTitle['condition-type'][value]).filter(condition_type => condition_type.Title == data)
  445. if (isEmptyArr(condition_type)) { return data; }
  446. return _.first(condition_type)['Code'];
  447. }
  448. function format_func_condition_type(value, data) {
  449. if (window.CodeTitle['condition-type'] && window.CodeTitle['condition-type'][value][data]) {
  450. return window.CodeTitle['condition-type'][value][data]['Title'];
  451. }
  452. return 'Invalid';
  453. }
  454. function check_dom_input_number(dom_array) {
  455. let arr = dom_array.filter(el => isNaN($(el).val()))
  456. arr.forEach(el => $(el).val('') );
  457. if (! isEmptyArr(arr)) {
  458. iziToast.error({
  459. title: 'Error',
  460. message: $('#please-enter-a-number').text(),
  461. });
  462. return true;
  463. }
  464. return false;
  465. }
  466. function show_iziToast_msg(page, callback = undefined) {
  467. if (page) {
  468. iziToast.success({
  469. title: 'Success',
  470. message: $('#action-completed').text(),
  471. });
  472. if (! isEmpty(callback)) {
  473. callback()
  474. }
  475. } else {
  476. iziToast.error({
  477. title: 'Error',
  478. message: page.data.body ?? $('#api-request-failed-please-check').text(),
  479. });
  480. }
  481. }
  482. const generate_random_string = (num) => {
  483. const characters ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  484. let result = '';
  485. const charactersLength = characters.length;
  486. for (let i = 0; i < num; i++) {
  487. result += characters.charAt(Math.floor(Math.random() * charactersLength));
  488. }
  489. return result;
  490. }
  491. function find_menu_info(data, find_code) {
  492. return data.filter(menu => menu['MenuCode'] === find_code)[0]
  493. }
  494. async function show_recrystallize_server(print_vars, type, vars) {
  495. let simple_filter = '', list_type1_vars = ''
  496. switch (type) {
  497. case 'formB':
  498. simple_filter = vars
  499. break
  500. case 'type1':
  501. list_type1_vars = vars
  502. break
  503. }
  504. if (isEmpty(window.env['REPORT_SERVER_URL'])) {
  505. return iziToast.error({ title: 'Error', message: 'REPORT_SERVER_URL 의 지정 내용이 없어 PDF를 생성할 수 없습니다.' })
  506. }
  507. const response = await get_api_data('list-type1-page', {
  508. QueryVars: {
  509. QueryName: print_vars['QueryName'],
  510. SimpleFilter: simple_filter
  511. },
  512. ListType1Vars: {
  513. ...list_type1_vars,
  514. IsntPageReturn: true,
  515. IsCrystalReport: true,
  516. IsDownloadList: true,
  517. IsAddTotalLine: false,
  518. }
  519. })
  520. // console.log(response)
  521. if (response.data['apiStatus']) {
  522. return iziToast.error({ title: 'Error', message: response.data['body'] ?? $('#api-request-failed-please-check').text() })
  523. }
  524. const reportName = print_vars['ReportPath']
  525. let url = window.env['REPORT_SERVER_URL'] + '?reportName=' + reportName + '&listToken='
  526. + response.data['ListType1Vars']['ListToken'] + '&ofcCode=' + window.User['OfcCode']
  527. if (print_vars['ExportFmt']) {
  528. url = url + '&exportfmt=' + print_vars['ExportFmt']
  529. }
  530. switch (print_vars['ExportFmt']) {
  531. case '':
  532. case 'PDF':
  533. window.open(url)
  534. break
  535. default:
  536. location.href = url
  537. break
  538. }
  539. // window.open(url)
  540. }
  541. async function show_popup(component, width, variable = '', namespace = 'window') {
  542. const popupOption = eval(namespace).popupOptions.filter(option => option.Component.includes(component))
  543. if (isEmpty(popupOption)) { return }
  544. const modal_class_name = popupOption[0]['ModalClassName'];
  545. $(`#modal-select-popup.${modal_class_name} .modal-dialog`).css('max-width', `${width}px`)
  546. eval(capitalize(camelCase(modal_class_name))).btn_act_new_callback(variable)
  547. $(`#modal-select-popup.${modal_class_name}`).modal('show')
  548. }
  549. function groupBy (data, key) {
  550. return data.reduce(function (carry, el) {
  551. var group = el[key];
  552. if (carry[group] === undefined) {
  553. carry[group] = []
  554. }
  555. carry[group].push(el)
  556. return carry
  557. }, {})
  558. }
  559. function isEmptyObject(obj){
  560. if (obj.constructor === Object && Object.keys(obj).length === 0) return true;
  561. return false;
  562. }
  563. function check_login() {
  564. if (isEmpty(window.Member)) {
  565. // location.href = '/member-login-broker'
  566. return false
  567. }
  568. return true
  569. }
  570. function chunk(data = [], size = 1) {
  571. const arr = [];
  572. for (let i = 0; i < data.length; i += size) {
  573. arr.push(data.slice(i, i + size));
  574. }
  575. return arr;
  576. }
  577. function addIdParameter(url, idValue) {
  578. const urlObj = new URL(url, window.location.origin); // Assuming a relative URL, we need a base URL for URL parsing
  579. const params = urlObj.searchParams;
  580. if (!params.has('id')) {
  581. params.append('id', idValue);
  582. }
  583. return urlObj.toString();
  584. }