rbrindley: branch rbrindley/astman_revamp r4575 - /team/rbrindley/astman_reva...
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Thu Mar 5 09:01:22 CST 2009
Author: rbrindley
Date: Thu Mar 5 09:01:19 2009
New Revision: 4575
URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4575
Log:
- copied ASTGUI.cookies to cookies in js/session.js
- renamed ASTGUI.cookies.getCookie to just cookies.get
- same rename for setCookie, removeCookie and clearCookies
- added a few lines of top.log messages as there were none
Modified:
team/rbrindley/astman_revamp/config/js/session.js
Modified: team/rbrindley/astman_revamp/config/js/session.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/rbrindley/astman_revamp/config/js/session.js?view=diff&rev=4575&r1=4574&r2=4575
==============================================================================
--- team/rbrindley/astman_revamp/config/js/session.js (original)
+++ team/rbrindley/astman_revamp/config/js/session.js Thu Mar 5 09:01:19 2009
@@ -40,3 +40,68 @@
}
};
+/**
+ * Cookie Management.
+ * This object manages all cookies needs.
+ */
+var cookies = {};
+
+
+/**
+ * Get Cookie.
+ * Get a Cookie. OM NOM NOM NOM
+ * @param user Username
+ */
+cookies.get = function(user) {
+ var ck = top.document.cookie;
+
+ if (ck.indexOf(user + '=') == -1) {
+ top.log.warn("Can't seem to find the user in a cookie, exiting.");
+ return '';
+ }
+
+ var cookies = ck.split(';');
+ for (var i=0; i < cookies.length; i++) {
+ var c = cookies[y].strip();
+ if (c.beginsWith(x + '=')) {
+ return c.split(x + '=')[1];
+ }
+ }
+
+ top.log.info("No cookie found for user, exiting.");
+ return '';
+};
+
+/**
+ * Set Cookie.
+ * @param varname Variable to set.
+ * @param val Value to set the variable to.
+ */
+cookies.set = function(varname, val) {
+ if (varname == '') {
+ top.log.error('Variable name cannot be empty when setting a cookie.');
+ return false;
+ }
+
+ var tmp = varname + '=' + val + '; path=/';
+ top.document.cookie = tmp;
+};
+
+/**
+ * Remove Cookie.
+ * Remove a cookie...from the cookie jar!
+ * @param ck The cookie.
+ */
+cookies.remove = function(ck) {
+ top.log.info('Removing cookie: ' + ck);
+ top.document.cookie = ck + '=somevalue; expires=Thu, 16 Aug 1984, 00:00:00 UTC; path=/';
+};
+
+/**
+ * Clear Cookies.
+ * Clear the cookies.
+ */
+cookies.clear = function() {
+ top.log.info('Clearing cookies!');
+ top.document.cookie = '';
+};
More information about the asterisk-gui-commits
mailing list