Subversion Repositories DevTools

Rev

Rev 13 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13 rsolanki 1
/* Copyright (c) 2005 Tim Taylor Consulting (see LICENSE.txt)
2
 
3
based on http://www.quirksmode.org/js/cookies.html
4
*/
5
 
6
ToolMan._cookieOven = {
7
 
8
	set : function(name, value, expirationInDays) {
9
		if (expirationInDays) {
10
			var date = new Date()
11
			date.setTime(date.getTime() + (expirationInDays * 24 * 60 * 60 * 1000))
12
			var expires = "; expires=" + date.toGMTString()
13
		} else {
14
			var expires = ""
15
		}
16
		document.cookie = name + "=" + value + expires + "; path=/"
17
	},
18
 
19
	get : function(name) {
20
		var namePattern = name + "="
21
		var cookies = document.cookie.split(';')
22
		for(var i = 0, n = cookies.length; i < n; i++) {
23
			var c = cookies[i]
24
			while (c.charAt(0) == ' ') c = c.substring(1, c.length)
25
			if (c.indexOf(namePattern) == 0)
26
				return c.substring(namePattern.length, c.length)
27
		}
28
		return null
29
	},
30
 
31
	eraseCookie : function(name) {
32
		createCookie(name, "", -1)
33
	}
34
}