mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 18:00:26 +00:00
sort unlisted tags by title
when the tiddlers are not listed in the list field, sort them by title nonetheless, otherwise we get a real poor taglist from **$:/core/ui/TagTemplate**
This commit is contained in:
parent
f4005871b4
commit
a8ab08e8fa
@ -516,7 +516,7 @@ exports.sortByList = function(array,listTitle) {
|
|||||||
if(!array || array.length === 0) {
|
if(!array || array.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
var titles = [], t, title;
|
var t, title, titles = [], unlisted = [];
|
||||||
// First place any entries that are present in the list
|
// First place any entries that are present in the list
|
||||||
for(t=0; t<list.length; t++) {
|
for(t=0; t<list.length; t++) {
|
||||||
title = list[t];
|
title = list[t];
|
||||||
@ -524,13 +524,15 @@ exports.sortByList = function(array,listTitle) {
|
|||||||
titles.push(title);
|
titles.push(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Then place any remaining entries
|
// Add remaining entries to unlisted
|
||||||
for(t=0; t<array.length; t++) {
|
for(t=0; t<array.length; t++) {
|
||||||
title = array[t];
|
title = array[t];
|
||||||
if(list.indexOf(title) === -1) {
|
if(list.indexOf(title) === -1) {
|
||||||
titles.push(title);
|
unlisted.push(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//concat listed with unlisted, sorted
|
||||||
|
titles = titles.concat(unlisted.sort());
|
||||||
// Finally obey the list-before and list-after fields of each tiddler in turn
|
// Finally obey the list-before and list-after fields of each tiddler in turn
|
||||||
var sortedTitles = titles.slice(0);
|
var sortedTitles = titles.slice(0);
|
||||||
for(t=0; t<sortedTitles.length; t++) {
|
for(t=0; t<sortedTitles.length; t++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user