<commit_before>// **Extends** Backbone.View
//
// **Usage** ```require(['drawer-view'], function(DrawerView) {})```
//
// **Jurisdiction** Left panel drawer container
define('drawer-view', ['jquery', 'underscore', 'backbone', 'jquery-cookie', 'dispatch', 'toc-view', 'history-view', 'search-view'], function($, _, Backbone, jQCookie, Dispatch, TOCView, HistoryView, SearchView) {
    'use strict';

    var DrawerView = Backbone.View.extend({
        el: '#menu',

        initialize: function() {
            // the cookieValue defaults to the table of contents, else the value of the cookie set within changeContents
            var cookieValue = $.cookie('Drawer_State') || 'table-of-contents';

            Dispatch.on('drawer:stateChange', this.changeContents, this);

            this.$label = $('.toc-type');
            this.$children = $('.toc-container');
            this.childViews = {
                'table-of-contents': {
                    'selector': $('#table-of-contents'),
                    'title':('Table of contents for'),
                    'constructor': TOCView
                },
                'history': {
                    'selector': $('#history'),
                    'title':('Switch between versions of'),
                    'constructor': HistoryView
                },
                'search': {
                    'selector': $('#search'),
                    'title':('Search'),
                    'constructor': SearchView
                }
            };
            
            // initialize child view to populate drawer
            this.changeContents(cookieValue); 
        },

        changeContents: function(activeId) {
            // hide the content of all drawer sections
            this.$children.addClass('hidden');
            // remove the 'hidden' class from the active drawer section
            this.childViews[activeId]['selector'].removeClass('hidden');
            // update the title of the drawer section
            this.$label.html(this.childViews[activeId]['title']);
            // create a new childView if a view doesn't already exist
            this.childViews[activeId].view = this.childViews[activeId].view || new this.childViews[activeId].constructor();
            Dispatch.set('drawerState', activeId);

            // set a cookie value equal to the active drawer id
            $.cookie('Drawer_State', activeId);
        }
<commit_msg>set cookie to expire after 60 minutes<commit_after>// **Extends** Backbone.View
//
// **Usage** ```require(['drawer-view'], function(DrawerView) {})```
//
// **Jurisdiction** Left panel drawer container
define('drawer-view', ['jquery', 'underscore', 'backbone', 'jquery-cookie', 'dispatch', 'toc-view', 'history-view', 'search-view'], function($, _, Backbone, jQCookie, Dispatch, TOCView, HistoryView, SearchView) {
    'use strict';

    var DrawerView = Backbone.View.extend({
        el: '#menu',

        initialize: function() {
            // the cookieValue defaults to the table of contents, else the value of the cookie set within changeContents
            var cookieValue = $.cookie('Drawer_State') || 'table-of-contents';
            
            Dispatch.on('drawer:stateChange', this.changeContents, this);

            this.$label = $('.toc-type');
            this.$children = $('.toc-container');
            this.childViews = {
                'table-of-contents': {
                    'selector': $('#table-of-contents'),
                    'title':('Table of contents for'),
                    'constructor': TOCView
                },
                'history': {
                    'selector': $('#history'),
                    'title':('Switch between versions of'),
                    'constructor': HistoryView
                },
                'search': {
                    'selector': $('#search'),
                    'title':('Search'),
                    'constructor': SearchView
                }
            };
            
            // initialize child view to populate drawer
            this.changeContents(cookieValue); 
        },

        changeContents: function(activeId) {
            var $expiration = new Date(),
                minutes = 60;
            //set date to 60 minutes for cookie expiration    
            $expiration.setTime($expiration.getTime() + (minutes * 60 * 1000));
            // hide the content of all drawer sections
            this.$children.addClass('hidden');
            // remove the 'hidden' class from the active drawer section
            this.childViews[activeId]['selector'].removeClass('hidden');
            // update the title of the drawer section
            this.$label.html(this.childViews[activeId]['title']);
            // create a new childView if a view doesn't already exist
            this.childViews[activeId].view = this.childViews[activeId].view || new this.childViews[activeId].constructor();
            Dispatch.set('drawerState', activeId);

            // set a cookie value equal to the active drawer id
            $.cookie('Drawer_State', activeId, { expires: $expiration });
        }

{'fraction_non_alphanumeric': 0.13725872489764088, 'fraction_numerical': 0.0023396373562097877, 'mean_word_length': 1.8885135135135136, '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': '4046141', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1208, 'n_words': 330}