Created
March 3, 2014 14:30
-
-
Save pichfl/9326116 to your computer and use it in GitHub Desktop.
timetracking-ticker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// Get global namespace | |
var SP = window.SP || {}; | |
(function($) { | |
var target = $('#working-time-count'); | |
var appointmentStartTime = SP.APPOINTMENT_START_TIME; | |
if (appointmentStartTime && target) { | |
var startParts = appointmentStartTime.split(' '); | |
var start = new Date(startParts[0]); | |
var startTime = startParts[1].split(':'); | |
var displayTime = function() { | |
var now = new Date().getTime(); | |
var delta = new Date(now - start); | |
var hours = delta.getHours(); | |
var min = delta.getMinutes(); | |
var sec = delta.getSeconds(); | |
var timeLeft = ''; | |
if (hours) { | |
timeLeft += hours + 'h '; | |
} | |
timeLeft += min + 'min ' + sec + 's'; | |
target.text(timeLeft); | |
}; | |
start.setHours(startTime[0]); | |
start.setMinutes(startTime[1]); | |
start.setSeconds(startTime[3]); | |
setInterval(displayTime, 1000); | |
} | |
} (jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment