Skip to content

Commit

Permalink
added option to set priority for to-do item:
Browse files Browse the repository at this point in the history
	! - low priority
	!! - medium priority
	!!! - high priority

more than 3 exclamation marks are parsed as high priority
it simply adds class name to <span class="todotext">...
  • Loading branch information
greeneng authored and einhirn committed May 10, 2024
1 parent 73a1e77 commit 180cffa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ span.todouser { font-size: x-small; cursor:default; font-style: italic; padding-
span.tododates { font-size: x-small; padding-left: 3px; padding-right: 3px; margin-right: 4px; }
span.todostarted { background:#EEA; font-weight: bold; }
span.tododue { background:#EAA; font-weight: bold; }

span.todolow { background-color: #ffc; }
span.todomedium { background-color: #fd3; font-weight: bold; }
span.todohigh { background-color: #ffbcaf; font-weight: bold; font-size:1.1em; }
19 changes: 18 additions & 1 deletion syntax/todo.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ protected function parseTodoArgs($todoargs) {
unset($data['completeddate']);
$data['showdate'] = $this->getConf("ShowdateTag");
$data['username'] = $this->getConf("Username");
$data['priority'] = 0;
$options = explode(' ', $todoargs);
foreach($options as $option) {
$option = trim($option);
Expand All @@ -210,6 +211,13 @@ protected function parseTodoArgs($todoargs) {
$data['completeddate'] = new DateTime($completeddate);
}
}
elseif($option[0] == '!') {
$plen = strlen($option);
$excl_count = substr_count($option, "!");
if (($plen == $excl_count) && ($excl_count >= 0)) {
$data['priority'] = $excl_count;
}
}
else {
@list($key, $value) = explode(':', $option, 2);
switch($key) {
Expand Down Expand Up @@ -301,7 +309,16 @@ protected function createTodoItem($renderer, $id, $data) {
$return .= ']</span>';
}

$spanclass = 'todotext';
// priority
$priorityclass = '';
if (isset($data['priority'])) {
$priority = $data['priority'];
if ($priority == 1) $priorityclass = ' todolow';
else if ($priority == 2) $priorityclass = ' todomedium';
else if ($priority >= 3) $priorityclass = ' todohigh';
}

$spanclass = 'todotext' . $priorityclass;
if($this->getConf("CheckboxText") && !$this->getConf("AllowLinks") && $oldID == $ID && $data['checkbox']) {
$spanclass .= ' clickabletodo todohlght';
}
Expand Down

0 comments on commit 180cffa

Please sign in to comment.