Skip to content

Instantly share code, notes, and snippets.

@jonghwanhyeon
Created August 8, 2014 05:23
Show Gist options
  • Save jonghwanhyeon/27e6398b099828af595d to your computer and use it in GitHub Desktop.
Save jonghwanhyeon/27e6398b099828af595d to your computer and use it in GitHub Desktop.
var $log = $('<div />');
function HanyangRegistration(student_number, grade, interval) {
this.student_number=student_number;
this.grade = grade;
this.interval_second = interval
if (typeof interval === "undefinded")
this.interval_second = 10;
this.grade_time = {
"1" : new Date(2014, 7, 7, 10, 50, 0, 0).getTime(),
"2" : new Date(2014, 7, 6, 10, 50, 0, 0).getTime(),
"3" : new Date(2014, 7, 5, 10, 50, 0, 0).getTime(),
"4" : new Date(2014, 7, 4, 10, 50, 0, 0).getTime(),
"5" : new Date(2014, 7, 4, 10, 50, 0, 0).getTime(),
};
this.want_course = this.get_wanting_course();
$log.css({
position: 'absolute',
left: '0px',
top: '0px',
width: '700px',
height: '50px',
backgroundColor: 'white',
overflow: 'scroll'
});
$('body').append($log);
};
HanyangRegistration.prototype.start = function() {
if (this.want_course === null) {
console.log("ERROR");
return;
}
var reg = this.register;
var registration_time = this.grade_time[this.grade] - Date.now();
var courses = this.want_course;
var interval = this.interval_second * 1000;
// clear keeping session interval
courses.forEach(function(course) {
reg(course.suupNo, course.gwamokNm);
});
setInterval(function() {
courses.forEach(function(course) {
reg(course.suupNo, course.gwamokNm);
});
}, interval);
};
HanyangRegistration.prototype.keep_session = function() {
// Insert session keeping code..
}
HanyangRegistration.prototype.get_wanting_course = function() {
var want_course = null;
$.ajax({
type:"post",
contentType:"application/json+sua; charset=UTF-8",
url: '/sugang/SgscAct/findHeemangSuupSearchs.do',
async:false,
data: JSON.stringify({"strSuupYear":"2014","strSuupTerm":"20","strHakbun":this.student_number,"strJojikGb":"3","strGrade":this.grade}),
}).done(function ( data ) {
want_course = data.DS_SUUPGG03TTM01[0].list;
});
return want_course;
}
HanyangRegistration.prototype.register = function(suupNo, gwamokName) {
$.ajax({
type:"post",
contentType:"application/json+sua; charset=UTF-8",
url: '/sugang/SgscAct/saveSugangSincheong2.do',
data: JSON.stringify({'IN_A_JAESUGANG_GB':"", 'IN_JAESUGANG_HAKSU_NO':"", 'IN_JAESUGANG_YN':"N", 'IN_JOJIK_GB_CD':"Y0000316", 'IN_SINCHEONG_FLAG':"1", 'IN_SUNSU_FLAG':"", 'IN_SUUP_NO':suupNo}),
}).done(function ( data ) {
$log.html(("["+gwamokName+"("+suupNo+")] : "+data.outMsg) + '<br />' + $log.html());
$log.html($log.html().split(/\n/).slice(0, 2).join('\n'))
});
};
var id = prompt("학번")
new HanyangRegistration(id, "4", 1.0).start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment