|
| 1 | +import { color } from "@/styles"; |
| 2 | + |
| 3 | +// 심신미약자나 노약자, 임산부, 유아는 코드를 읽는 것을 삼가하기바람 |
| 4 | + |
| 5 | +export const useMeisterHTML = () => { |
| 6 | + const getBasicJobSkills = (html: string) => { |
| 7 | + return [ |
| 8 | + { |
| 9 | + title: "의사소통 국어", |
| 10 | + value: +html.substring( |
| 11 | + html.lastIndexOf("의사소통(국어) : ") + 11, |
| 12 | + html.lastIndexOf("의사소통(국어) : ") + 12, |
| 13 | + ), |
| 14 | + status: color.primary_blue, |
| 15 | + }, |
| 16 | + { |
| 17 | + title: "의사소통 영어", |
| 18 | + value: +html.substring( |
| 19 | + html.lastIndexOf("의사소통(영어) : ") + 11, |
| 20 | + html.lastIndexOf("의사소통(영어) : ") + 12, |
| 21 | + ), |
| 22 | + status: color.primary_mint, |
| 23 | + }, |
| 24 | + { |
| 25 | + title: "수리 활용", |
| 26 | + value: +html.substring( |
| 27 | + html.lastIndexOf("수리활용 : ") + 7, |
| 28 | + html.lastIndexOf("수리활용 : ") + 8, |
| 29 | + ), |
| 30 | + status: color.primary_red, |
| 31 | + }, |
| 32 | + { |
| 33 | + title: "문제 해결", |
| 34 | + value: +html.substring( |
| 35 | + html.lastIndexOf("문제해결 : ") + 7, |
| 36 | + html.lastIndexOf("문제해결 : ") + 8, |
| 37 | + ), |
| 38 | + status: color.primary_yellow, |
| 39 | + }, |
| 40 | + ]; |
| 41 | + }; |
| 42 | + |
| 43 | + const scoreParser = (html: string) => { |
| 44 | + const parsedHTML = html; |
| 45 | + return ( |
| 46 | + parsedHTML |
| 47 | + .replaceAll( |
| 48 | + '<div>[ <span style="font-weight:bold; color:blue;">', |
| 49 | + (match) => { |
| 50 | + return `<section class="list-item">${match}`; |
| 51 | + }, |
| 52 | + ) |
| 53 | + .replace(/\[ (\d{4}-\d{2}-\d{2}) \]/g, (match) => { |
| 54 | + return `<br> |
| 55 | + <hgroup class="section-date"> |
| 56 | + ${match |
| 57 | + .replaceAll("[ ", "") |
| 58 | + .replaceAll(" ]", "") |
| 59 | + .replace("-", "년 ") |
| 60 | + .replace("-", "월 ")}일</hgroup></section>`; |
| 61 | + }) |
| 62 | + .replaceAll("- 시도와 전국은 중복부여 안함", "") |
| 63 | + .replace(/[①-⑮].*?: -<br>/gi, "") |
| 64 | + .replace(/[①-⑮].*?: -/gi, "") |
| 65 | + .replace(/\([^)]*\)/gi, "") |
| 66 | + .replace(/총점\s+([\d.]+)\s*점/gi, (match) => { |
| 67 | + return `<span class="total-score-item">${match}</span>`; |
| 68 | + }) |
| 69 | + .replace(/ \d+ 점/gi, (match) => { |
| 70 | + return `<span class="item-score" >${match.replaceAll( |
| 71 | + " ", |
| 72 | + "", |
| 73 | + )}</span>`; |
| 74 | + }) |
| 75 | + .replaceAll( |
| 76 | + '[ <span style="font-weight:bold; color:red;">종합</span> ]', |
| 77 | + "", |
| 78 | + ) |
| 79 | + .replaceAll(",", "") |
| 80 | + .replaceAll("font-weight:bold; color:blue;", "") |
| 81 | + .replaceAll( |
| 82 | + '⑥ 헌혈 : <span style="font-weight:bold;">0 점</span> ( 총 : 시간 )<br>', |
| 83 | + "", |
| 84 | + ) |
| 85 | + .replaceAll( |
| 86 | + '⑧ 스포츠관련 행사 : <span style="font-weight:bold;"> 점</span> ( 총 : 0 건 )<br>', |
| 87 | + "", |
| 88 | + ) |
| 89 | + .replaceAll( |
| 90 | + '⑬ 직업관련 교육 : <span style="font-weight:bold;"> 점</span> ( 총 : 0 건 )<br>', |
| 91 | + "", |
| 92 | + ) |
| 93 | + .replaceAll( |
| 94 | + '⑪ 체육/음악 관련 대회 : <span style="font-weight:bold;">0 점</span> - 시도와 전국은 중복부여 안함 (최고 득점 1개만 적용)<br>', |
| 95 | + "", |
| 96 | + ) |
| 97 | + .replaceAll("font-weight:bold;", "") |
| 98 | + .replaceAll( |
| 99 | + '⑪ 체육/음악 관련 대회 : <span style="font-weight:bold;"> 점</span> - 시도와 전국은 중복부여 안함 (최고 득점 1개만 적용)<br>', |
| 100 | + "", |
| 101 | + ) |
| 102 | + .replace(/[①-⑮]/gi, "") |
| 103 | + // .replaceAll(":", "·") |
| 104 | + .replaceAll( |
| 105 | + '[ <span style="font-weight:bold; color:red;">종합</span> ]', |
| 106 | + "", |
| 107 | + ) |
| 108 | + .replaceAll(": 점", ": 0점") |
| 109 | + .replaceAll(": 점", ": 0점") |
| 110 | + .replaceAll("\n", "") |
| 111 | + .replaceAll("\t", "") |
| 112 | + .replaceAll(" ", "") |
| 113 | + ); |
| 114 | + }; |
| 115 | + |
| 116 | + const pointParser = (html: string) => { |
| 117 | + return html.replaceAll( |
| 118 | + 'style="border:1px solid #ccc;margin-bottom:10px;border-radius:3px;padding:10px;box-shadow: 2px 2px 1px 2px #ddd;"', |
| 119 | + "", |
| 120 | + ); |
| 121 | + }; |
| 122 | + |
| 123 | + return { getBasicJobSkills, scoreParser, pointParser }; |
| 124 | +}; |
0 commit comments