Commit 938ec32c4cb0a8be01d3db6338e3fd585eb1b3ff
Sort items in rev menu
Prevent items from getting mixed up and the same group appearing more than onceCharles Lehner committed on 3/27/2016, 5:01:35 PM
Parent: d5e0970d64c9af2207d041e9b6c2196ce7ec2fe9
Files changed
index.js | changed |
package.json | changed |
index.js | ||
---|---|---|
@@ -286,13 +286,8 @@ | ||
286 | 286 | 'git-update': true, |
287 | 287 | 'issue': true |
288 | 288 | } |
289 | 289 | |
290 | -var refLabels = { | |
291 | - heads: 'Branches', | |
292 | - tags: 'Tags' | |
293 | -} | |
294 | - | |
295 | 290 | var imgMimes = { |
296 | 291 | png: 'image/png', |
297 | 292 | jpeg: 'image/jpeg', |
298 | 293 | jpg: 'image/jpeg', |
@@ -923,35 +918,24 @@ | ||
923 | 918 | |
924 | 919 | /* Repo tree */ |
925 | 920 | |
926 | 921 | function revMenu(repo, currentName) { |
927 | - var currentGroup | |
928 | - return cat([ | |
929 | - pull.once('<select name="rev" onchange="this.form.submit()">'), | |
930 | - pull( | |
931 | - repo.refs(), | |
932 | - pull.map(function (ref) { | |
933 | - var m = ref.name.match(/^refs\/([^\/]*)\/(.*)$/) || [,, ref.name] | |
934 | - var group = m[1] | |
935 | - var name = m[2] | |
936 | - | |
937 | - var optgroup = (group === currentGroup) ? '' : | |
938 | - (currentGroup ? '</optgroup>' : '') + | |
939 | - '<optgroup label="' + (refLabels[group] || group) + '">' | |
940 | - currentGroup = group | |
941 | - var selected = (name == currentName) ? ' selected="selected"' : '' | |
942 | - var htmlName = escapeHTML(name) | |
943 | - return optgroup + | |
944 | - '<option value="' + htmlName + '"' + selected + '>' + | |
945 | - htmlName + '</option>' | |
946 | - }) | |
947 | - ), | |
948 | - readOnce(function (cb) { | |
949 | - cb(null, currentGroup ? '</optgroup>' : '') | |
950 | - }), | |
951 | - pull.once('</select> ' + | |
952 | - '<noscript><input type="submit" value="Go" /></noscript>') | |
953 | - ]) | |
922 | + return readOnce(function (cb) { | |
923 | + repo.getRefNames(true, function (err, refs) { | |
924 | + if (err) return cb(err) | |
925 | + cb(null, '<select name="rev" onchange="this.form.submit()">' + | |
926 | + Object.keys(refs).map(function (group) { | |
927 | + return '<optgroup label="' + group + '">' + | |
928 | + refs[group].map(function (name) { | |
929 | + var htmlName = escapeHTML(name) | |
930 | + return '<option value="' + htmlName + '"' + | |
931 | + (name == currentName ? ' selected="selected"' : '') + | |
932 | + '>' + htmlName + '</option>' | |
933 | + }).join('') + '</optgroup>' | |
934 | + }).join('') + | |
935 | + '</select><noscript> <input type="submit" value="Go"/></noscript>') | |
936 | + }) | |
937 | + }) | |
954 | 938 | } |
955 | 939 | |
956 | 940 | function renderRepoLatest(repo, rev) { |
957 | 941 | return readOnce(function (cb) { |
Built with git-ssb-web