Skip to content

Commit d87066c

Browse files
author
shengyonggen
committed
全埋点和点击图埋点的合并
1 parent 52f8887 commit d87066c

File tree

4 files changed

+22
-316
lines changed

4 files changed

+22
-316
lines changed

sensorsdata.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sdk.js

Lines changed: 7 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,159 +1162,6 @@ _.url = (function() {
11621162
};
11631163
})();
11641164

1165-
_.dom_query = (function() {
1166-
function getAllChildren(e) {
1167-
return e.all ? e.all : e.getElementsByTagName('*');
1168-
}
1169-
var bad_whitespace = /[\t\r\n]/g;
1170-
function hasClass(elem, selector) {
1171-
var className = ' ' + selector + ' ';
1172-
return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
1173-
}
1174-
function getElementsBySelector(selector) {
1175-
if (!document.getElementsByTagName) {
1176-
return [];
1177-
}
1178-
var tokens = selector.split(' ');
1179-
var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
1180-
var currentContext = [document];
1181-
for (i = 0; i < tokens.length; i++) {
1182-
token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
1183-
if (token.indexOf('#') > -1) {
1184-
bits = token.split('#');
1185-
tagName = bits[0];
1186-
var id = bits[1];
1187-
var element = document.getElementById(id);
1188-
if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
1189-
return [];
1190-
}
1191-
currentContext = [element];
1192-
continue;
1193-
}
1194-
if (token.indexOf('.') > -1) {
1195-
bits = token.split('.');
1196-
tagName = bits[0];
1197-
var className = bits[1];
1198-
if (!tagName) {
1199-
tagName = '*';
1200-
}
1201-
found = [];
1202-
foundCount = 0;
1203-
for (j = 0; j < currentContext.length; j++) {
1204-
if (tagName == '*') {
1205-
elements = getAllChildren(currentContext[j]);
1206-
} else {
1207-
elements = currentContext[j].getElementsByTagName(tagName);
1208-
}
1209-
for (k = 0; k < elements.length; k++) {
1210-
found[foundCount++] = elements[k];
1211-
}
1212-
}
1213-
currentContext = [];
1214-
currentContextIndex = 0;
1215-
for (j = 0; j < found.length; j++) {
1216-
if (found[j].className &&
1217-
_.isString(found[j].className) && // some SVG elements have classNames which are not strings
1218-
hasClass(found[j], className)
1219-
) {
1220-
currentContext[currentContextIndex++] = found[j];
1221-
}
1222-
}
1223-
continue;
1224-
}
1225-
var token_match = token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/);
1226-
if (token_match) {
1227-
tagName = token_match[1];
1228-
var attrName = token_match[2];
1229-
var attrOperator = token_match[3];
1230-
var attrValue = token_match[4];
1231-
if (!tagName) {
1232-
tagName = '*';
1233-
}
1234-
found = [];
1235-
foundCount = 0;
1236-
for (j = 0; j < currentContext.length; j++) {
1237-
if (tagName == '*') {
1238-
elements = getAllChildren(currentContext[j]);
1239-
} else {
1240-
elements = currentContext[j].getElementsByTagName(tagName);
1241-
}
1242-
for (k = 0; k < elements.length; k++) {
1243-
found[foundCount++] = elements[k];
1244-
}
1245-
}
1246-
currentContext = [];
1247-
currentContextIndex = 0;
1248-
var checkFunction;
1249-
switch (attrOperator) {
1250-
case '=': // Equality
1251-
checkFunction = function(e) {
1252-
return (e.getAttribute(attrName) == attrValue);
1253-
};
1254-
break;
1255-
case '~': // Match one of space seperated words
1256-
checkFunction = function(e) {
1257-
return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
1258-
};
1259-
break;
1260-
case '|': // Match start with value followed by optional hyphen
1261-
checkFunction = function(e) {
1262-
return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
1263-
};
1264-
break;
1265-
case '^': // Match starts with value
1266-
checkFunction = function(e) {
1267-
return (e.getAttribute(attrName).indexOf(attrValue) === 0);
1268-
};
1269-
break;
1270-
case '$': // Match ends with value - fails with "Warning" in Opera 7
1271-
checkFunction = function(e) {
1272-
return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
1273-
};
1274-
break;
1275-
case '*': // Match ends with value
1276-
checkFunction = function(e) {
1277-
return (e.getAttribute(attrName).indexOf(attrValue) > -1);
1278-
};
1279-
break;
1280-
default:
1281-
checkFunction = function(e) {
1282-
return e.getAttribute(attrName);
1283-
};
1284-
}
1285-
currentContext = [];
1286-
currentContextIndex = 0;
1287-
for (j = 0; j < found.length; j++) {
1288-
if (checkFunction(found[j])) {
1289-
currentContext[currentContextIndex++] = found[j];
1290-
}
1291-
}
1292-
continue; // Skip to next token
1293-
}
1294-
tagName = token;
1295-
found = [];
1296-
foundCount = 0;
1297-
for (j = 0; j < currentContext.length; j++) {
1298-
elements = currentContext[j].getElementsByTagName(tagName);
1299-
for (k = 0; k < elements.length; k++) {
1300-
found[foundCount++] = elements[k];
1301-
}
1302-
}
1303-
currentContext = found;
1304-
}
1305-
return currentContext;
1306-
}
1307-
return function(query) {
1308-
if (_.isElement(query)) {
1309-
return [query];
1310-
} else if (_.isObject(query) && !_.isUndefined(query.length)) {
1311-
return query;
1312-
} else {
1313-
return getElementsBySelector.call(this, query);
1314-
}
1315-
};
1316-
})();
1317-
13181165
_.ry = function(dom){
13191166
return new _.ry.init(dom);
13201167
};
@@ -1977,6 +1824,10 @@ saEvent.send = function(p, callback) {
19771824
return false;
19781825
}
19791826

1827+
sd.para.heatmap = {};
1828+
heatmap.init();
1829+
return false;
1830+
19801831
if(sd.para.heatmap){
19811832
return false;
19821833
}
@@ -3065,7 +2916,9 @@ var heatmap = {
30652916
}else{
30662917
todo();
30672918
//进入热力图采集模式
3068-
this.init();
2919+
if (_.isObject(sd.para.heatmap)) {
2920+
this.init();
2921+
}
30692922
}
30702923
},
30712924
init : function() {

src/sensorsdata.full.js

Lines changed: 7 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,159 +1238,6 @@ _.url = (function() {
12381238
};
12391239
})();
12401240

1241-
_.dom_query = (function() {
1242-
function getAllChildren(e) {
1243-
return e.all ? e.all : e.getElementsByTagName('*');
1244-
}
1245-
var bad_whitespace = /[\t\r\n]/g;
1246-
function hasClass(elem, selector) {
1247-
var className = ' ' + selector + ' ';
1248-
return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
1249-
}
1250-
function getElementsBySelector(selector) {
1251-
if (!document.getElementsByTagName) {
1252-
return [];
1253-
}
1254-
var tokens = selector.split(' ');
1255-
var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
1256-
var currentContext = [document];
1257-
for (i = 0; i < tokens.length; i++) {
1258-
token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
1259-
if (token.indexOf('#') > -1) {
1260-
bits = token.split('#');
1261-
tagName = bits[0];
1262-
var id = bits[1];
1263-
var element = document.getElementById(id);
1264-
if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
1265-
return [];
1266-
}
1267-
currentContext = [element];
1268-
continue;
1269-
}
1270-
if (token.indexOf('.') > -1) {
1271-
bits = token.split('.');
1272-
tagName = bits[0];
1273-
var className = bits[1];
1274-
if (!tagName) {
1275-
tagName = '*';
1276-
}
1277-
found = [];
1278-
foundCount = 0;
1279-
for (j = 0; j < currentContext.length; j++) {
1280-
if (tagName == '*') {
1281-
elements = getAllChildren(currentContext[j]);
1282-
} else {
1283-
elements = currentContext[j].getElementsByTagName(tagName);
1284-
}
1285-
for (k = 0; k < elements.length; k++) {
1286-
found[foundCount++] = elements[k];
1287-
}
1288-
}
1289-
currentContext = [];
1290-
currentContextIndex = 0;
1291-
for (j = 0; j < found.length; j++) {
1292-
if (found[j].className &&
1293-
_.isString(found[j].className) && // some SVG elements have classNames which are not strings
1294-
hasClass(found[j], className)
1295-
) {
1296-
currentContext[currentContextIndex++] = found[j];
1297-
}
1298-
}
1299-
continue;
1300-
}
1301-
var token_match = token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/);
1302-
if (token_match) {
1303-
tagName = token_match[1];
1304-
var attrName = token_match[2];
1305-
var attrOperator = token_match[3];
1306-
var attrValue = token_match[4];
1307-
if (!tagName) {
1308-
tagName = '*';
1309-
}
1310-
found = [];
1311-
foundCount = 0;
1312-
for (j = 0; j < currentContext.length; j++) {
1313-
if (tagName == '*') {
1314-
elements = getAllChildren(currentContext[j]);
1315-
} else {
1316-
elements = currentContext[j].getElementsByTagName(tagName);
1317-
}
1318-
for (k = 0; k < elements.length; k++) {
1319-
found[foundCount++] = elements[k];
1320-
}
1321-
}
1322-
currentContext = [];
1323-
currentContextIndex = 0;
1324-
var checkFunction;
1325-
switch (attrOperator) {
1326-
case '=': // Equality
1327-
checkFunction = function(e) {
1328-
return (e.getAttribute(attrName) == attrValue);
1329-
};
1330-
break;
1331-
case '~': // Match one of space seperated words
1332-
checkFunction = function(e) {
1333-
return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
1334-
};
1335-
break;
1336-
case '|': // Match start with value followed by optional hyphen
1337-
checkFunction = function(e) {
1338-
return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
1339-
};
1340-
break;
1341-
case '^': // Match starts with value
1342-
checkFunction = function(e) {
1343-
return (e.getAttribute(attrName).indexOf(attrValue) === 0);
1344-
};
1345-
break;
1346-
case '$': // Match ends with value - fails with "Warning" in Opera 7
1347-
checkFunction = function(e) {
1348-
return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
1349-
};
1350-
break;
1351-
case '*': // Match ends with value
1352-
checkFunction = function(e) {
1353-
return (e.getAttribute(attrName).indexOf(attrValue) > -1);
1354-
};
1355-
break;
1356-
default:
1357-
checkFunction = function(e) {
1358-
return e.getAttribute(attrName);
1359-
};
1360-
}
1361-
currentContext = [];
1362-
currentContextIndex = 0;
1363-
for (j = 0; j < found.length; j++) {
1364-
if (checkFunction(found[j])) {
1365-
currentContext[currentContextIndex++] = found[j];
1366-
}
1367-
}
1368-
continue; // Skip to next token
1369-
}
1370-
tagName = token;
1371-
found = [];
1372-
foundCount = 0;
1373-
for (j = 0; j < currentContext.length; j++) {
1374-
elements = currentContext[j].getElementsByTagName(tagName);
1375-
for (k = 0; k < elements.length; k++) {
1376-
found[foundCount++] = elements[k];
1377-
}
1378-
}
1379-
currentContext = found;
1380-
}
1381-
return currentContext;
1382-
}
1383-
return function(query) {
1384-
if (_.isElement(query)) {
1385-
return [query];
1386-
} else if (_.isObject(query) && !_.isUndefined(query.length)) {
1387-
return query;
1388-
} else {
1389-
return getElementsBySelector.call(this, query);
1390-
}
1391-
};
1392-
})();
1393-
13941241
_.ry = function(dom){
13951242
return new _.ry.init(dom);
13961243
};
@@ -2047,6 +1894,10 @@ saEvent.send = function(p, callback) {
20471894
return false;
20481895
}
20491896

1897+
sd.para.heatmap = {};
1898+
heatmap.init();
1899+
return false;
1900+
20501901
if(sd.para.heatmap){
20511902
return false;
20521903
}
@@ -3135,7 +2986,9 @@ var heatmap = {
31352986
}else{
31362987
todo();
31372988
//进入热力图采集模式
3138-
this.init();
2989+
if (_.isObject(sd.para.heatmap)) {
2990+
this.init();
2991+
}
31392992
}
31402993
},
31412994
init : function() {

vtrack.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)