Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | 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
 
11
dojo.provide("dojo.cal.textDirectory");
12
dojo.require("dojo.string");
13
dojo.cal.textDirectory.Property = function (line) {
14
	var left = dojo.string.trim(line.substring(0, line.indexOf(":")));
15
	var right = dojo.string.trim(line.substr(line.indexOf(":") + 1));
16
	var parameters = dojo.string.splitEscaped(left, ";");
17
	this.name = parameters[0];
18
	parameters.splice(0, 1);
19
	this.params = [];
20
	var arr;
21
	for (var i = 0; i < parameters.length; i++) {
22
		arr = parameters[i].split("=");
23
		var key = dojo.string.trim(arr[0].toUpperCase());
24
		if (arr.length == 1) {
25
			this.params.push([key]);
26
			continue;
27
		}
28
		var values = dojo.string.splitEscaped(arr[1], ",");
29
		for (var j = 0; j < values.length; j++) {
30
			if (dojo.string.trim(values[j]) != "") {
31
				this.params.push([key, dojo.string.trim(values[j])]);
32
			}
33
		}
34
	}
35
	if (this.name.indexOf(".") > 0) {
36
		arr = this.name.split(".");
37
		this.group = arr[0];
38
		this.name = arr[1];
39
	}
40
	this.value = right;
41
};
42
dojo.cal.textDirectory.tokenise = function (text) {
43
	var nText = dojo.string.normalizeNewlines(text, "\n").replace(/\n[ \t]/g, "").replace(/\x00/g, "");
44
	var lines = nText.split("\n");
45
	var properties = [];
46
	for (var i = 0; i < lines.length; i++) {
47
		if (dojo.string.trim(lines[i]) == "") {
48
			continue;
49
		}
50
		var prop = new dojo.cal.textDirectory.Property(lines[i]);
51
		properties.push(prop);
52
	}
53
	return properties;
54
};
55