fd-gulp-convert-encoding
Version:
convert file to assigned charset
270 lines (256 loc) • 7.25 kB
JavaScript
/**
* @overview:���utility��
*
* @author: dongming.jidm
* @date: 2012-12-11
*/
!(function($) {
$.extend(Qingguo.Utility,{
/**
* �������
* @method aliclick
* @param {HTMLElement} u
* @param {String} param ������,ע:
*/
aliclick:function(u, param){
if(typeof window.dmtrack!="undefined"){
setTimeout(function(){dmtrack.clickstat("http://stat.1688.com/search/queryreport.html",param);}, 10);
}else{
if (document.images)
(new Image()).src = "http://stat.1688.com/search/queryreport.html" + param + "&time=" + (+new Date);
}
return true;
},
/**
* p4p�۷Ѻ���
* @param {String} url
* @param {Boolean} type ע:����ǰ�������,���ڷ�IE�²��۷�
*/
p4pClick:function(url, type) {
var d = new Date;
if (document.images &&(!arguments[1] || arguments[1] && $.browser.msie)){
(new Image).src = url + "&j=1&time=" + d.getTime();
}
return true;
},
/**
* �������
* @method statAdClick
* @param {HTMLElement} u
* @param {String} param ������
*/
statAdClick:function(u, param){
if(typeof window.dmtrack!="undefined"){
dmtrack.clickstat("http://stat.1688.com/ad.html",param);
}else{
if (document.images)
(new Image()).src = "http://stat.1688.com/ad.html" + param + "&time=" + (+new Date);
}
return true;
},
/*�ع���*/
exposureClick:function(sectionexp){
if(typeof window.dmtrack!="undefined"){
dmtrack.clickstat("http://stat.1688.com/sectionexp.html",('?sectionexp='+sectionexp));
}else{
if (document.images){
(new Image).src="http://stat.1688.com/sectionexp.html?sectionexp="+sectionexp+"&time="+(+new Date);
}
}
},
/*�ع���*/
exposureClickKeyValue:function(keyvaluepair){
if(typeof window.dmtrack!="undefined"){
dmtrack.clickstat("http://stat.1688.com/sectionexp.html",('?'+keyvaluepair));
}else{
if (document.images){
(new Image).src="http://stat.1688.com/sectionexp.html?"+keyvaluepair+"&time="+(+new Date);
}
}
},
/**
* ���
* @param {Object} o
*/
traceEnquiryClick:function(o){
var fromId = '',params = [];
fromId = FE.util.LastLoginId();
if(fromId!=''){
params.push('?fromId='+fromId);
params.push('toId='+(o.toId||''));
params.push('offerId='+(o.offerId||''));
params.push('source='+(o.source||1));
params.push('cna='+(this.getCookie('cna')||''));
var offerUrl = '';
if(o.offerId&&o.offerId!=''){
offerUrl = 'http://detail.1688.com/buyer/offerdetail/'+o.offerId+'.html';
}
params.push('sourceUrl='+offerUrl);
if(typeof window.dmtrack!="undefined"){
dmtrack.clickstat("http://interface.xp.1688.com/eq/enquiry/traceEnquiry.json",params.join('&'));
}else{
d = new Date();
if(document.images) {
(new Image()).src="http://interface.xp.1688.com/eq/enquiry/traceEnquiry.json" + params.join('&') + "&time=" + d.getTime();
}
}
return true;
}
},
/**
* ��ȡcookie
* @method getCookie
* @public
* @param {String} name cookie������
*/
getCookie:function(name) {
var value = document.cookie.match('(?:^|;)\\s*'+name+'=([^;]*)');
return value ? unescape(value[1]): '';
},
/**
* ����cookie
* @method addCookie
* @puiblic
* @param {String} name cookie������
* @param {String} v cookie��value
* @param {String} domainName
*/
addCookie:function(name,v,domainName){
var expDate = new Date,sevenDay=604800000;
expDate=new Date(expDate.getTime() +sevenDay);
document.cookie = name + ("=" + escape(v) + ";expires=" + expDate.toGMTString() + ";path=/;" + "domain=" + domainName);
},
/**
* ��ȡǰ��ָ��cookie������(alicnweb)��ֵ
* eg:
* alicnweb=firstv=1|a=2
* @method getFDCookie
* @param {String} name
*/
getFDCookie:function(name){
var alicnweb = this.getCookie("alicnweb");
var reg = new RegExp("(^|)"+ name +"=([^|]*)", "i");
if(reg.test(alicnweb)) {
return unescape(RegExp.$2.replace(/\+/g, " "));
}
return "";
},
/**
* ����ǰ��ָ��cookie������(alicnweb)��ֵ
* @param {String} name
* @param {String|int|Boolean} v
*/
setFDCookie:function(name,v){
var alicnweb = this.getCookie('alicnweb');
var index0 = alicnweb.indexOf(name);
if(index0 == -1){
alicnweb+=(name+'='+v+'|');
this.addCookie('alicnweb',alicnweb,'.china.alibaba.com');
}else{
var index1 = alicnweb.indexOf('|',index0);
var str0 = alicnweb.substring(0,index0);
var str1 = alicnweb.substring(index1);
alicnweb = str0 + name + '=' + v + str1;
this.addCookie('alicnweb',alicnweb,'.china.alibaba.com');
}
},
getSWCookie:function(name){
var alisw = this.getCookie("alisw");
var reg = new RegExp("(^|)"+ name +"=([^|]*)", "i");
if(reg.test(alisw)) {
return unescape(RegExp.$2.replace(/\+/g, " "));
}
return "";
},
setSWCookie:function(name,v){
var alisw = this.getCookie('alisw');
var index0 = alisw.indexOf(name);
if(index0 == -1){
alisw+=(name+'='+v+'|');
this.addCookie('alisw',alisw,'s.1688.com');
}else{
var index1 = alisw.indexOf('|',index0);
var str0 = alisw.substring(0,index0);
var str1 = alisw.substring(index1);
alisw = str0 + name + '=' + v + str1;
this.addCookie('alisw',alisw,'s.1688.com');
}
},
/**
* ��ȡmemberId
* @method getMemberId
*/
getMemberId:function(){
var name = 'last_mid';
var value = document.cookie.match('(?:^|;)\\s*'+name+'=([^;]*)');
return value ? decodeURIComponent(value[1]): '';
},
/**
* ��ȡpageId
* @method getSearchPageId
*/
getSearchPageId:function(){
return typeof window.dmtrack_pageid=='undefined' ? -1 : dmtrack_pageid;
},
/**
* ͳһ���첽JSON_VIEW�ӿ�������
* @method getJsonp
*/
getJsonView:function(url,o){
$.ajax(url, {
data: o.data,
dataType: 'jsonp',
success: function(data){
if(data.error!=='0'){
return ;
}else{
o.success(data.result);
}
},
error: function(){
o.error();
}
});
},
/**
* ͳһ���첽JSONP������
* @method getJsonp
*/
getRPCJsonp:function(url,o){
$.ajax(url, {
data: o.data,
dataType: 'jsonp',
success: function(data){
if(data.hasError){
return;
}else{
o.success(data.content);
}
},
error: function(infor){
o.error();
}
});
},
renderHTML:function(template,data,node){
$.use('web-sweet', function(){
var html = FE.util.sweet(template).applyData(data);
node.html(html);
});
},
//ȥ���ظ���
uniqueMerge:function(des,a){
for(var i=0;i<a.length;i++){
for(var j=0,len=des.length;j<len;j++){
if(a[i] === des[j]){
des.splice(j,1);
break;
}
}
}
},
end:0
});
/*Ϊ������ʷ���룬��ʱ����ȫ�ֺ���*/
window.aliclick = Qingguo.Utility.aliclick;
})(jQuery);