var UIMonitor = function(config){ if(window != window.top) return; if(!UIMonitor.startTime) UIMonitor.start(); if(!UIMonitor.pageId) return; for(var s in config) if(config.hasOwnProperty(s)) this[s] = config[s]; this.viewName = this.getViewName(UIMonitor.pageId); if(!this.viewName) return; this.initialize(); UIMonitor.instances.push(this); }; UIMonitor.prototype = { getViewName: function(pageId){return null}, initialize: function(){}, finalize: function(){return null} }; UIMonitor.start = function(){ var r1 = /^\w+\.\w+\.sh\.ctriptravel.com$/i.test(location.hostname); var r2 = /^\w+\.ego2.cn$/i.test(location.hostname); var r3 = /big5/.test(location.hostname); if(!r1 && !r2 || r3) return; this.startTime = new Date(); this.instances = []; this.visitId = this.getVisitId(); this.pageId = this.getPageId(); this.prevPage = this.getPrevPage(); this.urlId = this.getUrlId(); if(!this.pageId) return; var ifr = document.createElement('iframe'); ifr.style.cssText="left:-1000px;top:-1000px;width:100px;height:100px;position:absolute"; $$.status.container.appendChild(ifr); var doc = ifr.contentWindow.document; doc.open(); doc.write([ '
"' ].join('')); doc.close(); this.proxyDoc = doc; window.$r('beforeunload', this.end); }; UIMonitor.end = function(){ if(new Date() - UIMonitor.startTime > 500 && UIMonitor.post){ UIMonitor.post(); UIMonitor.post = null; } }; UIMonitor.post = function(){ var doc = this.proxyDoc; var form = doc.getElementsByTagName('form')[0]; var pushField = function(name, value, index){ if(value.constructor == Array && value.length > 0){ for(var i = 0; i < value.length; i ++) value[i] = '|:' + value[i].join('|:'); value = '@' + value.join('@'); } var el = doc.createElement('input'); el.name = name + '_' + index; el.value = escape(value); form.appendChild(el); }; var arr = this.instances; for(var i = 0, j = 0; i < arr.length; i ++){ var map = arr[i].dataMap; // try{ var dat = arr[i].finalize(); // }catch(e){ //to do // }; if(!dat) continue; for(var s in dat) if(dat.hasOwnProperty(s)) pushField(map[s], dat[s], j); pushField('viewName', arr[i].viewName, j); ++ j; } if(form.length == 0) return; form.submit(); if(window.ActiveXObject) return; var tt = new Date(); while(new Date() - tt < 200); }; UIMonitor.getUserAgent = function(){ var name = 'unknown'; var version = ''; if (window.opera){ name = 'presto'; version = document.getElementsByClassName ? 950 : 925; }else if(window.ActiveXObject){ name = 'trident'; version = window.XMLHttpRequest ? 5 : 4; }else if(!navigator.taintEnabled){ name = 'webkit'; version = document.evaluate ? 420 : 419; }else if(document.getBoxObjectFor){ name = 'gecko'; version = document.getElementsByClassName ? 19 : 18; } return name + version; }; UIMonitor.parseUrl = function(url){ url = url.replace(/[?#].*$/g, '').toLowerCase(); url = url.toLowerCase().replace(/\?.*$/,''); url = url.slice(url.indexOf('//') + 2); if(url.indexOf('/') < 0) url += '/'; var i = url.indexOf('/'); var d = url.slice(0, i).split('.'); var p = url.slice(i); var r = { root:d.slice(-2).join('.'), sub: d.slice(0, -2).join('.'), path: p }; //for debug if(r.root == 'ctriptravel.com'){ r.root = 'ego2.cn'; r.sub = d[0]; } //to do: big5 return r; }; UIMonitor.getPageId = function(u){ if(!u) u = this.parseUrl(location.href); if(u.root != 'ego2.cn') return null; if(u.sub == 'vacations' && $('pkgPageName')){ return { 'pkgsearch.aspx': 40, 'showpkglist.aspx': 41, 'pkgdetail.aspx': 42, 'pkgreserve.aspx': 43, 'pkgreserveoption.aspx': 44, 'pkgcontact.aspx': 45, 'pkgdeliver.aspx': 46, 'pkgcheck.aspx': 47, 'pkgsubmit.aspx': 48, 'pkgstore.aspx': 49 //20081008 }[$('pkgPageName').value.toLowerCase()]; } var r = { 'www': { '/': 10, '/index.asp': 10, '/member/signup.asp': 11, '/member/login.asp': 12, '/member/postLogin.asp': 13, '/member/signupsubmit.asp': 14 }, 'hotels': { '/default.aspx': 20, '/domestic/': 20, '/domestic/searchhotel.aspx': 20, '/domestic/showhotellist.aspx': 21, '/domestic/showhotelinfo.aspx': 22, '/domestic/inputneworder.aspx': 23, '/domestic/confirmorder.aspx': 24, '/domestic/reservesuccess.aspx': 25 }, 'flights': { //20081013 '/domestic/': 30, '/domestic/searchflights.aspx': 30, '/domestic/showfarefirst.aspx': 31, '/domestic/showfaresecond.aspx': 32, '/domestic/inputorder.aspx': 33, '/domestic/inputcontact.aspx': 34, '/domestic/revieworder.aspx': 35, '/domestic/confirmorder.aspx': 36, '/international/': 50, '/international/searchflights.aspx': 50, '/international/showfarefirst.aspx': 51, '/international/showfaresecond.aspx': 52, '/international/fltpassenger.aspx': 53, '/international/fltdeliver.aspx': 54, '/international/fltcheck.aspx': 55, '/international/fltsubmitorder.aspx': 56 }, 'vacations': { '/': 40, '/booking/pkgsearch.aspx': 40, '/booking/showpkglist.aspx': 41, '/booking/pkgdetail.aspx': 42, '/booking/pkgreserve.aspx': 43, '/booking/pkgreserveoption.aspx': 44, '/booking/pkgcontact.aspx': 45, '/booking/pkgdeliver.aspx': 46, '/booking/pkgcheck.aspx': 47, '/booking/pkgsubmit.aspx': 48 } }; if(u.sub == 'flights'){ if(!document.aspnetForm){ r = void(0); }else{ u.path = u.path.replace(/[^\/]+$/, (document.aspnetForm.action.split('?')[0].match(/[^\/]+$/)+'').toLowerCase()); r = r[u.sub][u.path]; } }else if(r = r[u.sub]){ r = r[u.path]; } if(u.sub == 'hotels'){ if(!r && u.path.indexOf('/hotel/') == 0){ if(/\/[a-z]+\d+\/$/.test(u.path)) r = 21; else if(/\/\d+\.html$/.test(u.path)) r = 22; } } return r; }; UIMonitor.getPrevPage = function(){ if(!document.referrer) return -2; var c = this.getCookie(); if(c.lp) return c.lp; var u = this.parseUrl(document.referrer); var r = this.getPageId(u); if(r === null) return -1; return r || ({www: 100, hotels:200, flights:300, vacations:400}[u.sub]) || 999; }; UIMonitor.getVisitId = function(){ var c = this.getCookie(); c.vi = c.lv ? parseInt(c.vi, 10) + 1 : 1; c.lv = new Date().getTime(); c.lp = this.getPageId() || ''; this.setCookie(c); return c.vi; }; UIMonitor.getCookie = function(){ var uig = document.cookie.match(/(^| )uig=([^;]*)/); var ret = {}; if(!uig) return ret; var a = uig[2].split('&'); for(var i = 0; i < a.length; i ++){ var b = a[i].split('='); ret[b[0]] = unescape(b[1]); } return ret; }; UIMonitor.setCookie = function(obj){ var a = []; for(var s in obj) if(obj.hasOwnProperty(s)) a.push(s + '=' + escape(obj[s])); document.cookie =[ 'uig=' + a.join('&'), 'expires=' + new Date('1/1/2020'), 'domain=' + location.hostname.split('.').slice(-2).join('.'), 'path=/' ].join('; '); } UIMonitor.wrapFn = function(fn, name, ar, cn){ return function(){ var a = [new Date() - UIMonitor.startTime, name]; //time, name, arg1, arg2, arg3, arg4 for(var i = 0; i < arguments.length; i ++){ var t = arguments[i]; if(t && t.nodeType == 1 && t.id) t = t.id; a.push(t + ''); } a.length = 6; ar.push(a); ++cn[name]; return fn ? fn.apply(null, arguments) : null; }; }; UIMonitor.getUrlId = function(){ return { 'http://vacations.ego2.cn/booking/pkgdetail--pkg--11435---startcity--2.html': 1 //20081014 }[document.URL] || 0; }; UIMonitor.evts = {}; UIMonitor.evts_fired = {}; UIMonitor.register = function(key, fn){ if(fn){ this.evts[key] = fn; this.evts_fired[key] = 0; }else{ delete this.evts[key]; delete this.evts_fired[key]; } }; UIMonitor.trigger = function(key, arg){ if(!this.evts[key]) return; this.evts[key](arg); ++ this.evts_fired[key]; }; UIMonitor.m = {}; UIMonitor.m.GENERAL = { dataMap: { pageId: 'intA', prevPage: 'intB', sessionId: 'bigintA', urlId: 'bigintB', visitId: 'intC', userName: 'varchar32A', screenSize: 'varchar32B', userAgent: 'varchar8A', systemPlatform: 'varchar8B', stayTime: 'intD', footPrints: 'textA' }, getViewName: function(pageId){ /* 2009-1-4 return { 1: 'ui_www_main_ie', 2: 'ui_hotel_main_ie', 3: 'ui_flights', 4: 'ui_vacations_main_ie_2', 5: 'ui_flights_i' }[(pageId + '').charAt(0)]; */ return pageId >= 20 && pageId < 30 ? 'ui_hotel_main_ie' : null; }, initialize: function(){ this.clickArray = []; this.startTime = new Date(); this.monitorClick(); }, finalize: function(){ return { pageId: UIMonitor.pageId, prevPage: UIMonitor.getPrevPage(), sessionId: '@@sessionId', urlId: UIMonitor.urlId, visitId: UIMonitor.visitId, userName: '@@userName', screenSize: screen.width + 'x' + screen.height, userAgent: UIMonitor.getUserAgent(), systemPlatform: (navigator.platform.match(/mac|win|linux|nix/i) || ['other'])[0].toLowerCase(), stayTime: new Date() - this.startTime, footPrints: this.clickArray }; }, monitorClick: function(){ var allyesEl = null; var adjustX = $('pubGlobal_main'); var adjustY = $('pubGlobal_topAlert01'); var clickInterval = 500; var lastClick = 0; var dataArray = this.clickArray; document.documentElement.$r('mousedown', function(e){ var evt = e || window.event; var el = evt.srcElement || evt.target; if(el == document.documentElement) return; var newClick = new Date(); if(newClick - lastClick < clickInterval) return; lastClick = newClick; recordClick(el, evt); }); document.documentElement.$r('mouseover', function(e){ var evt = e || window.event; var el = evt.srcElement || evt.target; if(el.tagName == 'IFRAME'){ el = el.parentNode; if(el.getAttribute('mod') == 'allyes' && !el.allyesEd){ allyesEl = el; el.allyesEd = true; window.focus(); } } }); document.documentElement.$r('mouseout', function(){ allyesEl = null; }); window.$r('blur', function(){ if(allyesEl){ recordClick(allyesEl); allyesEl = null; } }); function recordClick(el, evt){ var a; //time, x, y, tag, id, parentTag, parentId var pl = el.parentNode || {}; if(evt){ a = [ new Date() - UIMonitor.startTime, evt.pageX || (evt.clientX + document.documentElement.scrollLeft) || 0, evt.pageY || evt.clientY + document.documentElement.scrollTop || 0, el.tagName, idex(el), pl.tagName, idex(pl) ]; }else{ if(!el.$getPos) Ctrip.Object.apply(el); var p = el.$getPos(); a = [ new Date() - UIMonitor.startTime, p[0] + Math.floor(Math.random() * el.offsetWidth), p[1] + Math.floor(Math.random() * el.offsetHeight), 'allyes', el.getAttribute('user') || el.getAttribute('mod_allyes_user') || '', '', '' ]; } if(adjustX) a[1] -= adjustX.offsetLeft; if(adjustY) a[2] -= adjustY.offsetHeight; dataArray.push(a); } function idex(el){ return el.href && el.href || el.id || el.name || el.className || ''; } } }; UIMonitor.m.HOTEL_QUERY = { dataMap: { pageId: 'intA', cityId: 'intB', priceLow: 'intC', priceHigh: 'intD', hotelName: 'varchar32A', complexQuery: 'varchar8A', hotelArea: 'varchar8B', hotelType: 'bigintA', hotelStar: 'bigintB', recId: 'varchar32B' }, getViewName: function(pageId){ return pageId >=20 && pageId <= 22 && $('txtCheckIn') ? 'ui_hotel_query_v2' : null; }, initialize: function(){ var me = this; UIMonitor.register('hotel_query', function(query){ var p = UIMonitor.pageId; var f = document.forms[0]; var t = p == 21 ? { pageId: p, cityId: query.cityId || query.districtId, priceLow: query.priceLow, priceHigh: query.priceHigh, hotelName: query.hotelName, complexQuery: '0', hotelArea: query.zoneId ? 'z' + query.zoneId : query.locationId ? 'l' + query.locationId : '', hotelType: '', hotelStar: '', recId: '@@mainId' } : { pageId: p, cityId: f.cityId.value || f.districtId.value, priceLow: f.priceLow.value, priceHigh: f.priceHigh.value, hotelName: f.hotelName.value, complexQuery: $('btnSimple') && $('btnSimple').offsetWidth ? '1' : '0', hotelArea: f.zoneId.value ? 'z' + f.zoneId.value : f.locationId.value ? 'l' + f.locationId.value : '', hotelType: f.hotelType.value, hotelStar: f.hotelStar.value, recId: '@@mainId' }; if(p == 20) t.cityId = ($('txtCity').isNull() ? '-' : '') + t.cityId; if(p == 21) new UIMonitor(UIMonitor.m.HOTEL_QUERY_V2); me.returnData = t; }); }, finalize: function(){ if(UIMonitor.pageId == 20 && document.forms[0].cityId.value) UIMonitor.trigger('hotel_query', null); return this.returnData; } }; UIMonitor.m.HOTEL_ERROR = { dataMap: { pageId: 'intA', sessionId: 'bigintA', recId: 'bigintB', alert: 'intB', checkinfo: 'intC', jserror: 'intD', detail: 'textA' }, getViewName: function(pageId){ return (pageId >= 20 && pageId <= 29) ? 'ui_hotel_error' : null; }, initialize: function(){ this.rec = []; this.cnt = { 'alert': 0, 'checkinfo': 0, 'jserror': 0 }; var f0 = window.alert; var f1 = function(s){f0(s)}; var f2 = window.$alert; var f3 = window.jserror || function(){}; window.alert = UIMonitor.wrapFn(f1, 'alert', this.rec, this.cnt); window.$alert = window.checkinfo = UIMonitor.wrapFn(f2, 'checkinfo', this.rec, this.cnt); window.onerror = UIMonitor.wrapFn(f3, 'jserror', this.rec, this.cnt); }, finalize: function(){ if(!this.cnt.alert && !this.cnt.checkinfo && !this.cnt.jserror) return null; return { pageId: UIMonitor.pageId, sessionId: '@@sessionId', recId: '@@mainId', alert: this.cnt.alert, checkinfo: this.cnt.checkinfo, jserror: this.cnt.jserror, detail: this.rec }; } }; UIMonitor.m.HOTEL_CHOICE = new function(){ var hotelList = null; return { dataMap: { pageId: 'intA', sessionId: 'bigintA', recId: 'bigintB', orderBy: 'varchar8A', orderType: 'varchar8B', page: 'intB', index: 'intC', hotel: 'intD' }, getViewName: function(pageId){ return (pageId == 21 || pageId == 25) ? 'ui_hotel_choice' : null; }, initialize: function(){ hotelList = $('htl_list'); if(UIMonitor.pageId == 21 && hotelList) hotelList.$r('click', hotelMousedown); }, finalize: function(){ if(UIMonitor.pageId != 25) return null; var obj = getCookie1() || ['', '', 0, 0, 0]; return { pageId: UIMonitor.pageId, sessionId: '@@sessionId', recId: '@@mainId', orderBy: obj[0], orderType: obj[1], page: obj[2], index: obj[3], hotel: obj[4] }; } }; function recHotelPos(el){ while(el.parentNode && el.parentNode != hotelList) el = el.parentNode; if(!el.parentNode) return; var cur = hotelList.firstChild; var index = 1; while(cur && cur != el){ cur = cur.nextSibling; ++ index; } if(cur == el){ var p = cur.getElementsByTagName('p'); for(var i = 0; i < p.length; i ++) if(p[i].className == 'hotel_room_showall') break; if(i >= p.length) return; var m = (p[i].onclick + '').match(/\d+(?=\))/); if(!m) return; setCookie1([HotelQuery.orderBy, HotelQuery.orderType.charAt(0), HotelQuery.page, index, m[0]]); } } function setCookie1(ar){ document.cookie = 'uig1=' + ar.join(','); } function getCookie1(){ var m = document.cookie.match(/(^| )uig1=([^;]+)/); if(!m) return null; return m[2].split(','); } function hotelMousedown(e){ var el = $event.fix(e).target; var flag = false; if(/orderHotel/.test(el.onclick + '') || /orderHotel/.test(el.href)){ flag = true; }else if(el.tagName == 'A'){ if(el.parentNode.tagName == 'H3') flag = true; if(/searchresult_abbrpic/.test(el.className)) flag = true; } if(flag){ try{recHotelPos(el);}catch(e){} } } }; $r('domready', function(){ for(var s in UIMonitor.m) if(UIMonitor.m.hasOwnProperty(s)) new UIMonitor(UIMonitor.m[s]); }); //2009-01-08, xhzhou window.$r('domready', function(){ ['ctl00_ctl00_lblCrpName', 'ctl00_ctl01_lblCrpName', 'ctl00_ctl02_lblCrpName'].each(function(id){ var el = $(id); if(el) with(el.style){ fontFamily = 'arial'; fontSize = '18pt'; fontWeight = 'bold'; lineHeight = '120%'; } }); });