<commit_before>'use strict';

/*global Wodo*/

angular.module('manticoreApp')
.controller('TitleEditorCtrl', function ($scope, $timeout) {
    function handleTitleChanged(changes) {
        var title = changes.setProperties['dc:title'];
        if (title !== undefined && title !== $scope.title) {
            $timeout(function () {
                $scope.title = title;
            });
        }
    }

    $scope.changeTitle = function () {
        if ($scope.title !== $scope.editor.getMetadata('dc:title')) {
            $scope.editor.setMetadata({
                'dc:title': $scope.title
            });
        }
    };

    $scope.handleEnterKey = function ($event) {
        if ($event.keyCode === 13) {
            $event.target.blur();
        }
    };

    $scope.$watch('joined', function (online) {
        if (online === undefined) { return; }
        if (online) {
            $scope.editor.addEventListener(Wodo.EVENT_METADATACHANGED, handleTitleChanged);
            $scope.title = $scope.editor.getMetadata('dc:title');
        } else {
            $scope.editor.removeEventListener(Wodo.EVENT_METADATACHANGED, handleTitleChanged);<commit_msg>Set metadata as UI title only when someone changes it<commit_after>'use strict';

/*global Wodo*/

angular.module('manticoreApp')
.controller('TitleEditorCtrl', function ($scope, $timeout) {
    function handleTitleChanged(changes) {
        var title = changes.setProperties['dc:title'];
        if (title !== undefined && title !== $scope.title) {
            $timeout(function () {
                $scope.title = title;
            });
        }
    }

    $scope.changeTitle = function () {
        if ($scope.title !== $scope.editor.getMetadata('dc:title')) {
            $scope.editor.setMetadata({
                'dc:title': $scope.title
            });
        }
    };

    $scope.handleEnterKey = function ($event) {
        if ($event.keyCode === 13) {
            $event.target.blur();
        }
    };

    $scope.$watch('joined', function (online) {
        if (online === undefined) { return; }
        if (online) {
            $scope.editor.addEventListener(Wodo.EVENT_METADATACHANGED, handleTitleChanged);
        } else {
            $scope.editor.removeEventListener(Wodo.EVENT_METADATACHANGED, handleTitleChanged);
{'fraction_non_alphanumeric': 0.1496953872932985, 'fraction_numerical': 0.0017406440382941688, 'mean_word_length': 2.265625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7317068', 'n_tokens_mistral': 657, 'n_tokens_neox': 636, 'n_words': 112}