You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2011/12/22 13:53:44 UTC
svn commit: r1222209 - in /felix/trunk/webconsole/src/main/resources/res:
lib/support.js ui/bundles.js
Author: fmeschbe
Date: Thu Dec 22 12:53:44 2011
New Revision: 1222209
URL: http://svn.apache.org/viewvc?rev=1222209&view=rev
Log:
FELIX-3290 Unify cookie handling:
- global prefix "felix-webconsole-" with local names (bundlelist, locale)
- sticky cookie for 20 years
- bind to web console root path
Modified:
felix/trunk/webconsole/src/main/resources/res/lib/support.js
felix/trunk/webconsole/src/main/resources/res/ui/bundles.js
Modified: felix/trunk/webconsole/src/main/resources/res/lib/support.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/res/lib/support.js?rev=1222209&r1=1222208&r2=1222209&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/res/lib/support.js (original)
+++ felix/trunk/webconsole/src/main/resources/res/lib/support.js Thu Dec 22 12:53:44 2011
@@ -268,6 +268,30 @@ function Xdialog(text) {
return element;
}
+/**
+ * Sets the name cookie at the appRoot (/system/console by default) path
+ * to last for 20 years.
+ * @param name The name of the cookie
+ * @param value The value for the cookie
+ */
+function setCookie( /* String */name, /* String */value) {
+ var date = new Date();
+ date.setFullYear(date.getFullYear() + 20);
+ $.cookies.set("felix-webconsole-" + name, value, {
+ expiresAt : date,
+ path : appRoot
+ });
+}
+
+/**
+ * Returns the value of the name cookie or nothing if the cookie does
+ * not exist or is not accessible.
+ * @param name The name of the cookie
+ */
+/* String */ function getCookie(/*String */name) {
+ $.cookies.get("felix-webconsole-" + name);
+}
+
// language selection element
var langSelect = false;
$(document).ready(function() {
@@ -275,14 +299,10 @@ $(document).ready(function() {
function() { $(this).find('.flags').show('blind') },
function() { $(this).find('.flags').hide('blind') });
langSelect.find('.flags img').click(function() {
- var date = new Date();
- date.setFullYear(date.getFullYear() + 20);
- $.cookies.set('felix.webconsole.locale',
- $(this).attr('alt'),
- { expiresAt: date });
+ setCookie("locale", $(this).attr('alt'));
location.reload();
});
- var locale = $.cookies.get('felix.webconsole.locale');
+ var locale = getCookie("locale");
if (locale) {
if ( !$.datepicker.regional[locale] ) locale = '';
$.datepicker.setDefaults($.datepicker.regional[locale]);
Modified: felix/trunk/webconsole/src/main/resources/res/ui/bundles.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/res/ui/bundles.js?rev=1222209&r1=1222208&r2=1222209&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/res/ui/bundles.js (original)
+++ felix/trunk/webconsole/src/main/resources/res/ui/bundles.js Thu Dec 22 12:53:44 2011
@@ -41,8 +41,10 @@ function renderData( eventData, filter )
}
initStaticWidgets();
- var cv = $.cookies.get("webconsolebundlelist");
- if (cv) bundlesTable.trigger('sorton', [cv]);
+ var cv = getCookie("bundlelist");
+ if (cv) {
+ bundlesTable.trigger('sorton', [cv]);
+ }
// show dialog on error
if (eventData.error) bundleOpError.dialog('open').find('pre').text(eventData.error)
@@ -261,9 +263,11 @@ $(document).ready(function(){
},
textExtraction:mixedLinksExtraction
}).bind("sortEnd", function() {
- var t = bundlesTable.eq(0).attr("config");
- if (t.sortList) $.cookies.set("webconsolebundlelist", t.sortList);
- });
+ var t = bundlesTable.eq(0).attr("config");
+ if (t.sortList) {
+ setCookie("bundlelist", t.sortList);
+ }
+ });
bundlesBody = bundlesTable.find('tbody');
bundlesTemplate = bundlesBody.find('tr').clone();