<commit_before>/**
 * Created by Administrator on 2016/11/8 0008.
 */
;(function(){
    'use strict'

    var $content = $("#task_content"),
        $addTaskBtn = $("#add_task_btn"),
        task_list = [],
        $delete_task;

    init();
        
    $addTaskBtn.on("click", function(e){
        var new_task = {};
        /* 获取新Task的值 */
        new_task.content = $content.val();
        /* 如果新Task的值为空则直接返回，否则继续执行 */
        if(!new_task.content) return;
        /* 存入新Task */
        if(addTask(new_task)){
            renderTaskList();
        }
        $content.val(null);
        console.log("new_task",new_task);
    });

    function addTask(new_task){
        /* 将新Task推入TaskList */
        task_list.push(new_task);
        /* 更新LocalStorege */
        store.set("task_list",task_list);

        return true;
    }

    function renderTaskList(){
        var $task_list = $(".task_list");
        $task_list.html("");
        for(var i=0; i<task_list.length; i++){
            var $task = renderTaskItem(task_list[i],i);
            $task_list.append($task);
        }

        $delete_task = $(".task_list").find(".del");

        //console.log("$delete_task",$delete_task);
    }

    
    function renderTaskItem(data,index){
        if(!data || (!index && index != 0)) return;
        var task_item_tpl = `
        <div class="task_item" data-index="${index}">
            <div class="task_item_content">
                <span><input type="checkbox"/></span><commit_msg>删除Task<commit_after>/**
 * Created by Administrator on 2016/11/8 0008.
 */
;(function(){
    'use strict'

    var $content = $("#task_content"),
        $addTaskBtn = $("#add_task_btn"),
        task_list = [],
        $delete_task;

    init();
        
    $addTaskBtn.on("click", function(e){
        var new_task = {};
        /* 获取新Task的值 */
        new_task.content = $content.val();
        /* 如果新Task的值为空则直接返回，否则继续执行 */
        if(!new_task.content) return;
        /* 存入新Task */
        if(addTask(new_task)){
            $content.val(null);
        }
    });

    function addTask(new_task){
        /* 将新Task推入TaskList */
        task_list.push(new_task);
        /* 更新LocalStorege */
        refreshTaskList();
        return true;
    }

    function renderTaskList(){
        var $task_list = $(".task_list");
        $task_list.html("");
        for(var i=0; i<task_list.length; i++){
            var $task = renderTaskItem(task_list[i],i);
            $task_list.append($task);
        }

        $delete_task = $(".task_list").find(".del");
        listenTaskDelete();

        //console.log("$delete_task",$delete_task);
    }

    function listenTaskDelete(){
        $delete_task.on("click", function(){
            var $this = $(this);
            var $item = $this.parent().parent();
            var index = $item.data("index");
            var temp = confirm("确认删除？");
            temp ? deleteTask(index) : null;
        });
    }

    /**
     * 刷新localStorage数据并渲染模版
     */
    function refreshTaskList(){
        store.set("task_list",task_list);
        renderTaskList();
    }

    function deleteTask(index){
        if((!index && index != 0) || !task_list[index]) return;
        delete task_list[index];
        /*更新localStorage*/
        refreshTaskList();
    }
    
    function renderTaskItem(data,index){
        if(!data || (!index && index != 0)) return;
        var task_item_tpl = `
        <div class="task_item" data-index="${index}">
            <div class="task_item_content">
                <span><input type="checkbox"/></span>
{'fraction_non_alphanumeric': 0.16545148625911385, 'fraction_numerical': 0.007571508693213685, 'mean_word_length': 2.015215553677092, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '1811763', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1163, 'n_words': 181}