Skip to content

Instantly share code, notes, and snippets.

View naoyeye's full-sized avatar
🦾

J.Y Han naoyeye

🦾
View GitHub Profile
var minisiteUrl = 'http://www.wandoujia.com/campaign/pizzahut/';
var UTM = {
'weibo': '?utm_source=weibo&utm_medium=sns&utm_campaign=pizzahut',
'wechatFriend': '?utm_source=wechatFriend&utm_medium=sns&utm_campaign=pizzahut',
'wechatTimeline': '?utm_source=wechatTimeline&utm_medium=sns&utm_campaign=pizzahut',
// 扫描站内二维码的回流
'qrcode': '?utm_source=qrcode&utm_medium=minisite&utm_campaign=pizzahut'
};
/*
* @Author: @schumilin
* @Date: 2015-01-28 14:20:50
* @Last Modified by: midare
* @Last Modified time: 2015-05-19 13:49:55
*/
/*global $, jQuery, ga, _gaq*/
/* jshint ignore:start */
// <script src="/javascripts/www/campaign/jquery-1.11.1.min.js"></script>
// <script src="/components/underscore/underscore-min.js"></script>
// <script src="/components/fastclick/lib/fastclick.js"></script>
// <script src="/components/history.js/scripts/bundled-uncompressed/html4+html5/jquery.history.js"></script>
// <script src="/components/velocity/velocity.min.js"></script>
// <script src="/components/velocity/velocity.ui.min.js"></script>
// <script src="/javascripts/www/campaign/avos.min.js"></script>
// <script src="/javascripts/www/jweixin-1.0.0.js"></script>
// <script src="/javascripts/www/campaign/scrollTo.min.js"></script>
@naoyeye
naoyeye / moment.js
Created March 31, 2015 08:45
时间转换
function moment(timestamp) {
var dateTarget = new Date(timestamp.replace(/-/g, '/')); // fix for iOS e.g: http://stackoverflow.com/questions/5324178/javascript-date-parsing-on-iphone
var dateCurrent = new Date();
var textMinute = dateTarget.getMinutes();
var textHour = dateTarget.getHours();
if (textMinute < 10) {
textMinute = '0' + dateTarget.getMinutes();
}
@naoyeye
naoyeye / wechatShare.js
Created February 26, 2015 06:55
微信 js sdk 分享
function wechatShareSetup() {
$.ajax({
url: 问我,
type: 'POST',
data: {
// url: 'http://www.wandoujia.com/campaign/spring2015/?utm_source=wechat&utm_medium=sns&utm_campaign=spring2015'
url: location.href.split('#')[0] // 将当前URL地址上传至服务器用于产生数字签名
}
}).done(function (r) {
// 返回了数字签名对象
@naoyeye
naoyeye / device.js
Created February 12, 2015 08:34
判断是不是在淘宝中、是不是在虾米中、是不是在微博中、是不是在微信中
var j = window.navigator.userAgent;
var g = {
android: j.match(/(Android);?[\s\/]+([\d.]+)?/),
iphone: j.match(/(iPhone\sOS)\s([\d_]+)/)
};
var d = {
aliapp: j.match(/\AliApp\(([^\/]+)\/([\d\.\w]+)\)/),
xiami: j.match(/(AliApp)\((XM)\/([0-9.]+)\)*/),
weibo: j.match(/.*?(weibo\_\_([0-9.]+))\s*/),
weixin: j.match(/.*?(MicroMessenger\/([0-9.]+))\s*/)
@naoyeye
naoyeye / isPC.js
Created January 22, 2015 11:12
判断是否是 PC
var ispc = false;
(function(){
var SUA = navigator.userAgent, SUA_OF = function(s){return SUA.indexOf(s) > -1};
if (SUA_OF('Android') && SUA_OF('Mobile') || SUA_OF('iPhone') || SUA_OF('iPod') || SUA_OF('Symbian') || SUA_OF('IEMobile')){
}else{
ispc = true;
}
})();
@naoyeye
naoyeye / P4.js
Last active August 29, 2015 14:11
P4 webview 相关接口的代码片段参考
/*
* @Author: [email protected]
* @Date: 2014-12-17 19:50:08
* @Last Modified by: [email protected]
* @Last Modified time: 2014-12-17 20:04:19
*/
// 判断是不是在 P4 中
if (window.campaignPlugin) {
// 微博分享
trackEvent({category: 'movie2014', action: 'share', label: 'weibo'});
// 微信好友分享
trackEvent({category: 'movie2014', action: 'share', label: 'wechat-friend'});
// 微信朋友圈分享
trackEvent({category: 'movie2014', action: 'share', label: 'wechat-timeline'});
// 每个电影点击喜欢的 的数据
@naoyeye
naoyeye / ga.js
Created December 3, 2014 11:55
GA 事件跟踪代码
// GA 统计
var trackEvent = function (opt) {
if (typeof ga !== 'undefined' && ga) {
var _act, _cat, _lbl, _val;
if (opt) {
_cat = opt.category || '';
_act = opt.action || '';
_lbl = opt.label || '';
_val = opt.value || 0;
return ga('send', 'event', _cat, _act, _lbl, _val);