NO LONGER MAINTAINED. SEE https://gist.github.com/4026211
Shows whether tracking is running in the page icon.
To be used with https://www.toggl.com/track
Tested on Chrome.
NO LONGER MAINTAINED. SEE https://gist.github.com/4026211
Shows whether tracking is running in the page icon.
To be used with https://www.toggl.com/track
Tested on Chrome.
| ;(function() { | |
| var onElementAttributesChange = function(element, callback) { | |
| new WebKitMutationObserver(callback).observe(element, {attributes: true}) | |
| } | |
| var Tracking = function() { | |
| var el = document.getElementById('running-task-form') | |
| return { | |
| isRunning: function() { return el.style.display != 'none' }, | |
| onChange: function(callback) { onElementAttributesChange(el, callback) } | |
| } | |
| } | |
| var Icon = function(tracking) { | |
| var el = document.querySelector('link[rel~=icon]') | |
| if (! el) { | |
| el = document.createElement('link') | |
| el.setAttribute('rel', 'icon') | |
| el.setAttribute('type', 'image/png') | |
| document.head.appendChild(el) | |
| } | |
| var update = function() { | |
| el.setAttribute('href', tracking.isRunning() ? | |
| 'http://cdn.dustball.com/clock_stop.png' : | |
| 'http://cdn.dustball.com/clock_play.png') | |
| } | |
| tracking.onChange(update) | |
| update() | |
| } | |
| new Icon(new Tracking) | |
| })() |