Permanent cookie for version

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1340 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2010-03-05 16:22:54 +00:00
parent b681dfbbff
commit 8338ec9a0f
3 changed files with 15 additions and 6 deletions

View file

@ -388,12 +388,10 @@ function schemaMouseup(ev) {
ev = ev || event;
tablePos[that.firstChild.firstChild.firstChild.data] = [ (ev.clientY - y) / em, (ev.clientX - x) / em ];
that = undefined;
var date = new Date();
date.setMonth(date.getMonth() + 1);
var s = '';
for (var key in tablePos) {
s += '_' + key + ':' + Math.round(tablePos[key][0] * 10000) / 10000 + 'x' + Math.round(tablePos[key][1] * 10000) / 10000;
}
document.cookie = 'adminer_schema=' + encodeURIComponent(s.substr(1)) + '; expires=' + date + '; path="' + location.pathname + location.search + '"';
cookie('adminer_schema=' + encodeURIComponent(s.substr(1)), 30, '; path="' + location.pathname + location.search + '"');
}
}

View file

@ -11,10 +11,21 @@ function toggle(id) {
return true;
}
/** Set permanent cookie
* @param string
* @param number
* @param string optional
*/
function cookie(assign, days, params) {
var date = new Date();
date.setDate(date.getDate() + days);
document.cookie = assign + '; expires=' + date + (params || '');
}
/** Verify current Adminer version
*/
function verifyVersion() {
document.cookie = 'adminer_version=0';
cookie('adminer_version=0', 1);
var script = document.createElement('script');
script.src = 'https://adminer.svn.sourceforge.net/svnroot/adminer/trunk/version.js';
document.body.appendChild(script);

View file

@ -1,2 +1,2 @@
// downloaded from repository by version_checker()
document.cookie = 'adminer_version=2.3.0'; // last released version
// downloaded from repository by verifyVersion()
cookie('adminer_version=2.3.0', 7); // last released version, valid for 7 days