Skip to content

Commit

Permalink
feat:添加来源信息
Browse files Browse the repository at this point in the history
  • Loading branch information
shaobeichen committed Jun 25, 2018
1 parent dc8f9b9 commit 3390de2
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@
})();
</script>
<script async src="http://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js" type="text/javascript"></script>

<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script src="static/bmob-min.js"></script>
<script src="static/bmob-info.js"></script>

</body>
</html>
67 changes: 67 additions & 0 deletions static/bmob-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
function getBrowserInfo() {
var agent = navigator.userAgent.toLowerCase();
var arr = [];
var system = agent.split(' ')[1].split(' ')[0].split('(')[1];
arr.push(system);
var regStr_edge = /edge\/[\d.]+/gi;
var regStr_ie = /trident\/[\d.]+/gi;
var regStr_ff = /firefox\/[\d.]+/gi;
var regStr_chrome = /chrome\/[\d.]+/gi;
var regStr_saf = /safari\/[\d.]+/gi;
var regStr_opera = /opr\/[\d.]+/gi;
//IE
if (agent.indexOf("trident") > 0) {
arr.push(agent.match(regStr_ie)[0].split('/')[0]);
arr.push(agent.match(regStr_ie)[0].split('/')[1]);
return arr;
}
//Edge
if (agent.indexOf('edge') > 0) {
arr.push(agent.match(regStr_edge)[0].split('/')[0]);
arr.push(agent.match(regStr_edge)[0].split('/')[1]);
return arr;
}
//firefox
if (agent.indexOf("firefox") > 0) {
arr.push(agent.match(regStr_ff)[0].split('/')[0]);
arr.push(agent.match(regStr_ff)[0].split('/')[1]);
return arr;
}
//Opera
if (agent.indexOf("opr") > 0) {
arr.push(agent.match(regStr_opera)[0].split('/')[0]);
arr.push(agent.match(regStr_opera)[0].split('/')[1]);
return arr;
}
//Safari
if (agent.indexOf("safari") > 0 && agent.indexOf("chrome") < 0) {
arr.push(agent.match(regStr_saf)[0].split('/')[0]);
arr.push(agent.match(regStr_saf)[0].split('/')[1]);
return arr;
}
//Chrome
if (agent.indexOf("chrome") > 0) {
arr.push(agent.match(regStr_chrome)[0].split('/')[0]);
arr.push(agent.match(regStr_chrome)[0].split('/')[1]);
return arr;
} else {
arr.push('请更换主流浏览器,例如chrome,firefox,opera,safari,IE,Edge!')
return arr;
}
}

Bmob.initialize("d19fc452ebff91c7997a4ef3f3e7e7d8", "fee019e3f8acfb4ac43f9c22c4b74917");
var GameScore = Bmob.Object.extend("GameScore");
var gameScore = new GameScore();
gameScore.set("sourcePage", window.location.href);
gameScore.set("cip", returnCitySN["cip"]);
gameScore.set("cname", returnCitySN["cname"]);
gameScore.set("system", getBrowserInfo()[0]);
gameScore.set("browse", getBrowserInfo()[1]);
gameScore.set("browseNum", getBrowserInfo()[2]);
gameScore.save(null, {
success: function (gameScore) {
},
error: function (gameScore, error) {
}
});
11 changes: 11 additions & 0 deletions static/bmob-min.js

Large diffs are not rendered by default.

0 comments on commit 3390de2

Please sign in to comment.