<commit_before>/*
**  ComponentJS -- Component System for JavaScript <http://componentjs.com>
**  Copyright (c) 2009-2013 <NAME> <http://engelschall.com>
**
**  This Source Code Form is subject to the terms of the Mozilla Public
**  License, v. 2.0. If a copy of the MPL was not distributed with this
**  file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/* global ace: true */
cs.ns('app.ui.widget.constraintset')

app.ui.widget.constraintset = cs.clazz({
    mixin: [ cs.marker.controller ],
    dynamics: {
        editor: null,
        timer: null
    },
    protos: {
        create: function () {
            var self = this

            cs(self).create('model/view',
                app.ui.widget.constraintset.model,
                app.ui.widget.constraintset.view
            )

            /*  calculate the savable content on demand  */
            cs(self).register({
                name: 'getContent', spool: 'created',
                func: function () {
                    return cs(self, 'model').value('data:constraintset')
                }
            })

            cs(self, 'model').observe({
                name: 'data:constraintset', spool: '..:created',
                touch: true,
                func: function (ev, content) {
                    if (self.timer !== null) {
                        /* global clearTimeout: true */
                        clearTimeout(self.timer)
                    }
                    /* global setTimeout: true */
                    self.timer = setTimeout(function () {
                        cs(self).publish('setChanged', content)
                    }, 1000)
                }
            })

            cs(self).register({
                name: 'setContent', spool: 'created',
                func: function (content) {
                    cs(self, 'model').value('data:constraintset', content, true)
                }
            })

            cs(self).register({
                name: 'displaySyntacticError', spool: 'created',
                func: function (errors) {
                    cs(self, 'model').value('state:syntactic-errors', errors)
                }
            })

            cs(self).register({
                name: 'displaySemanticError', spool: 'created',
                func: function (errors) {
                    cs(self, 'model').value('state:semantic-errors', errors)
                }
            })
        }
    }
})

app.ui.widget.constraintset.model = cs.clazz({
    mixin: [ cs.marker.model ],
    protos: {
        create: function () {
            /*  presentation model for items  */
            cs(this).model({
                'data:constraintset'     : { value: '', valid: 'string', store: true },<commit_msg>Clear timer on component destruction<commit_after>/*
**  ComponentJS -- Component System for JavaScript <http://componentjs.com>
**  Copyright (c) 2009-2013 <NAME> <http://engelschall.com>
**
**  This Source Code Form is subject to the terms of the Mozilla Public
**  License, v. 2.0. If a copy of the MPL was not distributed with this
**  file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/* global ace: true */
cs.ns('app.ui.widget.constraintset')

app.ui.widget.constraintset = cs.clazz({
    mixin: [ cs.marker.controller ],
    dynamics: {
        editor: null,
        timer: null
    },
    protos: {
        create: function () {
            var self = this

            cs(self).create('model/view',
                app.ui.widget.constraintset.model,
                app.ui.widget.constraintset.view
            )

            /*  calculate the savable content on demand  */
            cs(self).register({
                name: 'getContent', spool: 'created',
                func: function () {
                    return cs(self, 'model').value('data:constraintset')
                }
            })

            cs(self, 'model').observe({
                name: 'data:constraintset', spool: '..:created',
                touch: true,
                func: function (ev, content) {
                    if (self.timer !== null) {
                        /* global clearTimeout: true */
                        clearTimeout(self.timer)
                    }
                    /* global setTimeout: true */
                    self.timer = setTimeout(function () {
                        cs(self).publish('setChanged', content)
                    }, 1000)
                }
            })

            cs(self).register({
                name: 'setContent', spool: 'created',
                func: function (content) {
                    cs(self, 'model').value('data:constraintset', content, true)
                }
            })

            cs(self).register({
                name: 'displaySyntacticError', spool: 'created',
                func: function (errors) {
                    cs(self, 'model').value('state:syntactic-errors', errors)
                }
            })

            cs(self).register({
                name: 'displaySemanticError', spool: 'created',
                func: function (errors) {
                    cs(self, 'model').value('state:semantic-errors', errors)
                }
            })
        },
        destroy: function () {
            clearTimeout(this.timer)
        }
    }
})

app.ui.widget.constraintset.model = cs.clazz({
    mixin: [ cs.marker.model ],
    protos: {
        create: function () {
            /*  presentation model for items  */
            cs(this).model({
                'data:constraintset'     : { value: '', valid: 'string', store: true },
{'fraction_non_alphanumeric': 0.13086287146437522, 'fraction_numerical': 0.005728607232366631, 'mean_word_length': 1.4061154177433248, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2221836', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1427, 'n_words': 333}