Changeset 6776

Show
Ignore:
Timestamp:
12/02/06 11:32:46 (2 years ago)
Author:
peller
Message:

Add comments, style changes. Fixes #1553

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.4.1_working/src/cal/textDirectory.js

    r6228 r6776  
    22dojo.require("dojo.string"); 
    33 
    4 /* 
    5  * This class parses a single line from a text/directory file 
    6  * and returns an object with four named values; name, group, params 
    7  * and value. name, group and value are strings containing the original 
    8  * tokens unaltered and values is an array containing name/value pairs 
    9  * or a single name token packed into arrays. 
    10  */ 
    11 dojo.cal.textDirectory.Property = function (line) { 
     4dojo.cal.textDirectory.Property = function(/*String*/line){ 
     5// summary: parses a single line from an iCalendar text/directory file 
     6// and creates an object with four named values; name, group, params 
     7// and value. name, group and value are strings containing the original 
     8// tokens unaltered and values is an array containing name/value pairs 
     9// or a single name token packed into arrays. 
     10 
    1211        // split into name/value pair 
    1312        var left = dojo.string.trim(line.substring(0, line.indexOf(':'))); 
    1413        var right = dojo.string.trim(line.substr(line.indexOf(':') + 1)); 
    1514 
    16         // seperate name and paramters   
     15        // separate name and paramters   
    1716        var parameters = dojo.string.splitEscaped(left,';'); 
    18         this.name = parameters[0] 
     17        this.name = parameters[0]; 
    1918        parameters.splice(0, 1); 
    2019 
    2120        // parse paramters 
    2221        this.params = []; 
    23         for (var i = 0; i < parameters.length; i++) { 
    24                 var arr = parameters[i].split("="); 
     22        var arr; 
     23        for(var i = 0; i < parameters.length; i++){ 
     24                arr = parameters[i].split("="); 
    2525                var key = dojo.string.trim(arr[0].toUpperCase()); 
    26                  
    27                 if (arr.length == 1) { this.params.push([key]); continue; } 
    28                  
     26 
     27                if(arr.length == 1){ this.params.push([key]); continue; } 
     28 
    2929                var values = dojo.string.splitEscaped(arr[1],','); 
    30                 for (var j = 0; j < values.length; j++) { 
    31                         if (dojo.string.trim(values[j]) != '') { 
     30                for(var j = 0; j < values.length; j++){ 
     31                        if(dojo.string.trim(values[j]) != ''){ 
    3232                                this.params.push([key, dojo.string.trim(values[j])]); 
    3333                        } 
     
    3535        } 
    3636 
    37         // seperate group 
    38         if (this.name.indexOf('.') > 0) { 
    39                 var arr = this.name.split('.'); 
     37        // separate group 
     38        if(this.name.indexOf('.') > 0){ 
     39                arr = this.name.split('.'); 
    4040                this.group = arr[0]; 
    4141                this.name = arr[1]; 
    4242        } 
    43          
     43 
    4444        // don't do any parsing, leave to implementation 
    4545        this.value = right; 
     
    4747 
    4848 
    49 // tokeniser, parses into an array of properties. 
    50 dojo.cal.textDirectory.tokenise = function (text) { 
    51         // normlize to one propterty per line and parse 
    52         var nText = dojo.string.normalizeNewlines(text,"\n"); 
    53         nText = nText.replace(/\n[ \t]/g, ''); 
    54         nText = nText.replace(/\x00/g, ''); 
    55                  
     49dojo.cal.textDirectory.tokenise = function(/*String*/text){ 
     50// summary: parses text into an array of properties. 
     51 
     52        // normlize to one property per line and parse 
     53        var nText = dojo.string.normalizeNewlines(text,"\n"). 
     54                replace(/\n[ \t]/g, ''). 
     55                replace(/\x00/g, ''); 
     56 
    5657        var lines = nText.split("\n"); 
    57         var properties = [] 
     58        var properties = []; 
    5859 
    59         for (var i = 0; i < lines.length; i++) { 
    60                 if (dojo.string.trim(lines[i]) == '') { continue; } 
     60        for(var i = 0; i < lines.length; i++){ 
     61                if(dojo.string.trim(lines[i]) == ''){ continue; } 
    6162                var prop = new dojo.cal.textDirectory.Property(lines[i]); 
    6263                properties.push(prop); 
    6364        } 
    64         return properties; 
     65        return properties; // Array 
    6566}