<commit_before>﻿define(function () {
    'use function';

    var InstallButtonView = Backbone.View.extend({
        el: $('#installButton'),

        events: {
            'click': 'install'
        },
        
        webstoreUrl: 'https://chrome.google.com/webstore/detail/jbnkffmindojffecdhbbmekbmkkfpmjd',

        initialize: function () {

            //  http://stackoverflow.com/questions/17129261/detect-mobile-browser-with-javascript-detectmobilebrowsers-returns-false-for-m
            if (window.mobileCheck || screen.width < 768) {
                this.$el.attr('disabled', true).text('Desktop computer required');
                return;
            }

            var browserIsNotChrome = navigator.userAgent.toLowerCase().indexOf('chrome') === -1;
            if (browserIsNotChrome) {
                this.$el.attr('disabled', true).text('Google Chrome required');
                return;
            }

            //  Check version of Chrome. Streamus requires v29+ currently:
            var majorVersion = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);

            if (majorVersion < 29) {
                this.$el.attr('disabled', true).text('Google Chrome v29+ required. Please update.');
            }

        },

        install: function () {

            if (!this.$el.attr('disabled')) {

                this.$el.attr('disabled', true).text('Installing...');

                var self = this;
                chrome.webstore.install(this.webstoreUrl, function () {
                    self.$el.text('Installed!');
                    self.$el.trigger('installed');
                }, function (error) {
                    //  TODO: It would be nice to know more about where this error message came from / what others could occur.
                    if (error == 'User cancelled install') {
                        self.$el.attr('disabled', false).text('Install extension now');
                    } else {
                        self.$el.text('Error: ' + error);
                    }

                });
            }
<commit_msg>Updated install button for opera<commit_after>﻿define(function () {
    'use function';

    var InstallButtonView = Backbone.View.extend({
        el: $('#installButton'),

        events: {
            'click': 'install'
        },
        
        webstoreUrl: 'https://chrome.google.com/webstore/detail/jbnkffmindojffecdhbbmekbmkkfpmjd',
        operaExtensionId: 'nnmcpagedcgekmljdamaeahfbmmjloho',

        initialize: function () {

            //  http://stackoverflow.com/questions/17129261/detect-mobile-browser-with-javascript-detectmobilebrowsers-returns-false-for-m
            if (window.mobileCheck || screen.width < 768) {
                this.$el.attr('disabled', true).text('Desktop computer required');
                return;
            }

            var browserIsNotChrome = navigator.userAgent.toLowerCase().indexOf('chrome') === -1;
            if (browserIsNotChrome) {
                this.$el.attr('disabled', true).text('Google Chrome or Opera required');
                return;
            }

            //  Check version of Chrome. Streamus requires v32+ currently:
            var majorVersion = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);

            if (majorVersion < 29) {
                this.$el.attr('disabled', true).text('Google Chrome v32+ required. Please update.');
            }

        },

        install: function () {
            if (!this.$el.attr('disabled')) {
                this.$el.attr('disabled', true).text('Installing...');

                if (this._isBrowserOpera()) {
                    opr.addons.installExtension(this.operaExtensionId, this._onInstallSuccess.bind(this), this._onInstallError.bind(this));
                } else {
                    chrome.webstore.install(this.webstoreUrl, this._onInstallSuccess.bind(this), this._onInstallError.bind(this));
                }
            }
        },
        
        _onInstallSuccess: function() {
            this.$el.text('Installed!');
            this.$el.trigger('installed');
        },
        
        _onInstallError: function(error) {
            //  TODO: It would be nice to know more about where this error message came from / what others could occur.
            if (error == 'User cancelled install') {
                this.$el.attr('disabled', false).text('Install extension now');
            } else {
                this.$el.text('Error: ' + error);
            }
        },
        
        _isBrowserOpera: function() {
            return navigator.userAgent.indexOf(' OPR/') >= 0;  
{'fraction_non_alphanumeric': 0.13360585197934596, 'fraction_numerical': 0.009251290877796902, 'mean_word_length': 1.7508875739644971, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '4018919', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1189, 'n_words': 228}