Added inactive component, which checks for inactivity of the user.

This commit is contained in:
FrozenCow 2011-10-02 15:25:54 +02:00
parent 68cb59997e
commit f05dfac0a4
3 changed files with 47 additions and 1 deletions

View File

@ -95,7 +95,13 @@ components:
# type: logo
# text: "Dynmap"
# linkurl: "http://forums.bukkit.org/threads/dynmap.489/"
#- class: org.dynmap.ClientComponent
# type: inactive
# timeout: 1800 # in seconds (1800 seconds = 30 minutes)
# redirecturl: inactive.html
# #showmessage: 'You were inactive for too long.'
#- class: org.dynmap.regions.RegionsComponent
# type: regions
# name: WorldGuard

19
web/inactive.html Normal file
View File

@ -0,0 +1,19 @@
<html>
<head><title>Minecraft Dynamic Map - Inactive</title></head>
<style>
body > div {
position:fixed;
top:50%;left:50%;margin:-.5em 0 0 -6.5em;
text-align: center;
}
h1 {
color:#c33;
}
</style>
<body>
<div>
<h1>Map disabled due to inactivity.</h1>
<a href="./">Click here to go back</a>
</div>
</body>
</html>

21
web/js/inactive.js Normal file
View File

@ -0,0 +1,21 @@
componentconstructors['inactive'] = function(dynmap, configuration) {
var me = this;
var inactivetimer = null;
$(document)
.ready(onactivity)
.mousemove(onactivity)
.mouseup(onactivity)
.keypress(onactivity);
function onactivity() {
clearTimeout(inactivetimer);
inactivetimer = setTimeout(oninactive, (configuration.timeout || 1800)*1000);
}
function oninactive() {
if (configuration.showmessage) {
alert(configuration.showmessage);
}
if (configuration.redirecturl) {
window.location = configuration.redirecturl;
}
}
};