(function(global, factory){
typeof module === 'object' && typeof module.exports === 'object' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) :global.PicName = factory(global);
})(this, function(){
var PicName = {
log: '',
data: {
"pic": "000001"
},
find: function(id){
var self = this;
var _id = parseInt(id, 10);
for(var k in self.data){
var vs = self.data[k].split(',');
self.log += ['k[vs]-', k, '{', vs, '}<br/>'].join('');
for(var m in vs){
self.log += [' m[vs[m]]-', m, '{', vs[m], '}<br/>'].join('');
var vss = vs[m].split('-');
self.log += [' m[vss]-', vss, '<br/>'].join('');
var s = parseInt(vss[0], 10), e = parseInt(vss[1], 10);
self.log += [' m[vss[i]]-', s, '--', e, '<br/>'].join('');
if(s === e && s === _id){
// 单值符合-返回
return k;
}else{
// 单值不符合,查找区间值
if(s < e && s <= _id && _id <= e){
// 区间值符合-返回
return k;
}else{
// 区间值不符合-继续查找
continue;
}
}
}
}
},
getName: function(id){
return id ? (this.find(id) || 'default') : 'default';
},
getLog: function(){
return this.log;
}
};
return PicName;
});