uclick.js 4.03 KB
$(function(){
	function query(ele){
        if( document.querySelector === undefined && window.jQuery){
            return jQuery(ele);
        }else{
            return document.querySelector(ele);
        }
		
	}
	if(query(".u-sc")){
		query(".u-sc").onclick = function(){
		var aa = document.getElementById("uname");
                        if (aa == null) {
                                _paq.push(['setCustomVariable',1,"UserName","","visit"]);
                        }else{
                                _paq.push(['setCustomVariable',1,"UserName",aa.innerHTML,"visit"]);
                }
		var clickname = this.title;
		var pid = query("#pid").value || query("#pid").val();
		var result = clickname + ":" + pid;
		_paq.push(['trackEvent','UserClick',clickname,result,1]);
		}
	}

	if(query(".m-p-header li[val='0']")){
		query(".m-p-header li[val='0']").onclick = function (){
		var aa = document.getElementById("uname");
                        if (aa == null) {
                                _paq.push(['setCustomVariable',1,"UserName","","visit"]);
                        }else{
                                _paq.push(['setCustomVariable',1,"UserName",aa.innerHTML,"visit"]);
                }
		var clickname = this.innerHTML;
		var pid = query("#pid").value || query("#pid").val();
		var result = clickname + ":" + pid;
		 _paq.push(['trackEvent','UserClick',clickname,result,1]);
		}		
	}

	if(query(".m-p-header li[val='1']")){
		query(".m-p-header li[val='1']").onclick = function (){
		var aa = document.getElementById("uname");
                        if (aa == null) {
                                _paq.push(['setCustomVariable',1,"UserName","","visit"]);
                        }else{
                                _paq.push(['setCustomVariable',1,"UserName",aa.innerHTML,"visit"]);
                }
                var clickname = this.innerHTML;
                var pid = query("#pid").value || query("#pid").val();
                var result = clickname + ":" + pid;
                 _paq.push(['trackEvent','UserClick',clickname,result,1]);
        }
	}

	if(query(".m-p-header li[val='2']")){
		query(".m-p-header li[val='2']").onclick = function (){
		var aa = document.getElementById("uname");
                        if (aa == null) {
                                _paq.push(['setCustomVariable',1,"UserName","","visit"]);
                        }else{
                                _paq.push(['setCustomVariable',1,"UserName",aa.innerHTML,"visit"]);
                }
                var clickname = this.innerHTML;
                var pid = query("#pid").value || query("#pid").val();
                var result = clickname + ":" + pid;
                 _paq.push(['trackEvent','UserClick',clickname,result,1]);
        }
	}

	if(query(".doact .btn-big-r")){
		query(".doact .btn-big-r").onclick = function (){
		var aa = document.getElementById("uname");
                        if (aa == null) {
                                _paq.push(['setCustomVariable',1,"UserName","","visit"]);
                        }else{
                                _paq.push(['setCustomVariable',1,"UserName",aa.innerHTML,"visit"]);
                }
                var clickname = this.innerHTML;
                var pid = query("#pid").value || query("#pid").val();
                var result = clickname + ":" + pid;
                 _paq.push(['trackEvent','UserClick',clickname,result,1]);
        }
	}
	
	if(query(".doact .btn-big-y")){
		query(".doact .btn-big-y").onclick = function (){
		var aa = document.getElementById("uname");
                        if (aa == null) {
                                _paq.push(['setCustomVariable',1,"UserName","","visit"]);
                        }else{
                                _paq.push(['setCustomVariable',1,"UserName",aa.innerHTML,"visit"]);
                }
                var clickname = this.innerHTML;
                var pid = query("#pid").value || query("#pid").val();
                var result = clickname + ":" + pid;
                 _paq.push(['trackEvent','UserClick',clickname,result,1]);
        }
	}
});