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

	angular
        .module('ionic-link-tap.tapAction',[])
        .directive('ionicLinkTapAction',ionicLinkTapAction);

    ionicLinkTapAction.$inject = ['$timeout','$compile','$window','$ionicPlatform','$cordovaEmailComposer','$cordovaDialogs'];

	function ionicLinkTapAction($timeout,$compile,$window,$ionicPlatform,$cordovaEmailComposer,$cordovaDialogs){
        
        var isCordovaEnabled = (function(){
            if(typeof $window.cordova === 'object'){
                return true;
            }
            else{
                return false;
            }
        })();
           
		return {
			restrict: 'A',
			scope:{
				ionicLinkTapAction: '=ionicLinkTapAction'
			},
			link: link
		};

		function link(scope, element, attrs) {
            if(scope.ionicLinkTapAction === null){
                return false;
            }
            
            if(scope.ionicLinkTapAction.indexOf('http') !== -1){
                element.bind('click', function() {
                    $timeout(function() {
                        checkAppType(function(){openBrowser(scope.ionicLinkTapAction,'_blank');},function(){openBrowser(scope.ionicLinkTapAction,'_system');});
                    });
                });
            }
            else{
                checkAppType(function(){nativeAction(scope,element,attrs);},function(){webAction(scope,attrs);});
            }
        }
        
        function webAction(scope,attrs){
            attrs.$set('href', scope.ionicLinkTapAction);
            $compile(attrs)(scope);
        }
        
        function nativeAction(scope,element,attrs){
            var email;
            //Email: mailto:<EMAIL>?subject=&body=
            if(scope.ionicLinkTapAction.indexOf('mailto') !== -1){
                email = parseEmail(scope.ionicLinkTapAction);
                                
                element.bind('click', function() {
                    $timeout(function() {
                        emailComposer(email);
                    });
                });
            }
            else{
                webAction(scope,attrs);
            }
        }
        
        function openBrowser(url,target) {
            window.open(url, target, 'location=no,toolbar=yes');
            return false;
        }
        
        function emailComposer(email){
            $ionicPlatform.ready(function() {
                $cordovaEmailComposer.isAvailable().then(function() {
                    $cordovaEmailComposer.open(email).then(null, function () {
                        // user cancelled email
                    });
                }, function() {
                    showAlertDialog('No email client installed.','Cannot send email','OK');
                });
            });
        }
        
        function showAlertDialog(message, title, button, callback) {
            $ionicPlatform.ready(function() {
                $cordovaDialogs.alert(message, title, button)
                    .then(function() {
                        if (isFunction(callback) === true) {
                            callback();
                        }
                });
            });
        }
        
        function parseEmail(mailto){
            //REGEX: /mailto:(.*?)\?(.*)/ get email and split parameters 
            var expression = /mailto:(.*?)\?subject=(.*)\&body=(.*)/,
                emailDetails = expression.exec(mailto);
            
            return {
                to: emailDetails[1],
                subject: emailDetails[2],
                body: emailDetails[3],
                isHtml: true
            };
        }

        function checkAppType(nativeCallback,webCallback){
            if(isCordovaEnabled === true){
                if (isFunction(nativeCallback) === true) {
                    return nativeCallback();
                }
            }
            else{
                if (isFunction(webCallback) === true) {
                    return webCallback();
                }
            }
        }
        
        function isFunction(callback){
            return typeof callback === 'function' ? true : false;
        }
    }
})();<commit_msg>fixed identation<commit_after>(function(){
  'use strict';
  angular
    .module('ionic-link-tap.tapAction',[])
    .directive('ionicLinkTapAction',ionicLinkTapAction);

  ionicLinkTapAction.$inject = ['$timeout','$compile','$window','$ionicPlatform','$cordovaEmailComposer','$cordovaDialogs'];

  function ionicLinkTapAction($timeout,$compile,$window,$ionicPlatform,$cordovaEmailComposer,$cordovaDialogs){

    var isCordovaEnabled = (function(){
        if(typeof $window.cordova === 'object'){
            return true;
        }
        else{
            return false;
        }
    })();

    return {
        restrict: 'A',
        scope:{
            ionicLinkTapAction: '=ionicLinkTapAction'
        },
        link: link
    };

    function link(scope, element, attrs) {
      
      if(scope.ionicLinkTapAction === null){
        return false;
      }

      if(scope.ionicLinkTapAction.indexOf('http') !== -1){
        element.bind('click', function() {
          $timeout(function() {
            checkAppType(function(){openBrowser(scope.ionicLinkTapAction,'_blank');},function(){openBrowser(scope.ionicLinkTapAction,'_system');});
          });
        });
      }
      else{
          checkAppType(function(){nativeAction(scope,element,attrs);},function(){webAction(scope,attrs);});
      }
    }

    function webAction(scope,attrs){
      attrs.$set('href', scope.ionicLinkTapAction);
      $compile(attrs)(scope);
    }

    function nativeAction(scope,element,attrs){
      var email;
      //Email: mailto:<EMAIL>?subject=&body=
      if(scope.ionicLinkTapAction.indexOf('mailto') !== -1){
        email = parseEmail(scope.ionicLinkTapAction);

        element.bind('click', function() {
          $timeout(function() {
            emailComposer(email);
          });
        });
      }
      else{
        webAction(scope,attrs);
      }
    }

    function openBrowser(url,target) {
      window.open(url, target, 'location=no,toolbar=yes');
      return false;
    }

    function emailComposer(email){
      $ionicPlatform.ready(function() {
        $cordovaEmailComposer.isAvailable().then(function() {
          $cordovaEmailComposer.open(email).then(null, function () {
            // user cancelled email
          });
        }, function() {
          showAlertDialog('No email client installed.','Cannot send email','OK');
        });
      });
    }

    function showAlertDialog(message, title, button, callback) {
      $ionicPlatform.ready(function() {
        $cordovaDialogs.alert(message, title, button)
            .then(function() {
              if (isFunction(callback) === true) {
                callback();
              }
        });
      });
    }

    function parseEmail(mailto){
      //REGEX: /mailto:(.*?)\?(.*)/ get email and split parameters 
      var expression = /mailto:(.*?)\?subject=(.*)\&body=(.*)/,
          emailDetails = expression.exec(mailto);

      return {
        to: emailDetails[1],
        subject: emailDetails[2],
        body: emailDetails[3],
        isHtml: true
      };
    }

    function checkAppType(nativeCallback,webCallback){
      if(isCordovaEnabled === true){
        if (isFunction(nativeCallback) === true) {
          return nativeCallback();
        }
      }
      else{
        if (isFunction(webCallback) === true) {
          return webCallback();
        }
      }
    }

    function isFunction(callback){
      return typeof callback === 'function' ? true : false;
    }
  }
})();
{'fraction_non_alphanumeric': 0.13831727012242773, 'fraction_numerical': 0.0013024225058609013, 'mean_word_length': 1.751343604442852, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5728209', 'n_tokens_mistral': 2105, 'n_tokens_neox': 1984, 'n_words': 299}