From 38d354c1990a6827050ef73979251121fb94a12e Mon Sep 17 00:00:00 2001 From: "john.j.camilleri" Date: Wed, 29 Jan 2014 13:21:52 +0000 Subject: [PATCH] RGL browser: add recent modules list --- lib/doc/browse/script.js | 26 ++++++++++++++++++++++++-- lib/doc/browse/style.css | 8 ++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/doc/browse/script.js b/lib/doc/browse/script.js index 9c1660d67..04d07520f 100644 --- a/lib/doc/browse/script.js +++ b/lib/doc/browse/script.js @@ -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"); - $("") .attr('href','#') .click(t.clearSearchModule) .html("Clear") .appendTo("#languages"); + // Recent modules + var recent = $("
") + .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 + $('') + .html(full_module) + .attr('href', "#"+lang+"/"+module+".gf") + .prependTo("#recent"); } // Load a tags file diff --git a/lib/doc/browse/style.css b/lib/doc/browse/style.css index ae556ec1c..10e4dd3c7 100644 --- a/lib/doc/browse/style.css +++ b/lib/doc/browse/style.css @@ -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; }