Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.cal.textDirectory");
14
dojo.require("dojo.string");
15
dojo.cal.textDirectory.Property = function (line) {
16
	var left = dojo.string.trim(line.substring(0, line.indexOf(":")));
17
	var right = dojo.string.trim(line.substr(line.indexOf(":") + 1));
18
	var parameters = dojo.string.splitEscaped(left, ";");
19
	this.name = parameters[0];
20
	parameters.splice(0, 1);
21
	this.params = [];
22
	var arr;
23
	for (var i = 0; i < parameters.length; i++) {
24
		arr = parameters[i].split("=");
25
		var key = dojo.string.trim(arr[0].toUpperCase());
26
		if (arr.length == 1) {
27
			this.params.push([key]);
28
			continue;
29
		}
30
		var values = dojo.string.splitEscaped(arr[1], ",");
31
		for (var j = 0; j < values.length; j++) {
32
			if (dojo.string.trim(values[j]) != "") {
33
				this.params.push([key, dojo.string.trim(values[j])]);
34
			}
35
		}
36
	}
37
	if (this.name.indexOf(".") > 0) {
38
		arr = this.name.split(".");
39
		this.group = arr[0];
40
		this.name = arr[1];
41
	}
42
	this.value = right;
43
};
44
dojo.cal.textDirectory.tokenise = function (text) {
45
	var nText = dojo.string.normalizeNewlines(text, "\n").replace(/\n[ \t]/g, "").replace(/\x00/g, "");
46
	var lines = nText.split("\n");
47
	var properties = [];
48
	for (var i = 0; i < lines.length; i++) {
49
		if (dojo.string.trim(lines[i]) == "") {
50
			continue;
51
		}
52
		var prop = new dojo.cal.textDirectory.Property(lines[i]);
53
		properties.push(prop);
54
	}
55
	return properties;
56
};
57