lunr.js实现一个全文索引搜索效果代码

代码语言:html

所属分类:搜索

代码描述:lunr.js实现一个全文索引搜索效果代码

代码标签: lunr.js 全文索引 搜索

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">



    <link rel='stylesheet' href='https://fonts.googleapis.com/icon?family=Material+Icons'>
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/material.indigo-pink.min.css">

    <style>
        li {
          display: none;
          margin: 23px 0;
        }
        
        li a {
            color: #3CA8FF;
            text-decoration: initial;
        }
        li a:hover {
            text-decoration: underline;
        }
        
        .show {
          display: block;
        }
        
        h2,
        h3 {
          margin: 0px 0;
          line-height: 23px;
          font-size: 18px;
        }
        
        div#wrap {
          margin: 17px;
        }
        
        ul,
        ol {
          padding: 0;
        }
    </style>




</head>

<body>
    <div id="wrap">
        <header>
            <h1>Lunr.js 示例代码</h1><a href="http://lunrjs.com/">visit lunrjs.com</a>
        </header>

        <article>

            <p>输入以下文本,例如: javascript, json or browser</p>
        </article>

        <div class="controls">
            <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input id="searchterm" class="mdl-textfield__input" type="text" />
                <label class="mdl-textfield__label" for="sample3">Search...</label>
            </div>
            <a class="all" href="#">Show All</a>
        </div>

        <div class="questions">
            <div id="question-list-container">
                <div>
                    <ul>
                        <li data-question-id="6414827">
                            <h2><a href="#">Checkbox returns the wrong state?</a></h2>
                            <p>javascript jquery html</p>
                        </li>
                        <li data-question-id="6414614">
                            <h2><a href="#">Fairly easy JQuery Input Selection location problem</a></h2>
                            <p>php javascript jquery html div</p>
                        </li>
                        <li data-question-id="6296451">
                            <h2><a href="#">problem in file upload</a></h2>
                            <p>javascript jquery html file-upload</p>
                        </li>
                        <li data-question-id="6414782">
                            <h2><a href="#">Provide link/Redirect after a 'Like' or 'Share' on Facebook or a 'Share' on Twitter</a></h2>
                            <p>php javascript facebook twitter share</p>
                        </li>
                        <li data-question-id="6412607">
                            <h2><a href="#">Passing argument to function. What's wrong?</a></h2>
                            <p>javascript jquery</p>
                        </li>
                        <li data-question-id="6414755">
                            <h2><a href="#">Convert Matlab Fuzzy Logic toolbox fis file to c# / c++ / javascript</a></h2>
                            <p>c# javascript matlab</p>
                        </li>
                        <li data-question-id="5306132">
                            <h2><a href="#">Translate Javascript keyCode into charCode for non-U.S. keyboard layout (i.e. azerty)</a></h2>
                            <p>javascript html5 browser cross-browser</p>
                        </li>
                        <li data-question-id="6413951">
                            <h2><a href="#">How do I update my model object before a create/update?</a></h2>
                            <p>javascript ruby-on-rails</p>
                        </li>
                        <li data-question-id="6414530">
                            <h2><a href="#">Change background using Javascript - AJAX - jQuery</a></h2>
                            <p>javascript jquery ajax jquery-ajax</p>
                        </li>
                        <li data-question-id="4047072">
                            <h2><a href="#">JS: setInterval and blur.</a></h2>
                            <p>javascript</p>
                        </li>
                        <li data-question-id="4272538">
                            <h2><a href="#">How can I parse XML in javascript in both IE and firefox?</a></h2>
                            <p>javascript xml</p>
                        </li>
                        <li data-question-id="6414613">
                            <h2><a href="#">Using Dashcode's List Controller without their DataSource option</a></h2>
                            <p>javascript json apple dashcode</p>
                        </li>
                        <li data-question-id="6413244">
                            <h2><a href="#">How to set the google-maps marker as it is showed on the original website</a></h2>
                            <p>javascript google-maps marker</p>
                        </li>
                        <li data-question-id="6414578">
                            <h2><a href="#">Javascript slider not showing in IE9</a></h2>
                            <p>javascript jquery internet internet-explorer-9 explorer</p>
                        </li>
                        <li data-question-id="6409944">
                            <h2><a href="#">NowJS manually initiating a new connection after a lost connection</a></h2>
                            <p>javascript node.js socket.io nowjs</p>
                        </li>
                        <li data-question-id="6413444">
                            <h2><a href="#">Regex Comma Separated Emails</a></h2>
                            <p>javascript regex comma</p>
                        </li>
                        <li data-question-id="6414240">
                            <h2><a href="#">Constant Variables in Javascript</a></h2>
                            <p>javascript javascript-library</p>
                        </li>
                        <li data-question-id="6414558">
                            <h2><a href="#">In IE8 with Chrome Frame, after Download, App hangs</a></h2>
                            <p>javascript internet-explorer-8 frame hang google-chrome-frame</p>
                        </li>
                        <li data-question-id="3047391">
                            <h2><a href="#">Parsing complex string using regex</a></h2>
                            <p>java javascript xml regex parsing</p>
                        </li>
                        <li data-question-id="6414438">
                            <h2><a href="#">jQuery jqPlot library 12 hour Time Y-Axis Inversion issue</a></h2>
                            <p>javascript jquery jquery-plugins jqplot time-format</p>
                        </li>
                        <li data-question-id="6414376">
                            <h2><a href="#">Can I see what jquery is sending to an external server?</a></h2>
                            <p>javascript jquery firefox</p>
                        </li>
                        <li data-question-id="6414473">
                            <h2><a href="#">How to cause live text wrap while image/element is being dragged, in javascript?</a></h2>
                            <p>javascript html text-editor textwrapping</p>
                        </li>
                        <li data-question-id="6414123">
                            <h2><a href="#">javascript trigger function on event from a script, not explicitly from html</a></h2>
                            <p>javascript javascript-events</p>
                        </li>
                        <li data-question-id="6414093">
                            <h2><a href="#">Why isn't this google maps loaded?</a></h2>
                            <p>javascript google-maps</p>
                        </li>
                        <li data-question-id="6413881">
                            <h2><a href="#">Setting a maximum and minimum value for text box</a></h2>
                            <p>php javascript</p>
                        </li>
                        <li data-question-id="6413908">
                            <h2><a href="#">Simple XMLHttpRequest (Google Weather)</a></h2>
                            <p>javascript xmlhttprequest google-weather-api</p>
                        </li>
                        <li data-question-id="5351143">
                            <h2><a href="#">how to create autocomplete forum using html5 local storage?</a></h2>
                            <p>javascript forms html5 autocomplete localstorage</p>
                        </li>
                        <li data-question-id="6413732">
                            <h2><a href="#">Why won't this web page finish loading?</a></h2>
                            <p>javascript firefox browser</p>
                        </li>
                        <li data-question-id="6412632">
                            <h2><a href="#">How to find and modify an asp.net control with JavaScript?</a></h2>
                            <p>javascript asp.net</p>
                        </li>
                        <li data-question-id="4529460">
                            <h2><a href="#">How to fix the width and height of jquery lightbox?</a></h2>
                            <p>javascript jquery css lightbox</p>
                        </li>
                        <li data-question-id="6414253">
                            <h2><a href="#">Prototype - How to deselect the selected value from a dropdown</a></h2>
                            <p>javascript html prototype prototypejs</p>
                        </li>
                        <li data-question-id="6398787">
                            <h2><a href="#">Javascript Shorthand for getElementById</a></h2>
                            <p>javascript</p>
                        </li>
                        <li data-question-id="6414107">
                            <h2><a href="#">In Java, How do I represent multiple objects (of same type) in a single JSON object.</a></h2>
                            <p>java javascript json</p>
                        </li>
                        <li data-question-id="6414060">
                            <h2><a href="#">how get href all images in page using javascript?</a></h2>
                            <p>javascript attributes</p>
                        </li>
                        <li data-question-id="6413183">
                            <h2><a href="#">Manipulate Select Multiple List Setup On Page Load</a></h2>
                            <p>javascript jquery</p>
                        </li>
                        <li data-question-id="6401696">
                            <h2><a href="#">javascript, what is this?</a></h2>
                            <p>javascript</p>
                        </li>
                        <li data-question-id="6414152">
                            <h2><a href="#">Navigating / scraping hashbang links with javascript (phantomjs)</a></h2>
                            <p>javascript python web-scraping hashbang phantomjs</p>
                        </li>
                        <li data-question-id="6414105">
                            <h2><a href="#">Facebook API FB.getLoginStatus returns undefined</a></h2>
                            <p>javascript facebook api like app-id</p>
                        </li>
                        <li data-question-id="6410184">
                            <h2><a href="#">jQuery.find().each(fn) is not working in Firefox</a></h2>
                            <p>javascript jquery xml firefox</p>
                        </li>
                        <li data-question-id="6413944">
                            <h2><a href="#">Changing content of a webpage using Ajax</a></h2>
                            <p>javascript ajax jquery-ajax</p>
                        </li>
                        <li data-question-id="6413889">
                            <h2><a href="#">Use JavaScript to store and return user info</a></h2>
                            <p>javascript forms user</p>
                        </li>
                        <li data-question-id="6413778">
                            <h2><a href="#">javascript: Problem with dynamically adding xsl-stylesheet to XML Data</a></h2>
                            <p>javascript xml xslt firefox-addon</p>
                        </li>
                        <li data-question-id="6364675">
                            <h2><a href="#">HtmlUnit's HtmlPage.getElementById seems to reinitialize JavaScript after many calls.</a></h2>
                            <p>java javascript html scala htmlunit</p>
                        </li>
                        <li data-question-id="6397574">
                            <h2><a href="#">How to access session in express, outside of the req?</a></h2>
                            <p>javascript node.js express socket.io</p>
                        </li>
                        <li data-question-id="6405964">
                            <h2><a href="#">Check if a String is HTML or XML</a></h2>
                            <p>javascript jquery html xml check</p>
                        </li>
                        <li data-question-id="6413523">
                            <h2><a href="#">complex problem with setTimeout, clearTimeout, and javascript</a></h2>
                            <p>javascript settimeout autosuggest</p>
                        </li>
                        <li data-question-id="6413720">
                            <h2><a href="#">facebook wall post message with js from innerhtml</a></h2>
                            <p>javascript facebook innerhtml getelementbyid</p>
                        </li>
                        <li data-question-id="6412334">
                            <h2><a href="#">jQuery "drop" and "over" are not firing on a droppable</a></h2>
                            <p>javascript jquery jquery-ui droppable</p>
                        </li>
                        <li data-question-id="6413541">
                            <h2><a href="#">Put an image on Google map</a></h2>
                            <p>javascript google-maps google</p>
                        </li>
                        <li data-question-id="6413744">
                            <h2><a href="#">Looking to access 16-bit image data in Javascript/WebGL</a></h2>
                            <p>javascript image-processing webgl</p>
                        </li>
                        <li data-question-id="6413440">
                            <h2><a href="#">Jquery: passing variable to the next chained function, is this the correct way?</a></h2>
                            <p>javascript jquery function variables passing</p>
                        </li>
                        <li data-question-id="318630">
       .........完整代码请登录后点击上方下载按钮下载查看

网友评论0