1 // Functions used by login pages
3 function cookiesEnabled() {
4 // Test whether cookies are enabled by attempting to set a cookie and then change its value
6 var c
= "areYourCookiesEnabled=0";
8 var dc
= document
.cookie
;
9 // cookie not set? fail
10 if (dc
.indexOf(c
) == -1) return 0;
12 c
= "areYourCookiesEnabled=1";
15 // cookie not changed? fail
16 if (dc
.indexOf(c
) == -1) return 0;
18 document
.cookie
= "areYourCookiesEnabled=; expires=Thu, 01-Jan-70 00:00:01 GMT";
22 function setLoginVars(user_name_id
, alt_user_name_id
, password_id
, empty_password_id
, js_enabled_id
, cookies_enabled_id
) {
23 // Indicate that javascript is enabled, set cookie status, copy username and password length info to
24 // alternative variables since these vars are removed from the request by zope's authentication mechanism.
26 el
= document
.getElementById(js_enabled_id
);
27 if (el
) { el
.value
= 1; }
29 if (cookies_enabled_id
) {
30 el
= document
.getElementById(cookies_enabled_id
);
31 // Do a fresh cookies enabled test every time we press the login button
32 // so that we are up to date in case the user enables cookies after seeing
33 // the cookies message.
34 if (el
) { el
.value
= cookiesEnabled(); }
36 if (user_name_id
&& alt_user_name_id
) {
37 user_name
= document
.getElementById(user_name_id
)
38 alt_user_name
= document
.getElementById(alt_user_name_id
)
39 if (user_name
&& alt_user_name
) {
40 alt_user_name
.value
= user_name
.value
;
43 if (password_id
&& empty_password_id
) {
44 password
= document
.getElementById(password_id
)
45 empty_password
= document
.getElementById(empty_password_id
)
46 if (password
&& empty_password
) {
47 if (password
.value
.length
==0) {
48 empty_password
.value
= '1';
50 empty_password
.value
= '0';
57 function showCookieMessage(msg_id
) {
58 // Show the element with the given id if cookies are not enabled
59 msg
= document
.getElementById(msg_id
)
61 if (cookiesEnabled()) {
62 msg
.style
.display
= 'none';
64 msg
.style
.display
= 'block';
69 function showEnableCookiesMessage() {
70 // Show the element with the id 'enable_cookies_message' if cookies are not enabled
71 showCookieMessage('enable_cookies_message')
73 // Call showEnableCookiesMessage after the page loads
74 registerPloneFunction(showEnableCookiesMessage
);