1
0
forked from GitHub/gf-core

RGL browser: add recent modules list

This commit is contained in:
john.j.camilleri
2014-01-29 13:21:52 +00:00
parent c6703f267f
commit 38d354c199
2 changed files with 32 additions and 2 deletions

View File

@@ -43,6 +43,7 @@ function Thing() {
index: undefined, index: undefined,
lookup: {}, lookup: {},
loadCount: 0, loadCount: 0,
recentCount: 5,
language: undefined, // lang of drop-down language: undefined, // lang of drop-down
current: { // current file current: { // current file
language: undefined, language: undefined,
@@ -223,13 +224,17 @@ function Thing() {
t.searchModule($(this).val()); t.searchModule($(this).val());
}) })
.appendTo("#languages"); .appendTo("#languages");
$("<a>") $("<a>")
.attr('href','#') .attr('href','#')
.click(t.clearSearchModule) .click(t.clearSearchModule)
.html("Clear") .html("Clear")
.appendTo("#languages"); .appendTo("#languages");
// Recent modules
var recent = $("<div>")
.attr('id', 'recent')
.appendTo("#languages");
// Initialize API results // Initialize API results
t.initAPI(); t.initAPI();
@@ -257,7 +262,7 @@ function Thing() {
.attr('href', "#"+lang+"/"+module+".gf") .attr('href', "#"+lang+"/"+module+".gf")
.appendTo("#modules"); .appendTo("#modules");
} }
}; }
// Load both scope & source for a file // Load both scope & source for a file
this.loadFile = function(lang, module, lineNo){ this.loadFile = function(lang, module, lineNo){
@@ -267,6 +272,23 @@ function Thing() {
t.loadSourceFile(lang, module, lineNo); t.loadSourceFile(lang, module, lineNo);
if ($('.tab.api').hasClass('active')) if ($('.tab.api').hasClass('active'))
t.showPanel("#scope"); t.showPanel("#scope");
t.addRecent(lang, module);
}
// Add item to recent list
this.addRecent = function(lang, module) {
var full_module = lang+'/'+module;
// If already there, do nothing
if ($('#recent').text().indexOf(full_module) > -1) return;
// Delete oldest if at limit
if ($('#recent a').length >= t.state.recentCount) {
$('#recent a').last().remove();
}
// Add it
$('<a>')
.html(full_module)
.attr('href', "#"+lang+"/"+module+".gf")
.prependTo("#recent");
} }
// Load a tags file // Load a tags file

View File

@@ -47,11 +47,19 @@ header h1 {
#language_select { #language_select {
width:100%; width:100%;
} }
#recent {
border-bottom:1px #999 solid;
}
#recent a {
color: #999;
}
#recent a,
#modules a { #modules a {
display: block; display: block;
text-decoration: none; text-decoration: none;
margin: 2px 5px; margin: 2px 5px;
} }
#recent a:hover,
#modules a:hover { #modules a:hover {
text-decoration:underline; text-decoration:underline;
} }