Changeset 44


Ignore:
Timestamp:
10/27/07 19:28:18 (6 years ago)
Author:
Lantash
Message:

String.prototype.addressify removes any characters except alphanumeric ones, hyphens and whitespaces (which are replaced by hyphens). Performance improvement by caching addressified strings.

Button titles can't be undefined.

Location:
trunk/javascript
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/javascript/klassenbuch.controls.js

    r40 r44  
    238238        $super(new Element(this.options.tag, { 
    239239                        className: "unselectable " + this.options.className, 
    240                         title: this.options.title 
     240                        title: this.options.title || "" 
    241241                })); 
    242242         
  • trunk/javascript/prototype.extensions.js

    r31 r44  
    466466         
    467467        addressify: function() { 
    468                 return this.replace(/([\s])/g, "").replaceAll("ü", "ue").replaceAll("ä", "ae").replaceAll("ö", "oe").toLowerCase(); 
     468                var store = arguments.callee._STORE[this]; 
     469                 
     470                if (Object.isDefined(store)) { 
     471                        return store; 
     472                } 
     473                 
     474                return arguments.callee._STORE[this] = this.toLowerCase() 
     475                        .replace(/([\s])/g, "-") 
     476                        .replaceAll("ü", "ue") 
     477                        .replaceAll("ä", "ae") 
     478                        .replaceAll("ö", "oe") 
     479                        .replace(/[^A-Z^a-z^0-9-]/g, ""); 
    469480        }, 
    470481         
     
    485496        } 
    486497}); 
     498 
     499String.prototype.addressify._STORE = {}; 
    487500 
    488501String.Builder = function() { 
Note: See TracChangeset for help on using the changeset viewer.