Skip to content

Instantly share code, notes, and snippets.

@mvaneijgen mvaneijgen/todoist.coffee
Last active Sep 27, 2019

Embed
What would you like to do?
# Config Variables
# To get your API access token
# - go to https://developer.todoist.com/appconsole.html
# - Click create new app
# - Fill out the infromation and click create app
# - On the page you get redirected to scroll down a bit and click 'Create test token'
# - This is the token you need to set down here
token = '123abc'
# To get your project ID run the following command
# # curl -X GET https://beta.todoist.com/API/v8/projects -H "Authorization: Bearer $token"
project_id = '127864854'
# Local/Instance Variables
command: "curl -s GET 'https://beta.todoist.com/API/v8/tasks?project_id=#{project_id}' -H 'Authorization: Bearer #{token}'"
showDebug: false
refreshFrequency: 1000 * 60 * 5 # refreshs every 5 minutes
render: (_) -> """
<h1>Todo's</h1>
<hr />
<div class="todoist-wrapper"></div>
"""
update: (output, domEl) ->
# convert output to JSON
try
myoutput = JSON.parse output
catch
return
# grab dom elements
container = $(domEl).find '.todoist-wrapper'
.empty()
container.append myoutput
@renderList myoutput, container
renderList: (obj, container) ->
listHtml = ''
# switch list type for header
listHtml += "<ul class='todoist-list'>"
# iterate over list items
for item in obj
listHtml += "<li class='todoist-item'><span></span> #{item.content}</li>"
listHtml += "</ul>"
container.append listHtml
style: """
right: 30px
top: 30px
width: 370px
color: #fff
font-family: Roboto
overflow: hidden
hr
height: 2px
border: 0
background-color: #fff
margin: 10px 0
h1
text-align: right
margin-bottom: 0
font-size: 22px
line-height: 1.4
font-weight: 400
ul
list-style: none
padding: 0
margin: 0
li
margin-bottom: 15px
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
span
display: inline-block
transfrom: translateY(-1px)
border: 1px solid #fff
height: 7px
width: 7px
margin-bottom: 3px
margin-right: 5px
font-size: .6rem
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.