JS 暴虐算法查找

 
@dd|ad|fds|d@dd|ad|fds|d@dd|ad|fds|d@
 
var e = [];
    window.onload = function () {
        var O = stocklist.split("@");
        for (var N = 1; N < O.length; N++) {
            var Q = O[N];
            e.push(Q.split("|"));
        }
    };
 
    String.prototype.replaceAll = stringReplaceAll;
    function stringReplaceAll(AFindText, ARepText) {
        var raRegExp = new RegExp(AFindText.replace(/([\(\)\[\]\{\}\^\$\+\-\*\?\.\"\'\|\/\\])/g, "\\$1"), "ig");
        return this.replace(raRegExp, ARepText);
    }
 
    function hint() {
        var index = [];
        var stocks = new String(stocklist);
        var key = $("#text01").val();
        stocks = stocks.replaceAll(key, '#');
        stocks = stocks.replace(/[^@#]/g, "");
        while (stocks.indexOf("#") > 0) {
            var idx = stocks.indexOf("#");
            if (index.indexOf(idx) == -1) {
                index.push(idx);
            }
            stocks = stocks.substring(0, idx) + stocks.substring(idx + 1, stocks.length);
 
        }
        var htm = "";
        $('#slist').html(htm);
        if (index[0] != undefined){
        htm=htm+'
  • 股票代码股票简拼股票简称
  • '
            }
            for (var i = 0; i < 10; i++) {
                if (index[i] == undefined) break;
                var idx = index[i];
                var stock = e[index[i] - 1];
                htm = htm + ''+stock[1]+' '+stock[2]+' '+stock[0]+'';
            }
             if (index[0] != undefined){
            htm=htm+' ';
            }
            $('#slist').html(htm);
     
            if (index[0] != undefined) {
                var stock = e[index[0] - 1];
                $('#firstsearch').val(stock[1]);
            } else {
                $('#firstsearch').val('');
            }
        }


    来自为知笔记(Wiz)


    你可能感兴趣的:(JS 暴虐算法查找)