1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
let COURSES = [ "蛙泳[男]", ];
let COURSE_GROUPS = [ ];
let INTERVAL_MS = 1000;
let ENABLE_GGXXK = false;
let mainInterval; let targetCourses = [];
const start = () => { mainInterval = setInterval(handler, INTERVAL_MS); console.log("--- start grabbing courses ---"); };
const stop = () => { clearInterval(mainInterval); console.log("--- stop grabbing courses ---"); };
const handler = () => { if (targetCourses.length === 0) { getCourses(); }
console.log( `--- found ${targetCourses.length} courses ---` );
let paths = [ "/jsxsd/xsxkkc/xxxkOper", "/jsxsd/xsxkkc/bxxkOper", ]; if (ENABLE_GGXXK) { paths.push("/jsxsd/xsxkkc/ggxxkxkOper"); } for (let course of targetCourses) { for (let path of paths) { $.get(path, course, console.log); } } };
const getCourses = () => { let params = { sEcho: 1, iColumns: 11, iDisplayStart: 0, iDisplayLength: 999, }; let paths = [ "/jsxsd/xsxkkc/xsxkBxxk", "/jsxsd/xsxkkc/xsxkXxxk", ]; if (ENABLE_GGXXK) { paths.push("/jsxsd/xsxkkc/xsxkGgxxkxk"); } for (let path of paths) { $.post(path, params, (data) => { let aaData = $.parseJSON(data).aaData; for (let course of aaData) { if (COURSES.includes(course.kcmc)) { targetCourses.push(course); } else if (COURSE_GROUPS.includes(course.fzmc)) { targetCourses.push(course); } } }); } };
start();
|