Commit 809b0371b10e9b8a9c20cfb8e31141cbd001936b

Authored by dlstatic
0 parents

Init commit.

README.md 0 → 100644
  1 +++ a/README.md
  1 +#Data Piwik Static Source.
  2 +There is piwik common javascript directory.
nong12Piwik.js 0 → 100644
  1 +++ a/nong12Piwik.js
  1 +/*
  2 + * 每个站点一个js,每个站点的siteId不一样
  3 + */
  4 +
  5 +var _paq = _paq || [];
  6 +$(function(){
  7 +
  8 + jQuery.ajax({
  9 + type : "GET",
  10 + url : "https://passport.nong12.com/uc/ws/helloService",
  11 + dataType : "jsonp",
  12 + cache:false,
  13 + success : function(data) {
  14 + if (data) {
  15 + if(data.info.indexOf("logout") > 0) {
  16 + _paq.push(['setCustomVariable',1,"UserName",$(data.info).find("#uname").html(),"visit"]);
  17 + } else {
  18 + _paq.push(['setCustomVariable',1,"UserName","","visit"]);
  19 + }
  20 + }
  21 + _paq.push(['trackPageView']);
  22 + _paq.push(['enableLinkTracking']);
  23 + },
  24 + error : function() {
  25 + return false;
  26 + }
  27 + });
  28 +});
  29 +
  30 +$(function(){
  31 + $("body").on('click','a[data-gpi-anchor-id]',function(){
  32 + var url = $(this).attr('href');
  33 + var gpi = getFullGpi(this);
  34 + if(/^((https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6}))?([\/\w \.-]*)*\/?(\?.*)?$/.test(url)){
  35 + var reg = /gpi=[^&]*/;
  36 + if(url.indexOf('?') != -1){
  37 + if(reg.test(url)){
  38 + url = url.replace(reg,'gpi='+gpi);
  39 + }else{
  40 + url = url.replace('\?','?gpi='+gpi+'&' );
  41 + }
  42 + }else{
  43 + url = url + "?gpi=" + gpi ;
  44 + }
  45 + $(this).attr('href',url);
  46 + }
  47 + _paq.push(['trackEvent',gpi,'Clicked','TestClick',1]);
  48 + });
  49 +});
  50 +
  51 +$(function(){
  52 + $("body").on('click','input[data-gpi-anchor-id]',function(){
  53 + var gpi = getFullGpi(this);
  54 + _paq.push(['trackEvent',gpi,'Clicked','TestClick',1]);
  55 +
  56 + });
  57 +});
  58 +
  59 +$(function(){
  60 + $("body").on('click','button[data-gpi-anchor-id]',function(){
  61 + var gpi = getFullGpi(this);
  62 + _paq.push(['trackEvent',gpi,'Clicked','TestClick',1]);
  63 + });
  64 +});
  65 +
  66 +function getFullGpi(dom){
  67 + var $dom = $(dom);
  68 + var gpi = $dom.attr('data-gpi');
  69 + var extGpiReg = /^[A-Z]+$/;
  70 + var fullGpi = [];
  71 + // var sysGpi = document.getElementsByTagName('meta')['data-gpi'].content;
  72 + var sysGpi = $.trim($('meta[name=data-gpi]').attr('content'));
  73 + var pageGpi = $dom.parents('body').attr('data-gpi');
  74 + fullGpi.push(sysGpi);
  75 + fullGpi.push(pageGpi);
  76 + if(extGpiReg.test(gpi)){
  77 + fullGpi.push($dom.parents('[data-gpi]').eq(1).attr('data-gpi'));
  78 + }
  79 + fullGpi.push($dom.parents('[data-gpi]').eq(0).attr('data-gpi'));
  80 + fullGpi.push(gpi);
  81 + return fullGpi.join('.');
  82 +}
  83 +
  84 +(function() {
  85 + var u=(("https:" == document.location.protocol) ? "https" : "http") + "://dltj.nong12.com/";
  86 + _paq.push(['setTrackerUrl', u+'piwik.php']);
  87 + //var siteId = parseInt(document.getElementsByTagName('meta')['data-gpi'].content);
  88 + _paq.push(['setSiteId', 2]);
  89 + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
  90 + g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  91 +})();
piwik_app.js 0 → 100644
  1 +++ a/piwik_app.js
  1 +/*
  2 + * 每个站点一个js,每个站点的siteId不一样
  3 + */
  4 +
  5 +var _paq = _paq || [];
  6 +$(function(){
  7 + _paq.push(['trackPageView']);
  8 + _paq.push(['enableLinkTracking']);
  9 +});
  10 +
  11 +$(function(){
  12 + $(document).on('click','a[data-gpi-anchor-id]',function(){
  13 + var url = $(this).attr('href');
  14 + var gpi = getFullGpi(this);
  15 + if(/^((https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6}))?([\/\w \.-]*)*\/?(\?.*)?$/.test(url)){
  16 + var reg = /gpi=[^&]*/;
  17 + if(url.indexOf('?') != -1){
  18 + if(reg.test(url)){
  19 + url = url.replace(reg,'gpi='+gpi);
  20 + }else{
  21 + url = url.replace('\?','?gpi='+gpi+'&' );
  22 + }
  23 + }else{
  24 + url = url + "?gpi=" + gpi ;
  25 + }
  26 + $(this).attr('href',url);
  27 + }
  28 + _paq.push(['trackEvent',gpi,'Clicked','TestClick',1]);
  29 + });
  30 +});
  31 +
  32 +$(function(){
  33 + $(document).on('click','input[data-gpi-anchor-id]',function(){
  34 + var gpi = getFullGpi(this);
  35 + _paq.push(['trackEvent',gpi,'Clicked','TestClick',1]);
  36 +
  37 + });
  38 +});
  39 +
  40 +$(function(){
  41 + $(document).on('click','button[data-gpi-anchor-id]',function(){
  42 + var gpi = getFullGpi(this);
  43 + _paq.push(['trackEvent',gpi,'Clicked','TestClick',1]);
  44 + });
  45 +});
  46 +
  47 +function getFullGpi(dom){
  48 + var $dom = $(dom);
  49 + var gpi = $dom.attr('data-gpi');
  50 + var extGpiReg = /^[A-Z]+$/;
  51 + var fullGpi = [];
  52 + // var sysGpi = document.getElementsByTagName('meta')['data-gpi'].content;
  53 + var sysGpi = $.trim($('meta[name=data-gpi]').attr('content'));
  54 + var pageGpi = $dom.parents('body').attr('data-gpi');
  55 + fullGpi.push(sysGpi);
  56 + fullGpi.push(pageGpi);
  57 + if(extGpiReg.test(gpi)){
  58 + fullGpi.push($dom.parents('[data-gpi]').eq(1).attr('data-gpi'));
  59 + }
  60 + fullGpi.push($dom.parents('[data-gpi]').eq(0).attr('data-gpi'));
  61 + fullGpi.push(gpi);
  62 + return fullGpi.join('.');
  63 +}
  64 +
  65 +(function() {
  66 + var u=(("https:" == document.location.protocol) ? "https" : "http") + "://dltj.nong12.com/";
  67 + _paq.push(['setTrackerUrl', u+'piwik.php']);
  68 + //var siteId = parseInt(document.getElementsByTagName('meta')['data-gpi'].content);
  69 + _paq.push(['setSiteId', 2]);
  70 + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
  71 + g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  72 +})();
piwik_wap.js 0 → 100644
  1 +++ a/piwik_wap.js
  1 +/*
  2 + * for single page
  3 + */
  4 +var _paq = _paq || [];
  5 +window._paq = _paq;
  6 +$(function() {
  7 + _paq.push(['enableLinkTracking']);
  8 + //remove last events
  9 + $(document).off('click.gpi');
  10 + $(document).on('click.gpi', 'a[data-gpi-anchor-id]', function() {
  11 + var url = $(this).attr('href');
  12 + // var url = $.mobile.path.getLocation();
  13 + var gpi = getFullGpi(this);
  14 + if (/^((https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6}))?([\/\w \.-]*)*\/?(\?.*)?$/.test(url)) {
  15 + var reg = /gpi=[^&]*/;
  16 + if (url.indexOf('?') != -1) {
  17 + if (reg.test(url)) {
  18 + url = url.replace(reg, 'gpi=' + gpi);
  19 + } else {
  20 + url = url.replace('\?', '?gpi=' + gpi + '&');
  21 + }
  22 + } else {
  23 + url = url + "?gpi=" + gpi;
  24 + }
  25 + $(this).attr('href', url);
  26 + }
  27 + _paq.push(['trackEvent', gpi, 'Clicked', 'TestClick', 1]);
  28 + console.log(_paq);
  29 + }).on('click.gpi', 'input[data-gpi-anchor-id]', function() {
  30 + var gpi = getFullGpi(this);
  31 + _paq.push(['trackEvent', gpi, 'Clicked', 'TestClick', 1]);
  32 + console.log(_paq);
  33 + }).on('click.gpi', 'button[data-gpi-anchor-id]', function() {
  34 + var gpi = getFullGpi(this);
  35 + _paq.push(['trackEvent', gpi, 'Clicked', 'TestClick', 1]);
  36 + console.log(_paq);
  37 + });
  38 +});
  39 +
  40 +function getFullGpi(dom) {
  41 + var $dom = $(dom);
  42 + var gpi = $dom.attr('data-gpi');
  43 + var extGpiReg = /^[A-Z]+$/;
  44 + var fullGpi = [];
  45 + // var sysGpi = document.getElementsByTagName('meta')['data-gpi'].content;
  46 + var sysGpi = $.trim($('meta[name=data-gpi]').attr('content'));
  47 + var pageGpi = $dom.parents('body').attr('data-gpi');
  48 + fullGpi.push(sysGpi);
  49 + fullGpi.push(pageGpi);
  50 + if (extGpiReg.test(gpi)) {
  51 + fullGpi.push($dom.parents('[data-gpi]').eq(1).attr('data-gpi'));
  52 + }
  53 + fullGpi.push($dom.parents('[data-gpi]').eq(0).attr('data-gpi'));
  54 + fullGpi.push(gpi);
  55 + return fullGpi.join('.');
  56 +}
  57 +
  58 +(function() {
  59 + var u = (("https:" == document.location.protocol) ? "https" : "http") + "://dltj.nong12.com/";
  60 + _paq.push(['setTrackerUrl', u + 'piwik.php']);
  61 + //var siteId = parseInt(document.getElementsByTagName('meta')['data-gpi'].content);
  62 + _paq.push(['setSiteId', 4]);
  63 + var d = document,
  64 + g = d.createElement('script'),
  65 + s = d.getElementsByClassName('ui-page-active')[0];
  66 + s = d.getElementsByTagName('script')[0];
  67 + g.type = 'text/javascript';
  68 + g.defer = true;
  69 + g.async = true;
  70 + g.src = u + 'piwik.js';
  71 + // s.appendChild(g);
  72 + s.parentNode.insertBefore(g, s);
  73 +})();
piwik_wap.min.js 0 → 100644
  1 +++ a/piwik_wap.min.js
  1 +function getFullGpi(t){var a=$(t),e=a.attr("data-gpi"),i=/^[A-Z]+$/,p=[],n=document.getElementsByTagName("meta")["data-gpi"].content,c=a.parents("body").attr("data-gpi");return p.push(n),p.push(c),i.test(e)&&p.push(a.parents("[data-gpi]").eq(1).attr("data-gpi")),p.push(a.parents("[data-gpi]").eq(0).attr("data-gpi")),p.push(e),p.join(".")}var _paq=_paq||[];$(function(){_paq.push(["enableLinkTracking"]),$("body").off("click.gpi"),$("body").on("click.gpi","a[data-gpi-anchor-id]",function(){var t=$(this).attr("href"),a=getFullGpi(this);if(/^((https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6}))?([\/\w \.-]*)*\/?(\?.*)?$/.test(t)){var e=/gpi=[^&]*/;t=-1!=t.indexOf("?")?e.test(t)?t.replace(e,"gpi="+a):t.replace("?","?gpi="+a+"&"):t+"?gpi="+a,$(this).attr("href",t)}_paq.push(["trackEvent",a,"Clicked","TestClick",1])}).on("click.gpi","input[data-gpi-anchor-id]",function(){var t=getFullGpi(this);_paq.push(["trackEvent",t,"Clicked","TestClick",1])}).on("click.gpi","button[data-gpi-anchor-id]",function(){var t=getFullGpi(this);_paq.push(["trackEvent",t,"Clicked","TestClick",1])})}),function(){var t=("https:"==document.location.protocol?"https":"http")+"://dltj.nong12.com/";_paq.push(["setTrackerUrl",t+"piwik.php"]),_paq.push(["setSiteId",4]);var a=document,e=a.createElement("script"),i=a.getElementsByClassName("ui-page-active")[0];i=a.getElementsByTagName("script")[0],e.type="text/javascript",e.defer=!0,e.async=!0,e.src=t+"piwik.js",i.parentNode.insertBefore(e,i)}();
0 \ No newline at end of file 2 \ No newline at end of file