Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhea0 committed Oct 18, 2013
1 parent 3efd703 commit d81fea0
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 6 deletions.
15 changes: 15 additions & 0 deletions .gitignore
@@ -0,0 +1,15 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

npm-debug.log
node_modules
30 changes: 26 additions & 4 deletions app.js
Expand Up @@ -4,8 +4,8 @@
*/

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
// var routes = require('./routes');
// var user = require('./routes/user');
var http = require('http');
var path = require('path');

Expand All @@ -27,8 +27,30 @@ if ('development' == app.get('env')) {
app.use(express.errorHandler());
}

app.get('/', routes.index);
app.get('/users', user.list);
app.get('/', function(req, res) {res.render('index')});

app.get('/searching', function(req, res){
console.log(val)
// YQL
var url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20craigslist.search" +
"%20where%20location%3D%22sfbay%22%20and%20type%3D%22jjj%22%20and%20query%3D%22" + val + "%22&format=" +
"json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
craig = []
if(data.query.count === 0 || typeof data.query.results.RDF.item === 'undefined') {
craig = "No results found. Try again."
} else {
for (var i = 0; i < data.query.results.RDF.item.length; i++) {
craig = data.query.results.RDF.item[i].title[0]
}
}

res.send(craig);
})



// app.get('/', routes.index);
// app.get('/users', user.list);

http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
Expand Down
18 changes: 18 additions & 0 deletions public/javascripts/main.js
@@ -0,0 +1,18 @@
$(function(){
$('#search').on('keyup', function(e){
if(e.keyCode === 13) {
var val = $(this).val()

$.ajax({
type: 'GET',
url: '/searching',
data: {search: val},
dataType: 'json',
success: function(data) {
console.log(data)
$('#results').html(data);
}
})
}
})
})
8 changes: 8 additions & 0 deletions public/stylesheets/style.css
Expand Up @@ -5,4 +5,12 @@ body {

a {
color: #00B7FF;
}

#search {
text-align: center;
width:500px;
height: 70px;
font-size:3.5em;
border-radius:8px;
}
7 changes: 5 additions & 2 deletions views/index.jade
@@ -1,5 +1,8 @@
extends layout

block content
h1= title
p Welcome to #{title}
input#search(type="search", placeholder="Search Craig's Jobs")
#results

script(src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js")
script(src="/javascripts/main.js")

0 comments on commit d81fea0

Please sign in to comment.