<commit_before>/*global angular, hw */

angular.module('popup', ['siteSettings'])
.controller('PopupCtrl', ['$scope', function ($scope) {
    $scope.popup = { showSettings: false };
    
    $scope.hasSubdomain = function () {
        return $scope.domainInfo && $scope.domainInfo.tld != $scope.domainInfo.name &&
            ('www.' + $scope.domainInfo.tld) != $scope.domainInfo.name;
    };
    
    $scope.closeWindow = function () {
        window.close();
    };
    
    var _init = function (tab) {
        $scope.domainInfo = hw.getDomainInfo(tab.url);
        
        $scope.insertPassword = function () {
            var pw = hw.getHashword($scope.popup.domain, $scope.popup.password, $scope.settings);
            var items = {};
    
            // Populate field
            chrome.tabs.executeScript(tab.id, {
                code: 'document.activeElement.value=' + JSON.stringify(pw)
            });
    
            // Save settings
            items[$scope.popup.domain] = $scope.settings;
            chrome.storage.local.set(items);

            window.close();
        };
        
        $scope.changeDomain = function () {
            $scope.settings = $scope.allSettings[$scope.popup.domain] ||
                hw.getDefaultSettings();
        };
        
        chrome.storage.local.get([$scope.domainInfo.name, $scope.domainInfo.tld], function (items) {
            // Only use the full hostname as the key if there are already settings for it,
            // otherwise fall back to the effective TLD. In other words, the effective TLD
            // is the default unless the user specifically selects the full hostname
            // (or did so in the past).
            $scope.allSettings = items;
            $scope.popup.domain = items[$scope.domainInfo.name] ?
                    $scope.domainInfo.name : $scope.domainInfo.tld;
            $scope.changeDomain();
            $scope.$digest();
        });
    };
    
    chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
        if (tabs.length && tabs[0].url) _init(tabs[0]);
        else $scope.popup.error = 'Hashword cannot be used on this page.';
   
        $scope.$digest();
    });
}]);
<commit_msg>Show "not supported" notification on non-http pages<commit_after>/*global angular, hw */

angular.module('popup', ['siteSettings'])
.controller('PopupCtrl', ['$scope', function ($scope) {
    $scope.popup = { showSettings: false };
    
    $scope.hasSubdomain = function () {
        return $scope.domainInfo && $scope.domainInfo.tld != $scope.domainInfo.name &&
            ('www.' + $scope.domainInfo.tld) != $scope.domainInfo.name;
    };
    
    $scope.closeWindow = function () {
        window.close();
    };
    
    var _init = function (tab) {
        $scope.domainInfo = hw.getDomainInfo(tab.url);
        
        $scope.insertPassword = function () {
            var pw = hw.getHashword($scope.popup.domain, $scope.popup.password, $scope.settings);
            var items = {};
    
            // Populate field
            chrome.tabs.executeScript(tab.id, {
                code: 'document.activeElement.value=' + JSON.stringify(pw)
            });
    
            // Save settings
            items[$scope.popup.domain] = $scope.settings;
            chrome.storage.local.set(items);

            window.close();
        };
        
        $scope.changeDomain = function () {
            $scope.settings = $scope.allSettings[$scope.popup.domain] ||
                hw.getDefaultSettings();
        };
        
        chrome.storage.local.get([$scope.domainInfo.name, $scope.domainInfo.tld], function (items) {
            // Only use the full hostname as the key if there are already settings for it,
            // otherwise fall back to the effective TLD. In other words, the effective TLD
            // is the default unless the user specifically selects the full hostname
            // (or did so in the past).
            $scope.allSettings = items;
            $scope.popup.domain = items[$scope.domainInfo.name] ?
                    $scope.domainInfo.name : $scope.domainInfo.tld;
            $scope.changeDomain();
            $scope.$digest();
        });
    };
    
    chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
        if (tabs.length && tabs[0].url && tabs[0].url.indexOf('http') === 0) _init(tabs[0]);
        else $scope.popup.error = 'Hashword cannot be used on this page.';
   
        $scope.$digest();
    });
}]);

{'fraction_non_alphanumeric': 0.14022631462169957, 'fraction_numerical': 0.0013312624805857556, 'mean_word_length': 1.9657894736842105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '28738', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1239, 'n_words': 278}