Jump to content

User:Animum/todo.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//HOW-TO:
//Add the following lines and to-do items to your JavaScript file (without the "//") where appropriate:
//importScript('User:Animum/todo.js');
//var todo_list = ["Item 1", "Item 2", "Item 3", "etc."]; //The last item shouldn't have a comma after the closing quotation mark.


function displayTodoList() {
    if(typeof(todo_list) == 'undefined') {
        alert("Please add a to-do list to your JavaScript file in this format (you can have as many items in the list as you like) and then purge your cache:\n\nvar todo_list = [\"Item 1\", \"Item 2\", \"Item 3\"];");
    } else {
        var todo_list_text = "";
        for(i=0; i<todo_list.length; i++) {
            todo_list_text += (i+1) + ". " + todo_list[i] + "\n\n";
        }
        alert(todo_list_text);
    }
}

$(function() {
    mw.util.addPortletLink("p-cactions", "javascript:displayTodoList()", "todo", "ca-todo");
});