3 <title>listing directory {directory}</title>
7 var el = 'string' == typeof id
8 ? document.getElementById(id)
11 el.on = function(event, fn){
12 if ('content loaded' == event) event = 'DOMContentLoaded';
13 el.addEventListener(event, fn, false);
16 el.all = function(selector){
17 return $(el.querySelectorAll(selector));
20 el.each = function(fn){
21 for (var i = 0, len = el.length; i < len; ++i) {
26 el.getClasses = function(){
27 return this.getAttribute('class').split(/\s+/);
30 el.addClass = function(name){
31 var classes = this.getAttribute('class');
32 el.setAttribute('class', classes
33 ? classes + ' ' + name
37 el.removeClass = function(name){
38 var classes = this.getClasses().filter(function(curr){
41 this.setAttribute('class', classes);
48 var str = $('search').value
49 , links = $('files').all('a');
51 links.each(function(link){
52 var text = link.textContent;
54 if ('..' == text) return;
55 if (str.length && ~text.indexOf(str)) {
56 link.addClass('highlight');
58 link.removeClass('highlight');
63 $(window).on('content loaded', function(){
64 $('search').on('keyup', search);
68 <body class="directory">
69 <input id="search" type="text" placeholder="Search" autocomplete="off" />
71 <h1>{linked-path}</h1>