3 * Copyright 2012, Alain Peyrat
4 * http://fusionforge.org
6 * This file is part of FusionForge. FusionForge is free software;
7 * you can redistribute it and/or modify it under the terms of the
8 * GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the Licence, or (at your option)
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 jQuery.cookie = function(name, value, options) {
24 if (typeof value != 'undefined') { // name and value given, set cookie
25 options = options || {};
31 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
33 if (typeof options.expires == 'number') {
35 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
37 date = options.expires;
39 expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
41 // CAUTION: Needed to parenthesize options.path and options.domain
42 // in the following expressions, otherwise they evaluate to undefined
43 // in the packed version for some reason...
44 var path = options.path ? '; path=' + (options.path) : '';
45 var domain = options.domain ? '; domain=' + (options.domain) : '';
46 var secure = options.secure ? '; secure' : '';
47 document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
48 } else { // only name given, get cookie
49 var cookieValue = null;
50 if (document.cookie && document.cookie != '') {
51 var cookies = document.cookie.split(';');
52 for (var i = 0; i < cookies.length; i++) {
53 var cookie = jQuery.trim(cookies[i]);
54 // Does this cookie string begin with the name we want?
55 if (cookie.substring(0, name.length + 1) == (name + '=')) {
56 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
66 var $box = jQuery("#message_box"),
67 stateCookieName = 'message_box',
68 alreadyClosed = jQuery.cookie(stateCookieName);
70 // The box should already be hidden initially (using CSS preferrably).
71 // If not, uncomment the line below:
74 // Show the box if it hasn't already been closed.
75 if (alreadyClosed != 1) {
79 $box.find('#message_close').click(function() {
81 jQuery.cookie(stateCookieName, 1, { expires: 1, path: '/'});