Jquery method for selecting numbers for mobile phone numbers _ jquery

Source: Internet
Author: User
This article mainly introduces jquery's method of selecting numbers for mobile phone numbers. It involves jquery's analysis and filtering techniques for mobile phone numbers and has some reference value, for more information, see the following example. Share it with you for your reference. The details are as follows:

Some time ago I saw that China Unicom's free combination package was very attractive, so I decided to change the number. However, the number was a very tiring one and I did not select the desired number from the Free Number list for a long time, so I wrote a script to analyze these mobile phone numbers. Although they were not very accurate, they at least filtered out the junk numbers. Welcome to shoot bricks.

The Code depends on jQuery. If you are interested, refactor it yourself to remove dependencies.

We recommend that you use the debugging tool of Chrome.

Jquery mobile phone number analysis score:

/* Class */RegexpMatchScorer = function (/* Required RegExp */reg,/* Required Number */threshold) {return function (/* Required char [] */numberArray) {if (!! NumberArray &&!! Reg &&!! Threshold) {var matcheList = numberArray. join (). match (reg); if (matcheList! = Null) {return matcheList. length * threshold ;}} return 0 ;};}// score calculated by the last 8 digits: function analyseNumbers (/* Required String [] */numberList, /* Optional Object {begin, size} */range,/* Optional function (char []) [] */addtionRules) {// No 4 Number scoring function non4 (numberArray) {var threshold = 4; if (! NumberArray. inArray ("4") {return threshold;} return 0;} // you can add up to 10 points to the total number. function numberCount (numberArray) {var threshold = 10; var charCount = uniqueArray (numberArray ). length; return threshold-(charCount-1) * (threshold/(numberArray. length-1);} // repeat function adjoinRepeat (numberArray) {var threshold = 2; var score = 0; for (var I = 1; I
 
  
= _ Arr. length) {return;} if (_ arr [I] = _ arr [I + 1]) {_ arr. splice (I + 1, 1); _ unique (_ arr, I);} else {_ unique (_ arr, I + 1) ;}} var arr = parr. slice (). sort (); _ unique (arr, 0); return arr ;} /************** scoring logic **************/var nonRepeatList = uniqueArray (numberList ); var scorerList = [non4, numberCount, adjoinRepeat, straight, new RegexpMatchScorer (new RegExp ("(6 | 8 | 9)", "g"), 0.7)]; if (!! AddtionRules) {scorerList. concat (addtionRules);} var scoreTable = []; // analysis Number nonRepeatList. forEach (function (data) {var score = 0; var pn = data. toString (); if (!! Range) {pn = pn. substr (range. begin, range. size);} var numberArray = pn. split (""); scorerList. forEach (function (scorer) {score + = scorer (numberArray. slice () ;}); // publish score scoreTable. push ({"number": data, "score": score}) ;}); return scoreTable ;}
 

Capture and analyze the number list:

Else // must be executed under num.10010.com var url = "http://num.10010.com/NumApp/GoodsDetail/queryMoreNums? Callback = & province = 51 & cityCode = 540 & rankMoney = & groupKey = 65070778 & mid = & q_p = 51 & net = 01 & roleValue = & preFeeSel = 0 & keyValue = & Show4GNum = TRUE & q_p = "; var nl = []; for (var I = 1; I <= 50; I ++) {var urli = url + I; $. get (urli, function (data, status) {var _ json = eval (data); for (var j = 0; j <(_ json. moreNumArray. length/7); j ++) {var idx = j * 7; var num = _ json. moreNumArray [idx]; nl. push (num) ;}}) ;}// analyze the number after the above Code is captured. // query the number above XX (function (SC) {var x = []; analyseNumbers (nl, {begin:-8, size: 8 }). forEach (function (d, I) {if (d. score> = SC) x. push (d. number + ":" + d. score) ;}); return x. sort (). join ("\ n") ;}) (/* score */10 );

I hope this article will help you with jquery programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.