<commit_before>"use strict";
/*globals angular,window*/

window.twoFiftySix = {
   controllers: {},
   directives: {}
};
twoFiftySix.app = angular.module('twoFiftySix', []);


twoFiftySix.app.directive('eightBitPanel', function($compile) {
   return {
      restrict: 'A',
      transclude:true,
      template: '<div class="ebp-frame"><div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div><div class="content"  ng-transclude></div></div>',
      link: function (scope, element, attrs) {
         element.addClass('ebp');
         var compiled = $compile('')(scope);
         element.append(compiled);
      }
   };
});


twoFiftySix.app.directive('twoFiftySix', function($compile) {
   return {
      restrict: 'A',
      link: function (scope, element, attrs) {
         var self = this;

         var renderCanvas = $compile('<canvas style="position:absolute;left:-9000px;top:-9000px;" width="256" height="256"></canvas>')(scope);
         var context = renderCanvas[0].getContext("2d");
         context.webkitImageSmoothingEnabled = false;
         context.mozImageSmoothingEnabled = false;

         element.append(renderCanvas);


         var loader = new eburp.ResourceLoader();
         loader.loadAll([
            "images/animation.png",
            "images/characters.png",
            "images/creatures.png",
            "images/environment.png",
            "images/equipment.png",
            "images/items.png",
            "images/ui.png"
         ],function(){
            var tileView = new eburp.TileMapView(element[0],loader);
            tileView.imageProcessor = new eburp.ImageProcessor(renderCanvas[0], tileView);
            tileView.tileMap = new eburp.TileMap("town");
            var scene = new eburp.Scene({autoStart: true});
            scene.addView(tileView);

            // Rig the view, and toss a party sprite in there.
            tileView.camera.point.set(8,4);
            var challengeSpriteFeature = {
               type : "sign",
               x : 12,
               y : 8,
               icon : "party.png"
            };
            tileView.tileMap.map.features.push(challengeSpriteFeature);
            // HACKS: Draw the party sprite.  TODO: require image-drop directive.
            var sprite = tileView.imageProcessor.isolateSprite("party.png");
            sprite.onload = function(){
               var canvas = $("canvas.image-drop")[0];
               var context = canvas.getContext("2d");
               context.clearRect(0,0,128,128);
               context.drawImage(sprite,0,0,128,128); // Or at whatever offset you like
            };
            console.log("READY TO GO!");
         });
      }
   };
});


//


///
twoFiftySix.app.directive('imageDrop', function($compile) {
   function noopHandler(evt) {
      evt.stopPropagation();
      evt.preventDefault();
   }

   function onDragEnter(evt) {
      $(".drop-overlay").fadeIn(125);
   }

   function onDragLeave(e) {
      var evt = e.originalEvent;
      /*
       * We have to double-check the 'leave' event state because this event stupidly
       * gets fired by JavaScript when you mouse over the child of a parent element;
       * instead of firing a subsequent enter event for the child, JavaScript first
       * fires a LEAVE event for the parent then an ENTER event for the child even
       * though the mouse is still technically inside the parent bounds. If we trust
       * the dragenter/dragleave events as-delivered, it leads to "flickering" when
       * a child element (drop prompt) is hovered over as it becomes invisible,
       * then visible then invisible again as that continually triggers the enter/leave
       * events back to back. Instead, we use a 10px buffer around the window frame
       * to capture the mouse leaving the window manually instead. (using 1px didn't
       * work as the mouse can skip out of the window before hitting 1px with high
       * enough acceleration).
       */
      if(evt.pageX < 10 || evt.pageY < 10 || $(window).width() - evt.pageX < 10  || $(window).height - evt.pageY < 10) {
         $(".drop-overlay").fadeOut(125);
      }
   }

   function processDropImage(file,context){
      var reader = new FileReader();

      // When the file is done loading, POST to the server.
      reader.onloadend = function(evt){
         var data = evt.target.result;
         var img = new Image;
         img.onload = function(){
            context.clearRect(0,0,128,128);
            context.drawImage(img,0,0,128,128); // Or at whatever offset you like
            $(".drop-target .filename").text(file.name);
         };
         img.src = data;

      };

      // Handle errors that might occur while reading the file (before upload).
      reader.onerror = function(evt) {
         var message;
         // REF: http://www.w3.org/TR/FileAPI/#ErrorDescriptions
         switch(evt.target.error.code) {
            case 1:
               message = file.name + " not found.";
               break;
            case 2:
               message = file.name + " has changed on disk, please re-try.";
               break;
            case 4:
               message = "Cannot read " + file.name + ".";
               break;
         }<commit_msg>Note about using images.<commit_after>"use strict";
/*globals angular,window*/

window.twoFiftySix = {
   controllers: {},
   directives: {}
};
twoFiftySix.app = angular.module('twoFiftySix', []);


twoFiftySix.app.directive('eightBitPanel', function($compile) {
   return {
      restrict: 'A',
      transclude:true,
      template: '<div class="ebp-frame"><div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div><div class="content"  ng-transclude></div></div>',
      link: function (scope, element, attrs) {
         element.addClass('ebp');
         var compiled = $compile('')(scope);
         element.append(compiled);
      }
   };
});


twoFiftySix.app.directive('twoFiftySix', function($compile) {
   return {
      restrict: 'A',
      link: function (scope, element, attrs) {
         var self = this;

         var renderCanvas = $compile('<canvas style="position:absolute;left:-9000px;top:-9000px;" width="256" height="256"></canvas>')(scope);
         var context = renderCanvas[0].getContext("2d");
         context.webkitImageSmoothingEnabled = false;
         context.mozImageSmoothingEnabled = false;

         element.append(renderCanvas);


         var loader = new eburp.ResourceLoader();
         loader.loadAll([
            "images/animation.png",
            "images/characters.png",
            "images/creatures.png",
            "images/environment.png",
            "images/equipment.png",
            "images/items.png",
            "images/ui.png"
         ],function(){
            var tileView = new eburp.TileMapView(element[0],loader);
            tileView.imageProcessor = new eburp.ImageProcessor(renderCanvas[0], tileView);
            tileView.tileMap = new eburp.TileMap("town");
            var scene = new eburp.Scene({autoStart: true});
            scene.addView(tileView);

            // Rig the view, and toss a party sprite in there.
            tileView.camera.point.set(8,4);
            var challengeSpriteFeature = {
               type : "sign",
               x : 12,
               y : 8,
               icon : "party.png"
            };
            tileView.tileMap.map.features.push(challengeSpriteFeature);
            // HACKS: Draw the party sprite.  TODO: require image-drop directive.
            var sprite = tileView.imageProcessor.isolateSprite("party.png");
            sprite.onload = function(){
               var canvas = $("canvas.image-drop")[0];
               var context = canvas.getContext("2d");
               context.clearRect(0,0,128,128);
               context.drawImage(sprite,0,0,128,128); // Or at whatever offset you like
            };
            console.log("READY TO GO!");
         });
      }
   };
});


//


///
twoFiftySix.app.directive('imageDrop', function($compile) {
   function noopHandler(evt) {
      evt.stopPropagation();
      evt.preventDefault();
   }

   function onDragEnter(evt) {
      $(".drop-overlay").fadeIn(125);
   }

   function onDragLeave(e) {
      var evt = e.originalEvent;
      /*
       * We have to double-check the 'leave' event state because this event stupidly
       * gets fired by JavaScript when you mouse over the child of a parent element;
       * instead of firing a subsequent enter event for the child, JavaScript first
       * fires a LEAVE event for the parent then an ENTER event for the child even
       * though the mouse is still technically inside the parent bounds. If we trust
       * the dragenter/dragleave events as-delivered, it leads to "flickering" when
       * a child element (drop prompt) is hovered over as it becomes invisible,
       * then visible then invisible again as that continually triggers the enter/leave
       * events back to back. Instead, we use a 10px buffer around the window frame
       * to capture the mouse leaving the window manually instead. (using 1px didn't
       * work as the mouse can skip out of the window before hitting 1px with high
       * enough acceleration).
       */
      if(evt.pageX < 10 || evt.pageY < 10 || $(window).width() - evt.pageX < 10  || $(window).height - evt.pageY < 10) {
         $(".drop-overlay").fadeOut(125);
      }
   }

   function processDropImage(file,context){
      var reader = new FileReader();

      // When the file is done loading, POST to the server.
      reader.onloadend = function(evt){
         var data = evt.target.result;
         var img = new Image;
         img.onload = function(){
            context.clearRect(0,0,128,128);
            context.drawImage(img,0,0,128,128);
            // TODO: Append this image and stretch it up.  This way designers can save-as.
            $(".drop-target .filename").text(file.name);
         };
         img.src = data;



      };

      // Handle errors that might occur while reading the file (before upload).
      reader.onerror = function(evt) {
         var message;
         // REF: http://www.w3.org/TR/FileAPI/#ErrorDescriptions
         switch(evt.target.error.code) {
            case 1:
               message = file.name + " not found.";
               break;
            case 2:
               message = file.name + " has changed on disk, please re-try.";
               break;
            case 4:
               message = "Cannot read " + file.name + ".";
               break;
         }
{'fraction_non_alphanumeric': 0.12436260623229461, 'fraction_numerical': 0.014919735599622286, 'mean_word_length': 2.1205067766647026, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 31, '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': '3904579', 'n_tokens_mistral': 3077, 'n_tokens_neox': 2938, 'n_words': 796}