<commit_before>define([
'angular',
'lodash',
'../utils/utils'
],
function(
  angular,
  _,
  utils ){
  
  /*
    
    SHIFT+CMD+F for full screen mode
    Used for transparent .png animation
    
  */
  
  angular.module( 'animpng', [ 'angularFileUpload' ])
  .directive( 'animpng', [
    function(){
      return {
        scope: true,
        template: [
          
          '<div>',
            '<div id="timeGrid"></div>',
            '<audio id="myAudio" autoplay></audio>',
            '<input ',
              'type="file" ',
              'webkitdirectory ',
              'mozdirectory ',
              'nv-file-select ',
              'uploader="uploader" />',
            '<div id="clock"></div>',
          '</div>'
          
        ].join(' '),
        link: function( scope, elem ){
          $( elem ).addClass( 'animpng' )
          
          var fps = 12
          var keys = []
          var charKeys = []
          window.loopSave = {}
          
          function show( me ){
            $( me.canvas ).css({ 
              'top': 0 
            })
          }
          function hide( me ){
            $( me.canvas ).css({ 
              'top': me.height * -1 
            })
          }
          function getNth( n ){
            return ( n*1/fps ).toFixed( 3 )
          }
          
          // build the frame grid
          
          var nFrames = undefined
          var padding = 25
          function buildFrameGrid( duration ){
            nFrames = Math.ceil( duration * fps )
            _.remove( items, function( item ){
              return item.key == '_bg'
            })
            for ( var i=0; i<items.length; i++ ){
              
              // row label
              
              var div = document.createElement( 'div' )
              $( div ).addClass( 'row_label' )
              $( div ).text( items[i].key )
              $( div ).css({
                top: i * 20 + padding - 3,
                left: 5
              })
              $( '#timeGrid', elem ).append( div )
              
              // frames
              
              for ( var j=0; j<nFrames; j++ ){
                var div = document.createElement( 'div' )
                $( div ).addClass( 'frame' )
                $( div ).css({
                  top: i * 20 + padding,
                  left: j * 20 + padding * 1.5 
                })
                $( div ).attr( 'id', items[i].key + getNth( j ))
                $( '#timeGrid', elem ).append( div )
              }
            }
            
            // grid frame mouse controls
            
            $( '.frame', elem ).mousedown( function( e ){
              frameToggle( e )
              $( '.frame', elem ).mouseenter( function( e ){
                frameToggle( e )
              })
              $( window ).mouseup( function(){
                $( '.frame', elem ).off( 'mouseenter' )
              })
            })
          }
          
          function frameToggle( e ){
            var frame = $( e.target ).attr( 'id')
            var key = _.first( frame )
            frame = frame.substr( 1 )
            console.log( key, frame )
          }
          
          // color the grid
          
          window.colorGrid = function(){
            for ( var j=0; j<nFrames; j++ ){
              var tcode = getNth( j )
              var item = window.loopSave[ tcode ]
              if ( !!item ){
                _.each( item, function( key ){
                  if ( key[1]  && key[0]){
                    var uid = '#' + key[0].toUpperCase() + tcode.replace( '.', '\\.' )
                    try {
                      $( uid, elem ).css(
                        'background-color', 'blue'
                      )
                    }
                    catch{
                      console.log( 'lil error', item )
                    }
                  }
                })
              }
            }
          }
          function getFrame( n ){
            return Math.round(( ( n % 1 ).toFixed( 3 ) * fps-1 ) + 1 ) / fps
          }
          function getSeconds( n ){
            return Math.floor( n )
          }
          function getTimeCode( n ){
            return getSeconds( n ) + getFrame( n )
          }
          function register( key, isOn ){
            try {
              var cTime = getTimeCode( $audio.currentTime ).toFixed( 3 )
              if ( !window.loopSave[ cTime ] ){
                window.loopSave[ cTime ] = []
              }
              window.loopSave[ cTime ].push([ key.toUpperCase(), isOn ])
            }<commit_msg>simplifying data structure storing frame visibility<commit_after>define([
'angular',
'lodash',
'../utils/utils'
],
function(
  angular,
  _,
  utils ){
  
  /*
    
    SHIFT+CMD+F for full screen mode
    Used for transparent .png animation
    
  */
  
  angular.module( 'animpng', [ 'angularFileUpload' ])
  .directive( 'animpng', [
    function(){
      return {
        scope: true,
        template: [
          
          '<div>',
            '<div id="timeGrid"></div>',
            '<audio id="myAudio" autoplay></audio>',
            '<input ',
              'type="file" ',
              'webkitdirectory ',
              'mozdirectory ',
              'nv-file-select ',
              'uploader="uploader" />',
            '<div id="clock"></div>',
          '</div>'
          
        ].join(' '),
        link: function( scope, elem ){
          $( elem ).addClass( 'animpng' )
          
          var fps = 12
          var keys = []
          var charKeys = []
          window.loopSave = {}
          window.save = []
          
          function show( me ){
            $( me.canvas ).css({ 
              'top': 0 
            })
          }
          function hide( me ){
            $( me.canvas ).css({ 
              'top': me.height * -1 
            })
          }
          function getNth( n ){
            return ( n*1/fps ).toFixed( 3 )
          }
          
          // build the frame grid
          
          var nFrames = undefined
          var padding = 25
          function buildFrameGrid( duration ){
            nFrames = Math.ceil( duration * fps )
            _.remove( items, function( item ){
              return item.key == '_bg'
            })
            for ( var i=0; i<items.length; i++ ){
              
              // row label
              
              var div = document.createElement( 'div' )
              $( div ).addClass( 'row_label' )
              $( div ).text( items[i].key )
              $( div ).css({
                top: i * 20 + padding - 3,
                left: 5
              })
              $( '#timeGrid', elem ).append( div )
              
              // frames
              
              for ( var j=0; j<nFrames; j++ ){
                var div = document.createElement( 'div' )
                $( div ).addClass( 'frame' )
                $( div ).css({
                  top: i * 20 + padding,
                  left: j * 20 + padding * 1.5 
                })
                $( div ).attr( 'id', items[i].key + getNth( j ))
                $( '#timeGrid', elem ).append( div )
              }
            }
            
            // grid frame mouse controls
            
            $( '.frame', elem ).mousedown( function( e ){
              frameToggle( e )
              $( '.frame', elem ).mouseenter( function( e ){
                frameToggle( e )
              })
              $( window ).mouseup( function(){
                $( '.frame', elem ).off( 'mouseenter' )
              })
            })
          }
          
          function frameToggle( e ){
            var frame = $( e.target ).attr( 'id')
            var key = _.first( frame )
            frame = frame.substr( 1 )
            
            console.log( key, frame )
          }
          
          // color the grid
          
          window.colorGrid = function(){
            for ( var j=0; j<nFrames; j++ ){
              var tcode = getNth( j )
              var item = window.loopSave[ tcode ]
              if ( !!item ){
                _.each( item, function( key ){
                  if ( key[1]  && key[0]){
                    var uid = '#' + key[0].toUpperCase() + tcode.replace( '.', '\\.' )
                    try {
                      $( uid, elem ).css(
                        'background-color', 'blue'
                      )
                    }
                    catch{
                      console.log( 'lil error', item )
                    }
                  }
                })
              }
            }
          }
          function getFrame( n ){
            return Math.round(( ( n % 1 ).toFixed( 3 ) * fps-1 ) + 1 ) / fps
          }
          function getSeconds( n ){
            return Math.floor( n )
          }
          function getTimeCode( n ){
            return getSeconds( n ) + getFrame( n )
          }
          function timeToIndex( t, dur ){
            return Math.ceil( Math.ceil( dur * fps ) * t / dur )
          }
          function register( key, isOn ){
            
            // if audio isn't playing don't bother
            
            try {
              if ( $audio.played.end( 0 ) == $audio.duration ){
                return
              }
            }
            catch{}
            
            // register code
            
            try {
              var t = getTimeCode( $audio.currentTime ).toFixed( 3 )
              if ( !window.loopSave[ t ] ){
                window.loopSave[ t ] = []
              }
              window.loopSave[ t ].push([ key.toUpperCase(), isOn ])
            }
{'fraction_non_alphanumeric': 0.1305923777961889, 'fraction_numerical': 0.006317315658657829, 'mean_word_length': 0.9240884638374178, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 21, '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': '1973357', 'n_tokens_mistral': 2594, 'n_tokens_neox': 2487, 'n_words': 632}