lib.js 21 KB

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