<commit_before>'use strict';

angular.module('copayApp.controllers').controller('topbarController', function($rootScope, $scope, $timeout, $modal, isCordova, isMobile, go) {   
  var cordovaOpenScanner = function() {
    window.ignoreMobilePause = true;
    window.plugins.spinnerDialog.show(null, 'Preparing camera...', true);
    cordova.plugins.barcodeScanner.scan(
      function onSuccess(result) {
        $timeout(function() {
          window.plugins.spinnerDialog.hide();
          window.ignoreMobilePause = false;
        }, 100);
        if (result.cancelled) return;

        $timeout(function() {
          var data = result.text;
          $rootScope.$emit('dataScanned', data); 
        }, 1000);
      },
      function onError(error) {
        $timeout(function() {
          window.ignoreMobilePause = false;
          window.plugins.spinnerDialog.hide();
        }, 100);
        alert('Scanning error');
      }
    );
    go.send(); 
  }; 

  var modalOpenScanner = function() { 
    var _scope = $scope;
    var ModalInstanceCtrl = function($scope, $rootScope, $modalInstance) {
      // QR code Scanner
      var video;
      var canvas;
      var $video;
      var context;
      var localMediaStream;

      var _scan = function(evt) {
        if (localMediaStream) {
          context.drawImage(video, 0, 0, 300, 225);
          try {
            qrcode.decode();
          } catch (e) {
            //qrcodeError(e);
          }
        }
        $timeout(_scan, 500);
      };

      var _scanStop = function() {
        if (localMediaStream && localMediaStream.stop) localMediaStream.stop();
        localMediaStream = null;
        video.src = '';
      }; <commit_msg>Fix camera spinner for slow devices<commit_after>'use strict';

angular.module('copayApp.controllers').controller('topbarController', function($rootScope, $scope, $timeout, $modal, isCordova, isMobile, go) {   
  var cordovaOpenScanner = function() {
    window.ignoreMobilePause = true;
    window.plugins.spinnerDialog.show(null, 'Preparing camera...', true);
    $timeout(function() {
      cordova.plugins.barcodeScanner.scan(
        function onSuccess(result) {
          $timeout(function() {
            window.plugins.spinnerDialog.hide();
            window.ignoreMobilePause = false;
          }, 100);
          if (result.cancelled) return;

          $timeout(function() {
            var data = result.text;
            $rootScope.$emit('dataScanned', data); 
          }, 1000);
        },
        function onError(error) {
          $timeout(function() {
            window.ignoreMobilePause = false;
            window.plugins.spinnerDialog.hide();
          }, 100);
          alert('Scanning error');
        }
      );
      go.send(); 
    }, 100);
  }; 

  var modalOpenScanner = function() { 
    var _scope = $scope;
    var ModalInstanceCtrl = function($scope, $rootScope, $modalInstance) {
      // QR code Scanner
      var video;
      var canvas;
      var $video;
      var context;
      var localMediaStream;

      var _scan = function(evt) {
        if (localMediaStream) {
          context.drawImage(video, 0, 0, 300, 225);
          try {
            qrcode.decode();
          } catch (e) {
            //qrcodeError(e);
          }
        }
        $timeout(_scan, 500);
      };

      var _scanStop = function() {
        if (localMediaStream && localMediaStream.stop) localMediaStream.stop();
        localMediaStream = null;
        video.src = '';
      }; 
{'fraction_non_alphanumeric': 0.12874678846702825, 'fraction_numerical': 0.01284613188695404, 'mean_word_length': 2.07908611599297, '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': '4094763', 'n_tokens_mistral': 1062, 'n_tokens_neox': 994, 'n_words': 203}