Skip to content

Commit cd1a751

Browse files
committed
Замена табов на пробелы в исходнике
1 parent 7d326d2 commit cd1a751

1 file changed

Lines changed: 103 additions & 103 deletions

File tree

yametrika.js

Lines changed: 103 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88
(function () {
99
'use strict';
1010

11-
var HOST = 'mc.yandex.ru';
12-
var PATH = '/watch/';
13-
var PORT = 80;
11+
var HOST = 'mc.yandex.ru';
12+
var PATH = '/watch/';
13+
var PORT = 80;
1414

15-
var querystring = require('querystring');
16-
var http = require('http');
15+
var querystring = require('querystring');
16+
var http = require('http');
1717

1818
/**
1919
* Конструктор счётчика Метрики
2020
* @constructor
2121
*
2222
* @param {Object} settings - настройки счётчика
2323
*/
24-
var Counter = function (settings) {
24+
var Counter = function (settings) {
2525
// Номер счётчика
26-
this._id = settings.id;
26+
this._id = settings.id;
2727

2828
// Тип счётчика: 0 - обычный счётчик, 1 - РСЯ-счётчик
29-
this._type = settings.type || 0;
29+
this._type = settings.type || 0;
3030

31-
this._encoding = settings.encoding || 'utf-8';
31+
this._encoding = settings.encoding || 'utf-8';
3232

3333
this._request = {
3434
host: null,
@@ -37,9 +37,9 @@
3737
'user-agent': null,
3838
ip: null
3939
};
40-
};
40+
};
4141

42-
Counter.prototype = {
42+
Counter.prototype = {
4343
/**
4444
* Отправка хита
4545
*
@@ -53,7 +53,7 @@
5353
* @example
5454
* counter.hit('http://mysite.org', 'Main page', 'http://google.com/...');
5555
*/
56-
hit: function (pageUrl, pageTitle, pageRef, userParams, ut) {
56+
hit: function (pageUrl, pageTitle, pageRef, userParams, ut) {
5757
if (!pageUrl) {
5858
pageUrl = this._request.url;
5959
}
@@ -65,7 +65,7 @@
6565
this._hitExt(pageUrl, pageTitle, pageRef, userParams, {ut: ut});
6666

6767
return this;
68-
},
68+
},
6969
/**
7070
* Достижение цели
7171
*
@@ -75,17 +75,17 @@
7575
* @example
7676
* counter.reachGoal('goalName');
7777
*/
78-
reachGoal: function (target, userParams) {
79-
var referer;
80-
if (target) {
81-
target = 'goal://' + this._request.host + '/' + target;
82-
referer = this._request.url;
83-
} else {
84-
target = this._request.url;
85-
referer = this._request.referer;
86-
}
87-
88-
this._hitExt(target, null, referer, userParams, null);
78+
reachGoal: function (target, userParams) {
79+
var referer;
80+
if (target) {
81+
target = 'goal://' + this._request.host + '/' + target;
82+
referer = this._request.url;
83+
} else {
84+
target = this._request.url;
85+
referer = this._request.referer;
86+
}
87+
88+
this._hitExt(target, null, referer, userParams, null);
8989

9090
return this;
9191
},
@@ -99,16 +99,16 @@
9999
* @example
100100
* counter.extLink('http://nodejs.org');
101101
*/
102-
extLink: function (url, title) {
103-
if (url) {
104-
this._hitExt(url, title, this._request.url, null, {
105-
ln: true,
106-
ut: 'noindex'
107-
});
108-
}
102+
extLink: function (url, title) {
103+
if (url) {
104+
this._hitExt(url, title, this._request.url, null, {
105+
ln: true,
106+
ut: 'noindex'
107+
});
108+
}
109109

110110
return this;
111-
},
111+
},
112112
/**
113113
* Загрузка файла
114114
*
@@ -119,16 +119,16 @@
119119
* @example
120120
* counter.file('http://mysite.org/secret.zip');
121121
*/
122-
file: function (file, title) {
123-
if (file) {
124-
this._hitExt(file, title, this._request.url, null, {
125-
dl: true,
126-
ln: true
127-
});
128-
}
122+
file: function (file, title) {
123+
if (file) {
124+
this._hitExt(file, title, this._request.url, null, {
125+
dl: true,
126+
ln: true
127+
});
128+
}
129129

130130
return this;
131-
},
131+
},
132132
/**
133133
* Параметры визитов
134134
*
@@ -140,7 +140,7 @@
140140
* или
141141
* counter.params('level1', 'level2', 'level3', 1);
142142
*/
143-
params: function (data) {
143+
params: function (data) {
144144
var obj = {};
145145
var pointer = obj;
146146
var len = arguments.length;
@@ -162,7 +162,7 @@
162162
}
163163

164164
return this;
165-
},
165+
},
166166
/**
167167
* Не отказ
168168
*
@@ -171,11 +171,11 @@
171171
* @example
172172
* counter.notBounce();
173173
*/
174-
notBounce: function () {
175-
this._hitExt('', '', '', null, {nb: true});
174+
notBounce: function () {
175+
this._hitExt('', '', '', null, {nb: true});
176176

177177
return this;
178-
},
178+
},
179179
/**
180180
* Заполнение необходимых параметров из запроса сервера для отправки данных в Метрику
181181
*
@@ -205,79 +205,79 @@
205205
var rh = req.headers;
206206
return rh['x-forwarded-proto'] || rh.protocol || (req.secure ? 'https' : 'http');
207207
},
208-
_hitExt: function (pageUrl, pageTitle, pageRef, userParams, modes) {
209-
var postData = {};
208+
_hitExt: function (pageUrl, pageTitle, pageRef, userParams, modes) {
209+
var postData = {};
210210

211-
if (this._type) {
212-
postData['cnt-class'] = this._type;
213-
}
214-
215-
if (pageUrl) {
216-
postData['page-url'] = pageUrl;
217-
}
218-
219-
if (pageRef) {
220-
postData['page-ref'] = pageRef;
221-
}
222-
223-
if (modes) {
224-
modes.ar = true;
225-
} else {
226-
modes = {ar: true};
227-
}
228-
229-
var browserInfo = [];
230-
for(var key in modes) {
231-
if (!modes.hasOwnProperty(key)) {
232-
continue;
233-
}
234-
235-
if (key != 'ut') {
236-
browserInfo.push(key + ':' + (modes[key] === true ? '1' : modes[key]));
237-
}
238-
}
239-
240-
browserInfo.push('en:' + this._encoding);
241-
browserInfo.push('rn:' + (Math.floor(Math.random() * 1E6)));
211+
if (this._type) {
212+
postData['cnt-class'] = this._type;
213+
}
214+
215+
if (pageUrl) {
216+
postData['page-url'] = pageUrl;
217+
}
218+
219+
if (pageRef) {
220+
postData['page-ref'] = pageRef;
221+
}
222+
223+
if (modes) {
224+
modes.ar = true;
225+
} else {
226+
modes = {ar: true};
227+
}
228+
229+
var browserInfo = [];
230+
for(var key in modes) {
231+
if (!modes.hasOwnProperty(key)) {
232+
continue;
233+
}
234+
235+
if (key != 'ut') {
236+
browserInfo.push(key + ':' + (modes[key] === true ? '1' : modes[key]));
237+
}
238+
}
239+
240+
browserInfo.push('en:' + this._encoding);
241+
browserInfo.push('rn:' + (Math.floor(Math.random() * 1E6)));
242242

243-
if (pageTitle) {
244-
browserInfo.push('t:' + pageTitle);
245-
}
246-
247-
postData['browser-info'] = browserInfo.join(':');
248-
249-
if (userParams) {
250-
postData['site-info'] = JSON.stringify(userParams);
251-
}
243+
if (pageTitle) {
244+
browserInfo.push('t:' + pageTitle);
245+
}
246+
247+
postData['browser-info'] = browserInfo.join(':');
248+
249+
if (userParams) {
250+
postData['site-info'] = JSON.stringify(userParams);
251+
}
252252

253-
if (modes['ut']) {
254-
postData['ut'] = modes['ut'];
255-
}
253+
if (modes['ut']) {
254+
postData['ut'] = modes['ut'];
255+
}
256256

257257
this._sendData(postData);
258-
},
258+
},
259259
_sendData: function (data) {
260260
var path = PATH + this._id
261261
+ '/1?rn=' + (Math.floor(Math.random() * 1E6))
262262
+ '&wmode=2'
263263
+ '&' + querystring.stringify(data);
264264

265-
var req = http.request({
266-
host: HOST,
267-
port: PORT,
268-
path: path,
269-
method: 'GET',
270-
headers: {
271-
'x-real-ip': this._request.ip,
272-
'user-agent': this._request['user-agent']
273-
}
274-
}, function () {});
265+
var req = http.request({
266+
host: HOST,
267+
port: PORT,
268+
path: path,
269+
method: 'GET',
270+
headers: {
271+
'x-real-ip': this._request.ip,
272+
'user-agent': this._request['user-agent']
273+
}
274+
}, function () {});
275275

276276
req.end();
277277
}
278-
};
278+
};
279279

280-
exports.counter = function (settings) {
280+
exports.counter = function (settings) {
281281
return new Counter(settings);
282282
};
283283
})();

0 commit comments

Comments
 (0)