/** * jquery mobiletype * * @param mobilenumber * returnlanguage(zh or en) * @returns mobiletype * * example code * $.mobiletype("xxxxxxxxxx", "zh"); * result * "移动" * * * * version 1.0 */ /**移动:134、135、136、137、138、139、150、151、152、157、158、159、182、183、184、187、188、178(4g)、147(上网卡); * 联通:130、131、132、155、156、185、186、176(4g)、145(上网卡); * 电信:133、153、180、181、189 、177、 173(4g); * 卫星通信:1349; * 虚拟运营商:170。*/ (function($) { var mobiledata = [ { type : 'chinamobile', title : [ 134, 135, 136, 137, 138, 139, 150, 151, 152, 157, 158, 159,182,183,184,178,147, 187, 188, 184, 198 ], name : '移动' }, { type : 'chinaunicom', title : [ 130, 131, 132, 155, 156, 185, 186 ,176, 145, 166 ], name : '联通' }, { type : 'chinatelecom', title : [ 133, 153, 180, 189 ,181 ,177 ,173, 199 ], name : '电信' }, { type : 'virtualnetworkoperator', title : [ 170,171 ], name : '虚拟运营商' }]; var search = function(k, k1) { var json = eval(mobiledata); for ( var i = 0; i < json.length; i++) { var mobile_title = json[i].title; for ( var j = 0; j < mobile_title.length; j++) { if (mobile_title[j] == parseint(k)) { if (k1 == 'zh') { return json[i].name; } else { return json[i].type; } } } } }; $.extend({ mobiletype : function(string, string2) { if (string.match('^[0-9]*[1-9][0-9]*$') && string.length > 3) { var k = string.substring(0, 3); return search(k, string); } else { return "unknow"; } } }); })(jquery);