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,
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