<commit_before>define(function (require) {
    'use strict';

    return function (options, onLoad) {
        var metka = require('./../../metka');
        require('./../server')('viewAjax', {
            method: 'GET',
            success: function (data) {
                if (!data || !data.transferData) {
                    require('./../assignUrl')('searchPage');
                }
                metka.revision = metka.no = data.transferData.key.no;
                history.replaceState(undefined, '', require('./../url')('view'));
                $.extend(options, data.gui);
                options.readOnly = !data.transferData.state.uiState === 'DRAFT' || !(data.transferData.state.handler === MetkaJS.User.userName);
                options.dataConf = data.configuration;
                options.data = data.transferData;

                options.header = function header($header) {
                    var supplant = {
                        page: metka.PAGE
                    };

                    var $buttons = $('<div class="pull-right btn-toolbar">');

                    // visit content fields, until some has translatable: true
                    if ((function r(content) {
                        return content.some(function (item) {
                            var containerContent = {
                                TAB: item.content,
                                SECTION: item.content,
                                COLUMN: item.rows,
                                ROW: item.cells
                            }[item.type];
                            if (containerContent) {
                                return r(containerContent);
                            } else {
                                if (item.field) {
                                    return require('./../utils/getPropertyNS')(options, 'dataConf.fields', item.field.key, 'translatable');
                                } else {
                                    return false;
                                }
                            }
                        });
                    })(options.content)) {
                        $buttons
                            .append(require('./../languageRadioInputGroup')(options, 'translation-lang', options.defaultLang));
                    }

                    var header = {
                        localized: 'type.{page}.title',
                        pattern: '{localized} - {id} - {no}{state}',
                        buttons: $buttons
                            .append($('<div class="btn-group btn-group-xs">')
                                .append([{
                                    icon: 'glyphicon-chevron-left',
                                    action: 'prev'
                                }, {
                                    icon: 'glyphicon-chevron-right',
                                    action: 'next'
                                }].map(function (o) {
                                        return $('<button type="button" class="btn btn-default">')
                                            .prop('disabled', true)
                                            .append($('<span class="glyphicon">')
                                                .addClass(o.icon))
                                            .click(function () {
                                                require('./../assignUrl')(o.action);
                                            });
                                    })))
                            .append($('<div class="btn-group btn-group-xs">')
                                .append($('<button type="button" class="btn btn-default">')
                                    //.prop('disabled', true)
                                    .text(MetkaJS.L10N.get('general.buttons.download'))
                                    .click(function () {
                                        require('./../assignUrl')('download');
                                    })))
                    };
                    var labelAndValue = String.prototype.supplant.bind('{label}&nbsp;{value}');
                    supplant.id = labelAndValue({
                        label: MetkaJS.L10N.get('general.id'),
                        value: metka.id
                    });
                    supplant.no = labelAndValue({
                        label: MetkaJS.L10N.get('general.revision'),
                        value: metka.revision
                    });
                    supplant.state = metka.state === 'DRAFT' ? ' - ' + MetkaJS.L10N.get('general.DRAFT') : '';

                    supplant.localized = MetkaJS.L10N.get(header.localized.supplant(supplant));
                    $header.html(header.pattern.supplant(supplant));

                    if (header.buttons) {
                        $header.append(header.buttons);
                    }

                    return $header;
                };

                onLoad();
            }
        });
    };
});
<commit_msg>Fixed issue #60<commit_after>define(function (require) {
    'use strict';

    return function (options, onLoad) {
        var metka = require('./../../metka');
        require('./../server')('viewAjax', {
            method: 'GET',
            success: function (data) {
                if (!data || !data.transferData) {
                    require('./../assignUrl')('searchPage');
                }
                metka.revision = metka.no = data.transferData.key.no;
                history.replaceState(undefined, '', require('./../url')('view'));
                $.extend(options, data.gui);
                options.readOnly = !data.transferData.state.uiState === 'DRAFT' || !(data.transferData.state.handler === MetkaJS.User.userName);
                options.dataConf = data.configuration;
                options.data = data.transferData;

                options.header = function header($header) {
                    var supplant = {
                        page: metka.PAGE
                    };

                    var $buttons = $('<div class="pull-right btn-toolbar">');

                    // visit content fields, until some has translatable: true
                    if ((function r(content) {
                        return content.some(function (item) {
                            var containerContent = {
                                TAB: item.content,
                                SECTION: item.content,
                                COLUMN: item.rows,
                                ROW: item.cells
                            }[item.type];
                            if (containerContent) {
                                return r(containerContent);
                            } else {
                                if (item.field) {
                                    return require('./../utils/getPropertyNS')(options, 'dataConf.fields', item.field.key, 'translatable');
                                } else {
                                    return false;
                                }
                            }
                        });
                    })(options.content)) {
                        $buttons
                            .append(require('./../languageRadioInputGroup')(options, 'translation-lang', options.defaultLang));
                    }

                    var header = {
                        localized: 'type.{page}.title',
                        pattern: '{localized} - {id} - {no}{state}',
                        buttons: $buttons
                            .append($('<div class="btn-group btn-group-xs">')
                                .append([{
                                    icon: 'glyphicon-chevron-left',
                                    action: 'prev'
                                }, {
                                    icon: 'glyphicon-chevron-right',
                                    action: 'next'
                                }].map(function (o) {
                                        return $('<button type="button" class="btn btn-default">')
                                            .prop('disabled', true)
                                            .append($('<span class="glyphicon">')
                                                .addClass(o.icon))
                                            .click(function () {
                                                require('./../assignUrl')(o.action);
                                            });
                                    })))
                            .append($('<div class="btn-group btn-group-xs">')
                                .append($('<button type="button" class="btn btn-default">')
                                    //.prop('disabled', true)
                                    .text(MetkaJS.L10N.get('general.buttons.download'))
                                    .click(function () {
                                        require('./../assignUrl')('download');
                                    })))
                    };
                    var labelAndValue = String.prototype.supplant.bind('{label}&nbsp;{value}');
                    supplant.id = labelAndValue({
                        label: MetkaJS.L10N.get('general.id'),
                        value: metka.id
                    });
                    supplant.no = labelAndValue({
                        label: MetkaJS.L10N.get('general.revision'),
                        value: metka.revision
                    });

                    supplant.state = data.transferData.state.uiState ? ' - ' + MetkaJS.L10N.get('state.' + data.transferData.state.uiState) : '';

                    supplant.localized = MetkaJS.L10N.get(header.localized.supplant(supplant));
                    $header.html(header.pattern.supplant(supplant));

                    if (header.buttons) {
                        $header.append(header.buttons);
                    }

                    return $header;
                };

                onLoad();
            }
        });
    };
});

{'fraction_non_alphanumeric': 0.12010288880094974, 'fraction_numerical': 0.0021764938662445586, 'mean_word_length': 0.8558839728290802, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 58, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5710722', 'n_tokens_mistral': 2254, 'n_tokens_neox': 2077, 'n_words': 342}