Last active
October 11, 2024 00:03
-
-
Save doug4j/45c1745b4fc65f3e41c1da92dcfe087c to your computer and use it in GitHub Desktop.
Revisions
-
doug4j revised this gist
Feb 1, 2019 . 1 changed file with 51 additions and 29 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,35 +1,57 @@ // jshint esversion:6 (function() { var app = Application('OmniFocus'); //This assumes that OmniFocus is installed on MacOS app.includeStandardAdditions = true; var doc = app.defaultDocument; var content = doc.documentWindows.at(0).content; var selectedTree = content.selectedTrees(); var selectedLen = selectedTree.length; var totalItems = 0; var totalMinutes = 0; for (var i=0;i < selectedLen; i++) { try{ var task = selectedTree[i]; //var hasParentTask = false; if (isLeafTask(task)) { var estimatedMinutes = task.value().estimatedMinutes(); if (estimatedMinutes !== null) { totalMinutes = totalMinutes + estimatedMinutes; } totalItems = totalItems + 1; } }catch(e) { if (e.message === "User canceled.") { return; //get out of the loop (end the program) } else { app.displayDialog("[Exception] Content Selected index [" + i + "] is not a task: " + e); return; } } } function isLeafTask(item) { try { if(item.value().inInbox()) { return true; } if (item.value().containingProject().id() === item.value().id()) { //This is a project, tag, or some other top-level container return false; } return item.value().numberOfTasks() == 0; } catch (e) { return false; } } var msg = ""; if (totalItems > 1) { msg = "" + Math.floor(totalMinutes / 60) + "h " + (totalMinutes % 60).toFixed(0) + "m " + totalItems + " items"; } else { msg = "" + Math.floor(totalMinutes / 60) + "h " + (totalMinutes % 60).toFixed(0) + "m " + totalItems + " item"; } app.displayDialog(msg); })(); -
doug4j revised this gist
Dec 31, 2018 . 1 changed file with 35 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,35 @@ var app = Application('OmniFocus'); app.includeStandardAdditions = true; var doc = app.defaultDocument; var content = doc.documentWindows.at(0).content; var selectedTree = content.selectedTrees(); var selectedLen = selectedTree.length var totalItems = 0; var totalMinutes = 0 for (var i=0;i < selectedLen; i++) { try{ var task = selectedTree[i] var hasParentTask = false; var estimatedMinutes = task.value().estimatedMinutes() if (estimatedMinutes !== null) { totalMinutes = totalMinutes + estimatedMinutes; } totalItems = totalItems + 1 }catch(e) { if (e.message === "User canceled.") { break; //get out of the loop (end the program) } else { // app.displayDialog("[Exception] Content Selected index [" + i + "] is not a task: " + e); } } } var msg = "" if (totalItems > 1) { msg = "" + Math.floor(totalMinutes / 60) + "h " + (totalMinutes % 60).toFixed(0) + "m " + totalItems + " items" } else { msg = "" + Math.floor(totalMinutes / 60) + "h " + (totalMinutes % 60).toFixed(0) + "m " + totalItems + " item" } app.displayDialog(msg) -
doug4j created this gist
Dec 31, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ a