このテーマの前回: タスクリストを #HandyFlowy から #Trello に転送する試み その5
「タスクリストを #HandyFlowy から #Trello に転送する試み その4」を前回同様にノート部分に期限タグを記入した場合にも対応させた。
期限タグがノート部分にあっても認識され、ネーム部分にもあえて明示されていたらそれを優先し、ネーム部分・ノート部分どちらであれ複数の期限タグがあった場合は後ろに書いた方が優先される。
上記「定期検診の予約をする」の期限はそのノートに書かれた12/1になり、「定期検診を受ける」はその親の「定期検診」のノートに書かれた12/31に。
「パネルの参加に関するメールに返信する」のノートには11/26と書かれているが、ネームの末尾に11/25と11/24が書かれており、後ろの11/24が期限として入力され、
となる。
/* WFy2Trello_Project2List_note.js */ var readTasks = function (ele, nestL, parentN, parentD) { var tasks = []; $(ele).each(function(){ var className = $(this).attr('class'); var classNameS = className.split(' '); var projectId = ($(this).attr("projectid").split("-"))[4]; var name = $(this).find("> .name > .content").text(); var note = $(this).find("> .notes > .content").text(); var tagsInName = $.makeArray( $(this).find("> .name > .content > .contentTag > .contentTagText").map(function(){ return $(this).text(); }) ); var tagsInNote = $.makeArray( $(this).find("> .notes > .content > .contentTag > .contentTagText").map(function(){ return $(this).text(); }) ); var tags = tagsInNote.concat(tagsInName); var due = ""; if (tags.length > 0) { var dueTags = $.grep(tags, function(obj) { return (obj.match(/d20[0-9][0-9]-[0-1][0-9]-[0-3][0-9](T[0-2][0-9]:[0-5][0-9](:[0-5][0-9])*)*/)); }); if (dueTags.length > 0) due = dueTags.pop().slice(1); } if (classNameS.indexOf("open")>=0) { var k = (nestL == 0) ? name : name + " / " + parentN; tasks = tasks.concat( readTasks($(this).find("> .children > .project"), nestL + 1, k, due) ) } else { var v = {}; v.name = name; v.parentN = parentN v.note = note; v.projectId = projectId; v.due = (due == "") ? parentD : due; tasks.push(v); } }); return tasks; } var readProjects = function (ele) { var projects = []; $(ele).each(function(){ var className = $(this).attr('class'); var classNameS = className.split(' '); var listName = $(this).find("> .name > .content").text(); var o = {}; o.listName = listName; o.tasks = []; if (classNameS.indexOf("open")>=0) o.tasks = readTasks($(this).find("> .children > .project"), 0, "", ""); projects.push(o); }); return projects; } var projectList = {}; projectList.projects = readProjects($('.project.selected > .children > .project')); //console.log(projectList); var projectListJ = JSON.stringify(projectList); window.open('workflow://run-workflow?name=clip_to_Trello_pList&input=text&text=' + encodeURIComponent(projectListJ));
Workflowのレシピは同じ。