Skip to content

Instantly share code, notes, and snippets.

@rohanb10
Last active January 30, 2024 06:12
Show Gist options
  • Save rohanb10/68b6de82b5504821e50b4b4476a5c5c7 to your computer and use it in GitHub Desktop.
Save rohanb10/68b6de82b5504821e50b4b4476a5c5c7 to your computer and use it in GitHub Desktop.
Implementing Search on a Static Website

Implementing Search on a Static Website

Need search on your website but don't want to do all the work of setting up a server or a db? Here's how to do it:

Unfortunately, this method requires jQuery, so if you're trying to avoid that you're out of luck.

Search results will show up on the same page as the search input.

After the content of your website is complete and final, you index all the html files once and save the results in a js file. Your search results will be generated from the keywords in this file.

Download these two zip files after making sure you have the pre-requisites

Indexing your HTML files

  1. From the Tipue Search zip, move the files tipuesearch_set.js, tipuesearch.js to the JS folder in your project. I recommend you minify these two files yourself.
  2. Have all your static website's HTML files in a single directory (you can move them back later)
  3. Move the file indexer.js from the other zip to this directory as well
  4. In terminal, execute the command
node indexer.js
  1. Move the newly generated tipuesearch_content.js file to the same JS folder as step 1.
  2. If you have moved any HTML files from the original directories in step 2, now is the time to move them back. If you are moving anything, make sure to update the url param for each file in the tipuesearch_content.js at the end of each line

Implementing Search on your website

Now that you have indexing out of the way, implementing search is easy. You are in charge of the style and these are simply instructions to display results in another div.

  1. Create an input field in your website of type search or text. in your HTML file(s). Optionally, wrap it in a <form>.
<input type="text" id="search_input" placeholder="Search" autocomplete=off>
  1. Include the Tipue Search JS files after your jQuery file
	...
	<script src="js/jquery.min.js"></script>
	<script src="js/tipuesearch.js"></script>
	<script src="js/tipuesearch_set.js"></script>
	<script src="js/tipuesearch_content.js"></script>
	<script src="js/scripts.js"></script>
	...
  1. In a JS file, add the following line of code to connect the input field to the search library
$('#search_input').tipuesearch();
  1. Create a div to display the search results.
<div id="tipue_search_content"></div>

I prefer to wrap this in a modal

<div class="modal">
	<div class="modal-content">
		<div class="modal-header">
			<h4>Search Results: <span class="search-keywords"></span></h4>
			<button class="close">&times;</button>
		</div>
		<div class="modal-body">
			<div id="tipue_search_content"></div>
		</div>
	</div>
</div>
  1. This is the structure of the search results that are returned on form submission
<div id="tipue_search_content">
	<div id="tipue_search_results_count">X results (X.XX seconds)</div>
	<div id="tipue_search_image_modal"><div class="tipue_search_image_close">✕</div><div class="tipue_search_image_block"><a id="tipue_search_zoom_url"><img id="tipue_search_zoom_img"></a><div id="tipue_search_zoom_text"></div></div></div>
	<div class="tipue_search_result">
		<div class="tipue_search_content_title">
			<a href="path/to/file1.html">File 1 Title</a>
		</div>
		<div class="tipue_search_content_url">
			<a href="path/to/file1.html">path/to/file1.html</a>
		</div>
		<div class="tipue_search_content_text">
			... Lorem Ipsum <span class="tipue_search_content_bold">Search Keywords</span> dolor sit amet ...</div>
		</div>
	</div>
	<div class="tipue_search_result">
		<div class="tipue_search_content_title">
			<a href="path/to/file2.html">File 2 Title</a>
		</div>
		<div class="tipue_search_content_url">
			<a href="path/to/file2.html">path/to/file2.html</a>
		</div>
		<div class="tipue_search_content_text">
			... consectetur adipiscing <span class="tipue_search_content_bold">Search Keywords</span> Suspendisse aliquam ...</div>
		</div>
	</div>
	...
</div>
  1. That is the default output above, but you can clean it up a lot. These are my preferred .tipuesearch() options and the HTML output below. JS
$('#tipue_search_input').tipuesearch({
	imageZoom: false,
	showTime: false,
	showTitleCount: false,
	showURL: false,
	wholeWords: false
});

HTML

<div id="tipue_search_content">
	<div id="tipue_search_results_count">X results</div>
	<div class="tipue_search_result">
		<div class="tipue_search_content_title">
			<a href="path/to/file1.html">File 1 Title</a>
		</div>
		<div class="tipue_search_content_text">
			... Lorem Ipsum <span class="tipue_search_content_bold">Search Keywords</span> dolor sit amet ...</div>
		</div>
	</div>
	<div class="tipue_search_result">
		<div class="tipue_search_content_title">
			<a href="path/to/file2.html">File 2 Title</a>
		</div>
		<div class="tipue_search_content_text">
			... consectetur adipiscing <span class="tipue_search_content_bold">Search Keywords</span> Suspendisse aliquam ...</div>
		</div>
	</div>
	...
</div>
  1. I like to add the search keywords to the top of my modal, so I use this line of code to copy it from the search input field
$('.search-keywords').text($('#search_input').val());
  1. You can style the results as needed using the classnames above.
  2. That's it. You're done

Notes

  1. If you have search in your navbar and need it on every page, I recommend bundling the tipuesearch.js, tipuesearch_set.js and the .tipuesearch() code above into a standalone search.js file and reusing that.

  2. If you only have a handful of HTML files, you could also add tipuesearch_content.js to that same file above

  3. If you're using a form to control your search input, don't forget to add e.preventDefault() on submission to prevent reload/redirect of the webpage

  4. I highly recommend the .tipuesearch() option wholeWords: false. This will allow partial search for words -> Searching for hell will allow Hello World to show up in the results. When that option is set to true (default), hell will return no results.


I've included copies of the files in case they get taken down / moved.

// https://github.com/MaxBittker/StaticIndexer/
var path = require("path");
var fs = require('fs');
var dir = __dirname; //'./tmpl/';
var data = {};
var cheerio = require('cheerio');
fs.writeFile('tipuesearch_content.js', 'var tipuesearch = {"pages": [\n', function(err) {
if (err) throw err;
console.log('Cleared:');
});
function cleanup(str, stripCommas = 0) {
if (str == undefined) {
str = "";
} else {
if (stripCommas == 1) {
str = str.replace(/,/g, ' '); // Replace all commas with spaces.
}
if (stripCommas == 2) { // Replace all punctuation with spaces.
body = body.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/, ' ');
}
str = $('<textarea />').html(str).text(); // Unescape html entities.
str = str.replace(/\s\s+/g, ' '); // Replace tabs, newlines and multiple spaces with 1 space.
}
return str;
}
fs.readdir(dir, function(err, files) {
if (err) throw err;
var c = 0;
files.forEach(function(file) {
fs.stat(path.join(dir, file), function(err, stats) {
if (!stats.isDirectory() && (path.extname(path.join(dir, file)) === ".html" || path.extname(path.join(dir, file)) === ".htm")) {
c++;
fs.readFile(path.join(__dirname, file), function(err, data) {
if (err) throw err;
$ = cheerio.load(data);
var body = $('h1,h2,p,table,div').map(function(i, el) {
return $(this).text();
}).get().join(' ');
body = cleanup(body);
var title = $('title').text();
title = cleanup(title);
var tags = $('meta[name="keywords"]').attr('content');
tags = cleanup(tags, 1);
fs.appendFile('tipuesearch_content.js', JSON.stringify({
title: title,
text: body,
tags: tags,
url: file
}) + ',\n', function(err) {
if (err) throw err;
console.log(file + ' processed!');
if (0 === --c) {
fs.appendFile('tipuesearch_content.js', ']};', function(err) {
if (err) throw err;
console.log('Done');
});
}
});
});
}
});
});
});
/*
Tipue Search 7.1
Copyright (c) 2019 Tipue
Tipue Search is released under the MIT License
http://www.tipue.com/search
*/
(function($) {
$.fn.tipuesearch = function(options) {
var set = $.extend( {
'contextBuffer' : 60,
'contextLength' : 60,
'contextStart' : 90,
'debug' : false,
'descriptiveWords' : 25,
'footerPages' : 3,
'highlightTerms' : true,
'imageZoom' : true,
'minimumLength' : 3,
'newWindow' : false,
'show' : 10,
'showContext' : true,
'showRelated' : true,
'showTime' : true,
'showTitleCount' : true,
'showURL' : true,
'wholeWords' : true
}, options);
return this.each(function() {
var tipuesearch_t_c = 0;
var tipue_search_w = '';
if (set.newWindow)
{
tipue_search_w = ' target="_blank"';
}
function getURLP(name)
{
var locSearch = location.search;
var splitted = (new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(locSearch)||[,""]);
var searchString = splitted[1].replace(/\+/g, '%20');
try
{
searchString = decodeURIComponent(searchString);
}
catch(e)
{
searchString = unescape(searchString);
}
return searchString || null;
}
if (getURLP('q'))
{
$('#tipue_search_input').val(getURLP('q'));
getTipueSearch(0, true);
}
$(this).keyup(function(event)
{
if(event.keyCode == '13')
{
getTipueSearch(0, true);
}
});
function getTipueSearch(start, replace)
{
window.scrollTo(0, 0);
var out = '';
var show_replace = false;
var show_stop = false;
var standard = true;
var c = 0;
var found = [];
var d_o = $('#tipue_search_input').val();
d_o = d_o.replace(/\+/g, ' ').replace(/\s\s+/g, ' ');
d_o = $.trim(d_o);
var d = d_o.toLowerCase();
if ((d.match("^\"") && d.match("\"$")) || (d.match("^'") && d.match("'$")))
{
standard = false;
}
var d_w = d.split(' ');
if (standard)
{
d = '';
for (var i = 0; i < d_w.length; i++)
{
var a_w = true;
for (var f = 0; f < tipuesearch_stop_words.length; f++)
{
if (d_w[i] == tipuesearch_stop_words[f])
{
a_w = false;
show_stop = true;
}
}
if (a_w)
{
d = d + ' ' + d_w[i];
}
}
d = $.trim(d);
d_w = d.split(' ');
}
else
{
d = d.substring(1, d.length - 1);
}
if (d.length >= set.minimumLength)
{
if (standard)
{
if (replace)
{
var d_r = d;
for (var i = 0; i < d_w.length; i++)
{
for (var f = 0; f < tipuesearch_replace.words.length; f++)
{
if (d_w[i] == tipuesearch_replace.words[f].word)
{
d = d.replace(d_w[i], tipuesearch_replace.words[f].replace_with);
show_replace = true;
}
}
}
d_w = d.split(' ');
}
var d_t = d;
for (var i = 0; i < d_w.length; i++)
{
for (var f = 0; f < tipuesearch_stem.words.length; f++)
{
if (d_w[i] == tipuesearch_stem.words[f].word)
{
d_t = d_t + ' ' + tipuesearch_stem.words[f].stem;
}
}
}
d_w = d_t.split(' ');
for (var i = 0; i < tipuesearch.pages.length; i++)
{
var score = 0;
var s_t = tipuesearch.pages[i].text;
for (var f = 0; f < d_w.length; f++)
{
if (set.wholeWords)
{
var pat = new RegExp('\\b' + d_w[f] + '\\b', 'gi');
}
else
{
var pat = new RegExp(d_w[f], 'gi');
}
if (tipuesearch.pages[i].title.search(pat) != -1)
{
var m_c = tipuesearch.pages[i].title.match(pat).length;
score += (20 * m_c);
}
if (tipuesearch.pages[i].text.search(pat) != -1)
{
var m_c = tipuesearch.pages[i].text.match(pat).length;
score += (20 * m_c);
}
if (tipuesearch.pages[i].tags)
{
if (tipuesearch.pages[i].tags.search(pat) != -1)
{
var m_c = tipuesearch.pages[i].tags.match(pat).length;
score += (10 * m_c);
}
}
if (tipuesearch.pages[i].url.search(pat) != -1)
{
score += 20;
}
if (score != 0)
{
for (var e = 0; e < tipuesearch_weight.weight.length; e++)
{
if (tipuesearch.pages[i].url == tipuesearch_weight.weight[e].url)
{
score += tipuesearch_weight.weight[e].score;
}
}
}
if (d_w[f].match('^-'))
{
pat = new RegExp(d_w[f].substring(1), 'i');
if (tipuesearch.pages[i].title.search(pat) != -1 || tipuesearch.pages[i].text.search(pat) != -1 || tipuesearch.pages[i].tags.search(pat) != -1)
{
score = 0;
}
}
}
if (score != 0)
{
found.push(
{
"score": score,
"title": tipuesearch.pages[i].title,
"desc": s_t,
"img": tipuesearch.pages[i].img,
"url": tipuesearch.pages[i].url,
"note": tipuesearch.pages[i].note
});
c++;
}
}
}
else
{
for (var i = 0; i < tipuesearch.pages.length; i++)
{
var score = 0;
var s_t = tipuesearch.pages[i].text;
var pat = new RegExp(d, 'gi');
if (tipuesearch.pages[i].title.search(pat) != -1)
{
var m_c = tipuesearch.pages[i].title.match(pat).length;
score += (20 * m_c);
}
if (tipuesearch.pages[i].text.search(pat) != -1)
{
var m_c = tipuesearch.pages[i].text.match(pat).length;
score += (20 * m_c);
}
if (tipuesearch.pages[i].tags)
{
if (tipuesearch.pages[i].tags.search(pat) != -1)
{
var m_c = tipuesearch.pages[i].tags.match(pat).length;
score += (10 * m_c);
}
}
if (tipuesearch.pages[i].url.search(pat) != -1)
{
score += 20;
}
if (score != 0)
{
for (var e = 0; e < tipuesearch_weight.weight.length; e++)
{
if (tipuesearch.pages[i].url == tipuesearch_weight.weight[e].url)
{
score += tipuesearch_weight.weight[e].score;
}
}
}
if (score != 0)
{
found.push(
{
"score": score,
"title": tipuesearch.pages[i].title,
"desc": s_t,
"img": tipuesearch.pages[i].img,
"url": tipuesearch.pages[i].url,
"note": tipuesearch.pages[i].note
});
c++;
}
}
}
if (c != 0)
{
if (set.showTitleCount && tipuesearch_t_c == 0)
{
var title = document.title;
document.title = '(' + c + ') ' + title;
tipuesearch_t_c++;
}
if (c == 1)
{
out += '<div id="tipue_search_results_count">' + tipuesearch_string_4;
}
else
{
var c_c = c.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
out += '<div id="tipue_search_results_count">' + c_c + ' ' + tipuesearch_string_5;
}
if (set.showTime)
{
var endTimer = new Date().getTime();
var time = (endTimer - startTimer) / 1000;
out += ' (' + time.toFixed(2) + ' ' + tipuesearch_string_14 + ')';
set.showTime = false;
}
out += '</div>';
if (set.showRelated && standard)
{
var ront = '';
f = 0;
for (var i = 0; i < tipuesearch_related.Related.length; i++)
{
if (d == tipuesearch_related.Related[i].search)
{
if (!f)
{
out += '<div class="tipue_search_related">' + tipuesearch_string_10 + ': ';
}
if (show_replace)
{
d_o = d;
}
if (tipuesearch_related.Related[i].include)
{
var r_d = d_o + ' ' + tipuesearch_related.Related[i].related;
}
else
{
var r_d = tipuesearch_related.Related[i].related;
}
ront += '<a class="tipue_search_related_btn" id="' + r_d + '">' + tipuesearch_related.Related[i].related + '</a>, ';
f++;
}
}
if (f)
{
ront = ront.slice(0, -2);
ront += '.</div>';
out += ront;
}
}
if (show_replace)
{
out += '<div id="tipue_search_replace">' + tipuesearch_string_2 + ' ' + d + '. ' + tipuesearch_string_3 + ' <a id="tipue_search_replaced">' + d_r + '</a></div>';
}
found.sort(function(a, b) { return b.score - a.score } );
var l_o = 0;
if (set.imageZoom)
{
out += '<div id="tipue_search_image_modal"><div class="tipue_search_image_close">&#10005;</div><div class="tipue_search_image_block"><a id="tipue_search_zoom_url"><img id="tipue_search_zoom_img"></a><div id="tipue_search_zoom_text"></div></div></div>';
}
for (var i = 0; i < found.length; i++)
{
if (l_o >= start && l_o < set.show + start)
{
out += '<div class="tipue_search_result">';
out += '<div class="tipue_search_content_title"><a href="' + found[i].url + '"' + tipue_search_w + '>' + found[i].title + '</a></div>';
if (set.debug)
{
out += '<div class="tipue_search_content_debug">Score: ' + found[i].score + '</div>';
}
if (set.showURL)
{
var s_u = found[i].url.toLowerCase();
if (s_u.indexOf('http://') == 0)
{
s_u = s_u.slice(7);
}
out += '<div class="tipue_search_content_url"><a href="' + found[i].url + '"' + tipue_search_w + '>' + s_u + '</a></div>';
}
if (found[i].img)
{
if (set.imageZoom)
{
out += '<div class="tipue_search_image"><img class="tipue_search_img tipue_search_image_zoom" src="' + found[i].img + '" alt="' + found[i].title + '" data-url="' + found[i].url + '"></div>';
}
else
{
out += '<div class="tipue_search_image"><a href="' + found[i].url + '"' + tipue_search_w + '><img class="tipue_search_img" src="' + found[i].img + '" alt="' + found[i].title + '"></a></div>';
}
}
if (found[i].desc)
{
var t = found[i].desc;
if (set.showContext)
{
d_w = d.split(' ');
var s_1 = found[i].desc.toLowerCase().indexOf(d_w[0]);
if (s_1 > set.contextStart)
{
var t_1 = t.substr(s_1 - set.contextBuffer);
var s_2 = t_1.indexOf(' ');
t_1 = t.substr(s_1 - set.contextBuffer + s_2);
t_1 = $.trim(t_1);
if (t_1.length > set.contextLength)
{
t = '... ' + t_1;
}
}
}
if (standard)
{
d_w = d.split(' ');
for (var f = 0; f < d_w.length; f++)
{
if (set.highlightTerms)
{
var patr = new RegExp('(' + d_w[f] + ')', 'gi');
t = t.replace(patr, "<h0011>$1<h0012>");
}
}
}
else if (set.highlightTerms)
{
var patr = new RegExp('(' + d + ')', 'gi');
t = t.replace(patr, "<span class=\"tipue_search_content_bold\">$1</span>");
}
var t_d = '';
var t_w = t.split(' ');
if (t_w.length < set.descriptiveWords)
{
t_d = t;
}
else
{
for (var f = 0; f < set.descriptiveWords; f++)
{
t_d += t_w[f] + ' ';
}
}
t_d = $.trim(t_d);
if (t_d.charAt(t_d.length - 1) != '.')
{
t_d += ' ...';
}
t_d = t_d.replace(/h0011/g, 'span class=\"tipue_search_content_bold\"');
t_d = t_d.replace(/h0012/g, '/span');
out += '<div class="tipue_search_content_text">' + t_d + '</div>';
}
if (found[i].note)
{
out += '<div class="tipue_search_note">' + found[i].note + '</div>';
}
out += '</div>';
}
l_o++;
}
if (c > set.show)
{
var pages = Math.ceil(c / set.show);
var page = (start / set.show);
if (set.footerPages < 3)
{
set.footerPages = 3;
}
out += '<div id="tipue_search_foot"><ul id="tipue_search_foot_boxes">';
if (start > 0)
{
out += '<li role="navigation"><a class="tipue_search_foot_box" accesskey="b" id="' + (start - set.show) + '_' + replace + '">' + tipuesearch_string_6 + '</a></li>';
}
if (page <= 2)
{
var p_b = pages;
if (pages > set.footerPages)
{
p_b = set.footerPages;
}
for (var f = 0; f < p_b; f++)
{
if (f == page)
{
out += '<li class="current" role="navigation">' + (f + 1) + '</li>';
}
else
{
out += '<li role="navigation"><a class="tipue_search_foot_box" id="' + (f * set.show) + '_' + replace + '">' + (f + 1) + '</a></li>';
}
}
}
else
{
var p_b = page + set.footerPages - 1;
if (p_b > pages)
{
p_b = pages;
}
for (var f = page - 1; f < p_b; f++)
{
if (f == page)
{
out += '<li class="current" role="navigation">' + (f + 1) + '</li>';
}
else
{
out += '<li role="navigation"><a class="tipue_search_foot_box" id="' + (f * set.show) + '_' + replace + '">' + (f + 1) + '</a></li>';
}
}
}
if (page + 1 != pages)
{
out += '<li role="navigation"><a class="tipue_search_foot_box" accesskey="m" id="' + (start + set.show) + '_' + replace + '">' + tipuesearch_string_7 + '</a></li>';
}
out += '</ul></div>';
}
}
else
{
out += '<div id="tipue_search_error">' + tipuesearch_string_8 + '</div>';
}
}
else
{
if (show_stop)
{
out += '<div id="tipue_search_error">' + tipuesearch_string_8 + ' ' + tipuesearch_string_9 + '</div>';
}
else
{
if (set.minimumLength == 1)
{
out += '<div id="tipue_search_error">' + tipuesearch_string_11 + '</div>';
}
else
{
out += '<div id="tipue_search_error">' + tipuesearch_string_12 + ' ' + set.minimumLength + ' ' + tipuesearch_string_13 + '</div>';
}
}
}
$('#tipue_search_content').hide().html(out).slideDown(200);
$('#tipue_search_replaced').click(function()
{
getTipueSearch(0, false);
});
$('.tipue_search_related_btn').click(function()
{
$('#tipue_search_input').val($(this).attr('id'));
getTipueSearch(0, true);
});
$('.tipue_search_image_zoom').click(function()
{
$('#tipue_search_image_modal').fadeIn(300);
$('#tipue_search_zoom_img').attr('src', this.src);
var z_u = $(this).attr('data-url');
$('#tipue_search_zoom_url').attr('href', z_u);
var z_o = this.alt + '<div class="tipue_search_zoom_options"><a href="' + this.src + '" target="_blank">' + tipuesearch_string_15 + '</a>&nbsp; <a href="' + z_u + '">' + tipuesearch_string_16 + '</a></div>';
$('#tipue_search_zoom_text').html(z_o);
});
$('.tipue_search_image_close').click(function()
{
$('#tipue_search_image_modal').fadeOut(300);
});
$('.tipue_search_foot_box').click(function()
{
var id_v = $(this).attr('id');
var id_a = id_v.split('_');
getTipueSearch(parseInt(id_a[0]), id_a[1]);
});
}
});
};
})(jQuery);
/*
Tipue Search 7.1
Copyright (c) 2019 Tipue
Tipue Search is released under the MIT License
http://www.tipue.com/search
*/
/*
Stop words
Stop words list from http://www.ranks.nl/stopwords
*/
var tipuesearch_stop_words = ["a", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "aren't", "as", "at", "be", "because", "been", "before", "being", "below", "between", "both", "but", "by", "can't", "cannot", "could", "couldn't", "did", "didn't", "do", "does", "doesn't", "doing", "don't", "down", "during", "each", "few", "for", "from", "further", "had", "hadn't", "has", "hasn't", "have", "haven't", "having", "he", "he'd", "he'll", "he's", "her", "here", "here's", "hers", "herself", "him", "himself", "his", "how", "how's", "i", "i'd", "i'll", "i'm", "i've", "if", "in", "into", "is", "isn't", "it", "it's", "its", "itself", "let's", "me", "more", "most", "mustn't", "my", "myself", "no", "nor", "not", "of", "off", "on", "once", "only", "or", "other", "ought", "our", "ours", "ourselves", "out", "over", "own", "same", "shan't", "she", "she'd", "she'll", "she's", "should", "shouldn't", "so", "some", "such", "than", "that", "that's", "the", "their", "theirs", "them", "themselves", "then", "there", "there's", "these", "they", "they'd", "they'll", "they're", "they've", "this", "those", "through", "to", "too", "under", "until", "up", "very", "was", "wasn't", "we", "we'd", "we'll", "we're", "we've", "were", "weren't", "what", "what's", "when", "when's", "where", "where's", "which", "while", "who", "who's", "whom", "why", "why's", "with", "won't", "would", "wouldn't", "you", "you'd", "you'll", "you're", "you've", "your", "yours", "yourself", "yourselves"];
// Word replace
var tipuesearch_replace = {'words': [
{'word': 'tip', 'replace_with': 'tipue'},
{'word': 'javscript', 'replace_with': 'javascript'},
{'word': 'jqeury', 'replace_with': 'jquery'}
]};
// Weighting
var tipuesearch_weight = {'weight': [
{'url': 'http://www.tipue.com', 'score': 60},
{'url': 'http://www.tipue.com/search', 'score': 60},
{'url': 'http://www.tipue.com/tipr', 'score': 30},
{'url': 'http://www.tipue.com/support', 'score': 20}
]};
// Illogical stemming
var tipuesearch_stem = {'words': [
{'word': 'e-mail', 'stem': 'email'},
{'word': 'javascript', 'stem': 'jquery'},
{'word': 'javascript', 'stem': 'js'}
]};
// Related
var tipuesearch_related = {'Related': [
{'search': 'tipue', 'related': 'Search', 'include': 1},
{'search': 'tipue', 'related': 'jQuery'},
{'search': 'tipue', 'related': 'Blog'},
{'search': 'tipue', 'related': 'Support'},
{'search': 'tipue search', 'related': 'Demo', 'include': 1},
{'search': 'tipue search', 'related': 'Support'}
]};
// Internal strings
var tipuesearch_string_1 = 'No title';
var tipuesearch_string_2 = 'Showing results for';
var tipuesearch_string_3 = 'Search instead for';
var tipuesearch_string_4 = '1 result';
var tipuesearch_string_5 = 'results';
var tipuesearch_string_6 = '<';
var tipuesearch_string_7 = '>';
var tipuesearch_string_8 = 'Nothing found.';
var tipuesearch_string_9 = 'Common words are largely ignored.';
var tipuesearch_string_10 = 'Related';
var tipuesearch_string_11 = 'Search should be one character or more.';
var tipuesearch_string_12 = 'Search should be';
var tipuesearch_string_13 = 'characters or more.';
var tipuesearch_string_14 = 'seconds';
var tipuesearch_string_15 = 'Open Image';
var tipuesearch_string_16 = 'Goto Page';
// Internals
// Timer for showTime
var startTimer = new Date().getTime();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment