From df11f7746f733c916136c059623f58b12acfb038 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 23 Dec 2010 12:21:07 -0500 Subject: [PATCH] Partial fix for Bug 4238, OPAC timeout feature for patron privacy This patch re-implements the changes made by PTFS and included in Harley. The code seems to work well, but in order for this to be a complete fix it would have to include an update to the database and preferences. --- C4/Auth.pm | 1 + .../opac-tmpl/prog/en/includes/doc-head-close.inc | 14 +++++ koha-tmpl/opac-tmpl/prog/en/js/screensaver.js | 60 ++++++++++++++++++++ 3 files changed, 75 insertions(+), 0 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/screensaver.js diff --git a/C4/Auth.pm b/C4/Auth.pm index 2f13b86..041501f 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -439,6 +439,7 @@ sub get_template_and_user { suggestion => "" . C4::Context->preference("suggestion"), virtualshelves => "" . C4::Context->preference("virtualshelves"), OPACSerialIssueDisplayCount => C4::Context->preference("OPACSerialIssueDisplayCount"), + ResetOpacInactivityTimeout => C4::Context->preference("ResetOpacInactivityTimeout"), OpacAddMastheadLibraryPulldown => C4::Context->preference("OpacAddMastheadLibraryPulldown"), OPACXSLTDetailsDisplay => C4::Context->preference("OPACXSLTDetailsDisplay"), OPACXSLTResultsDisplay => C4::Context->preference("OPACXSLTResultsDisplay"), diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc index fe7e7db..d92e523 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc @@ -84,3 +84,17 @@ + + + + diff --git a/koha-tmpl/opac-tmpl/prog/en/js/screensaver.js b/koha-tmpl/opac-tmpl/prog/en/js/screensaver.js new file mode 100644 index 0000000..4257b81 --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/js/screensaver.js @@ -0,0 +1,60 @@ +/* +Copyright (c) 2007, Andreas Blixt, http://blixt.org/. All rights reserved. +Code licensed under the MIT License: +http://www.opensource.org/licenses/mit-license.php +*/ + +// waitTime is in milliseconds. +var ScreenSaver = function (waitTime) { + this.lastActivity = new Date().getTime(); + this.waitTime = waitTime; + + var $this = this; + this._timer = setInterval(function () { $this._checkTime.call($this) }, 1000); + document.onmousemove = function () { $this._mouseHandler.call($this) }; +}; + +ScreenSaver.prototype = { + _timer: null, + + lastActivity: 0, + started: false, + waitTime: 0, + + onstart: function () {}, + onend: function () {}, + + dispose: function () { + if (this._timer) clearInterval(this._timer); + document.onmousemove = null; + }, + + _checkTime: function () { + if (!this.started && new Date().getTime() - this.lastActivity >= this.waitTime) { + this.started = true; + this.onstart(); + } + }, + + _mouseHandler: function () { + this.lastActivity = new Date().getTime(); + if (this.started) { + this.started = false; + this.onend(); + } + } +}; + +/*********** Begin Example *********** + +var ss = new ScreenSaver(5000); + +ss.onstart = function () { + document.getElementsByTagName("body")[0].style.backgroundColor = "#000"; +}; + +ss.onend = function () { + document.getElementsByTagName("body")[0].style.backgroundColor = "#fff"; +}; + +************* End Example *************/ \ No newline at end of file -- 1.7.1