// Danh sách công việc const checkList = [ { id: 'form-thoi-gian-dem-nguoc', label: 'Thời gian đếm ngược', func: checkTimeDown, }, { id: 'form-dang-nhap', label: 'Form đăng nhập thông tin', func: checkFormLogin, }, { id: 'form-trang-thai-nguoi-choi', label: 'Hiển thị trạng thái người chơi', func: checkPlayerPresent, }, { id: 'form-danh-sach-giai-thuong', label: 'Hiển thị danh sách giải thưởng', func: checkRewardList, }, { id: 'form-danh-sach-nguoi-choi-trung-giai', label: 'Hiển thị danh sách người chơi trúng giải', func: checkWinerRecentList, }, { id: 'form-the-le-chuong-trinh', label: 'Hiển thị thể lệ chương trình', func: checkPolicyGame, }, { id: 'form-luot-choi-toi-da', label: 'Số lượt chơi tối đa', }, { id: 'form-chon-giai-thuong', label: 'Chọn giải thưởng', }, ] // FUNCTION // Hàm check PASSED/FAILED function checkListForm(id, condition) { switch (condition) { case true: $(`#js-${id}`).html("PASSED"); break; case false: $(`#js-${id}`).html("FAILED"); break; default: $(`#js-${id}`).html(`${condition}`); break; } }; // Kiểm tra thời gian chơi game còn lại function checkTimeDown() { let check_id_time = $("#js-time-game-left") return new Promise((resolve, reject) => { let check_1 = check_id_time.html(); setTimeout(() => { let check_2 = check_id_time.html(); resolve(check_2 !== check_1); }, 2000); }); } // Kiểm tra các ô điền thông tin người chơi đã đủ chưa function checkFormLogin() { const game_info = Adman.MiniGame.getInfo(); const requireEmail = game_info.rules.require_email_before_play; const requireTel = game_info.rules.require_mobile_before_play; const requireName = game_info.rules.require_name_before_play; const totalRequire = requireEmail + requireTel + requireName; const totalRequireInput = $("#js-user-info input").length; return totalRequire === totalRequireInput; } // Kiểm tra người chơi dang xem - dang choi - da choi function checkPlayerPresent() { const checkHtml = $(".js-users-status-online").html(); return checkHtml !== "999"; } // Kiểm tra danh sách giải thưởng function checkRewardList() { const checkHtml = $("#js-reward-product-list").html(); return checkHtml !== ""; } // Kiểm tra danh sách người chơi trúng giải function checkWinerRecentList() { const checkHtml = $("#js-recent-winners").html(); return checkHtml !== ""; } // Kiểm tra danh sách người chơi trúng giải function checkPolicyGame() { const checkHtml = $("#js-game-policy").html(); return checkHtml !== ""; } const check_work = { checkList, checkListForm } module.exports = check_work;