OTRS_Timer

Timer for OTRS with auto-complete of Time Units

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        OTRS_Timer
// @author      Pedro VAZ PEREIRA
// @description Timer for OTRS with auto-complete of Time Units
// @include     */otrs/index.pl?Action=AgentTicketNote*
// @include     */otrs/index.pl?Action=AgentTicketPhone*
// @include     */otrs/index.pl?Action=AgentTicketClose*
// @include     */otrs/index.pl?Action=AgentTicketPending*
// @version     1.4
// @license     Licence Creative Commons Attribution - Partage dans les Mêmes Conditions 3.0 France (CC BY-SA 3.0 FR)
// @grant       none
// @namespace https://greasyfork.org/users/6245
// ==/UserScript==
function addTimer() {
  var ban = document.getElementsByClassName('Header') [0];
  var banClose = ban.getElementsByTagName('p') [1];
  var newTimer = createTimer();
  ban.insertBefore(newTimer, banClose)
}
function createTimer() {
  var newDiv = document.createElement('div');
  var buttonStart = document.createElement('button');
  var buttonStop = document.createElement('button');
  var buttonReset = document.createElement('button');
  newDiv.id = 'Timer';
  buttonStart.id = 'Start';
  buttonStop.id = 'Stop';
  buttonReset.id = 'Reset';
  newDiv.innerHTML = '<H3><time>00:00<sec style=\'font-size: 0.8em;\'>:00</sec></time></H3>';
  buttonStart.innerHTML = 'START';
  buttonStop.innerHTML = 'STOP';
  buttonReset.innerHTML = 'RESET';
  newDiv.appendChild(buttonStart);
  newDiv.appendChild(buttonStop);
  newDiv.appendChild(buttonReset);
  return newDiv;
}
addTimer();
timer();

var h3 = document.getElementsByTagName('h3') [0],
start = document.getElementById('Start'),
stop = document.getElementById('Stop'),
clear = document.getElementById('Reset'),
seconds = 0,
minutes = 0,
hours = 0,
t;

function add() {
  seconds++;
  if (seconds >= 60) {
    seconds = 0;
    minutes++;
    if (minutes >= 60) {
      minutes = 0;
      hours++;
    }
  }
  updateWorkUnits(hours, minutes);
  h3.innerHTML = (hours ? (hours > 9 ? hours : '0' + hours)  : '00') + ':' + (minutes ? (minutes > 9 ? minutes : '0' + minutes)  : '00') + '<sec style=\'font-size: 0.8em;\'>:' + (seconds > 9 ? seconds : '0' + seconds) + '</sec>';
  timer();
}
function updateWorkUnits(hour, min) {
  hour = parseInt(hour);
  min = parseInt(min);
  var timeUnitsInput = document.getElementById('TimeUnits');
  var totalMinutes = hour * 60 + min;
  var timeUnit = Math.floor(totalMinutes / 3) * 0.05
  timeUnitsInput.value = timeUnit;
}
function timer() {
  t = setTimeout(add, 1000);
}
/* Start button */

start.onclick = timer;
/* Stop button */
stop.onclick = function () {
  clearTimeout(t);
}
/* Clear button */

clear.onclick = function () {
  h3.innerHTML = '00:00<sec style=\'font-size: 0.8em;\'>:00</sec>';
  seconds = 0;
  minutes = 0;
  hours = 0;
  var timeUnitsInput = document.getElementById('TimeUnits');
  timeUnitsInput.value = 0;
}