Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>DC Municipal Regulations</title> | ||
<style> | ||
body { | ||
font:normal 15px/20px 'Helvetica'; | ||
} | ||
input { | ||
font-size:50px; | ||
} | ||
#output { | ||
width:100%; | ||
height:400px; | ||
} | ||
#output a { | ||
display:block; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<form action='POST'> | ||
<input type='text' id='search' /> | ||
</form> | ||
<pre id='output'></pre> | ||
<script src='jquery.js'></script> | ||
<script> | ||
var indexes = {}, titles; | ||
$.getJSON('titles.json', function(o) { | ||
titles = o; | ||
}); | ||
var $output = $('#output'); | ||
$('#search').keyup(function() { | ||
var v = this.value; | ||
var norm = v.replace(/[^A-Za-z]/g, '').toLowerCase(); | ||
if (norm.length > 2) { | ||
var a = norm[0]; | ||
if (!indexes[a]) { | ||
indexes[a] = {}; | ||
$('#output').text(''); | ||
$.getJSON('indexes/' + a + '.json', function(o) { | ||
indexes[a] = o; | ||
}); | ||
} else { | ||
$output.empty(); | ||
(indexes[a][norm] || []).map(function(i) { | ||
var link = document.createElement('a'); | ||
link.href = 'text/' + i + '.txt'; | ||
link.innerHTML = titles[i]; | ||
$output.append(link); | ||
}); | ||
} | ||
} else { | ||
$output.text(''); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var _s = require('underscore.string'), | ||
path = require('path'), | ||
fs = require('fs'); | ||
|
||
fs.readdir('docs', function(err, files) { | ||
var titles = {}; | ||
files.filter(function(f) { | ||
return f.indexOf('.title') !== -1; | ||
}).map(function(t) { | ||
var id = +t.match(/(\d+)/)[0]; | ||
titles[id] = fs.readFileSync('docs/' + t, 'utf8').trim(); | ||
}); | ||
console.log('done'); | ||
fs.writeFileSync('titles.json', JSON.stringify(titles)); | ||
console.log('writing thing'); | ||
}); |