Skip to content

Commit

Permalink
로그인 여부 확인기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
youngjin-k committed Aug 15, 2019
1 parent befeae9 commit 3752fde
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
let uid = 1;
const MAIN_URI = 'http://www.letskorail.com/ebizprd/EbizPrdTicketPr21111_i1.do';
const LOGIN_PAGE_URI = 'http://www.letskorail.com/korail/com/login.do';

const createCheckbox = () => {
const $rows = document.querySelectorAll('#tableResult > tbody > tr');
Expand All @@ -25,14 +26,16 @@ const isChecked = uid => {
return checkedItems.includes(String(uid));
};

const isLogin = () => !!document.querySelectorAll('.gnb_list > .log_nm').length;

const getCheckboxTemplate = uid => {
if (!uid) {
return;
}

return `
<label>
<input type="checkbox" class="ktx-macro-checkbox" value="${uid}" ${isChecked(uid) && "checked"}>
<input type="checkbox" class="ktx-macro-checkbox" value="${uid}" ${isChecked(uid) && 'checked'}>
매크로
</label>
`;
Expand All @@ -50,6 +53,13 @@ const setCheckboxEvent = () => {
};

const macroStart = () => {
if (!isLogin()) {
if (confirm('로그인이 필요합니다.\n로그인 페이지로 이동하시겠습니까?')) {
location.href = LOGIN_PAGE_URI;
}
return;
}

if (!sessionStorage.getItem('checkedItems')) {
alert('선택 된 항목이 없습니다.\n1개 이상 선택해주세요.');
return;
Expand Down

0 comments on commit 3752fde

Please sign in to comment.