var log4c = { event_name: '/portal/lib/log4c/log4c.gm', send_event_name:'/portal/lib/log4c/log4c.gm', event_type: 'main', event_src: this.window.location.href, event_startDate : new Date(), event_time : new Date(), owner_id: 'none', content_type: 'webpage', content_id : '', action_type : 'view', language : navigator.language, user_id : '', user_userid : '', user_username: '', session_id: '', referrer : document.referrer, userAgent: navigator.userAgent, ip: '54.82.93.116', duration : '', version: '1.2', course_id :'', course_content_id :'', course_study_id :'', course_section_id :'', course_id : '', course_frame_id :'', course_page_id :'', course_tool_type :'', course_tool_total :'', course_tool_current :'', course_tool_qt_total :'', course_tool_qt_corrent :'', course_tool_qt_score :'', course_tool_qt_score_string :'', site_user_id : '', ref :'', param_category_id : '', course_category_id : '', server_url : 'http://bmi.kyobobook.co.kr/portal/lib/log4c/log4c_proc.gm', sendlogdata: function(data) { var log4cxmlHttp = new XMLHttpRequest(); try{ log4cxmlHttp.open("POST", log4c.server_url, true); log4cxmlHttp.setRequestHeader("Content-type", "application/json"); log4cxmlHttp.onreadystatechange = function() { if(log4cxmlHttp.readyState == 4 && log4cxmlHttp.status == 200) { console.log('http.responseText = ' + log4cxmlHttp.responseText); } } log4cxmlHttp.send(data); }catch(e){ console.log('4c log error = ' + e.message); } }, getJsonData:function(){ var jsondata = JSON.stringify({ "event_name": log4c.send_event_name, "event_type": log4c.event_type, "event_src": log4c.event_src, "event_time": log4c.event_time, "content_type": log4c.content_type, "content_id": log4c.content_id, "owner_id": log4c.owner_id, "action_type": log4c.action_type, "language": navigator.language, "user_id": log4c.user_id, "user_userid": log4c.user_userid, "user_username": log4c.user_username, "session_id": log4c.session_id, "referrer" : log4c.referrer, "userAgent": navigator.userAgent, "ip": log4c.ip, "duration": log4c.duration, "version": log4c.version, "course_id" : log4c.course_id, "course_study_id" : log4c.course_study_id, "course_section_id" : log4c.course_section_id, "course_frame_id" : log4c.course_frame_id, "course_page_id" : log4c.course_page_id, "course_tool_type" : log4c.course_tool_type, "course_tool_total" : log4c.course_tool_total, "course_tool_current" : log4c.course_tool_current, "course_tool_qt_total" : log4c.course_tool_qt_total, "course_tool_qt_corrent" : log4c.course_tool_qt_corrent, "course_tool_qt_score" : log4c.course_tool_qt_score, "course_tool_qt_score_string" : log4c.course_tool_qt_score_string, "site_user_id" : log4c.site_user_id, "ref" : log4c.ref, "param_category_id" : log4c.param_category_id, "course_category_id" : log4c.course_category_id }); return jsondata; }, doOnloadEvt: function() { log4c.event_startDate = new Date(); log4c.event_time = log4c.event_startDate; log4c.duration = 0; log4c.event_type = 'onload'; log4c.content_type='webpage'; log4c.action_type='view'; log4c.send_event_name=log4c.event_name; console.log('4c onload evt = ' + log4c.send_event_name); console.log('4c referrer evt = ' + log4c.referrer); log4c.sendlogdata(log4c.getJsonData()); }, doOnUnloadEvt: function() { var exitDate = new Date(); log4c.duration = (exitDate - log4c.event_startDate) / 1000; if(log4c.duration>1800){ log4c.duration = 1800; } log4c.event_type = 'unload'; // browser callback-page unload log4c.content_type='webpage'; log4c.action_type='view'; log4c.send_event_name=log4c.event_name; console.log('4c unload evt = ' + log4c.send_event_name); log4c.sendlogdata(log4c.getJsonData()); }, doLoginTypeEvt: function(send_event_type) { log4c.event_time = new Date(); log4c.duration = 0; log4c.event_type = send_event_type; log4c.send_event_name='signin'; log4c.content_type='webpage'; log4c.action_type='click'; console.log('4c login evt = ' + send_event_type); log4c.sendlogdata(log4c.getJsonData()); }, doMemberJoinTypeEvt: function(send_event_type) { log4c.event_time = new Date(); log4c.duration = 0; log4c.event_type = send_event_type; log4c.send_event_name='signup'; log4c.action_type='click'; log4c.content_type='webpage'; console.log('4c MemberJoin evt = ' + send_event_type); log4c.sendlogdata(log4c.getJsonData()); }, doClassRoomEvt: function(send_event_type) { log4c.event_time = new Date(); log4c.duration = 0; log4c.event_type = send_event_type; log4c.send_event_name='classroom'; log4c.content_type='webpage'; log4c.action_type='click'; console.log('4c ClassRoom evt = ' + send_event_type); log4c.sendlogdata(log4c.getJsonData()); }, doWebPageEvt: function(send_event_name,send_event_type) { log4c.event_time = new Date(); log4c.duration = 0; log4c.event_type = send_event_type; log4c.send_event_name=send_event_name; log4c.content_type='webpage'; log4c.action_type='click'; console.log('4c WebPage evt = ' + send_event_type +' event_name =' + send_event_name); log4c.sendlogdata(log4c.getJsonData()); }, doWebPageEvtRef: function(send_event_name,send_event_type,ref) { log4c.event_time = new Date(); log4c.duration = 0; log4c.ref = ref; log4c.event_type = send_event_type; log4c.send_event_name=send_event_name; log4c.content_type='webpage'; log4c.action_type='click'; console.log('4c WebPage evt = ' + send_event_type +' event_name =' + send_event_name +' ref =' + ref); log4c.sendlogdata(log4c.getJsonData()); } }; // page onload window.onload = function() { log4c.doOnloadEvt(); } // page unload window.addEventListener("beforeunload", function (e) { log4c.doOnUnloadEvt(); });