Skip to content

Instantly share code, notes, and snippets.

@james-s-tayler
Created March 16, 2017 04:08
Show Gist options
  • Save james-s-tayler/23fbb0bef5520f910aee74fb8b88ba6e to your computer and use it in GitHub Desktop.
Save james-s-tayler/23fbb0bef5520f910aee74fb8b88ba6e to your computer and use it in GitHub Desktop.
function updateTimeLogged() {
var time = $("#log_hours").val() + "h " + $("#log_minutes").val() + "m";
$('#log-work-time-logged').val(time);
}
$(document).on("change", "#log_hours", function(event) {
updateTimeLogged();
});
$(document).on("change", "#log_minutes", function(event) {
updateTimeLogged();
});
function isLogworkDialogOpen() {
console.log("checking for #log-work-time-logged");
return $('#log-work-time-logged').length === 1;
}
function hasFacelift() {
console.log("checking if facelift has been applied...");
return $("#log_hours").length === 1;
}
function checkDOMChange()
{
if(isLogworkDialogOpen()) {
console.log("Log Work Dialog is open!!");
if(!hasFacelift()) {
console.log("applying facelift...");
$('#log-work-time-logged').hide();
$('#log-work-time-logged').after('<input id="log_minutes" class="form.aui" type="number" min="0" max="45" width="10%" step="15" value="0"><p style="display: -webkit-inline-box;">&nbsp;min&nbsp;</p>');
$('#log-work-time-logged').after('<input id="log_hours" class="form.aui" type="number" min="0" max="8" width="10%" step="1" value="0"><p style="display: -webkit-inline-box;">&nbsp;hr&nbsp;</p>');
} else {
console.log("already has facelift - nothing to do!");
}
}
// call the function again after 100 milliseconds
setTimeout( checkDOMChange, 1000 );
}
console.log("start polling...");
checkDOMChange();
{
"name": "Log Work Facelift",
"version": "0.9.0",
"description": "Make logging work great again!",
"content_scripts": [
{ "matches": ["https://*.atlassian.net/*"],
"js": ["jquery-3.1.1.min.js", "content_script.js"]
}
],
"manifest_version": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment