Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:daleharvey/erldocs.com
Browse files Browse the repository at this point in the history
  • Loading branch information
Dale committed Aug 17, 2009
2 parents 2f3a77a + cee4995 commit fd6a3bf
Show file tree
Hide file tree
Showing 4 changed files with 6,309 additions and 7 deletions.
9 changes: 9 additions & 0 deletions www/erldocs.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ padding:10px;
#sidebar input {
display:block;
width:228px;
outline:none;
font-family: 13px Arial, sans-serif;
padding:2px;
margin:3px;
Expand Down Expand Up @@ -152,6 +153,14 @@ border-color: #CCC #999 #999 #CCC;
background:#DDD;
}

#results li.selected {
background:#990033;
color:white;
}
#results li.selected a, #results li.selected span {
color:white;
}

#results .sub {
color:#333333;
font-size:11px;
Expand Down
51 changes: 45 additions & 6 deletions www/erldocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ ErlDocs = function() {

var that = this;

this.search = $("#search");
this.results = $("#results");
this.search = $("#search");
this.results = $("#results");
this.selected = null;
this.resultsCount = 0;

that.search.focus( function() {
if( that.search.val() == "Search" ) {
Expand All @@ -13,7 +15,7 @@ ErlDocs = function() {

that.search.keypress( function(e) {
setTimeout( function() {
that.filter(that.search.val());
that.keypress(e);
},0);
});

Expand All @@ -31,6 +33,38 @@ ErlDocs = function() {
this.showModules();
}

if( qs && qs.i ) {
this.setSelected(parseInt(qs.i, 10));
}

this.search.focus();
};

ErlDocs.prototype.setSelected = function(x, down)
{
down = (typeof down == "undefined") ? false : down;

if( x >= 0 && x < this.resultsCount ) {
if( this.selected != null ) {
this.results.children("li").eq(this.selected).removeClass("selected");
}
this.selected = x;
var selection = this.results.children("li").eq(x).addClass("selected");
selection[0].scrollIntoView(down);
}
};

ErlDocs.prototype.keypress = function(e)
{
if( e.keyCode == 40 ) { //DOWN
this.setSelected(this.selected + 1, false);
} else if( e.keyCode == 38 ) { //UP
this.setSelected(this.selected - 1, false);
} else if ( e.keyCode == 13 ) { //ENTER
document.location.href = this.results.children("li:eq("+this.selected+") a").attr("href");
} else {
this.filter(this.search.val());
}
};

ErlDocs.prototype.window_resize = function()
Expand All @@ -43,17 +77,20 @@ ErlDocs.prototype.showModules = function()
var html = "";
var preurl = document.location.href.match("index.html") == null ? "../" : "";

for( var i=0; i < ErlDocs.index.length; i++ ) {
for( var i=0, count=0; i < ErlDocs.index.length; i++ ) {
var item = ErlDocs.index[i];
if ( item[0] == "mod" ) {
var url = preurl+item[1]+"/"+item[2].split(":")[0]+".html";
var url = preurl+item[1]+"/"+item[2].split(":")[0]+".html?i="+i;
html += '<li class="'+item[0]+'"><a href="'+url+'">'
+'<span class="dat">'+item[0]+'</span><span class="name">'+item[2]+"</span>"
+'<br /><span class="sub">'+item[3]+'</span>'
+'</a></li>';
count++;
}
}
this.results[0].innerHTML = html;
this.setSelected(0);
this.resultsCount = count;
};


Expand All @@ -65,7 +102,7 @@ ErlDocs.prototype.searchApps = function(str)
for( var i=0, count=0; i < ErlDocs.index.length; i++ ) {
var item = ErlDocs.index[i];
if ( item[2].match(str) !== null ) {
var url = preurl+item[1]+"/"+item[2].split(":")[0]+".html?search="+str;
var url = preurl+item[1]+"/"+item[2].split(":")[0]+".html?search="+str+"&i="+count;
html += '<li class="'+item[0]+'"><a href="'+url+'">'
+'<span class="dat">'+item[0]+'</span><span class="name">'+item[2]+"</span>"
+'<br /><span class="sub">'+item[3]+'</span>'
Expand All @@ -76,13 +113,15 @@ ErlDocs.prototype.searchApps = function(str)
}
}
}
this.resultsCount = count;
return html;
};

ErlDocs.prototype.filter = function(str)
{
if( str != "" ) {
this.results[0].innerHTML = this.searchApps(str);
this.setSelected(0);
}
};

Expand Down
Loading

0 comments on commit fd6a3bf

Please sign in to comment.