things all work, about time for public release

This commit is contained in:
2010-03-10 17:25:12 +02:00
parent 8e3042cab5
commit 933cbc8ab9
8 changed files with 494 additions and 140 deletions

View File

@@ -4,11 +4,32 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb
/* @end */
body {
background: #fff;
font: 12px/1.5 'Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif;
}
p, dl, hr, h1, h2, h3, h4, h5, h6, ol,
ul, pre, table, address, fieldset {
margin-bottom: 20px;
}
h1 { font-size: 25px; }
h2 { font-size: 23px; }
h3 { font-size: 21px; }
h4 { font-size: 19px; }
h5 { font-size: 17px; }
h6 { font-size: 13px; }
input {
border: 1px solid #999;
width: 200px;
padding: 3px 3px;
font-size: 12px;
}
#container {
width: 960px;
margin: 0px auto;
text-align: center;
}

View File

@@ -1,60 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>examples</title>
<link rel="stylesheet" href="demo.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="../javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="../suggest_results/jquery.suggest_results.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="../suggest_results/jquery.suggest_results.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
var data = [
{title: "head", href: "/head", match: "head zzz"},
{title: "headache", href: "/headache", match: "headache zzz"},
{title: "health", href: "/health", match: "health zzz"},
{title: "healthcare", href: "/healthcare", match: "healthcare zzz"},
{title: "healthier", href: "/healthier", match: "healthier zzz"},
{title: "heck", href: "/heck", match: "heck zzz"},
{title: "hectic", href: "/hectic", match: "hectic zzz"},
{title: "held", href: "/held", match: "held zzz"},
{title: "hell", href: "/hell", match: "hell zzz"},
];
$("input").suggest_results({
data: data
});
});
</script>
</head>
<body>
<div id="container">
<br />
<br />
<input type="text" name="example1" value="" id="example1" />
<br />
<br />
<input type="text" name="example2" value="" id="example2" />
<br />
<br />
<input type="text" name="example3" value="" id="example3" />
</div>
</body>
</html>

102
demo/demo.js Normal file
View File

@@ -0,0 +1,102 @@
var data = [
{"title": "Ädams, Egbert", "info": "Bedfordshire", "href": "/demo/user/1"},
{"title": "Altman, Alisha", "info": "Buckinghamshire", "href": "/demo/user/2"},
{"title": "Archibald, Janna", "info": "Cambridgeshire", "href": "/demo/user/3"},
{"title": "Auman, Cody", "info": "Cheshire", "href": "/demo/user/4"},
{"title": "Bagley, Sheree", "info": "Cornwall", "href": "/demo/user/5"},
{"title": "Ballou, Wilmot", "info": "Cumbria", "href": "/demo/user/6"},
{"title": "Bard, Cassian", "info": "Derbyshire", "href": "/demo/user/1"},
{"title": "Bash, Latanya", "info": "Devon", "href": "/demo/user/2"},
{"title": "Beail, May", "info": "Dorset", "href": "/demo/user/3"},
{"title": "Black, Lux", "info": "Durham", "href": "/demo/user/4"},
{"title": "Bloise, India", "info": "East Sussex", "href": "/demo/user/5"},
{"title": "Blyant, Nora", "info": "Essex", "href": "/demo/user/6"},
{"title": "Bollinger, Carter", "info": "Gloucestershire", "href": "/demo/user/1"},
{"title": "Burns, Jaycob", "info": "Hampshire", "href": "/demo/user/2"},
{"title": "Carden, Preston", "info": "Hertfordshire", "href": "/demo/user/3"},
{"title": "Carter, Merrilyn", "info": "Kent", "href": "/demo/user/4"},
{"title": "Christner, Addie", "info": "Lancashire", "href": "/demo/user/5"},
{"title": "Churchill, Mirabelle", "info": "Leicestershire", "href": "/demo/user/6"},
{"title": "Conkle, Erin", "info": "Lincolnshire", "href": "/demo/user/1"},
{"title": "Countryman, Abner", "info": "Norfolk", "href": "/demo/user/2"},
{"title": "Courtney, Edgar", "info": "Northamptonshire", "href": "/demo/user/3"},
{"title": "Cowher, Antony", "info": "Northumberland", "href": "/demo/user/4"},
{"title": "Craig, Charlie", "info": "North Yorkshire", "href": "/demo/user/5"},
{"title": "Cram, Zacharias", "info": "Nottinghamshire", "href": "/demo/user/6"},
{"title": "Cressman, Ted", "info": "Oxfordshire", "href": "/demo/user/1"},
{"title": "Crissman, Annie", "info": "Shropshire", "href": "/demo/user/2"},
{"title": "Davis, Palmer", "info": "Somerset", "href": "/demo/user/3"},
{"title": "Downing, Casimir", "info": "Staffordshire", "href": "/demo/user/4"},
{"title": "Earl, Missie", "info": "Suffolk", "href": "/demo/user/5"},
{"title": "Eckert, Janele", "info": "Surrey", "href": "/demo/user/6"},
{"title": "Eisenman, Briar", "info": "Warwickshire", "href": "/demo/user/1"},
{"title": "Fitzgerald, Love", "info": "West Sussex", "href": "/demo/user/2"},
{"title": "Fleming, Sidney", "info": "Wiltshire", "href": "/demo/user/3"},
{"title": "Fuchs, Bridger", "info": "Worcestershire", "href": "/demo/user/4"},
{"title": "Fulton, Rosalynne", "info": "Durham", "href": "/demo/user/5"},
{"title": "Fye, Webster", "info": "East Sussex", "href": "/demo/user/6"},
{"title": "Geyer, Rylan", "info": "Essex", "href": "/demo/user/1"},
{"title": "Greene, Charis", "info": "Gloucestershire", "href": "/demo/user/2"},
{"title": "Greif, Jem", "info": "Hampshire", "href": "/demo/user/3"},
{"title": "Guest, Sarahjeanne", "info": "Hertfordshire", "href": "/demo/user/4"},
{"title": "Harper, Phyllida", "info": "Kent", "href": "/demo/user/5"},
{"title": "Hildyard, Erskine", "info": "Lancashire", "href": "/demo/user/6"},
{"title": "Hoenshell, Eulalia", "info": "Leicestershire", "href": "/demo/user/1"},
{"title": "Isaman, Lalo", "info": "Lincolnshire", "href": "/demo/user/2"},
{"title": "James, Diamond", "info": "Norfolk", "href": "/demo/user/3"},
{"title": "Jenkins, Merrill", "info": "Northamptonshire", "href": "/demo/user/4"},
{"title": "Jube, Bennett", "info": "Northumberland", "href": "/demo/user/5"},
{"title": "Kava, Marianne", "info": "North Yorkshire", "href": "/demo/user/6"},
{"title": "Kern, Linda", "info": "Nottinghamshire", "href": "/demo/user/1"},
{"title": "Klockman, Jenifer", "info": "Oxfordshire", "href": "/demo/user/2"},
{"title": "Lacon, Quincy", "info": "Shropshire", "href": "/demo/user/3"},
{"title": "Laurenzi, Leland", "info": "Somerset", "href": "/demo/user/4"},
{"title": "Leichter, Jeane", "info": "Staffordshire", "href": "/demo/user/5"},
{"title": "Leslie, Kerrie", "info": "Suffolk", "href": "/demo/user/6"},
{"title": "Lester, Noah", "info": "Surrey", "href": "/demo/user/1"},
{"title": "Llora, Roxana", "info": "Warwickshire", "href": "/demo/user/2"},
{"title": "Lombardi, Polly", "info": "West Sussex", "href": "/demo/user/3"},
{"title": "Lowstetter, Louisa", "info": "Wiltshire", "href": "/demo/user/4"},
{"title": "Mays, Emery", "info": "Worcestershire", "href": "/demo/user/5"},
{"title": "Mccullough, Bernadine", "info": "Durham", "href": "/demo/user/6"},
{"title": "Mckinnon, Kristie", "info": "East Sussex", "href": "/demo/user/1"},
{"title": "Meyers, Hector", "info": "Essex", "href": "/demo/user/2"},
{"title": "Monahan, Penelope", "info": "Gloucestershire", "href": "/demo/user/3"},
{"title": "Mull, Kaelea", "info": "Hampshire", "href": "/demo/user/4"},
{"title": "Newbiggin, Osmond", "info": "Hertfordshire", "href": "/demo/user/5"},
{"title": "Nickolson, Alfreda", "info": "Kent", "href": "/demo/user/6"},
{"title": "Pawle, Jacki", "info": "Lancashire", "href": "/demo/user/1"},
{"title": "Paynter, Nerissa", "info": "Leicestershire", "href": "/demo/user/2"},
{"title": "Pinney, Wilkie", "info": "Lincolnshire", "href": "/demo/user/3"},
{"title": "Pratt, Ricky", "info": "Norfolk", "href": "/demo/user/4"},
{"title": "Putnam, Stephanie", "info": "Northamptonshire", "href": "/demo/user/5"},
{"title": "Ream, Terrence", "info": "Northumberland", "href": "/demo/user/6"},
{"title": "Rumbaugh, Noelle", "info": "North Yorkshire", "href": "/demo/user/1"},
{"title": "Ryals, Titania", "info": "Nottinghamshire", "href": "/demo/user/2"},
{"title": "Saylor, Lenora", "info": "Oxfordshire", "href": "/demo/user/3"},
{"title": "Schofield, Denice", "info": "Shropshire", "href": "/demo/user/4"},
{"title": "Schuck, John", "info": "Somerset", "href": "/demo/user/5"},
{"title": "Scott, Clover", "info": "Staffordshire", "href": "/demo/user/6"},
{"title": "Smith, Estella", "info": "Suffolk", "href": "/demo/user/1"},
{"title": "Smothers, Matthew", "info": "Surrey", "href": "/demo/user/2"},
{"title": "Stainforth, Maurene", "info": "Warwickshire", "href": "/demo/user/3"},
{"title": "Stephenson, Phillipa", "info": "West Sussex", "href": "/demo/user/4"},
{"title": "Stewart, Hyram", "info": "Wiltshire", "href": "/demo/user/5"},
{"title": "Stough, Gussie", "info": "Worcestershire", "href": "/demo/user/6"},
{"title": "Strickland, Temple", "info": "Durham", "href": "/demo/user/1"},
{"title": "Sullivan, Gertie", "info": "East Sussex", "href": "/demo/user/2"},
{"title": "Swink, Stefanie", "info": "Essex", "href": "/demo/user/3"},
{"title": "Tavoularis, Terance", "info": "Gloucestershire", "href": "/demo/user/4"},
{"title": "Taylor, Kizzy", "info": "Hampshire", "href": "/demo/user/5"},
{"title": "Thigpen, Alwyn", "info": "Hertfordshire", "href": "/demo/user/6"},
{"title": "Treeby, Jim", "info": "Kent", "href": "/demo/user/1"},
{"title": "Trevithick, Jayme", "info": "Lancashire", "href": "/demo/user/2"},
{"title": "Waldron, Ashley", "info": "Leicestershire", "href": "/demo/user/3"},
{"title": "Wheeler, Bysshe", "info": "Lincolnshire", "href": "/demo/user/4"},
{"title": "Whishaw, Dodie", "info": "Norfolk", "href": "/demo/user/5"},
{"title": "Whitehead, Jericho", "info": "Northamptonshire", "href": "/demo/user/6"},
{"title": "Wilks, Debby", "info": "Northumberland", "href": "/demo/user/1"},
{"title": "Wire, Tallulah", "info": "North Yorkshire", "href": "/demo/user/2"},
{"title": "Woodworth, Alexandria", "info": "Nottinghamshire", "href": "/demo/user/3"},
{"title": "Zaun, Jillie", "info": "", "href": ""}
];

View File

@@ -1,11 +0,0 @@
[
{title: "head", href: "/head", match: "head zzz"},
{title: "headache", href: "/headache", match: "headache zzz"},
{title: "health", href: "/health", match: "health zzz"},
{title: "healthcare", href: "/healthcare", match: "healthcare zzz"},
{title: "healthier", href: "/healthier", match: "healthier zzz"},
{title: "heck", href: "/heck", match: "heck zzz"},
{title: "hectic", href: "/hectic", match: "hectic zzz"},
{title: "held", href: "/held", match: "held zzz"},
{title: "hell", href: "/hell", match: "hell zzz"},
];

71
demo/index.html Normal file
View File

@@ -0,0 +1,71 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Suggest Results Demo</title>
<link rel="stylesheet" href="demo.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="../javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="../suggest_results/jquery.suggest_results.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="../suggest_results/jquery.suggest_results.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="demo.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("#example1").suggest_results({
data: data
});
$("#example2").suggest_results({
url: "server-side.php"
});
$("#example3").suggest_results({
url: "server-side.php",
name: "example3",
limit: 4,
tpl_result_body: '<span class="title">{{title}}</span><span class="info">{{info}}</span>'
});
});
</script>
<style type="text/css" media="screen">
/* Example 3 */
#suggest_results.example3 ol li span.info {
color: #888;
font-size: 12px;
}
</style>
</head>
<body>
<div id="container">
<p></p>
<h1>Suggest Results Demo</h1>
<p>
<strong>Results from local array:</strong><br />
<input type="text" name="example1" value="" id="example1" />
</p>
<p>
<strong>Results from ajax call:</strong><br />
<input type="text" name="example2" value="" id="example2" />
</p>
<p>
<strong>Customized results from ajax call:</strong><br />
<input type="text" name="example3" value="" id="example3" />
</p>
</div>
</body>
</html>

135
demo/server-side.php Normal file
View File

@@ -0,0 +1,135 @@
<?php
/*
Borrowed and modified this example file from some other search suggest script.
*/
/*
this is just a static test version using a hard-coded countries array.
normally you would be populating the array out of a database
*/
$aUsers = array(
"Ädams, Egbert", "Altman, Alisha", "Archibald, Janna", "Auman, Cody", "Bagley, Sheree",
"Ballou, Wilmot", "Bard, Cassian", "Bash, Latanya", "Beail, May", "Black, Lux",
"Bloise, India", "Blyant, Nora", "Bollinger, Carter", "Burns, Jaycob", "Carden, Preston",
"Carter, Merrilyn", "Christner, Addie", "Churchill, Mirabelle", "Conkle, Erin",
"Countryman, Abner", "Courtney, Edgar", "Cowher, Antony", "Craig, Charlie",
"Cram, Zacharias", "Cressman, Ted", "Crissman, Annie", "Davis, Palmer",
"Downing, Casimir", "Earl, Missie", "Eckert, Janele", "Eisenman, Briar",
"Fitzgerald, Love", "Fleming, Sidney", "Fuchs, Bridger", "Fulton, Rosalynne",
"Fye, Webster", "Geyer, Rylan", "Greene, Charis", "Greif, Jem", "Guest, Sarahjeanne",
"Harper, Phyllida", "Hildyard, Erskine", "Hoenshell, Eulalia", "Isaman, Lalo",
"James, Diamond", "Jenkins, Merrill", "Jube, Bennett", "Kava, Marianne", "Kern, Linda",
"Klockman, Jenifer", "Lacon, Quincy", "Laurenzi, Leland", "Leichter, Jeane",
"Leslie, Kerrie", "Lester, Noah", "Llora, Roxana", "Lombardi, Polly", "Lowstetter, Louisa",
"Mays, Emery", "Mccullough, Bernadine", "Mckinnon, Kristie", "Meyers, Hector",
"Monahan, Penelope", "Mull, Kaelea", "Newbiggin, Osmond", "Nickolson, Alfreda",
"Pawle, Jacki", "Paynter, Nerissa", "Pinney, Wilkie", "Pratt, Ricky", "Putnam, Stephanie",
"Ream, Terrence", "Rumbaugh, Noelle", "Ryals, Titania", "Saylor, Lenora",
"Schofield, Denice", "Schuck, John", "Scott, Clover", "Smith, Estella", "Smothers, Matthew",
"Stainforth, Maurene", "Stephenson, Phillipa", "Stewart, Hyram", "Stough, Gussie",
"Strickland, Temple", "Sullivan, Gertie", "Swink, Stefanie", "Tavoularis, Terance",
"Taylor, Kizzy", "Thigpen, Alwyn", "Treeby, Jim", "Trevithick, Jayme", "Waldron, Ashley",
"Wheeler, Bysshe", "Whishaw, Dodie", "Whitehead, Jericho", "Wilks, Debby", "Wire, Tallulah",
"Woodworth, Alexandria", "Zaun, Jillie"
);
$aInfo = array(
"Bedfordshire", "Buckinghamshire", "Cambridgeshire", "Cheshire", "Cornwall", "Cumbria",
"Derbyshire", "Devon", "Dorset", "Durham", "East Sussex", "Essex", "Gloucestershire",
"Hampshire", "Hertfordshire", "Kent", "Lancashire", "Leicestershire", "Lincolnshire",
"Norfolk", "Northamptonshire", "Northumberland", "North Yorkshire", "Nottinghamshire",
"Oxfordshire", "Shropshire", "Somerset", "Staffordshire", "Suffolk", "Surrey",
"Warwickshire", "West Sussex", "Wiltshire", "Worcestershire", "Durham", "East Sussex",
"Essex", "Gloucestershire", "Hampshire", "Hertfordshire", "Kent", "Lancashire",
"Leicestershire", "Lincolnshire", "Norfolk", "Northamptonshire", "Northumberland",
"North Yorkshire", "Nottinghamshire", "Oxfordshire", "Shropshire", "Somerset",
"Staffordshire", "Suffolk", "Surrey", "Warwickshire", "West Sussex", "Wiltshire",
"Worcestershire", "Durham", "East Sussex", "Essex", "Gloucestershire", "Hampshire",
"Hertfordshire", "Kent", "Lancashire", "Leicestershire", "Lincolnshire", "Norfolk",
"Northamptonshire", "Northumberland", "North Yorkshire", "Nottinghamshire",
"Oxfordshire", "Shropshire", "Somerset", "Staffordshire", "Suffolk", "Surrey",
"Warwickshire", "West Sussex", "Wiltshire", "Worcestershire", "Durham", "East Sussex",
"Essex", "Gloucestershire", "Hampshire", "Hertfordshire", "Kent", "Lancashire",
"Leicestershire", "Lincolnshire", "Norfolk", "Northamptonshire", "Northumberland",
"North Yorkshire", "Nottinghamshire"
);
$aImg = array(
"demo/cast1", "demo/cast2", "demo/cast3", "demo/cast4", "demo/cast5",
"demo/cast6", "demo/cast1", "demo/cast2", "demo/cast3", "demo/cast4",
"demo/cast5", "demo/cast6", "demo/cast1", "demo/cast2", "demo/cast3",
"demo/cast4", "demo/cast5", "demo/cast6", "demo/cast1", "demo/cast2",
"demo/cast3", "demo/cast4", "demo/cast5", "demo/cast6", "demo/cast1",
"demo/cast2", "demo/cast3", "demo/cast4", "demo/cast5", "demo/cast6",
"demo/cast1", "demo/cast2", "demo/cast3", "demo/cast4", "demo/cast5",
"demo/cast6", "demo/cast1", "demo/cast2", "demo/cast3", "demo/cast4",
"demo/cast5", "demo/cast6", "demo/cast1", "demo/cast2", "demo/cast3",
"demo/cast4", "demo/cast5", "demo/cast6", "demo/cast1", "demo/cast2",
"demo/cast3", "demo/cast4", "demo/cast5", "demo/cast6", "demo/cast1",
"demo/cast2", "demo/cast3", "demo/cast4", "demo/cast5", "demo/cast6",
"demo/cast1", "demo/cast2", "demo/cast3", "demo/cast4", "demo/cast5",
"demo/cast6", "demo/cast1", "demo/cast2", "demo/cast3", "demo/cast4",
"demo/cast5", "demo/cast6", "demo/cast1", "demo/cast2", "demo/cast3",
"demo/cast4", "demo/cast5", "demo/cast6", "demo/cast1", "demo/cast2",
"demo/cast3", "demo/cast4", "demo/cast5", "demo/cast6", "demo/cast1",
"demo/cast2", "demo/cast3", "demo/cast4", "demo/cast5", "demo/cast6",
"demo/cast1", "demo/cast2", "demo/cast3", "demo/cast4", "demo/cast5",
"demo/cast6", "demo/cast1", "demo/cast2", "demo/cast3",
);
$input = strtolower( $_GET['search'] );
$len = strlen($input);
$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 0;
$aResults = array();
$count = 0;
if ($len)
{
for ($i=0;$i<count($aUsers);$i++)
{
// had to use utf_decode, here
// not necessary if the results are coming from mysql
//
// if (strtolower(substr(utf8_decode($aUsers[$i]),0,$len)) == $input)
if (strpos(strtolower($aUsers[$i]), $input) !== false)
{
$count++;
$aResults[] = array(
"id"=>($i+1),
"title"=>htmlspecialchars($aUsers[$i]),
"info"=>htmlspecialchars($aInfo[$i]),
"href"=>$aImg[$i],
);
}
if ($limit && $count==$limit)
break;
}
}
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
header("Content-Type: application/json");
echo "{\"results\": [\n\t";
$arr = array();
for ($i=0;$i<count($aResults);$i++)
{
$arr[] = "{\"title\": \"".$aResults[$i]['title']."\", " .
"\"info\": \"".$aResults[$i]['info']."\", " .
"\"href\": \"".$aResults[$i]['href']."\"}";
}
echo implode(",\n\t", $arr);
echo "\n]}";
?>