GT3 Subtasks

Script key

Posted by @nahumck

Install

Details

Label GT3 Subtasks
Voice Over
Script
// GT3 Key

// Make lines into subtasks for GoodTask3
//subtask format is: ..gt3[{"Subtasks":["0[[line|1]]","0[[line|2..]]",…,"0[[line|n]]"]}]gt3

var taskPrefix = "..gt3[{\"Subtasks\":[";
var taskSuffix = "]}]gt3";
var prefix = "\"0";
var suffix = "\"";

var lnRange = getSelectedLineRange();
var ln = getTextInRange(lnRange[0], lnRange[1]);
var selRange = getSelectedRange();

var lines = ln.split('\n');
var charsAdded = 0;

if (ln.length == 0) {
alert("No text selected");
} else {
  for (var ix=0; ix < lines.length; ix++) {
    if (lines[ix].length > 0) {
      if (lines[ix][0] != prefix) {
        if (lines[ix][0] != " ") {
        }
        lines[ix] = prefix + lines[ix] + suffix;
        charsAdded = charsAdded + prefix.length;
      }
    }
  }

var newLines = lines.join(",");
var subtasks = taskPrefix + newLines + taskSuffix + "\n";
setTextInRange(lnRange[0], lnRange[1],subtasks);
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus