<commit_before>(function() {

  var module = angular.module('loom_addlayers_directive', []);

  module.directive('loomAddlayers',
      function($location) {
        return {
          templateUrl: 'addlayers/partials/addlayers.tpl.html',
          link: function(scope) {
            var parser = new ol.parser.ogc.WMSCapabilities();
            // TODO: Add variable for ip to append onto url.
            var url = '/geoserver/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0';
            scope.addLayers = function() {
              var length = scope.layers.length;
              for (var index = 0; index < length; index += 1) {
                var layer = scope.layers[index];
                if (layer.add) {
                  var newLayer = new ol.layer.Tile({
                    source: new ol.source.TileWMS({
                      url: 'http://' + $location.host() + '/geoserver/wms',
                      params: {'LAYERS': layer.name}
                    })
                  });
                  map.addLayer(newLayer);
                  layer.add = false;
                  layer.added = true;
                }
              }
            };

            var xhr = new XMLHttpRequest();
            xhr.open('GET', url, true);

            /**
             * onload handler for the XHR request.
             */
            xhr.onload = function() {
              if (xhr.status == 200) {
                scope.$apply(function() {
                  scope.layers = parser.read(xhr.responseXML).capability.layers;
                  for (var index = 0; index < scope.layers.length; index += 1) {
                    scope.layers[index].added = false;
                  }
                });

                console.log('scope.layers', scope.layers);
              }
            };
            xhr.send();
          }
        };
      }
  );<commit_msg>Fixed scope of map in AddLayersDirective<commit_after>(function() {

  var module = angular.module('loom_addlayers_directive', []);

  module.directive('loomAddlayers',
      function($location) {
        return {
          templateUrl: 'addlayers/partials/addlayers.tpl.html',
          link: function(scope) {
            var parser = new ol.parser.ogc.WMSCapabilities();
            // TODO: Add variable for ip to append onto url.
            var url = '/geoserver/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0';
            scope.addLayers = function() {
              var length = scope.layers.length;
              for (var index = 0; index < length; index += 1) {
                var layer = scope.layers[index];
                if (layer.add) {
                  var newLayer = new ol.layer.Tile({
                    source: new ol.source.TileWMS({
                      url: 'http://' + $location.host() + '/geoserver/wms',
                      params: {'LAYERS': layer.name}
                    })
                  });
                  scope.map.addLayer(newLayer);
                  layer.add = false;
                  layer.added = true;
                }
              }
            };

            var xhr = new XMLHttpRequest();
            xhr.open('GET', url, true);

            /**
             * onload handler for the XHR request.
             */
            xhr.onload = function() {
              if (xhr.status == 200) {
                scope.$apply(function() {
                  scope.layers = parser.read(xhr.responseXML).capability.layers;
                  for (var index = 0; index < scope.layers.length; index += 1) {
                    scope.layers[index].added = false;
                  }
                });

                console.log('scope.layers', scope.layers);
              }
            };
            xhr.send();
          }
        };
      }
  );
{'fraction_non_alphanumeric': 0.12291831879460745, 'fraction_numerical': 0.005286809410520751, 'mean_word_length': 1.2350856467808624, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7648408', 'n_tokens_mistral': 1041, 'n_tokens_neox': 979, 'n_words': 201}