CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/main/_static/searchtools.js
Views: 494
/*1* searchtools.js_t2* ~~~~~~~~~~~~~~~~3*4* Sphinx JavaScript utilities for the full-text search.5*6* :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.7* :license: BSD, see LICENSE for details.8*9*/101112/* Non-minified version JS is _stemmer.js if file is provided */13/**14* Porter Stemmer15*/16var Stemmer = function() {1718var step2list = {19ational: 'ate',20tional: 'tion',21enci: 'ence',22anci: 'ance',23izer: 'ize',24bli: 'ble',25alli: 'al',26entli: 'ent',27eli: 'e',28ousli: 'ous',29ization: 'ize',30ation: 'ate',31ator: 'ate',32alism: 'al',33iveness: 'ive',34fulness: 'ful',35ousness: 'ous',36aliti: 'al',37iviti: 'ive',38biliti: 'ble',39logi: 'log'40};4142var step3list = {43icate: 'ic',44ative: '',45alize: 'al',46iciti: 'ic',47ical: 'ic',48ful: '',49ness: ''50};5152var c = "[^aeiou]"; // consonant53var v = "[aeiouy]"; // vowel54var C = c + "[^aeiouy]*"; // consonant sequence55var V = v + "[aeiou]*"; // vowel sequence5657var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>058var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=159var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>160var s_v = "^(" + C + ")?" + v; // vowel in stem6162this.stemWord = function (w) {63var stem;64var suffix;65var firstch;66var origword = w;6768if (w.length < 3)69return w;7071var re;72var re2;73var re3;74var re4;7576firstch = w.substr(0,1);77if (firstch == "y")78w = firstch.toUpperCase() + w.substr(1);7980// Step 1a81re = /^(.+?)(ss|i)es$/;82re2 = /^(.+?)([^s])s$/;8384if (re.test(w))85w = w.replace(re,"$1$2");86else if (re2.test(w))87w = w.replace(re2,"$1$2");8889// Step 1b90re = /^(.+?)eed$/;91re2 = /^(.+?)(ed|ing)$/;92if (re.test(w)) {93var fp = re.exec(w);94re = new RegExp(mgr0);95if (re.test(fp[1])) {96re = /.$/;97w = w.replace(re,"");98}99}100else if (re2.test(w)) {101var fp = re2.exec(w);102stem = fp[1];103re2 = new RegExp(s_v);104if (re2.test(stem)) {105w = stem;106re2 = /(at|bl|iz)$/;107re3 = new RegExp("([^aeiouylsz])\\1$");108re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");109if (re2.test(w))110w = w + "e";111else if (re3.test(w)) {112re = /.$/;113w = w.replace(re,"");114}115else if (re4.test(w))116w = w + "e";117}118}119120// Step 1c121re = /^(.+?)y$/;122if (re.test(w)) {123var fp = re.exec(w);124stem = fp[1];125re = new RegExp(s_v);126if (re.test(stem))127w = stem + "i";128}129130// Step 2131re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;132if (re.test(w)) {133var fp = re.exec(w);134stem = fp[1];135suffix = fp[2];136re = new RegExp(mgr0);137if (re.test(stem))138w = stem + step2list[suffix];139}140141// Step 3142re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;143if (re.test(w)) {144var fp = re.exec(w);145stem = fp[1];146suffix = fp[2];147re = new RegExp(mgr0);148if (re.test(stem))149w = stem + step3list[suffix];150}151152// Step 4153re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;154re2 = /^(.+?)(s|t)(ion)$/;155if (re.test(w)) {156var fp = re.exec(w);157stem = fp[1];158re = new RegExp(mgr1);159if (re.test(stem))160w = stem;161}162else if (re2.test(w)) {163var fp = re2.exec(w);164stem = fp[1] + fp[2];165re2 = new RegExp(mgr1);166if (re2.test(stem))167w = stem;168}169170// Step 5171re = /^(.+?)e$/;172if (re.test(w)) {173var fp = re.exec(w);174stem = fp[1];175re = new RegExp(mgr1);176re2 = new RegExp(meq1);177re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");178if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))179w = stem;180}181re = /ll$/;182re2 = new RegExp(mgr1);183if (re.test(w) && re2.test(w)) {184re = /.$/;185w = w.replace(re,"");186}187188// and turn initial Y back to y189if (firstch == "y")190w = firstch.toLowerCase() + w.substr(1);191return w;192}193}194195196197/**198* Simple result scoring code.199*/200var Scorer = {201// Implement the following function to further tweak the score for each result202// The function takes a result array [filename, title, anchor, descr, score]203// and returns the new score.204/*205score: function(result) {206return result[4];207},208*/209210// query matches the full name of an object211objNameMatch: 11,212// or matches in the last dotted part of the object name213objPartialMatch: 6,214// Additive scores depending on the priority of the object215objPrio: {0: 15, // used to be importantResults2161: 5, // used to be objectResults2172: -5}, // used to be unimportantResults218// Used when the priority is not in the mapping.219objPrioDefault: 0,220221// query found in title222title: 15,223// query found in terms224term: 5225};226227228229230231var splitChars = (function() {232var result = {};233var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,2341748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702,2352706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971,2362973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345,2373369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761,2383781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823,2394881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125,2408133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695,24111703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587,24243696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141];243var i, j, start, end;244for (i = 0; i < singles.length; i++) {245result[singles[i]] = true;246}247var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709],248[722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161],249[1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568],250[1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807],251[1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047],252[2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383],253[2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450],254[2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547],255[2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673],256[2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820],257[2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946],258[2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023],259[3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173],260[3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332],261[3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481],262[3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718],263[3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791],264[3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095],265[4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205],266[4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687],267[4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968],268[4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869],269[5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102],270[6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271],271[6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592],272[6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822],273[6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167],274[7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959],275[7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143],276[8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318],277[8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483],278[8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101],279[10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567],280[11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292],281[12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444],282[12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783],283[12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311],284[19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511],285[42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774],286[42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071],287[43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263],288[43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519],289[43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647],290[43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967],291[44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295],292[57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274],293[64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007],294[65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381],295[65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]];296for (i = 0; i < ranges.length; i++) {297start = ranges[i][0];298end = ranges[i][1];299for (j = start; j <= end; j++) {300result[j] = true;301}302}303return result;304})();305306function splitQuery(query) {307var result = [];308var start = -1;309for (var i = 0; i < query.length; i++) {310if (splitChars[query.charCodeAt(i)]) {311if (start !== -1) {312result.push(query.slice(start, i));313start = -1;314}315} else if (start === -1) {316start = i;317}318}319if (start !== -1) {320result.push(query.slice(start));321}322return result;323}324325326327328/**329* Search Module330*/331var Search = {332333_index : null,334_queued_query : null,335_pulse_status : -1,336337init : function() {338var params = $.getQueryParameters();339if (params.q) {340var query = params.q[0];341$('input[name="q"]')[0].value = query;342this.performSearch(query);343}344},345346loadIndex : function(url) {347$.ajax({type: "GET", url: url, data: null,348dataType: "script", cache: true,349complete: function(jqxhr, textstatus) {350if (textstatus != "success") {351document.getElementById("searchindexloader").src = url;352}353}});354},355356setIndex : function(index) {357var q;358this._index = index;359if ((q = this._queued_query) !== null) {360this._queued_query = null;361Search.query(q);362}363},364365hasIndex : function() {366return this._index !== null;367},368369deferQuery : function(query) {370this._queued_query = query;371},372373stopPulse : function() {374this._pulse_status = 0;375},376377startPulse : function() {378if (this._pulse_status >= 0)379return;380function pulse() {381var i;382Search._pulse_status = (Search._pulse_status + 1) % 4;383var dotString = '';384for (i = 0; i < Search._pulse_status; i++)385dotString += '.';386Search.dots.text(dotString);387if (Search._pulse_status > -1)388window.setTimeout(pulse, 500);389}390pulse();391},392393/**394* perform a search for something (or wait until index is loaded)395*/396performSearch : function(query) {397// create the required interface elements398this.out = $('#search-results');399this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out);400this.dots = $('<span></span>').appendTo(this.title);401this.status = $('<p style="display: none"></p>').appendTo(this.out);402this.output = $('<ul class="search"/>').appendTo(this.out);403404$('#search-progress').text(_('Preparing search...'));405this.startPulse();406407// index already loaded, the browser was quick!408if (this.hasIndex())409this.query(query);410else411this.deferQuery(query);412},413414/**415* execute search (requires search index to be loaded)416*/417query : function(query) {418var i;419var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];420421// stem the searchterms and add them to the correct list422var stemmer = new Stemmer();423var searchterms = [];424var excluded = [];425var hlterms = [];426var tmp = splitQuery(query);427var objectterms = [];428for (i = 0; i < tmp.length; i++) {429if (tmp[i] !== "") {430objectterms.push(tmp[i].toLowerCase());431}432433if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i].match(/^\d+$/) ||434tmp[i] === "") {435// skip this "word"436continue;437}438// stem the word439var word = stemmer.stemWord(tmp[i].toLowerCase());440// prevent stemmer from cutting word smaller than two chars441if(word.length < 3 && tmp[i].length >= 3) {442word = tmp[i];443}444var toAppend;445// select the correct list446if (word[0] == '-') {447toAppend = excluded;448word = word.substr(1);449}450else {451toAppend = searchterms;452hlterms.push(tmp[i].toLowerCase());453}454// only add if not already in the list455if (!$u.contains(toAppend, word))456toAppend.push(word);457}458var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" "));459460// console.debug('SEARCH: searching for:');461// console.info('required: ', searchterms);462// console.info('excluded: ', excluded);463464// prepare search465var terms = this._index.terms;466var titleterms = this._index.titleterms;467468// array of [filename, title, anchor, descr, score]469var results = [];470$('#search-progress').empty();471472// lookup as object473for (i = 0; i < objectterms.length; i++) {474var others = [].concat(objectterms.slice(0, i),475objectterms.slice(i+1, objectterms.length));476results = results.concat(this.performObjectSearch(objectterms[i], others));477}478479// lookup as search terms in fulltext480results = results.concat(this.performTermsSearch(searchterms, excluded, terms, titleterms));481482// let the scorer override scores with a custom scoring function483if (Scorer.score) {484for (i = 0; i < results.length; i++)485results[i][4] = Scorer.score(results[i]);486}487488// now sort the results by score (in opposite order of appearance, since the489// display function below uses pop() to retrieve items) and then490// alphabetically491results.sort(function(a, b) {492var left = a[4];493var right = b[4];494if (left > right) {495return 1;496} else if (left < right) {497return -1;498} else {499// same score: sort alphabetically500left = a[1].toLowerCase();501right = b[1].toLowerCase();502return (left > right) ? -1 : ((left < right) ? 1 : 0);503}504});505506// for debugging507//Search.lastresults = results.slice(); // a copy508//console.info('search results:', Search.lastresults);509510// print the results511var resultCount = results.length;512function displayNextItem() {513// results left, load the summary and display it514if (results.length) {515var item = results.pop();516var listItem = $('<li style="display:none"></li>');517if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') {518// dirhtml builder519var dirname = item[0] + '/';520if (dirname.match(/\/index\/$/)) {521dirname = dirname.substring(0, dirname.length-6);522} else if (dirname == 'index/') {523dirname = '';524}525listItem.append($('<a/>').attr('href',526DOCUMENTATION_OPTIONS.URL_ROOT + dirname +527highlightstring + item[2]).html(item[1]));528} else {529// normal html builders530listItem.append($('<a/>').attr('href',531item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +532highlightstring + item[2]).html(item[1]));533}534if (item[3]) {535listItem.append($('<span> (' + item[3] + ')</span>'));536Search.output.append(listItem);537listItem.slideDown(5, function() {538displayNextItem();539});540} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {541var suffix = DOCUMENTATION_OPTIONS.SOURCELINK_SUFFIX;542if (suffix === undefined) {543suffix = '.txt';544}545$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[5] + (item[5].slice(-suffix.length) === suffix ? '' : suffix),546dataType: "text",547complete: function(jqxhr, textstatus) {548var data = jqxhr.responseText;549if (data !== '' && data !== undefined) {550listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));551}552Search.output.append(listItem);553listItem.slideDown(5, function() {554displayNextItem();555});556}});557} else {558// no source available, just display title559Search.output.append(listItem);560listItem.slideDown(5, function() {561displayNextItem();562});563}564}565// search finished, update title and status message566else {567Search.stopPulse();568Search.title.text(_('Search Results'));569if (!resultCount)570Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));571else572Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));573Search.status.fadeIn(500);574}575}576displayNextItem();577},578579/**580* search for object names581*/582performObjectSearch : function(object, otherterms) {583var filenames = this._index.filenames;584var docnames = this._index.docnames;585var objects = this._index.objects;586var objnames = this._index.objnames;587var titles = this._index.titles;588589var i;590var results = [];591592for (var prefix in objects) {593for (var name in objects[prefix]) {594var fullname = (prefix ? prefix + '.' : '') + name;595if (fullname.toLowerCase().indexOf(object) > -1) {596var score = 0;597var parts = fullname.split('.');598// check for different match types: exact matches of full name or599// "last name" (i.e. last dotted part)600if (fullname == object || parts[parts.length - 1] == object) {601score += Scorer.objNameMatch;602// matches in last name603} else if (parts[parts.length - 1].indexOf(object) > -1) {604score += Scorer.objPartialMatch;605}606var match = objects[prefix][name];607var objname = objnames[match[1]][2];608var title = titles[match[0]];609// If more than one term searched for, we require other words to be610// found in the name/title/description611if (otherterms.length > 0) {612var haystack = (prefix + ' ' + name + ' ' +613objname + ' ' + title).toLowerCase();614var allfound = true;615for (i = 0; i < otherterms.length; i++) {616if (haystack.indexOf(otherterms[i]) == -1) {617allfound = false;618break;619}620}621if (!allfound) {622continue;623}624}625var descr = objname + _(', in ') + title;626627var anchor = match[3];628if (anchor === '')629anchor = fullname;630else if (anchor == '-')631anchor = objnames[match[1]][1] + '-' + fullname;632// add custom score for some objects according to scorer633if (Scorer.objPrio.hasOwnProperty(match[2])) {634score += Scorer.objPrio[match[2]];635} else {636score += Scorer.objPrioDefault;637}638results.push([docnames[match[0]], fullname, '#'+anchor, descr, score, filenames[match[0]]]);639}640}641}642643return results;644},645646/**647* search for full-text terms in the index648*/649performTermsSearch : function(searchterms, excluded, terms, titleterms) {650var docnames = this._index.docnames;651var filenames = this._index.filenames;652var titles = this._index.titles;653654var i, j, file;655var fileMap = {};656var scoreMap = {};657var results = [];658659// perform the search on the required terms660for (i = 0; i < searchterms.length; i++) {661var word = searchterms[i];662var files = [];663var _o = [664{files: terms[word], score: Scorer.term},665{files: titleterms[word], score: Scorer.title}666];667668// no match but word was a required one669if ($u.every(_o, function(o){return o.files === undefined;})) {670break;671}672// found search word in contents673$u.each(_o, function(o) {674var _files = o.files;675if (_files === undefined)676return677678if (_files.length === undefined)679_files = [_files];680files = files.concat(_files);681682// set score for the word in each file to Scorer.term683for (j = 0; j < _files.length; j++) {684file = _files[j];685if (!(file in scoreMap))686scoreMap[file] = {}687scoreMap[file][word] = o.score;688}689});690691// create the mapping692for (j = 0; j < files.length; j++) {693file = files[j];694if (file in fileMap)695fileMap[file].push(word);696else697fileMap[file] = [word];698}699}700701// now check if the files don't contain excluded terms702for (file in fileMap) {703var valid = true;704705// check if all requirements are matched706if (fileMap[file].length != searchterms.length)707continue;708709// ensure that none of the excluded terms is in the search result710for (i = 0; i < excluded.length; i++) {711if (terms[excluded[i]] == file ||712titleterms[excluded[i]] == file ||713$u.contains(terms[excluded[i]] || [], file) ||714$u.contains(titleterms[excluded[i]] || [], file)) {715valid = false;716break;717}718}719720// if we have still a valid result we can add it to the result list721if (valid) {722// select one (max) score for the file.723// for better ranking, we should calculate ranking by using words statistics like basic tf-idf...724var score = $u.max($u.map(fileMap[file], function(w){return scoreMap[file][w]}));725results.push([docnames[file], titles[file], '', null, score, filenames[file]]);726}727}728return results;729},730731/**732* helper function to return a node containing the733* search summary for a given text. keywords is a list734* of stemmed words, hlwords is the list of normal, unstemmed735* words. the first one is used to find the occurrence, the736* latter for highlighting it.737*/738makeSearchSummary : function(text, keywords, hlwords) {739var textLower = text.toLowerCase();740var start = 0;741$.each(keywords, function() {742var i = textLower.indexOf(this.toLowerCase());743if (i > -1)744start = i;745});746start = Math.max(start - 120, 0);747var excerpt = ((start > 0) ? '...' : '') +748$.trim(text.substr(start, 240)) +749((start + 240 - text.length) ? '...' : '');750var rv = $('<div class="context"></div>').text(excerpt);751$.each(hlwords, function() {752rv = rv.highlightText(this, 'highlighted');753});754return rv;755}756};757758$(document).ready(function() {759Search.init();760});761762