Today I used the snippets view in Chrome developer tools to write functions that interact with the todo list.
Here are all the functions saved under vanilla todo helpers
in snippets.
function clickItem(item){
item.click()
}
function toggleAll(){
document.querySelector("#toggle-all").click()
}
function selectItemX(x){
document.querySelector(`ul.todo-list > li:nth-child(${x}) input.toggle`).click()
}
function deleteItemX(x){
document.querySelector(`ul.todo-list > li:nth-child(${x}) button.destroy`).click()
}
function clearCompleted(){
document.querySelector('button.clear-completed').click()
}
function filterCompleted(){
location.hash="/completed"
}
function filterAll(){
location.hash="/"
}
function filterActive(){
location.hash="/active"
}
function createTodo(name){
document.querySelector("input.new-todo").value=name
document.querySelector("input.new-todo").dispatchEvent(new Event('change',{'bubbles':true}))
}
function amendTodo(x, amendedValue){
document.querySelector(`ul.todo-list > li:nth-child(${x}) > div > label`).dispatchEvent(new Event('dblclick', {'bubbles':true}))
document.querySelector(`ul.todo-list > li:nth-child(${x}) .edit`).value=amendedValue
document.querySelector(`ul.todo-list > li:nth-child(${x}) .edit`).dispatchEvent(new Event('blur'))
}
function clearCompleted(){
document.querySelector("button.clear-completed").click()
}
- Day 11 - Finish chapter 1
- Day 12 - Words + Active Voice
- Day 13 - Active Voice, Clear Sentences, Short Sentences
- Day 14 - Finish up Short Sentences
- Day 15 - Automating in the Browser Using JavaScript
- Day 16 - Automating in the Browser Using JavaScript | Chapter 8.1
- Day 17 - Automating in the Browser Using JavaScript | Chapters 8.2-11
- Day 18 - Easy Edabit
- Day 19 - What is Rockstar?
- Day 20 - Finished Automating in the Browser Using JavaScript