forked from GitHub/gf-core
RGL browser: add recent modules list
This commit is contained in:
@@ -43,6 +43,7 @@ function Thing() {
|
||||
index: undefined,
|
||||
lookup: {},
|
||||
loadCount: 0,
|
||||
recentCount: 5,
|
||||
language: undefined, // lang of drop-down
|
||||
current: { // current file
|
||||
language: undefined,
|
||||
@@ -223,13 +224,17 @@ function Thing() {
|
||||
t.searchModule($(this).val());
|
||||
})
|
||||
.appendTo("#languages");
|
||||
|
||||
$("<a>")
|
||||
.attr('href','#')
|
||||
.click(t.clearSearchModule)
|
||||
.html("Clear")
|
||||
.appendTo("#languages");
|
||||
|
||||
// Recent modules
|
||||
var recent = $("<div>")
|
||||
.attr('id', 'recent')
|
||||
.appendTo("#languages");
|
||||
|
||||
// Initialize API results
|
||||
t.initAPI();
|
||||
|
||||
@@ -257,7 +262,7 @@ function Thing() {
|
||||
.attr('href', "#"+lang+"/"+module+".gf")
|
||||
.appendTo("#modules");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Load both scope & source for a file
|
||||
this.loadFile = function(lang, module, lineNo){
|
||||
@@ -267,6 +272,23 @@ function Thing() {
|
||||
t.loadSourceFile(lang, module, lineNo);
|
||||
if ($('.tab.api').hasClass('active'))
|
||||
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
|
||||
|
||||
@@ -47,11 +47,19 @@ header h1 {
|
||||
#language_select {
|
||||
width:100%;
|
||||
}
|
||||
#recent {
|
||||
border-bottom:1px #999 solid;
|
||||
}
|
||||
#recent a {
|
||||
color: #999;
|
||||
}
|
||||
#recent a,
|
||||
#modules a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
margin: 2px 5px;
|
||||
}
|
||||
#recent a:hover,
|
||||
#modules a:hover {
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user