From 8338ec9a0fb09f0d2adf22fc79056f1124dae095 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Fri, 5 Mar 2010 16:22:54 +0000 Subject: [PATCH] Permanent cookie for version git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1340 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/static/editing.js | 4 +--- adminer/static/functions.js | 13 ++++++++++++- version.js | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/adminer/static/editing.js b/adminer/static/editing.js index 75fc26ab..f38dad78 100644 --- a/adminer/static/editing.js +++ b/adminer/static/editing.js @@ -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 + '"'); } } diff --git a/adminer/static/functions.js b/adminer/static/functions.js index dd31d83d..fa7de73e 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -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); diff --git a/version.js b/version.js index 07ab198b..7d3eb2f6 100644 --- a/version.js +++ b/version.js @@ -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