When Webfm is told to use files' meta-title in the file list and the user clicks on the "name" column title to sort by name, Webfm still sorts the list by the (undisplayed) filenames. Thus, the list in general seems to be left unsorted.

I've written the following patch for webfm.js:

Replace:

Webfm.sortByName = function(a, b) {
  var x = a.n.toLowerCase();
  var y = b.n.toLowerCase();
  return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

by:

Webfm.sortByName = function(a, b) {
  if(typeof a.ftitle != "undefined" && typeof b.ftitle != "undefined") {
    var x = a.ftitle.toLowerCase();
    var y = b.ftitle.toLowerCase();
  } else {
    var x = a.n.toLowerCase();
    var y = b.n.toLowerCase();
  }
  return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

This works fine for me. Attached you find the corrected version.

PS: Please excuse me if I didn't follow any guidelines (in case there are) since this is my first bug report... :)

CommentFileSizeAuthor
webfm.js_.txt123.6 KBseek300

Comments

robmilne’s picture

Well, close. Here is the code I've committed to head:

Webfm.sortByName = function(a, b) {
  if(typeof a.ftitle != "undefined") {
    var x = a.ftitle.toLowerCase();
  } else {
    var x = a.n.toLowerCase();
  }
  if(typeof b.ftitle != "undefined") {
    var y = b.ftitle.toLowerCase();
  } else {
    var y = b.n.toLowerCase();
  }
  return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

Thanks for pointing out that bug.

-rob

robmilne’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.