Permalink
Browse files

Remove PHP dependency for example

  • Loading branch information...
1 parent b4ce7eb commit 006324e5f8dc3c9ffe7e57e9c102179efa3e2027 @meltingice committed Dec 15, 2012
Showing with 68 additions and 76 deletions.
  1. +57 −0 data.json
  2. +0 −69 data.php
  3. +6 −6 index.html
  4. +5 −1 package.json
View
@@ -0,0 +1,57 @@
+{
+ "states": [
+ "Alabama",
+ "Alaska",
+ "Arizona",
+ "Arkansas",
+ "California",
+ "Colorado",
+ "Connecticut",
+ "Delaware",
+ "District of Columbia",
+ "Florida",
+ "Georgia",
+ "Hawaii",
+ "Idaho",
+ "Illinois",
+ "Indiana",
+ "Iowa",
+ "Kansas",
+ "Kentucky",
+ "Louisiana",
+ "Maine",
+ "Maryland",
+ "Massachusetts",
+ "Michigan",
+ "Minnesota",
+ "Mississippi",
+ "Missouri",
+ "Montana",
+ "Nebraska",
+ "Nevada",
+ "New Hampshire",
+ "New Jersey",
+ "New Mexico",
+ "New York",
+ "North Carolina",
+ "North Dakota",
+ "Ohio",
+ "Oklahoma",
+ "Oregon",
+ "Pennsylvania",
+ "Puerto Rico",
+ "Rhode Island",
+ "South Carolina",
+ "South Dakota",
+ "Tennessee",
+ "Texas",
+ "Utah",
+ "Vermont",
+ "Virginia",
+ "Virgin Islands",
+ "Washington",
+ "West Virginia",
+ "Wisconsin",
+ "Wyoming"
+ ]
+}
View
@@ -1,69 +0,0 @@
-<?php
-
-if (!isset($_GET['term'])) exit;
-else $term = trim($_GET['term']);
-
-$data = array(
- 'Alabama',
- 'Alaska',
- 'Arizona',
- 'Arkansas',
- 'California',
- 'Colorado',
- 'Connecticut',
- 'Delaware',
- 'District of Columbia',
- 'Florida',
- 'Georgia',
- 'Hawaii',
- 'Idaho',
- 'Illinois',
- 'Indiana',
- 'Iowa',
- 'Kansas',
- 'Kentucky',
- 'Louisiana',
- 'Maine',
- 'Maryland',
- 'Massachusetts',
- 'Michigan',
- 'Minnesota',
- 'Mississippi',
- 'Missouri',
- 'Montana',
- 'Nebraska',
- 'Nevada',
- 'New Hampshire',
- 'New Jersey',
- 'New Mexico',
- 'New York',
- 'North Carolina',
- 'North Dakota',
- 'Ohio',
- 'Oklahoma',
- 'Oregon',
- 'Pennsylvania',
- 'Puerto Rico',
- 'Rhode Island',
- 'South Carolina',
- 'South Dakota',
- 'Tennessee',
- 'Texas',
- 'Utah',
- 'Vermont',
- 'Virginia',
- 'Virgin Islands',
- 'Washington',
- 'West Virginia',
- 'Wisconsin',
- 'Wyoming'
-);
-
-
-$results = array();
-foreach ($data as $i => $state) {
- $results[$state] = levenshtein($term, $state);
-}
-
-asort($results);
-echo json_encode(array_keys(array_slice($results, 0, 5)));
View
@@ -3,11 +3,11 @@
<head>
<title>Ajax-Chosen: Bootstrapping a Popular jQuery Plugin to add Ajax Autocomplete</title>
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
- <script type="text/javascript" src="/ajax-chosen/dist/chosen/chosen/chosen.jquery.min.js"></script>
- <script type="text/javascript" src="/ajax-chosen/lib/ajax-chosen.js"></script>
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
+ <script type="text/javascript" src="/dist/chosen/chosen/chosen.jquery.min.js"></script>
+ <script type="text/javascript" src="/lib/ajax-chosen.js"></script>
- <link type="text/css" rel="stylesheet" href="/ajax-chosen/dist/chosen/chosen/chosen.css" />
+ <link type="text/css" rel="stylesheet" href="/dist/chosen/chosen/chosen.css" />
<style type="text/css">
#example1, #example2, #example3 { width: 300px; display: block; }
@@ -17,12 +17,12 @@
$(document).ready(function () {
$("#example1,#example2,#example3").ajaxChosen({
type: 'GET',
- url: '/ajax-chosen/data.php',
+ url: '/data.json',
dataType: 'json'
}, function (data) {
var terms = {};
- $.each(data, function (i, val) {
+ $.each(data.states, function (i, val) {
terms[i] = val;
});
View
@@ -9,6 +9,10 @@
},
"devDependencies": {
"coffee-script": ">= 1.3.1",
- "jsmin": "*"
+ "jsmin": "*",
+ "servedir": "*"
+ },
+ "scripts": {
+ "start": "servedir"
}
}

0 comments on commit 006324e

Please sign in to comment.