<commit_before># TODO
# * Limit lists displayed
# * Clean up code
update: (output, domEl) ->
    # Widget Settings
    tasksPerList = 5    # Number of tasks to show per list, 0 for all
    showNotes = false   # Whether notes get shown
    # Do not alter below here
    str = '<ul class="lists">'
    listNameTpl = ''
    reminders = JSON.parse(output)
    listTasks = @tasksByList(output)
    if !@content
        @content = $(domEl).find('.reminders-wrap')
    for listName in reminders.lists.sort()
        n = 0
        if listTasks[listName]?
            n = if tasksPerList > 0 and listTasks[listName].length > tasksPerList then tasksPerList else listTasks[listName].length
        if n > 0
            listNameTpl = '<div class="list-info">' +
                '<div class="list-name">' + listName + '</div>' +
                '<div class="tasks-length">' + n + ' of ' + listTasks[listName].length + '</div>' +
                '</div>'
            str +=  '<li class="list">' +
            listNameTpl + '<ul class="tasks">'
            i = 0
            for task in listTasks[listName]
                priority =  switch(task.priority)
                    when "1" then '!!!'
                    when "5" then '!!'
                    when "9" then '!'
                    else ''
                if i < n
                    task = listTasks[listName][i]
                    notes = if showNotes and task.notes then task.notes else ''
                    str += '<li class="task">' +
                        '<mark class="priority">' + priority + '</mark> ' + task.title
                    if task.dueDate != " "
                        now = new Date()
                        d = new Date(task.dueDate)
                        divcls = if d < now then 'overdue' else 'due'
                        str += '<div class="' + divcls + '">Due ' + d.toLocaleString() + '</div>'
                    if showNotes and task.notes
                        str += '<div class="notes">' + task.notes + '</div>'
                    str += '</li>'
                    i++
                else
                    break
            str += '</ul></li>'
    str += '</ul>'
    @content.html(str)

# Set the refresh frequency (milliseconds).
refreshFrequency: 1000 * 60	#1 minute

# Command
command: 'reminders.widget/pending.sh'

tasksByList: (output) ->
    reminders = JSON.parse(output)
    listTasks = {}
    for t in reminders.tasks
        listTasks[t.list] = [] if !listTasks[t.list]
        listTasks[t.list].push(t)
    return listTasks

# Most of the following was cribbed from
showError: (err) ->
	if @content
		@content.html '<div class="error">' + err + '</div>'

render: (output) -> """
	<div class='reminders-wrap'>
	</div>
"""

style: """
    top: 190px
    left: 10px
    color: #fff
    background: rgba(0,0,0,0.2)
    font-family: Arial
    font-size: 10pt
    width: 360px
    -webkit-backdrop-filter: blur(10px)


    .lists,.tasks
        margin: 0
        padding: 0

    .list,.task
        list-style: none

    .list-info<commit_msg>Changed top from 190 to 10.<commit_after># TODO
# * Limit lists displayed
# * Clean up code
update: (output, domEl) ->
    # Widget Settings
    tasksPerList = 5    # Number of tasks to show per list, 0 for all
    showNotes = false   # Whether notes get shown
    # Do not alter below here
    str = '<ul class="lists">'
    listNameTpl = ''
    reminders = JSON.parse(output)
    listTasks = @tasksByList(output)
    if !@content
        @content = $(domEl).find('.reminders-wrap')
    for listName in reminders.lists.sort()
        n = 0
        if listTasks[listName]?
            n = if tasksPerList > 0 and listTasks[listName].length > tasksPerList then tasksPerList else listTasks[listName].length
        if n > 0
            listNameTpl = '<div class="list-info">' +
                '<div class="list-name">' + listName + '</div>' +
                '<div class="tasks-length">' + n + ' of ' + listTasks[listName].length + '</div>' +
                '</div>'
            str +=  '<li class="list">' +
            listNameTpl + '<ul class="tasks">'
            i = 0
            for task in listTasks[listName]
                priority =  switch(task.priority)
                    when "1" then '!!!'
                    when "5" then '!!'
                    when "9" then '!'
                    else ''
                if i < n
                    task = listTasks[listName][i]
                    notes = if showNotes and task.notes then task.notes else ''
                    str += '<li class="task">' +
                        '<mark class="priority">' + priority + '</mark> ' + task.title
                    if task.dueDate != " "
                        now = new Date()
                        d = new Date(task.dueDate)
                        divcls = if d < now then 'overdue' else 'due'
                        str += '<div class="' + divcls + '">Due ' + d.toLocaleString() + '</div>'
                    if showNotes and task.notes
                        str += '<div class="notes">' + task.notes + '</div>'
                    str += '</li>'
                    i++
                else
                    break
            str += '</ul></li>'
    str += '</ul>'
    @content.html(str)

# Set the refresh frequency (milliseconds).
refreshFrequency: 1000 * 60	#1 minute

# Command
command: 'reminders.widget/pending.sh'

tasksByList: (output) ->
    reminders = JSON.parse(output)
    listTasks = {}
    for t in reminders.tasks
        listTasks[t.list] = [] if !listTasks[t.list]
        listTasks[t.list].push(t)
    return listTasks

# Most of the following was cribbed from
showError: (err) ->
	if @content
		@content.html '<div class="error">' + err + '</div>'

render: (output) -> """
	<div class='reminders-wrap'>
	</div>
"""

style: """
    top: 10px
    left: 10px
    color: #fff
    background: rgba(0,0,0,0.2)
    font-family: Arial
    font-size: 10pt
    width: 360px
    -webkit-backdrop-filter: blur(10px)


    .lists,.tasks
        margin: 0
        padding: 0

    .list,.task
        list-style: none

    .list-info
{'fraction_non_alphanumeric': 0.13794796269023074, 'fraction_numerical': 0.012109311078383244, 'mean_word_length': 1.619802828975568, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4020200', 'n_tokens_mistral': 1890, 'n_tokens_neox': 1773, 'n_words': 496}