Adding submodules from original svn externals
Showing
7 changed files
with
69 additions
and
0 deletions
.gitignore
0 → 100644
| 1 | /scripts/.DS_Store | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
.gitmodules
0 → 100644
ChatterBox @ 3c6a4b1f
| 1 | Subproject commit 3c6a4b1f0ff2a6517cf6eecfdac812b73a40b61a |
scripts/Cookie/Cookie.js
0 → 100644
| 1 | /** | ||
| 2 | * A Singleton class to create, read and delete cookies | ||
| 3 | * @author Chris Boden | ||
| 4 | * @version 0.3 | ||
| 5 | */ | ||
| 6 | Cookie = new function() { | ||
| 7 | /** | ||
| 8 | * Create a cookie for current domain | ||
| 9 | * @param {String} name The name of the cookie by reference | ||
| 10 | * @param {String} value The value of the cookie to be stored | ||
| 11 | * @param {Integer} days The Number of days until the cookie expires | ||
| 12 | * @returns null | ||
| 13 | */ | ||
| 14 | this.create = function(name, value, days) { | ||
| 15 | var expires = ''; | ||
| 16 | if (days) { | ||
| 17 | var date = new Date(); | ||
| 18 | date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | ||
| 19 | expires = '; expires= ' + date.toGMTString(); | ||
| 20 | } | ||
| 21 | |||
| 22 | document.cookie = name + '=' + value + expires + '; path=/'; | ||
| 23 | } | ||
| 24 | |||
| 25 | /** | ||
| 26 | * Get the value of a cookie for this domain | ||
| 27 | * @param {String} name The name of the cookie | ||
| 28 | * @returns A string if cookie exists null if not | ||
| 29 | */ | ||
| 30 | this.read = function read(name) { | ||
| 31 | var nameEQ = name + '='; | ||
| 32 | var ca = document.cookie.split(';'); | ||
| 33 | for(var i = 0; i < ca.length; i++) { | ||
| 34 | var c = ca[i]; | ||
| 35 | while (c.charAt(0)==' ') { | ||
| 36 | c = c.substring(1,c.length); | ||
| 37 | } | ||
| 38 | |||
| 39 | if (c.indexOf(nameEQ) == 0) { | ||
| 40 | return c.substring(nameEQ.length,c.length); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | return null; | ||
| 45 | } | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Erases a cookie from the domain | ||
| 49 | * @param {String} name Name of the cookie to erase | ||
| 50 | * @returns null | ||
| 51 | */ | ||
| 52 | this.erase = function(name) { | ||
| 53 | Cookie.create(name, '', -1); | ||
| 54 | } | ||
| 55 | } |
scripts/Cookie/summary.txt
0 → 100644
| 1 | A simple class to creat, read and erase cookies |
-
Please register or sign in to post a comment