<commit_before>/* CARDITEM object
    function CardItem(
        content: a string
        dateCrea: a timestamp
        datesModif: an array of timestamps
        question: a string
        marks: an array of numbers
        marksDates: an array of timestamps
    )
*/

function CardItem(content, dateCrea, datesModif, question, marks, marksDates) {

    /* PARAMS */
    this.dateCrea = dateCrea ? dateCrea : Date.now(), /* the creation date */
    this.datesModif = datesModif ? datesModif : [], /* the last modif date */

    /* CONTENT */
    this.content = content ? content : undefined, /* a string, such as "汉字" or "hanzi" */
    this.question = question ? question : 'I don\'t know.',
    this.marks = marks ? marks : [0], /* the marks the item got : [0, 1, 3, 2, 1, 0, 1]
                         0 : 'not seen yet'
                         1 : 'wrong answer'
                         2 : 'look'
                         3 : 'right answer' */
    this.marksDates = marksDates ? marksDates : [Date.now()], /* the dates when the marks happened :
                                       [timestamp, timestamp, ...] */


    /* UPDATE MARKS
        We consider that the person has +1 mark as long as he/she doesn't click
        on the answer.
    */
    this.updateMarks = function(number) {
        var itemObject = this;
        if (number === 1) {
            itemObject.marks.pop();
            itemObject.marks.push(number);
            console.log(itemObject.content + itemObject.marks);
            itemObject.marksDates.pop();
            itemObject.marksDates.push(Date.now());
        } else {
            itemObject.marks.push(number);
            itemObject.marksDates.push(Date.now());
        }
    }

    /* LEVEL KNOWN
        returns the number of times since last wrong answer
    */
    this.levelKnown = function() {
        var that = this;
        var levelKnown = 0;

        for (var i=that.marks.length; i>0; i--) {
            if (that.marks[i-1] > 1) {
                console.log("plus" + levelKnown);
                levelKnown++;
            } else {
                console.log("not" + levelKnown);
                return levelKnown;
            }
        }
        console.log("done" + levelKnown);
        return levelKnown;

    }

    /* CREATEHTML */
    /*
        -> makes an HTML version of the item
        -> returns it
        state : 'look', 'learn' & 'edit';
    */
    this.createHTML = function(state) {

        // CREATE VARIABLES ACCORDING TO STATE
        var itemObject = this;

        var editability, answerVisibility, questionVisibility;

        if (state === 'edit') {
            editability = true;
            answerVisibility = 'visible';
            questionVisibility = 'hidden';
        } else if (state === 'learn') {
            if (itemObject.levelKnown() === 0) {
                editability = false;
                answerVisibility = 'visible';
                questionVisibility = 'hidden';
                itemObject.updateMarks(2);
            } else {
                editability = false;
                answerVisibility = 'hidden';
                questionVisibility = 'visible';
                itemObject.updateMarks(3); /* add a good mark for this object,
                                                 see (a) for bad marks, */
            }
        } else {
            editability = false;
            answerVisibility = 'visible';
            questionVisibility = 'hidden';
            itemObject.updateMarks(2);
        }

        // CREATE HTML
        var itemHTML = document.createElement('div');
            itemHTML.className = 'card-item';
            itemHTML.setAttribute('data-state', state);

            var itemAnswer = document.createElement('span');
                itemAnswer.className = 'card-item__answer ' + answerVisibility;
                itemAnswer.textContent = this.content;
                itemAnswer.setAttribute('contenteditable', editability);<commit_msg>removed a few console.log<commit_after>/* CARDITEM object
    function CardItem(
        content: a string
        dateCrea: a timestamp
        datesModif: an array of timestamps
        question: a string
        marks: an array of numbers
        marksDates: an array of timestamps
    )
*/

function CardItem(content, dateCrea, datesModif, question, marks, marksDates) {

    /* PARAMS */
    this.dateCrea = dateCrea ? dateCrea : Date.now(), /* the creation date */
    this.datesModif = datesModif ? datesModif : [], /* the last modif date */

    /* CONTENT */
    this.content = content ? content : undefined, /* a string, such as "汉字" or "hanzi" */
    this.question = question ? question : 'I don\'t know.',
    this.marks = marks ? marks : [0], /* the marks the item got : [0, 1, 3, 2, 1, 0, 1]
                         0 : 'not seen yet'
                         1 : 'wrong answer'
                         2 : 'look'
                         3 : 'right answer' */
    this.marksDates = marksDates ? marksDates : [Date.now()], /* the dates when the marks happened :
                                       [timestamp, timestamp, ...] */


    /* UPDATE MARKS
        We consider that the person has +1 mark as long as he/she doesn't click
        on the answer.
    */
    this.updateMarks = function(number) {
        var that = this;
        if (number === 1) {
            that.marks.pop();
            that.marks.push(number);
            console.log(that.content + that.marks);
            that.marksDates.pop();
            that.marksDates.push(Date.now());
        } else {
            that.marks.push(number);
            that.marksDates.push(Date.now());
        }
    }

    /* LEVEL KNOWN
        returns the number of times since last wrong answer
    */
    this.levelKnown = function() {
        var that = this;
        var levelKnown = 0;

        for (var i=that.marks.length; i>0; i--) {
            if (that.marks[i-1] > 1) {
                console.log("plus" + levelKnown);
                levelKnown++;
            } else {
                console.log("not" + levelKnown);
                return levelKnown;
            }
        }
        console.log("done" + levelKnown);
        return levelKnown;

    }

    /* CREATEHTML */
    /*
        -> makes an HTML version of the item
        -> returns it
        state : 'look', 'learn' & 'edit';
    */
    this.createHTML = function(state) {

        // CREATE VARIABLES ACCORDING TO STATE
        var itemObject = this;

        var editability = false; /* most used state */
        var answerVisibility = 'visible';   /* idem */
        var questionVisibility = 'hidden';  /* idem */

        if (state === 'edit') {
            editability = true;
        } else if (state === 'learn') {
            if (itemObject.levelKnown() === 0) {
                itemObject.updateMarks(2);
            } else {
                answerVisibility = 'hidden';
                questionVisibility = 'visible';
                itemObject.updateMarks(3); /* add a good mark for this object,
                                                 see (a) for bad marks, */
            }
        } else {
            itemObject.updateMarks(2);
        }

        // CREATE HTML
        var itemHTML = document.createElement('div');
            itemHTML.className = 'card-item';
            itemHTML.setAttribute('data-state', state);

            var itemAnswer = document.createElement('span');
                itemAnswer.className = 'card-item__answer ' + answerVisibility;
                itemAnswer.textContent = this.content;
                itemAnswer.setAttribute('contenteditable', editability);
{'fraction_non_alphanumeric': 0.1130890052356021, 'fraction_numerical': 0.005759162303664921, 'mean_word_length': 1.5572289156626506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5861616', 'n_tokens_mistral': 2115, 'n_tokens_neox': 1993, 'n_words': 558}