updated 性别可以不确定
This commit is contained in:
parent
fac0ddc0cc
commit
09dd56ca46
2
dist/relationship.min.js
vendored
2
dist/relationship.min.js
vendored
File diff suppressed because one or more lines are too long
@ -2288,17 +2288,20 @@
|
|||||||
var hash = {};
|
var hash = {};
|
||||||
//性别判断
|
//性别判断
|
||||||
if(sex<0){
|
if(sex<0){
|
||||||
sex = selector.match(/^,w/)?1:0;
|
if(selector.match(/^,w/)){
|
||||||
|
sex = 1;
|
||||||
|
}else if(selector.match(/^,h/)){
|
||||||
|
sex = 0;
|
||||||
}
|
}
|
||||||
sex = sex?1:0;
|
}
|
||||||
|
// console.log('[selector]',selector);
|
||||||
|
var getId = function(selector,sex){
|
||||||
if(selector.indexOf(',1')==-1&&selector.indexOf(',0')==-1){
|
if(selector.indexOf(',1')==-1&&selector.indexOf(',0')==-1){
|
||||||
selector = ','+sex+selector;
|
selector = ','+sex+selector;
|
||||||
}
|
}
|
||||||
// console.log('[selector]',selector);
|
|
||||||
if(selector.match(/,[w0],w|,[h1],h/)){ //同志关系去除
|
if(selector.match(/,[w0],w|,[h1],h/)){ //同志关系去除
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var getId = function(selector){
|
|
||||||
var s='';
|
var s='';
|
||||||
if(!hash[selector]){
|
if(!hash[selector]){
|
||||||
hash[selector] = true;
|
hash[selector] = true;
|
||||||
@ -2328,7 +2331,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getId(selector);
|
if(sex<0){
|
||||||
|
getId(selector,1);
|
||||||
|
getId(selector,0);
|
||||||
|
}else{
|
||||||
|
getId(selector,sex);
|
||||||
|
}
|
||||||
return unique(result);
|
return unique(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2404,9 +2412,14 @@
|
|||||||
id = id.replace(/&[ol]/g,'');
|
id = id.replace(/&[ol]/g,'');
|
||||||
//性别判断
|
//性别判断
|
||||||
if(sex<0){
|
if(sex<0){
|
||||||
sex = id.match(/^w/)?1:0;
|
if(id.match(/^w/)){
|
||||||
|
sex = 1;
|
||||||
|
}else if(id.match(/^h/)){
|
||||||
|
sex = 0;
|
||||||
}
|
}
|
||||||
sex = sex?1:0;
|
}
|
||||||
|
var result = [];
|
||||||
|
var doing = function(sex){
|
||||||
var sid = (','+sex+','+id).replace(/,[fhs]|,[olx]b/g,',1').replace(/,[mwd]|,[olx]s/g,',0');
|
var sid = (','+sex+','+id).replace(/,[fhs]|,[olx]b/g,',1').replace(/,[mwd]|,[olx]s/g,',0');
|
||||||
sid = sid.substring(0,sid.lastIndexOf(','));
|
sid = sid.substring(0,sid.lastIndexOf(','));
|
||||||
var id_arr = id.split(',').reverse();
|
var id_arr = id.split(',').reverse();
|
||||||
@ -2421,8 +2434,16 @@
|
|||||||
g += gMap[r]||0;
|
g += gMap[r]||0;
|
||||||
});
|
});
|
||||||
return arr.join(',')+(g?'':age);
|
return arr.join(',')+(g?'':age);
|
||||||
|
};
|
||||||
|
if(sex<0){
|
||||||
|
result.push(doing(1));
|
||||||
|
result.push(doing(0));
|
||||||
|
}else{
|
||||||
|
result.push(doing(sex));
|
||||||
}
|
}
|
||||||
return '';
|
return result;
|
||||||
|
}
|
||||||
|
return [''];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过ID获取关系链条
|
// 通过ID获取关系链条
|
||||||
@ -2436,18 +2457,19 @@
|
|||||||
|
|
||||||
// 合并选择器,查找两个对象之间的关系
|
// 合并选择器,查找两个对象之间的关系
|
||||||
function mergeSelector(from,to,mid_sex){
|
function mergeSelector(from,to,mid_sex){
|
||||||
var sex = -1;
|
var sex = mid_sex;
|
||||||
if(to){
|
if(to){
|
||||||
sex = to.match(/([fhs1](&[ol])?|[olx]b)$/)?1:0;
|
sex = to.match(/([fhs1](&[ol])?|[olx]b)$/)?1:0;
|
||||||
}
|
}
|
||||||
if(mid_sex==-1){
|
var ids = reverseId(to.substr(1),mid_sex);
|
||||||
|
if(ids.length>1){
|
||||||
return {
|
return {
|
||||||
'selector':(to?','+reverseId(to.substr(1),1):'')+from+'#'+(to?','+reverseId(to.substr(1),0):'')+from,
|
'selector':(to?',['+ids.join('|')+']':'')+from,
|
||||||
'sex':sex
|
'sex':sex
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
return {
|
return {
|
||||||
'selector':(to?','+reverseId(to.substr(1),mid_sex):'')+from,
|
'selector':(to?','+ids[0]+'':'')+from,
|
||||||
'sex':sex
|
'sex':sex
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -2462,7 +2484,6 @@
|
|||||||
reverse:false, // true表示反向
|
reverse:false, // true表示反向
|
||||||
mode:'default', // 用户自定义模式
|
mode:'default', // 用户自定义模式
|
||||||
},parameter);
|
},parameter);
|
||||||
var sex = options.sex;
|
|
||||||
_data = Object.assign({},_map);
|
_data = Object.assign({},_map);
|
||||||
for(var lang in _mode){
|
for(var lang in _mode){
|
||||||
if(options.mode==lang){
|
if(options.mode==lang){
|
||||||
@ -2479,24 +2500,27 @@
|
|||||||
to_selectors.forEach(function(to){
|
to_selectors.forEach(function(to){
|
||||||
var data = mergeSelector(from,to,options.sex);
|
var data = mergeSelector(from,to,options.sex);
|
||||||
// console.log('[data]',data);
|
// console.log('[data]',data);
|
||||||
sex = data['sex']>-1?data['sex']:options.sex;
|
var ids = selector2id(data['selector'],data['sex']);
|
||||||
var ids = selector2id(data['selector'],sex);
|
|
||||||
// console.log('[ids]',data['selector'],sex,ids);
|
// console.log('[ids]',data['selector'],sex,ids);
|
||||||
if(ids){
|
if(ids){
|
||||||
ids.forEach(function(id){
|
ids.forEach(function(id){
|
||||||
|
var temps = [id];
|
||||||
if(options.type=='chain'){
|
if(options.type=='chain'){
|
||||||
if(options.reverse){
|
if(options.reverse){
|
||||||
id = reverseId(id,sex);
|
temps = reverseId(id,data['sex']);
|
||||||
}
|
}
|
||||||
|
temps.forEach(function(id){
|
||||||
var item = getChainById(id);
|
var item = getChainById(id);
|
||||||
if(item){
|
if(item){
|
||||||
result.push(item);
|
result.push(item);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}else{
|
}else{
|
||||||
if(options.reverse){
|
if(options.reverse){
|
||||||
id = reverseId(id,sex);
|
temps = reverseId(id,data['sex']);
|
||||||
}
|
}
|
||||||
var items = getDataById(sex+','+id);
|
temps.forEach(function(id){
|
||||||
|
var items = getDataById(data['sex']+','+id);
|
||||||
if(!items.length){
|
if(!items.length){
|
||||||
items = getDataById(id);
|
items = getDataById(id);
|
||||||
}
|
}
|
||||||
@ -2508,6 +2532,7 @@
|
|||||||
if(items.length){
|
if(items.length){
|
||||||
result = result.concat(items);
|
result = result.concat(items);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user