Permalink
Browse files

Add example and script to run example

  • Loading branch information...
arunthampi committed Apr 18, 2014
1 parent 5691343 commit 0e4a8092f8dc2016ad726aeec2609fd0068d7504
Showing with 83 additions and 0 deletions.
  1. +38 −0 examples/index.html
  2. +1 −0 examples/mailcheck.js
  3. +4 −0 script/server
  4. +40 −0 script/server.js
View
@@ -0,0 +1,38 @@
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="mailcheck.js"></script>
<title>Kicksend Mailcheck</title>
</head>
<body>
<h1>Kicksend Mailcheck</h1>
<p>For a demo, enter a@hotmale.com or b@gmail.co in the field below:</p>
<input id="email" name="email" type="email" />
<input name="Submit" type="submit" />
<p id="suggestion"></p>
<script>
var domains = ['hotmail.com', 'gmail.com', 'aol.com'];
var topLevelDomains = ["com", "net", "org"];
$('#email').on('blur', function(event) {
console.log("event ", event);
console.log("this ", $(this));
$(this).mailcheck({
domains: domains, // optional
topLevelDomains: topLevelDomains, // optional
suggested: function(element, suggestion) {
// callback code
console.log("suggestion ", suggestion.full);
$('#suggestion').html("Did you mean <b><i>" + suggestion.full + "</b></i>?");
},
empty: function(element) {
// callback code
$('#suggestion').html('No Suggestions :(');
}
});
});
</script>
</body>
View
View
@@ -0,0 +1,4 @@
#!/bin/bash
ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/../examples
node script/server.js 3000 $ABSOLUTE_PATH
View
@@ -0,0 +1,40 @@
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
base = process.argv[3] || process.cwd(),
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(base, uri);
fs.exists(filename, function(exists) {
console.log("File Name ", filename);
if(!exists) {
response.writeHead(404, {"Content-Type": "text/plain"});
response.write("404 Not Found\n");
response.end();
return;
}
if (fs.statSync(filename).isDirectory()) filename += '/index.html';
fs.readFile(filename, "binary", function(err, file) {
if(err) {
response.writeHead(500, {"Content-Type": "text/plain"});
response.write(err + "\n");
response.end();
return;
}
response.writeHead(200);
response.write(file, "binary");
response.end();
});
});
}).listen(parseInt(port, 10), '0.0.0.0');
console.log("Static file server running at\n => http://localhost:" + port + "/\nCTRL + C to shutdown");

0 comments on commit 0e4a809

Please sign in to comment.