<commit_before>'use strict';

angular.module( 'app.services', [] )

   .factory( 'windowService', ['$window', function ( $window ) {

      var signal = new signals.Signal();
      var o = {
         resize: signal,
         width: $window.innerWidth,
         height: $window.innerHeight,
         hasTouch: function () {
            return ( 'ontouchstart' in $window);
         },
         back: function () {
            $window.history.back();
         }

      };

      $window.onresize = function ( event ) {
         o.width = $window.innerWidth;
         o.height = $window.innerHeight;
         signal.dispatch( o.width, o.height );
      };
      return o;

   }] )

   /*  .factory( 'imageSize', ['Settings', 'windowService', function ( Settings, windowService ) {


    return {
    getValue: function () {

    var sizes = Settings.sizes;
    var currentSize = Settings.currentSize;
    var value = sizes[currentSize];

    if (value == 'auto') {
    var windowSize = windowService.width;
    if (windowSize <= sizes.xsmall)return sizes.xsmall;
    if (windowSize <= sizes.small)return sizes.small;
    if (windowSize <= sizes.medium)return sizes.medium;
    if (windowSize <= sizes.large)return sizes.large;
    if (windowSize <= sizes.xlarge)return sizes.xlarge;
    }
    return value;


    }
    }
    }] )*/

   .factory( 'API', ['$http', function ( $http ) {

      return {
         getBook: function ( bookID, imageSize ) {
            return $http.get( '/api/book?id=' + bookID + '&size=' + imageSize )
               .then( function ( result ) {
                  return result.data;
               } );
         },
         getProject: function ( projectID ) {
            return $http.get( '/api/project?id=' + projectID )
               .then( function ( result ) {
                  return result.data;
               } );
         },
         getPresets: function () {
            return $http.get( '/api/presets' )
               .then( function ( result ) {
                  return result.data;
               } );
         },

         getProjectList: function ( search ) {

            var projects = search.projects;
            projects = ( projects != undefined ) ? '?projects=' + projects : "/";
            return $http.get( '/api/listProject' + projects )
               .then( function ( result ) {
                  return result.data;
               } );
         }
      }


   }] )

   //todo - pull out the tick stuff into its own service
   .factory( 'bookData', ['Settings', function ( Settings ) {

      return {
         isComplete: function () {
            var threshold = Settings.killThreshold;
            var cV = Math.round( this.currentValue * threshold );
            var tV = Math.round( this.targetValue * threshold );
            return cV === tV;
         },
         reset: function () {
            this.totalPages = 0;
            this.currentPage = 0;
            this.currentValue = 0;
            this.currentAlpha = 0;
            this.targetValue = 0;
            this.baseURL = null;
            this.overlayURL = null;
            this.overlayOpacity = -1;
         },
         backToBase: function () {
            this.targetValue = this.currentValue;
         },
         applyValue: function ( value ) {
            var test = value;
            var newValue = this.targetValue + test;
            if (newValue < 0) this.targetValue = 0;
            else if (newValue > this.totalPages - 1)  this.targetValue = this.totalPages - 1;
            else this.targetValue += test;
            this.currentValue += (this.targetValue - this.currentValue) * Settings.drag;
            var v = this.currentValue;
            this.currentPage = Math.floor( v );
            this.currentAlpha = v - this.currentPage;
         },
         applyUrls: function ( imageService ) {

            var overlayIndex = this.currentPage + 1;
            var nextBase = imageService.images[this.currentPage].src;

            if (overlayIndex >= imageService.images.length) {
               overlayIndex = this.currentPage;
            }

            var nextOverlay = imageService.images[overlayIndex].src;

            this.baseURL = (this.baseURL == nextBase) ? null : nextBase;
            this.overlayURL = (this.overlayURL == nextOverlay) ? null : nextOverlay;
            this.overlayOpacity = this.currentAlpha;
         },
         totalPages: 0,
         currentPage: 0,
         currentAlpha: 0,
         currentValue: 0,
         targetValue: 0,
         baseURL: null,
         overlayURL: null,
         overlayOpacity: -1<commit_msg>Removes clamping from targetValue and adds to currentValue<commit_after>'use strict';

angular.module( 'app.services', [] )

   .factory( 'windowService', ['$window', function ( $window ) {

      var signal = new signals.Signal();
      var o = {
         resize: signal,
         width: $window.innerWidth,
         height: $window.innerHeight,
         hasTouch: function () {
            return ( 'ontouchstart' in $window);
         },
         back: function () {
            $window.history.back();
         }

      };

      $window.onresize = function ( event ) {
         o.width = $window.innerWidth;
         o.height = $window.innerHeight;
         signal.dispatch( o.width, o.height );
      };
      return o;

   }] )

   /*  .factory( 'imageSize', ['Settings', 'windowService', function ( Settings, windowService ) {


    return {
    getValue: function () {

    var sizes = Settings.sizes;
    var currentSize = Settings.currentSize;
    var value = sizes[currentSize];

    if (value == 'auto') {
    var windowSize = windowService.width;
    if (windowSize <= sizes.xsmall)return sizes.xsmall;
    if (windowSize <= sizes.small)return sizes.small;
    if (windowSize <= sizes.medium)return sizes.medium;
    if (windowSize <= sizes.large)return sizes.large;
    if (windowSize <= sizes.xlarge)return sizes.xlarge;
    }
    return value;


    }
    }
    }] )*/

   .factory( 'API', ['$http', function ( $http ) {

      return {
         getBook: function ( bookID, imageSize ) {
            return $http.get( '/api/book?id=' + bookID + '&size=' + imageSize )
               .then( function ( result ) {
                  return result.data;
               } );
         },
         getProject: function ( projectID ) {
            return $http.get( '/api/project?id=' + projectID )
               .then( function ( result ) {
                  return result.data;
               } );
         },
         getPresets: function () {
            return $http.get( '/api/presets' )
               .then( function ( result ) {
                  return result.data;
               } );
         },

         getProjectList: function ( search ) {

            var projects = search.projects;
            projects = ( projects != undefined ) ? '?projects=' + projects : "/";
            return $http.get( '/api/listProject' + projects )
               .then( function ( result ) {
                  return result.data;
               } );
         }
      }


   }] )

   //todo - pull out the tick stuff into its own service
   .factory( 'bookData', ['Settings', function ( Settings ) {

      return {
         isComplete: function () {
            var threshold = Settings.killThreshold;
            var cV = Math.round( this.currentValue * threshold );
            var tV = Math.round( this.targetValue * threshold );
            return cV === tV;
         },
         reset: function () {
            this.totalPages = 0;
            this.currentPage = 0;
            this.currentValue = 0;
            this.currentAlpha = 0;
            this.targetValue = 0;
            this.baseURL = null;
            this.overlayURL = null;
            this.overlayOpacity = -1;
         },
         backToBase: function () {
            this.targetValue = this.currentValue;
         },
         applyValue: function ( value ) {
            var test = value;
            var newValue = this.targetValue + test;
            this.targetValue += test;
            this.currentValue += (this.targetValue - this.currentValue) * Settings.drag;

            if (this.currentValue < 0) this.currentValue = 0;
            else if (this.currentValue > this.totalPages - 1)  this.currentValue = this.totalPages - 1;

            var v = this.currentValue;
            this.currentPage = Math.floor( v );
            this.currentAlpha = v - this.currentPage;
         },
         applyUrls: function ( imageService ) {

            var overlayIndex = this.currentPage + 1;
            var nextBase = imageService.images[this.currentPage].src;

            if (overlayIndex >= imageService.images.length) {
               overlayIndex = this.currentPage;
            }

            var nextOverlay = imageService.images[overlayIndex].src;

            this.baseURL = (this.baseURL == nextBase) ? null : nextBase;
            this.overlayURL = (this.overlayURL == nextOverlay) ? null : nextOverlay;
            this.overlayOpacity = this.currentAlpha;
         },
         totalPages: 0,
         currentPage: 0,
         currentAlpha: 0,
         currentValue: 0,
         targetValue: 0,
         baseURL: null,
         overlayURL: null,
         overlayOpacity: -1
{'fraction_non_alphanumeric': 0.1186623516720604, 'fraction_numerical': 0.003667745415318231, 'mean_word_length': 1.6526466380543634, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, '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': '7617408', 'n_tokens_mistral': 2564, 'n_tokens_neox': 2461, 'n_words': 591}