Changeset 476a9a


Ignore:
Timestamp:
Feb 28, 2009, 2:20:40 AM (13 years ago)
Author:
rene <rene@…>
Branches:
lite_0.1, multiEdit, ng_0.6, ng_0.6_help, ng_0.8, ng_0.9
Children:
74f9c7
Parents:
ec5638
Message:

repaired filter-function for stored data-entries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_rdfDatasource.js

    rec5638 r476a9a  
    235235
    236236    __findMatchingFilter : function (recDescription) {
    237         vI_notificationBar.dump("## vI_rdfDatasource: __findMatchingFilter.\n");
     237        vI_notificationBar.dump("## vI_rdfDatasource: __findMatchingFilter for " + recDescription + ".\n");
    238238        var enumerator = vI_rdfDatasource.filterContainer.GetElements();
    239239        while (enumerator && enumerator.hasMoreElements()) {
     
    241241            resource.QueryInterface(Components.interfaces.nsIRDFResource);
    242242            var filter = vI_rdfDatasource.__getRDFValue(resource, "name");
    243             vI_notificationBar.dump("## vI_rdfDatasource: __findMatchingFilter trying '" + filter + "'.\n");
    244             if (filter && recDescription.match(new RegExp(filter,"i"))) return resource;
     243           
     244            const filterType = { None : 0, RegExp : 1, StrCmp : 2 }
     245            var recentfilterType;
     246
     247            if (filter == "") continue;
     248            if (/^\/(.*)\/$/.exec(filter))
     249                { vI_notificationBar.dump("## vI_rdfDatasource: __findMatchingFilter with RegExp '"
     250                    + filter.replace(/\\/g,"\\\\") + "'\n"); recentfilterType = filterType.RegExp; }
     251            else    { vI_notificationBar.dump("## vI_rdfDatasource: __findMatchingFilter, compare with '"
     252                    + filter + "'\n"); recentfilterType = filterType.StrCmp; }
     253           
     254            switch (recentfilterType) {
     255                case filterType.RegExp:
     256                    try {   /^\/(.*)\/$/.exec(filter);
     257                        if (recDescription.match(new RegExp(RegExp.$1,"i"))) return resource;
     258                    }
     259                    catch(vErr) { }; break;
     260                case filterType.StrCmp:
     261                    if (recDescription.toLowerCase().indexOf(filter.toLowerCase()) != -1) return resource;
     262                    break;
     263            }
    245264        }
    246265        return null;
     
    332351
    333352    __setRDFValue : function (resource, field, value) {
    334 //      vI_notificationBar.dump("## vI_rdfDatasource: __setRDFValue " + resource.ValueUTF8 + " " + field + " " + value + ".\n");
     353//      vI_notificationBar.dump("## vI_rdfDatasource: __setRDFValue " + resource.ValueUTF8 + " " + field + " " + value + ".\n");
    335354        if (!value) return; // return if some value was not set.
    336355        var predicate = vI_rdfDatasource.rdfService.GetResource(vI_rdfDatasource.rdfNS + "rdf#" + field);
Note: See TracChangeset for help on using the changeset viewer.