Fix bad function declaration in wiki.js (#3559)

fix for #3555 - inner function declaration should be on top of its "host" function

error originally appeared on firefox v38.0.5
logging-improvements
BurningTreeC 2018-11-20 12:50:12 +01:00 zatwierdzone przez Jeremy Ruston
rodzic 430be4ec30
commit 7729649f0e
1 zmienionych plików z 40 dodań i 40 usunięć

Wyświetl plik

@ -538,29 +538,8 @@ exports.findListingsOfTiddler = function(targetTitle,fieldName) {
Sorts an array of tiddler titles according to an ordered list
*/
exports.sortByList = function(array,listTitle) {
var list = this.getTiddlerList(listTitle);
if(!array || array.length === 0) {
return [];
} else {
var titles = [], t, title;
// First place any entries that are present in the list
for(t=0; t<list.length; t++) {
title = list[t];
if(array.indexOf(title) !== -1) {
titles.push(title);
}
}
// Then place any remaining entries
for(t=0; t<array.length; t++) {
title = array[t];
if(list.indexOf(title) === -1) {
titles.push(title);
}
}
// Finally obey the list-before and list-after fields of each tiddler in turn
var sortedTitles = titles.slice(0),
replacedTitles = Object.create(null),
self = this;
var self = this,
replacedTitles = Object.create(null);
function replaceItem(title) {
if(!$tw.utils.hop(replacedTitles, title)) {
replacedTitles[title] = true;
@ -597,7 +576,28 @@ exports.sortByList = function(array,listTitle) {
}
}
}
};
}
var list = this.getTiddlerList(listTitle);
if(!array || array.length === 0) {
return [];
} else {
var titles = [], t, title;
// First place any entries that are present in the list
for(t=0; t<list.length; t++) {
title = list[t];
if(array.indexOf(title) !== -1) {
titles.push(title);
}
}
// Then place any remaining entries
for(t=0; t<array.length; t++) {
title = array[t];
if(list.indexOf(title) === -1) {
titles.push(title);
}
}
// Finally obey the list-before and list-after fields of each tiddler in turn
var sortedTitles = titles.slice(0);
for(t=0; t<sortedTitles.length; t++) {
title = sortedTitles[t];
replaceItem(title);