<commit_before>﻿/*global define, esri*/
/*jslint nomen:true*/
define(["require", "dojo/_base/declare", "dojo/Evented"], function (require, declare, Evented) {
	"use strict";
	var layerFactory;

	layerFactory = declare([Evented], {
		constructor: function (/*options*/) {
			// this.map = options.map || null;
		},
		_triggerLayerCreate: function(layer) {
			this.emit("layerCreate", {
				layer: layer
			});
		},
		createLayer: function (options) {
			var self = this, mapServerRe, featureLayerRe, url;

			if (options.url) {
				url = options.url;

				mapServerRe = /MapServer\/?$/i;
				featureLayerRe = /MapServer\/\d+\/?$/i;


				if (mapServerRe.test(url)) {
					if (options.tiled) {
						require(["esri/layers/agstiled"], function () {
							var layer;
							layer = new esri.layers.ArcGISTiledMapServiceLayer(url);
							self._triggerLayerCreate(layer);
						});
					} else {
						require(["esri/layers/agsdynamic"], function () {
							var layer;
							layer = new esri.layers.ArcGISDynamicMapServiceLayer(url);
							self._triggerLayerCreate(layer);
						});
					}
				} else if (featureLayerRe.test(url)) {
					require(["esri/layers/FeatureLayer"], function () {
						var layer;
						layer = new esri.layers.FeatureLayer(url);
						self._triggerLayerCreate(layer);
					});
				}
			}
		}
	});

	return layerFactory;
});<commit_msg>Layer factory modified to detect dynamic or tiled map service by querying URL.<commit_after>﻿/*global define, esri*/
/*jslint nomen:true*/
/// <reference path="../jsapi_vsdoc12_v33.js" />
define(["require", "dojo/_base/declare", "dojo/Evented", "dojo/io/script"], function (require, declare, Evented) {
	"use strict";
	var layerFactory;

	layerFactory = declare([Evented], {
		constructor: function (/*options*/) {
			// this.map = options.map || null;
		},
		_triggerLayerCreate: function(layer) {
			this.emit("layerCreate", {
				layer: layer
			});
		},
		createLayer: function (options) {
			var self = this, mapServerRe, featureLayerRe, url;

			if (options.url) {
				url = options.url;

				mapServerRe = /MapServer\/?$/i;
				featureLayerRe = /((MapServer\/\d+)|(FeatureServer))\/?$/i;


				// Create a different layer type based on the URL.
				if (mapServerRe.test(url)) {
					// Query the map service to see if it is a tiled map service. (We cannot determine this based on the URL alone.)
					esri.request({
						url: url,
						content: {
							f: "json"
						},
						callbackParamName: "callback",
						handleAs: "json"
					}).then(function (response) {
						if (response.singleFusedMapCache) {
							// Create a tile map service layer.
							require(["esri/layers/agstiled"], function () {
								var layer;
								layer = new esri.layers.ArcGISTiledMapServiceLayer(url);
								self._triggerLayerCreate(layer);
							});
						} else {
							// Create a dynamic map service layer.
							require(["esri/layers/agsdynamic"], function () {
								var layer;
								layer = new esri.layers.ArcGISDynamicMapServiceLayer(url);
								self._triggerLayerCreate(layer);
							});
						}
					}, function (error) {
					});
				} else if (featureLayerRe.test(url)) {
					require(["esri/layers/FeatureLayer"], function () {
						var layer;
						layer = new esri.layers.FeatureLayer(url);
						self._triggerLayerCreate(layer);
					});
				}
			}
		}
	});

	return layerFactory;
});
{'fraction_non_alphanumeric': 0.15204505038529934, 'fraction_numerical': 0.0011855364552459987, 'mean_word_length': 2.7836322869955157, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7363825', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1057, 'n_words': 233}