From: hickert Date: Fri, 21 May 2010 08:16:57 +0000 (+0000) Subject: Added logout timer X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c333042fd1b7a98e525b5991a94d99a3794940f5;p=gosa.git Added logout timer git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18608 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/html/include/gosa.js b/gosa-core/html/include/gosa.js index 862975fef..25098d805 100644 --- a/gosa-core/html/include/gosa.js +++ b/gosa-core/html/include/gosa.js @@ -22,6 +22,7 @@ /* Install event handlers */ Event.observe(window, 'resize', resizeHandler); Event.observe(window, 'load', resizeHandler); +Event.observe(window, 'load', initProgressPie); Event.observe(window, 'keypress', keyHandler); @@ -544,7 +545,79 @@ function capslock(e) { return false; } +function setProgressPie(context, percent) +{ + context.clearRect(0, 0, 22, 22); + + var r = "FF"; + var g = "FF"; + var b = "FF"; + + // Fade yellow + if (percent > 50) { + d = 255 - parseInt((percent-50) * 255 / 50) + b = d.toString(16); + } + + // Fade red + if (percent > 75) { + d = 255 - parseInt((percent-75) * 255 / 25) + g = d.toString(16); + } + context.strokeStyle = "#" + r + g + b + context.fillStyle = context.strokeStyle; + + context.beginPath(); + context.moveTo(11,11) + context.arc(11,11,8,-Math.PI/2,-Math.PI/2 + Math.PI*percent/50,true); + context.closePath(); + context.fill(); + + context.moveTo(11,11) + context.beginPath(); + context.arc(11,11,8,0,Math.PI*2,false); + context.closePath(); + context.stroke(); +} + +function initProgressPie(){ + var canvas = $('sTimeout'); + + // Check the element is in the DOM and the browser supports canvas + if(canvas && canvas.getContext) { + var percent = 0.01; + var context = canvas.getContext('2d'); + setProgressPie(context, percent); + + // Extract timeout and title string out out canvas.title + var data = canvas.title; + var timeout = data.replace(/\|.*$/,''); + var title = data.replace(/^.*\|/,''); + var interval = 1; + var time = 0; + setInterval(function() { + + // Calculate percentage + percent+= (interval / timeout) * 100; + + // Increase current time by interval + time += interval; + + // Generate title + var minutes = parseInt((timeout-time) / 60 ); + var seconds = '' + parseInt((timeout-time) % 60); + if(seconds.length == 1) seconds = '0' + seconds ; + minutes = minutes + ':' + seconds; + + // Set new canval title + canvas.title= title.replace(/%d/ ,minutes); + setProgressPie(context, percent); + + if (percent>99) percent= 99; + }, (interval * 1000)); + } +} /* Scroll down the body frame */ function scrollDown2() diff --git a/gosa-core/ihtml/themes/default/framework.tpl b/gosa-core/ihtml/themes/default/framework.tpl index 0bf462501..e7c8772fe 100644 --- a/gosa-core/ihtml/themes/default/framework.tpl +++ b/gosa-core/ihtml/themes/default/framework.tpl @@ -15,7 +15,12 @@
  • -
    {$loggedin}
    +
    {$loggedin}
    +
  • +
  • +
    + +