Changeset cdbc54


Ignore:
Timestamp:
Feb 19, 2013, 5:24:09 PM (9 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
a8f017
Parents:
a36ab2
Message:

fixed sorting of date-stamps in data-editor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • content/vI_rdfDataTree.js

    ra36ab2 rcdbc54  
    3838Components.utils.import("resource://v_identity/vI_prefs.js", virtualIdentityExtension);
    3939
     40tmpfield = null;
     41
    4042//prepares an object for easy comparison against another. for strings, lowercases them
    41 function prepareForComparison (o) {
     43function prepareForComparison (element, field) {
     44    if (field == "changedCol") {
     45        field = "changed"
     46    }
     47    if (field == "usedCol") {
     48        field = "used"
     49    }
     50    var o = element[field];
    4251    if (typeof o == "string") { return o.toLowerCase().replace(/\"/g,""); }
    43 //  if (typeof o == "number") { return o; }
    4452    return "";
    4553};
     
    8593                //we'll match on every property
    8694                for (var i in element) {
    87                     if (prepareForComparison(element[i]).indexOf(curFilterText) != -1) {
     95                    if (prepareForComparison(element, i).indexOf(curFilterText) != -1) {
    8896                        curTable.push(element);
    8997                        break;
     
    116124                idCol : localIdentityData.id.value,
    117125                usedCol : used?usedDate.toLocaleString():"",
     126                used : used,
    118127                changedCol : changed?changedDate.toLocaleString():"",
     128                changed : changed,
    119129//              idKey : localIdentityData.id.key,
    120130                resource : resource,
     
    134144        function columnSort(a, b) {
    135145          try {
    136             if (prepareForComparison(a[columnName]) >
    137                 prepareForComparison(b[columnName])) return 1 * order;
    138             if (prepareForComparison(a[columnName]) <
    139                 prepareForComparison(b[columnName])) return -1 * order;
     146            if (prepareForComparison(a, columnName) >
     147                prepareForComparison(b, columnName)) return 1 * order;
     148            if (prepareForComparison(a, columnName) <
     149                prepareForComparison(b, columnName)) return -1 * order;
    140150          } catch(e) {};
    141151            return 0;
     
    288298
    289299    inputFilter : function(event) {
    290         //do this now rather than doing it at every comparison
    291         var value = prepareForComparison(event.target.value);
     300        var value = "";
     301        if (typeof event.target.value == "string") {
     302            value = event.target.value.toLowerCase().replace(/\"/g,"");
     303        }
    292304        rdfDataTreeCollection.__setFilter(value);
    293305        document.getElementById("clearFilter").disabled = value.length == 0;
Note: See TracChangeset for help on using the changeset viewer.