Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/static/js/pad.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ var pad = {
// This will check if the prefs-cookie is set.
// Otherwise it shows up a message to the user.
padcookie.init();
if (!readCookie("prefs"))
if (!padcookie.isCookiesEnabled())
{
$('#loading').hide();
$('#noCookie').show();
Expand Down
9 changes: 7 additions & 2 deletions src/static/js/pad_cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

var padcookie = (function()
{
var cookieName = isHttpsScheme() ? "prefs" : "prefsHttp";

function getRawCookie()
{
// returns null if can't get cookie text
Expand All @@ -31,7 +33,7 @@ var padcookie = (function()
return null;
}
// look for (start of string OR semicolon) followed by whitespace followed by prefs=(something);
var regexResult = document.cookie.match(/(?:^|;)\s*prefs=([^;]*)(?:;|$)/);
var regexResult = document.cookie.match(new RegExp("(?:^|;)\\s*" + cookieName + "=([^;]*)(?:;|$)"));
if ((!regexResult) || (!regexResult[1]))
{
return null;
Expand All @@ -44,7 +46,7 @@ var padcookie = (function()
var expiresDate = new Date();
expiresDate.setFullYear(3000);
var secure = isHttpsScheme() ? ";secure" : "";
document.cookie = ('prefs=' + safeText + ';expires=' + expiresDate.toGMTString() + secure);
document.cookie = (cookieName + "=" + safeText + ";expires=" + expiresDate.toGMTString() + secure);
}

function parseCookie(text)
Expand Down Expand Up @@ -122,6 +124,9 @@ var padcookie = (function()
{
return wasNoCookie;
},
isCookiesEnabled: function() {
return !!getRawCookie();
},
getPref: function(prefName)
{
return cookieData[prefName];
Expand Down