<commit_before>var assert = require('assert');
var deepExtend = require('deep-extend');
var dot = require('dot-object');
var fs = require('fs');
var path = require('path');
var util = require('util');
var yamlJs = require('yaml-js');

// Replaces aliases by the block content of the anchors
function replaceAliases(yamlString) {
  var yamlLines = yamlString.split("\n");
  var newYamlLines = [];

  // Strip empty lines
  yamlLines.forEach(function (line) {
    if (line.length > 0) {
      newYamlLines.push(line);
    }
  });

  var anchors = [];

  // Find anchors, with their indentation and block content
  newYamlLines.forEach(function (line, index) {
    if (line.indexOf("&") > -1) {
      var anchorName = line.match("&(.*)")[1];

      var me = anchors[anchorName] = {
        indent: line.search(/\S|$/),
        block: []
      };

      // Store the block content
      for (var i = index + 1; i < newYamlLines.length; i++) {
        // when encountering an equal or lower indentation, the block ends
        if (newYamlLines[i].search(/\S|$/) <= me.indent) {
          break;
        }
        me.block.push(newYamlLines[i]);
      }
    }
  });

  var finalYamlLines = [];

  // Find aliases and add anchor content
  newYamlLines.forEach(function (line, index) {
    if (line.match(/<<: \*/)) {
      // TODO make * consuming in some way instead of replace
      var aliasName = line.trim().replace("<<: *", "");

      /* istanbul ignore else */
      if (anchors[aliasName]) {
        var indentDiff = line.search(/\S|$/) - anchors[aliasName].indent - 2;

        anchors[aliasName].block.forEach(function (blockLine) {
          var str;
          // Shift indentations of the block content
          if (indentDiff > 0) {
            str = new Array(indentDiff + 1).join(' ') + blockLine;
          } else {
            str = blockLine;
            for (var i = 0; i > indentDiff; i--) {
              str = str.replace('  ', ' ');
            }
          }

          finalYamlLines.push(str);
        });
      }
    } else {
      finalYamlLines.push(line);
    }
  });

  return finalYamlLines;
}

/** Write out the entire hierarchy in YAML
 * a:
 *  b:
 *   c:
 *
 * Becomes:
 *
 * a:
 * a.b:
 * a.b.c:
 *
 * @param yamlLines
 */
function blowUpHierarchy(yamlLines) {
  var key = "";
  var indent = 0;
  var currentIndent = 0;
  var indentSteps = [];
  var postLines = [];

  for (var index = 0; index < yamlLines.length; index++) {
    var line = yamlLines[index];
    // Skip empty lines
    if (line.trim().length === 0) {
      continue;
    }

    var match = line.trim().match(".*:");
    currentIndent = yamlLines[index].search(/\S|$/);

    // Down the tree
    if (match && (currentIndent > indent)) {
      if (currentIndent !== 0) {
        key += '.';
      }
      key += match[0].replace(/:.*/, "");
      if ((currentIndent - indent) > 0) {
        indentSteps.push(currentIndent - indent);
      }
    }

    // Up the tree or peer property
    if (match && (currentIndent <= indent)) {
      var keyArr = key.split('.');
      keyArr.pop();

      var steps = 0;
      // Get the number of steps to travel up the hierarchy tree
      while (indent > currentIndent) {
        indent -= indentSteps.pop();
        keyArr.pop();
        steps++;
      }

      key = keyArr.join('.');
      if (currentIndent !== 0) {
        key += '.';
      }
      key += match[0].replace(/:.*/, "");
    }

    if (line.match(/.*:/)) {
      postLines.push(line.replace(/.*:/, key + ':'));
    } else {
      postLines.push(line);
    }

    indent = currentIndent;
  }
  return postLines;
}

function parse(yamlLines) {
  var yaml = yamlJs.load(yamlLines.join('\n'));
  var result = [{}];

  Object.keys(yaml).forEach(function (key) {
    var value = yaml[key];

    if (value) {
      result.push(dot.str(key, value, {}));
    }
  });

  deepExtend.apply(null, result);
  return result[0];
}

function camlize(options) {
  if (!options) {
    return;
  }
  // Default dir is the current working dir
  options.dir = options.dir || path.join(process.cwd());
  var yamlString = "";

  options.files.forEach(function (fileName) {
    yamlString += fs.readFileSync(path.join(options.dir, fileName + ".yml"), 'UTF8');
  });

  return parse(
    blowUpHierarchy(
      replaceAliases(yamlString)
    )
  );
}

module.exports = {
  camlize: camlize,
  blowUpHierarchy: blowUpHierarchy,
  parse: parse,
  replaceAliases: replaceAliases
};
<commit_msg>Support absolute paths<commit_after>var assert = require('assert');
var deepExtend = require('deep-extend');
var dot = require('dot-object');
var fs = require('fs');
var path = require('path');
var util = require('util');
var yamlJs = require('yaml-js');

// Replaces aliases by the block content of the anchors
function replaceAliases(yamlString) {
  var yamlLines = yamlString.split("\n");
  var newYamlLines = [];

  // Strip empty lines
  yamlLines.forEach(function (line) {
    if (line.length > 0) {
      newYamlLines.push(line);
    }
  });

  var anchors = [];

  // Find anchors, with their indentation and block content
  newYamlLines.forEach(function (line, index) {
    if (line.indexOf("&") > -1) {
      var anchorName = line.match("&(.*)")[1];

      var me = anchors[anchorName] = {
        indent: line.search(/\S|$/),
        block: []
      };

      // Store the block content
      for (var i = index + 1; i < newYamlLines.length; i++) {
        // when encountering an equal or lower indentation, the block ends
        if (newYamlLines[i].search(/\S|$/) <= me.indent) {
          break;
        }
        me.block.push(newYamlLines[i]);
      }
    }
  });

  var finalYamlLines = [];

  // Find aliases and add anchor content
  newYamlLines.forEach(function (line, index) {
    if (line.match(/<<: \*/)) {
      // TODO make * consuming in some way instead of replace
      var aliasName = line.trim().replace("<<: *", "");

      /* istanbul ignore else */
      if (anchors[aliasName]) {
        var indentDiff = line.search(/\S|$/) - anchors[aliasName].indent - 2;

        anchors[aliasName].block.forEach(function (blockLine) {
          var str;
          // Shift indentations of the block content
          if (indentDiff > 0) {
            str = new Array(indentDiff + 1).join(' ') + blockLine;
          } else {
            str = blockLine;
            for (var i = 0; i > indentDiff; i--) {
              str = str.replace('  ', ' ');
            }
          }

          finalYamlLines.push(str);
        });
      }
    } else {
      finalYamlLines.push(line);
    }
  });

  return finalYamlLines;
}

/** Write out the entire hierarchy in YAML
 * a:
 *  b:
 *   c:
 *
 * Becomes:
 *
 * a:
 * a.b:
 * a.b.c:
 *
 * @param yamlLines
 */
function blowUpHierarchy(yamlLines) {
  var key = "";
  var indent = 0;
  var currentIndent = 0;
  var indentSteps = [];
  var postLines = [];

  for (var index = 0; index < yamlLines.length; index++) {
    var line = yamlLines[index];
    // Skip empty lines
    if (line.trim().length === 0) {
      continue;
    }

    var match = line.trim().match(".*:");
    currentIndent = yamlLines[index].search(/\S|$/);

    // Down the tree
    if (match && (currentIndent > indent)) {
      if (currentIndent !== 0) {
        key += '.';
      }
      key += match[0].replace(/:.*/, "");
      if ((currentIndent - indent) > 0) {
        indentSteps.push(currentIndent - indent);
      }
    }

    // Up the tree or peer property
    if (match && (currentIndent <= indent)) {
      var keyArr = key.split('.');
      keyArr.pop();

      var steps = 0;
      // Get the number of steps to travel up the hierarchy tree
      while (indent > currentIndent) {
        indent -= indentSteps.pop();
        keyArr.pop();
        steps++;
      }

      key = keyArr.join('.');
      if (currentIndent !== 0) {
        key += '.';
      }
      key += match[0].replace(/:.*/, "");
    }

    if (line.match(/.*:/)) {
      postLines.push(line.replace(/.*:/, key + ':'));
    } else {
      postLines.push(line);
    }

    indent = currentIndent;
  }
  return postLines;
}

function parse(yamlLines) {
  var yaml = yamlJs.load(yamlLines.join('\n'));
  var result = [{}];

  Object.keys(yaml).forEach(function (key) {
    var value = yaml[key];

    if (value) {
      result.push(dot.str(key, value, {}));
    }
  });

  deepExtend.apply(null, result);
  return result[0];
}

function camlize(options) {
  if (!options) {
    return;
  }
  // Default dir is the current working dir
  options.dir = options.dir || path.join(process.cwd());
  var yamlString = "";

  options.files.forEach(function (fileName) {
    if(path.isAbsolute(fileName)) {
      yamlString += fs.readFileSync(fileName + ".yml", 'UTF8');
    } else {
      yamlString += fs.readFileSync(path.join(options.dir, fileName + ".yml"), 'UTF8');
    }
  });

  return parse(
    blowUpHierarchy(
      replaceAliases(yamlString)
    )
  );
}

module.exports = {
  camlize: camlize,
  blowUpHierarchy: blowUpHierarchy,
  parse: parse,
  replaceAliases: replaceAliases
};
<|endoftext|>


<commit_before>// coat.js
// Aaron Taylor 2014

$.fn.coat = function(attributes) {

	// Retreive the attributes if supplied any
	var css;
	var points;
	var modifier;
	if (attributes != undefined) {
		css = attributes.css;
		points = attributes.points;
		modifier = attributes.modifier;
	}

	// Set the css, points and modifier variables to their defualts if they're undefined
	if (css == undefined) {
		css = {
			"color": "red"
		}
	}
	if (points == undefined) {
		points = ".coat";
	}
	if (modifier == undefined) {
		modifier = 0;
	}

	// Create/assign objects required for coating
	var $parent = this.parent();
	var $otherThis = this.clone();
	var $newParent = $('<div>');

	// Move the elements to their proper place
	$parent.append($newParent);
	this.detach();
	$newParent.append(this);
	$newParent.append($otherThis);

	// Setup the size/position attributes of the new parent
	$newParent.height(this.height());
	$newParent.width(this.width());

	// Set needed CSS rules
	$newParent.css({
		"position": "fixed",
		"top": this.position().top
	});
	this.css("overflow", "hidden");
	$otherThis.css("overflow", "hidden");

	// Apply the specified CSS rules to the second element
	$otherThis.css(css);
	$otherThis.children().css("color", "inherit");

	// Start off z-index values
	this.css("z-index", 2);
	$otherThis.css("z-index", 1);

	// create another variable so we can use "this"
	var $thisToPass = this;

	// Add to the onScroll function
	$(document).scroll(function() {

		// Grab the required elments for calculating height
		var scrollTop = $(document).scrollTop();
		var barHeight = $newParent.height();
		var $sections = $(points);

		// Offset the scroll top if there is a margin or something
		scrollTop += $newParent.position().top;

		// Loop through all possible selectors and ajust the z-index and height accordingly
		for (var i = 0; i < $sections.length; i++) {
			if (scrollTop-barHeight <= $($sections[i]).position().top && scrollTop > 0) { // Ensure there is no overscroll

				var newHeight = ($($sections[i]).position().top - (scrollTop + barHeight)) + barHeight;// Setup the new height

				// Set the z-index based on which pane the scrollTop is at
				if (i%2 == 0) {
					var behind = $thisToPass;
					var front = $otherThis;
				}
				else {
					var behind = $otherThis;
					var front = $thisToPass;
				}

				// Apply the CSS rules to the behind and front objects
				behind.css({
					"z-index": 1,
					"height": barHeight
				});
				front.css({
					"height": newHeight - modifier,
					"z-index": 2
				});

				break;
			}
		}
	});

	$(document).scroll(); // Scroll once so it starts pretty
}
<commit_msg>attribs used from original element<commit_after>// coat.js
// Aaron Taylor 2014

$.fn.coat = function(attributes) {

	// Retreive the attributes if supplied any
	var css;
	var points;
	var modifier;
	if (attributes != undefined) {
		css = attributes.css;
		points = attributes.points;
		modifier = attributes.modifier;
	}

	// Set the css, points and modifier variables to their defualts if they're undefined
	if (css == undefined) {
		css = {
			"color": "red"
		}
	}
	if (points == undefined) {
		points = ".coat";
	}
	if (modifier == undefined) {
		modifier = 0;
	}

	// Create/assign objects required for coating
	var $parent = this.parent();
	var $otherThis = this.clone();
	var $newParent = $('<div>');

	// Move the elements to their proper place
	$parent.append($newParent);
	this.detach();
	$newParent.append(this);
	$newParent.append($otherThis);

	// Setup the size/position attributes of the new parent
	$newParent.height(this.height());
	$newParent.width(this.width());

	// Set needed CSS rules
	$newParent.css({
		"position": "fixed",
		"top": this.position().top
	});
	this.css("overflow", "hidden");
	$otherThis.css("overflow", "hidden");

	// Apply the specified CSS rules to the second element
	$otherThis.css(css);
	$otherThis.children().css("color", "inherit");

	// Start off z-index values
	this.css("z-index", 2);
	$otherThis.css("z-index", 1);

	// Apply attributes of old element to newly created parent element
	$newParent.attributes = this.attributes;

	// create another variable so we can use "this"
	var $thisToPass = this;

	// Add to the onScroll function
	$(document).scroll(function() {

		// Grab the required elments for calculating height
		var scrollTop = $(document).scrollTop();
		var barHeight = $newParent.height();
		var $sections = $(points);

		// Offset the scroll top if there is a margin or something
		scrollTop += $newParent.position().top;

		// Loop through all possible selectors and ajust the z-index and height accordingly
		for (var i = 0; i < $sections.length; i++) {
			if (scrollTop-barHeight <= $($sections[i]).position().top && scrollTop > 0) { // Ensure there is no overscroll

				var newHeight = ($($sections[i]).position().top - (scrollTop + barHeight)) + barHeight;// Setup the new height

				// Set the z-index based on which pane the scrollTop is at
				if (i%2 == 0) {
					var behind = $thisToPass;
					var front = $otherThis;
				}
				else {
					var behind = $otherThis;
					var front = $thisToPass;
				}

				// Apply the CSS rules to the behind and front objects
				behind.css({
					"z-index": 1,
					"height": barHeight
				});
				front.css({
					"height": newHeight - modifier,
					"z-index": 2
				});

				break;
			}
		}
	});

	$(document).scroll(); // Scroll once so it starts pretty
}
<|endoftext|>


<commit_before>jQuery( function($) {
$(document).ready(function(){

	// return a reference from the Sample popup window back into the widget
	// and populate the form with this sample's data
	$('.select_sample').click(function(){
		row_data = $.parseJSON($('#'+$(this.parentNode).attr("uid")+"_row_data").val());
		column = row_data['column'];
		window.opener.$("#ar_"+column+"_SampleID_button").val(row_data['SampleID']);
		window.opener.$("#ar_"+column+"_SampleID").val(row_data['SampleID']);
		window.opener.$("#deleteSampleButton_" + column).toggle(true);
		window.opener.$("#ar_"+column+"_DateSampled")
			.val(row_data['DateSampled'])
			.removeClass('hasDatepicker')
			.removeData('datepicker')
			.unbind();
		window.opener.$("#ar_"+column+"_ClientReference").val(row_data['ClientReference']).attr('readonly', true);
		window.opener.$("#ar_"+column+"_ClientSampleID").val(row_data['ClientSampleID']).attr('readonly', true);
		window.opener.$("#ar_"+column+"_SampleType").val(row_data['SampleType']).attr('readonly', true);
		window.opener.$("#ar_"+column+"_SamplePoint").val(row_data['SamplePoint']).attr('readonly', true);
		window.opener.$("#ar_"+column+"_Composite").val(row_data['Composite']).attr('disabled', true);

		// handle samples that do have field analyses
		// field_analyses is a dict of lists: { catuid: [serviceuid,serviceuid], ... }
		if(row_data['field_analyses'] != null){
			$.each(row_data['field_analyses'], function(catuid,serviceuids){
				window.opener.toggleCat("field", catuid, serviceuids, column, true, true);
			});
		}
		// expand and disable field analyses even if there are no field analyses on this sample
		$.each(window.opener.$("tr[poc='field']").filter(".analysiscategory"), function(){
			window.opener.toggleCat($(this).attr('poc'), this.id, false, column, true, true);
		});

		$.each(window.opener.$('input[id*="_field_"]').filter(".cb"), function(i,e){
			if ($(e).attr('id').indexOf('_'+column+'_') > -1){
				$(e).attr('disabled', true);
			}
		});
		window.opener.recalc_prices();
		window.close();
	});

	function positionTooltip(event){
		var tPosX = event.pageX+15;
		var tPosY = event.pageY-20;
		$('div.tooltip').css({'font-size':'70%',
		                      'background-color':'#fff',
							  'position': 'absolute',
							  'top': tPosY,
							  'left': tPosX});
	};

	function createTooltip(event, row_data){
		$('
'+
			'
' +
		    '
'+
            '
Requests	'+row_data['Requests']+'
'+
            '
Date Sampled	'+row_data['DateSampled']+'
'+
            '
Date Received	'+row_data['DateReceived']+'
'+
			'
'+
			'

').appendTo('body');
		positionTooltip(event);
	};

	$('.getSampleID').mouseover(function(event) {
		row_data = $.parseJSON($('#'+$(this.parentNode).attr("uid")+"_row_data").val());
		createTooltip(event, row_data);
	}).mouseout(function(){
		$(".tooltip").remove();
	});

});
});

<commit_msg>fix 2ndary AR Sample Selector popup class<commit_after>jQuery( function($) {
$(document).ready(function(){

	// return a reference from the Sample popup window back into the widget
	// and populate the form with this sample's data
	$('.select_sample').click(function(){
		row_data = $.parseJSON($('#'+$(this.parentNode).attr("uid")+"_row_data").val());
		column = row_data['column'];
		window.opener.$("#ar_"+column+"_SampleID_button").val(row_data['SampleID']);
		window.opener.$("#ar_"+column+"_SampleID").val(row_data['SampleID']);
		window.opener.$("#deleteSampleButton_" + column).toggle(true);
		window.opener.$("#ar_"+column+"_DateSampled")
			.val(row_data['DateSampled'])
			.removeClass('hasDatepicker')
			.removeData('datepicker')
			.unbind();
		window.opener.$("#ar_"+column+"_ClientReference").val(row_data['ClientReference']).attr('readonly', true);
		window.opener.$("#ar_"+column+"_ClientSampleID").val(row_data['ClientSampleID']).attr('readonly', true);
		window.opener.$("#ar_"+column+"_SampleType").val(row_data['SampleType']).attr('readonly', true);
		window.opener.$("#ar_"+column+"_SamplePoint").val(row_data['SamplePoint']).attr('readonly', true);
		window.opener.$("#ar_"+column+"_Composite").val(row_data['Composite']).attr('disabled', true);

		// handle samples that do have field analyses
		// field_analyses is a dict of lists: { catuid: [serviceuid,serviceuid], ... }
		if(row_data['field_analyses'] != null){
			$.each(row_data['field_analyses'], function(catuid,serviceuids){
				window.opener.toggleCat("field", catuid, serviceuids, column, true, true);
			});
		}
		// expand and disable field analyses even if there are no field analyses on this sample
		$.each(window.opener.$("tr[poc='field']").filter(".analysiscategory"), function(){
			window.opener.toggleCat($(this).attr('poc'), this.id, false, column, true, true);
		});

		$.each(window.opener.$('input[id*="_field_"]').filter(".cb"), function(i,e){
			if ($(e).attr('id').indexOf('_'+column+'_') > -1){
				$(e).attr('disabled', true);
			}
		});
		window.opener.recalc_prices();
		window.close();
	});

	function positionTooltip(event){
		var tPosX = event.pageX+15;
		var tPosY = event.pageY-20;
		$('div.tooltip').css({'font-size':'70%',
		                      'background-color':'#fff',
							  'position': 'absolute',
							  'top': tPosY,
							  'left': tPosX});
	};

	function createTooltip(event, row_data){
		$('
'+
			'
' +
		    '
'+
            '
Requests	'+row_data['Requests']+'
'+
            '
Date Sampled	'+row_data['DateSampled']+'
'+
            '
Date Received	'+row_data['DateReceived']+'
'+
			'
'+
			'

').appendTo('body');
		positionTooltip(event);
	};

	$('.SampleID').mouseover(function(event) {
		row_data = $.parseJSON($('#'+$(this.parentNode).attr("uid")+"_row_data").val());
		createTooltip(event, row_data);
	}).mouseout(function(){
		$(".tooltip").remove();
	});

});
});

<|endoftext|>


<commit_before>/**
 * dat-gui JavaScript Controller Library
 * http://code.google.com/p/dat-gui
 *
 * Copyright 2011 Data Arts Team, Google Creative Lab
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 */

const ARR_EACH = Array.prototype.forEach;
const ARR_SLICE = Array.prototype.slice;

/**
 * Band-aid methods for things that should be a lot easier in JavaScript.
 * Implementation and structure inspired by underscore.js
 * http://documentcloud.github.com/underscore/
 */

const Common = {
  BREAK: {},

  extend: function(target) {
    this.each(ARR_SLICE.call(arguments, 1), function(obj) {
      if (!this.isUndefined(obj)) {
        const keys = Object.keys(obj);
        keys.forEach(function(key) {
          if (!this.isUndefined(obj[key])) {
            target[key] = obj[key];
          }
        }.bind(this));
      }
    }, this);

    return target;
  },

  defaults: function(target) {
    this.each(ARR_SLICE.call(arguments, 1), function(obj) {
      if (!this.isUndefined(obj)) {
        const keys = Object.keys(obj);
        keys.forEach(function(key) {
          if (this.isUndefined(target[key])) {
            target[key] = obj[key];
          }
        }.bind(this));
      }
    }, this);

    return target;
  },

  compose: function() {
    const toCall = ARR_SLICE.call(arguments);
    return function() {
      let args = ARR_SLICE.call(arguments);
      for (let i = toCall.length - 1; i >= 0; i--) {
        args = [toCall[i].apply(this, args)];
      }
      return args[0];
    };
  },

  each: function(obj, itr, scope) {
    if (!obj) {
      return;
    }

    if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {
      obj.forEach(itr, scope);
    } else if (obj.length === obj.length + 0) { // Is number but not NaN
      let key;
      let l;
      for (key = 0, l = obj.length; key < l; key++) {
        if (key in obj && itr.call(scope, obj[key], key) === this.BREAK) {
          return;
        }
      }
    } else {
      if (this.isUndefined(obj)) return;

      const keys = Object.keys(obj);
      keys.forEach(function(key) {
        if (itr.call(scope, obj[key], key) === this.BREAK) {
          return;
        }
      }.bind(this));
    }
  },

  defer: function(fnc) {
    setTimeout(fnc, 0);
  },

  // call the function immediately, but wait until threshold passes to allow it to be called again
  debounce: function(func, threshold) {
    let timeout;

    return function() {
      const obj = this;
      const args = arguments;
      function delayed() {
        timeout = null;
      }

      const allowCall = !timeout;

      clearTimeout(timeout);
      timeout = setTimeout(delayed, threshold);

      if (allowCall) {
        func.apply(obj, args);
      }
    };
  },

  toArray: function(obj) {
    if (obj.toArray) return obj.toArray();
    return ARR_SLICE.call(obj);
  },

  isUndefined: function(obj) {
    return obj === undefined;
  },

  isNull: function(obj) {
    return obj === null;
  },

  isNaN: function(obj) {
    return isNaN(obj);
  },

  isArray: Array.isArray || function(obj) {
    return obj.constructor === Array;
  },

  isObject: function(obj) {
    return obj === Object(obj);
  },

  isNumber: function(obj) {
    return obj === obj + 0;
  },

  isString: function(obj) {
    return obj === obj + '';
  },

  isBoolean: function(obj) {
    return obj === false || obj === true;
  },

  isFunction: function(obj) {
    return Object.prototype.toString.call(obj) === '[object Function]';
  }

};

export default Common;
<commit_msg>cleaner ForEach loops in common.js<commit_after>/**
 * dat-gui JavaScript Controller Library
 * http://code.google.com/p/dat-gui
 *
 * Copyright 2011 Data Arts Team, Google Creative Lab
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 */

const ARR_EACH = Array.prototype.forEach;
const ARR_SLICE = Array.prototype.slice;

/**
 * Band-aid methods for things that should be a lot easier in JavaScript.
 * Implementation and structure inspired by underscore.js
 * http://documentcloud.github.com/underscore/
 */

const Common = {
  BREAK: {},

  extend: function(target) {
    this.each(ARR_SLICE.call(arguments, 1), function(obj) {
      const keys = this.isObject(obj) ? Object.keys(obj) : [];
      keys.forEach(function(key) {
        if (!this.isUndefined(obj[key])) {
          target[key] = obj[key];
        }
      }.bind(this));
    }, this);

    return target;
  },

  defaults: function(target) {
    this.each(ARR_SLICE.call(arguments, 1), function(obj) {
      const keys = this.isObject(obj) ? Object.keys(obj) : [];
      keys.forEach(function(key) {
        if (this.isUndefined(target[key])) {
          target[key] = obj[key];
        }
      }.bind(this));
    }, this);

    return target;
  },

  compose: function() {
    const toCall = ARR_SLICE.call(arguments);
    return function() {
      let args = ARR_SLICE.call(arguments);
      for (let i = toCall.length - 1; i >= 0; i--) {
        args = [toCall[i].apply(this, args)];
      }
      return args[0];
    };
  },

  each: function(obj, itr, scope) {
    if (!obj) {
      return;
    }

    if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {
      obj.forEach(itr, scope);
    } else if (obj.length === obj.length + 0) { // Is number but not NaN
      let key;
      let l;
      for (key = 0, l = obj.length; key < l; key++) {
        if (key in obj && itr.call(scope, obj[key], key) === this.BREAK) {
          return;
        }
      }
    } else {
      for (const key in obj) {
        if (itr.call(scope, obj[key], key) === this.BREAK) {
          return;
        }
      }
    }
  },

  defer: function(fnc) {
    setTimeout(fnc, 0);
  },

  // call the function immediately, but wait until threshold passes to allow it to be called again
  debounce: function(func, threshold) {
    let timeout;

    return function() {
      const obj = this;
      const args = arguments;
      function delayed() {
        timeout = null;
      }

      const allowCall = !timeout;

      clearTimeout(timeout);
      timeout = setTimeout(delayed, threshold);

      if (allowCall) {
        func.apply(obj, args);
      }
    };
  },

  toArray: function(obj) {
    if (obj.toArray) return obj.toArray();
    return ARR_SLICE.call(obj);
  },

  isUndefined: function(obj) {
    return obj === undefined;
  },

  isNull: function(obj) {
    return obj === null;
  },

  isNaN: function(obj) {
    return isNaN(obj);
  },

  isArray: Array.isArray || function(obj) {
    return obj.constructor === Array;
  },

  isObject: function(obj) {
    return obj === Object(obj);
  },

  isNumber: function(obj) {
    return obj === obj + 0;
  },

  isString: function(obj) {
    return obj === obj + '';
  },

  isBoolean: function(obj) {
    return obj === false || obj === true;
  },

  isFunction: function(obj) {
    return Object.prototype.toString.call(obj) === '[object Function]';
  }

};

export default Common;
<|endoftext|>


<commit_before>"use strict";

var Class = require("nodeclass").Class,
    is = require("nodeclass").is,
    EventEmitter = require("./../shared/EventEmitter.class.js"),
    domAdapter = require("./domAdapter.js"),
    ALAMID = require("./ALAMID_CLIENT_CONST.js"),
    _ = require("underscore");

var INCUBATOR = typeof document !== "undefined" && document.createElement("div");

/**
 * @extends EventEmitter
 */
var DisplayObject = new Class({

    Extends: EventEmitter,

    /**
     * @type {object}
     *
     */
    node: null,

    /**
     * @type {object}
     * @protected
     */
    _nodeMap: {},

    /**
     * @type {object}
     * @protected
     */
    __displayObjectMap: {},

    /**
     * @type {Boolean}
     * @protected
     */
    _isDisplayed: true,

    /**
     * @type {Boolean}
     * @protected
     */
    _isAppended: false,

    /**
     * @param {string} template
     * @constructor
     */
    init: function (template) {

        this.Super();

        if (typeof template !== "string" && typeof this.Instance.constructor.template !== "string") {
            throw new Error("(alamid) error: Cannot create DisplayObject without template(-string).");
        }
        template = template || this.Instance.constructor.template;

        this.__initNode(template);
        this.__initNodeMap();

        //@TODO prepareLinks
    },

    /**
     * @return {Boolean}
     */
    isAppended: function () {
        return this._isAppended;
    },

    /**
     * @return {Boolean}
     */
    isDisplayed: function () {
        return this._isDisplayed;
    },

    /**
     * @param {object.<string, object>} nodeEventMap
     */
    _addNodeEvents: function (nodeEventMap) {

        var self = this;

        /**
         * @param {object.<string : function>} eventMap
         * @param {string} nodeName
         */
        function eventMapIterator(eventMap, nodeName) {

            var node;

            if (self.__isInNodeMap(nodeName)) {

                node = self._nodeMap[nodeName];

                _(eventMap).each(function attachEventsIterator(listener, event) {
                    domAdapter(node).on(event, listener);
                });

            } else { //Throw new Error

                var events = _(eventMap).keys().join(", "),
                    nodes = _(self._nodeMap).keys().join(", ");

                throw new Error(
                    "(alamid) error: Trying to attach " + events + " to node '" + nodeName +
                        "', but '" + nodeName + "' is not part of the nodeMap. " +
                        "Found nodes in nodeMap: " + nodes + "."
                );
            }

        }

        _(nodeEventMap).each(eventMapIterator);
    },

    /**
     * How to use: displayObjectInstance._append(new displayObjectInstance()).at("nodeName").
     *
     * @param {!DisplayObject} displayObject
     * @return {Object.<string, function(string): DisplayObject>}
     * @protected
     */
    _append: function (displayObject) {

        if (is(displayObject).notInstanceOf(DisplayObject)) {
            throw new TypeError("(alamid) type error: ._append() takes only objects kind of DisplayObject.");
        }

        return this._addNode(displayObject);

    },

    /**
     * How to use: displayObjectInstance._prepend(new displayObjectInstance()).at("nodeName").
     *
     * @param {!DisplayObject} displayObject
     * @return {Object.<string, function(string): DisplayObject>}
     * @protected
     */
    _prepend: function (displayObject) {

        if (is(displayObject).notInstanceOf(DisplayObject)) {
            throw new TypeError("(alamid) type error: ._prepend() takes only objects kind of DisplayObject.");
        }

        return this._addNode(displayObject, true);
    },

    /**
     * @param displayObject
     * @param {Boolean} prepend
     * @return {Object.<string, function(string): DisplayObject>}
     * @private
     */
    _addNode: function (displayObject, prepend) {

        var self = this,
            event = "append",
            __at;

            if (prepend === true) {
                event = "prepend";
            }

            __at = {
            /**
             * @param {String} nodeName
             * @return {DisplayObject}
             */
            at: function (nodeName) {
                var displayObjectParentNode,
                    displayObjectNode,
                    onDestroy,
                    onDispose;

                if (!self.__isInNodeMap(nodeName)) {
                    throw new Error(
                        "(alamid) error: Can not create node at '" + nodeName + "'. '" +
                            nodeName + "' is not a child node."
                    );
                }

                displayObject.emit("before" + event);
                //Get node where given childView should be placed...
                displayObjectParentNode = self._nodeMap[nodeName];
                displayObjectNode = displayObject.getNode();
                //and append or prepend it.
                if (prepend === true) {
                    displayObjectParentNode.insertBefore(displayObjectNode, displayObjectParentNode.firstChild);
                } else {
                    displayObjectParentNode.appendChild(displayObjectNode);
                }

                //Register DisplayObjects for destroy() and dispose()
                self.__addDisplayObject(nodeName, displayObject);

                //"destroy"- and "dispose"-Event will be attached with once to given DisplayObject ...
                onDestroy = function () {
                    self.__removeDisplayObject(nodeName, displayObject);
                    //... so we still need to remove listener for dispose if given DisplayObject calls destroy().
                    displayObject.removeListener("dispose", onDispose);
                };

                onDispose = function () {
                    self.__removeDisplayObject(nodeName, displayObject);
                    //... so we still need to remove listener for destroy if given DisplayObject calls dispose().
                    displayObject.removeListener("destroy", onDestroy);
                };

                displayObject.once("destroy", onDestroy);
                displayObject.once("dispose", onDispose);

                displayObject.emit(event);

                return self.Instance;
            }
        };

        return __at;
    },

    /**
     * @return {DisplayObject}
     */
    display: function (animator) {

        var self = this;

        this.Super.emit("beforedisplay");

        domAdapter(this.node).removeClass(ALAMID.HIDE_CLASS);

        if (typeof animator === "function") {
            animator(this.node, function () {
                self._isDisplayed = true;
                self.Super.emit("display");
            });
        } else {
            self._isDisplayed = true;
            self.Super.emit("display");
        }

        return this.Instance;
    },

    /**
     * @return {DisplayObject}
     */
    hide: function () {

        this.Super.emit("beforehide");

        domAdapter(this.node).addClass(ALAMID.HIDE_CLASS);
        this._isDisplayed = false;

        this.Super.emit("hide");

        return this.Instance;
    },

    /**
     * @return {DisplayObject}
     */
    destroy: function () {

        this.Super.emit("beforedestroy");

        domAdapter(this.node).destroy();
        this._isAppended = false;

        this.Super.once("append", this.__toggleAppendedState);

        this.Super.emit("destroy", this.Instance);

        return this.Instance;
    },

    /**
     * @return {DisplayObject}
     */
    dispose: function () {

        this.Super.emit("beforedispose");

        _(this._nodeMap).each(function disposeNodeMapIterator(node) {
            domAdapter(node).dispose();
        });

        this.node = undefined;
        this._nodeMap = undefined;

        this._isAppended = false;

        _(this.__displayObjectMap).each(function disposeDisplayObjectMapIterator(displayObject) {
            displayObject.dispose();
        });
        this.__displayObjectMap = undefined;

        this.Super.emit("dispose");
        this.Super.removeAllListeners();
    },

    /**
     * @private
     */
    __toggleAppendedState: function () {
        if (this._isAppended) {
            this._isAppended = false;
        }

        if (!this._isAppended) {
            this._isAppended = true;
        }
    },

    /**
     * @param {string} template
     * @private
     */
    __initNode: function (template) {
        INCUBATOR.innerHTML = template;
        this.node = INCUBATOR.firstChild;

        this.Super.once("append", this.__toggleAppendedState);
    },

    /**
     * Looks up for nodes which were defined with data-node-attribute and add them to nodeMap.
     * @see {DisplayObject.getNodeMap}
     * @protected
     */
    __initNodeMap: function () {
        //Find all own child nodes
        var nodes = domAdapter(this.node).find("[data-node]"),
            self = this;

        function iterator(node) {
            var nodeName = node.getAttribute("data-node");

            self._nodeMap[nodeName] = node;
        }

        _(nodes).each(iterator);
    },

    /**
     * @param {string} nodeName
     * @return {Boolean}
     * @protected
     */
    __isInNodeMap: function (nodeName) {

        var childNodeNames = _(this._nodeMap).keys();

        return _(childNodeNames).indexOf(nodeName) > -1;
    },

    /**
     * @param {String} nodeName
     * @param {DisplayObject} displayObject
     * @private
     */
    __addDisplayObject: function (nodeName, displayObject) {

        if (!this.__displayObjectMap[nodeName]) {
            this.__displayObjectMap[nodeName] = [];
        }

        this.__displayObjectMap[nodeName].push(displayObject);
    },

    /**
     * @param {String} nodeName
     * @param {DisplayObject} displayObject
     * @private
     */
    __removeDisplayObject: function (nodeName, displayObject) {

        function filterIterator(nodeNameDisplayObject) {
            return displayObject !== nodeNameDisplayObject;
        }

        this.__displayObjectMap[nodeName] = (this.__displayObjectMap[nodeName]).filter(filterIterator);
    }

});

module.exports = DisplayObject;<commit_msg>- Changed ALAMID_CLIENT_CONST require<commit_after>"use strict";

var Class = require("nodeclass").Class,
    is = require("nodeclass").is,
    EventEmitter = require("./../shared/EventEmitter.class.js"),
    domAdapter = require("./domAdapter.js"),
    ALAMID = require("./CONSTANTS.js"),
    _ = require("underscore");

var INCUBATOR = typeof document !== "undefined" && document.createElement("div");

/**
 * @extends EventEmitter
 */
var DisplayObject = new Class({

    Extends: EventEmitter,

    /**
     * @type {object}
     *
     */
    node: null,

    /**
     * @type {object}
     * @protected
     */
    _nodeMap: {},

    /**
     * @type {object}
     * @protected
     */
    __displayObjectMap: {},

    /**
     * @type {Boolean}
     * @protected
     */
    _isDisplayed: true,

    /**
     * @type {Boolean}
     * @protected
     */
    _isAppended: false,

    /**
     * @param {string} template
     * @constructor
     */
    init: function (template) {

        this.Super();

        if (typeof template !== "string" && typeof this.Instance.constructor.template !== "string") {
            throw new Error("(alamid) error: Cannot create DisplayObject without template(-string).");
        }
        template = template || this.Instance.constructor.template;

        this.__initNode(template);
        this.__initNodeMap();

        //@TODO prepareLinks
    },

    /**
     * @return {Boolean}
     */
    isAppended: function () {
        return this._isAppended;
    },

    /**
     * @return {Boolean}
     */
    isDisplayed: function () {
        return this._isDisplayed;
    },

    /**
     * @param {object.<string, object>} nodeEventMap
     */
    _addNodeEvents: function (nodeEventMap) {

        var self = this;

        /**
         * @param {object.<string : function>} eventMap
         * @param {string} nodeName
         */
        function eventMapIterator(eventMap, nodeName) {

            var node;

            if (self.__isInNodeMap(nodeName)) {

                node = self._nodeMap[nodeName];

                _(eventMap).each(function attachEventsIterator(listener, event) {
                    domAdapter(node).on(event, listener);
                });

            } else { //Throw new Error

                var events = _(eventMap).keys().join(", "),
                    nodes = _(self._nodeMap).keys().join(", ");

                throw new Error(
                    "(alamid) error: Trying to attach " + events + " to node '" + nodeName +
                        "', but '" + nodeName + "' is not part of the nodeMap. " +
                        "Found nodes in nodeMap: " + nodes + "."
                );
            }

        }

        _(nodeEventMap).each(eventMapIterator);
    },

    /**
     * How to use: displayObjectInstance._append(new displayObjectInstance()).at("nodeName").
     *
     * @param {!DisplayObject} displayObject
     * @return {Object.<string, function(string): DisplayObject>}
     * @protected
     */
    _append: function (displayObject) {

        if (is(displayObject).notInstanceOf(DisplayObject)) {
            throw new TypeError("(alamid) type error: ._append() takes only objects kind of DisplayObject.");
        }

        return this._addNode(displayObject);

    },

    /**
     * How to use: displayObjectInstance._prepend(new displayObjectInstance()).at("nodeName").
     *
     * @param {!DisplayObject} displayObject
     * @return {Object.<string, function(string): DisplayObject>}
     * @protected
     */
    _prepend: function (displayObject) {

        if (is(displayObject).notInstanceOf(DisplayObject)) {
            throw new TypeError("(alamid) type error: ._prepend() takes only objects kind of DisplayObject.");
        }

        return this._addNode(displayObject, true);
    },

    /**
     * @param displayObject
     * @param {Boolean} prepend
     * @return {Object.<string, function(string): DisplayObject>}
     * @private
     */
    _addNode: function (displayObject, prepend) {

        var self = this,
            event = "append",
            __at;

            if (prepend === true) {
                event = "prepend";
            }

            __at = {
            /**
             * @param {String} nodeName
             * @return {DisplayObject}
             */
            at: function (nodeName) {
                var displayObjectParentNode,
                    displayObjectNode,
                    onDestroy,
                    onDispose;

                if (!self.__isInNodeMap(nodeName)) {
                    throw new Error(
                        "(alamid) error: Can not create node at '" + nodeName + "'. '" +
                            nodeName + "' is not a child node."
                    );
                }

                displayObject.emit("before" + event);
                //Get node where given childView should be placed...
                displayObjectParentNode = self._nodeMap[nodeName];
                displayObjectNode = displayObject.getNode();
                //and append or prepend it.
                if (prepend === true) {
                    displayObjectParentNode.insertBefore(displayObjectNode, displayObjectParentNode.firstChild);
                } else {
                    displayObjectParentNode.appendChild(displayObjectNode);
                }

                //Register DisplayObjects for destroy() and dispose()
                self.__addDisplayObject(nodeName, displayObject);

                //"destroy"- and "dispose"-Event will be attached with once to given DisplayObject ...
                onDestroy = function () {
                    self.__removeDisplayObject(nodeName, displayObject);
                    //... so we still need to remove listener for dispose if given DisplayObject calls destroy().
                    displayObject.removeListener("dispose", onDispose);
                };

                onDispose = function () {
                    self.__removeDisplayObject(nodeName, displayObject);
                    //... so we still need to remove listener for destroy if given DisplayObject calls dispose().
                    displayObject.removeListener("destroy", onDestroy);
                };

                displayObject.once("destroy", onDestroy);
                displayObject.once("dispose", onDispose);

                displayObject.emit(event);

                return self.Instance;
            }
        };

        return __at;
    },

    /**
     * @return {DisplayObject}
     */
    display: function (animator) {

        var self = this;

        this.Super.emit("beforedisplay");

        domAdapter(this.node).removeClass(ALAMID.HIDE_CLASS);

        if (typeof animator === "function") {
            animator(this.node, function () {
                self._isDisplayed = true;
                self.Super.emit("display");
            });
        } else {
            self._isDisplayed = true;
            self.Super.emit("display");
        }

        return this.Instance;
    },

    /**
     * @return {DisplayObject}
     */
    hide: function () {

        this.Super.emit("beforehide");

        domAdapter(this.node).addClass(ALAMID.HIDE_CLASS);
        this._isDisplayed = false;

        this.Super.emit("hide");

        return this.Instance;
    },

    /**
     * @return {DisplayObject}
     */
    destroy: function () {

        this.Super.emit("beforedestroy");

        domAdapter(this.node).destroy();
        this._isAppended = false;

        this.Super.once("append", this.__toggleAppendedState);

        this.Super.emit("destroy", this.Instance);

        return this.Instance;
    },

    /**
     * @return {DisplayObject}
     */
    dispose: function () {

        this.Super.emit("beforedispose");

        _(this._nodeMap).each(function disposeNodeMapIterator(node) {
            domAdapter(node).dispose();
        });

        this.node = undefined;
        this._nodeMap = undefined;

        this._isAppended = false;

        _(this.__displayObjectMap).each(function disposeDisplayObjectMapIterator(displayObject) {
            displayObject.dispose();
        });
        this.__displayObjectMap = undefined;

        this.Super.emit("dispose");
        this.Super.removeAllListeners();
    },

    /**
     * @private
     */
    __toggleAppendedState: function () {
        if (this._isAppended) {
            this._isAppended = false;
        }

        if (!this._isAppended) {
            this._isAppended = true;
        }
    },

    /**
     * @param {string} template
     * @private
     */
    __initNode: function (template) {
        INCUBATOR.innerHTML = template;
        this.node = INCUBATOR.firstChild;

        this.Super.once("append", this.__toggleAppendedState);
    },

    /**
     * Looks up for nodes which were defined with data-node-attribute and add them to nodeMap.
     * @see {DisplayObject.getNodeMap}
     * @protected
     */
    __initNodeMap: function () {
        //Find all own child nodes
        var nodes = domAdapter(this.node).find("[data-node]"),
            self = this;

        function iterator(node) {
            var nodeName = node.getAttribute("data-node");

            self._nodeMap[nodeName] = node;
        }

        _(nodes).each(iterator);
    },

    /**
     * @param {string} nodeName
     * @return {Boolean}
     * @protected
     */
    __isInNodeMap: function (nodeName) {

        var childNodeNames = _(this._nodeMap).keys();

        return _(childNodeNames).indexOf(nodeName) > -1;
    },

    /**
     * @param {String} nodeName
     * @param {DisplayObject} displayObject
     * @private
     */
    __addDisplayObject: function (nodeName, displayObject) {

        if (!this.__displayObjectMap[nodeName]) {
            this.__displayObjectMap[nodeName] = [];
        }

        this.__displayObjectMap[nodeName].push(displayObject);
    },

    /**
     * @param {String} nodeName
     * @param {DisplayObject} displayObject
     * @private
     */
    __removeDisplayObject: function (nodeName, displayObject) {

        function filterIterator(nodeNameDisplayObject) {
            return displayObject !== nodeNameDisplayObject;
        }

        this.__displayObjectMap[nodeName] = (this.__displayObjectMap[nodeName]).filter(filterIterator);
    }

});

module.exports = DisplayObject;<|endoftext|>


<commit_before>(function () {
    'use strict';

    angular
        .module('dpDataSelection')
        .constant('DATA_SELECTION_CONFIG', {
            options: {
                MAX_NUMBER_OF_CLUSTERED_MARKERS: 10000
            },
            datasets: {
                bag: {
                    CUSTOM_API: 'dataSelectionApiDataSelection',
                    MAX_AVAILABLE_PAGES: 100,
                    ENDPOINT_PREVIEW: 'dataselectie/bag/',
                    ENDPOINT_MARKERS: 'dataselectie/bag/geolocation/',
                    ENDPOINT_EXPORT: 'dataselectie/bag/export/',
                    ENDPOINT_DETAIL: 'bag/nummeraanduiding/',
                    PRIMARY_KEY: 'nummeraanduiding_id',
                    TITLE: 'Adressen',
                    FILTERS: [
                        {
                            slug: 'stadsdeel_naam',
                            label: 'Stadsdeel'
                        }, {
                            slug: 'ggw_naam',
                            label: 'GGW-gebied'
                        }, {
                            slug: 'buurtcombinatie_naam',
                            label: 'Wijk'
                        }, {
                            slug: 'buurt_naam',
                            label: 'Buurt'
                        }, {
                            slug: 'openbare_ruimte',
                            label: 'Openbare ruimte'
                        }, {
                            slug: 'postcode',
                            label: 'Postcode'
                        }
                    ],
                    CONTENT: {
                        TABLE: [
                            {
                                label: 'Naam openbare ruimte',
                                variables: ['_openbare_ruimte_naam']
                            },
                            {
                                label: 'Num.',
                                variables: ['huisnummer']
                            },
                            {
                                label: 'Let.',
                                variables: ['huisletter']
                            },
                            {
                                label: 'Toev.',
                                variables: ['huisnummer_toevoeging']
                            },
                            {
                                label: 'Postcode',
                                variables: ['postcode']
                            },
                            {
                                label: 'Stadsdeel',
                                variables: ['stadsdeel_naam']
                            },
                            {
                                label: '-code',
                                variables: ['stadsdeel_code']
                            },
                            {
                                label: 'GGW-gebied',
                                variables: ['ggw_naam']
                            },
                            {
                                label: '-code',
                                variables: ['ggw_code']
                            },
                            {
                                label: 'Wijk',
                                variables: ['buurtcombinatie_naam']
                            },
                            {
                                label: '-code',
                                variables: ['buurtcombinatie_code']
                            },
                            {
                                label: 'Buurt',
                                variables: ['buurt_naam']
                            },
                            {
                                label: '-code',
                                variables: ['buurt_code']
                            }
                        ],
                        LIST: [
                            {
                                variables: [
                                    '_openbare_ruimte_naam',
                                    'huisnummer',
                                    'huisletter',
                                    'huisnummer_toevoeging'
                                ],
                                formatter: 'bagAddress'
                            },
                            {
                                variables: [
                                    'ligplaats_id',
                                    'standplaats_id'
                                ],
                                formatter: 'nummeraanduidingType'
                            },
                            {
                                variables: [
                                    'hoofdadres'
                                ],
                                formatter: 'nevenadres'
                            },
                            {
                                variables: [
                                    'status_id'
                                ],
                                formatter: 'verblijfsobjectGevormd'
                            }
                        ]
                    }
                },
                catalogus: {
                    MAX_ITEMS_PER_PAGE: 100,
                    CUSTOM_API: 'dataSelectionApiCkan',
                    ENDPOINT_PREVIEW: 'catalogus/api/3/action/package_search',
                    ENDPOINT_DETAIL: 'catalogus/api/3/action/package_show',
                    PRIMARY_KEY: 'id',
                    TITLE: 'Catalogus',
                    SHOW_FILTER_OPTION_COUNTS: false,
                    FILTERS: [
                        {
                            slug: 'groups',
                            label: 'Thema\'s'
                        }, {
                            slug: 'res_format',
                            label: 'Formaten',
                            formatter: 'lowercase'
                        }, {
                            slug: 'organization',
                            label: 'Gepubliceerd door'
                        }
                    ],
                    CONTENT: {
                        CARDS: [
                            {
                                label: 'Naam',
                                variables: ['title']
                            }, {
                                label: 'Datum',
                                variables: ['metadata_created', 'metadata_modified'],
                                formatter: 'modificationDate'
                            }, {
                                label: 'Formaten',
                                variables: ['resources.format'],
                                formatter: 'aggregate',
                                template: 'file-type'
                            }, {
                                label: 'Labels',
                                variables: ['tags.display_name'],
                                formatter: 'aggregate',
                                template: 'tags'
                            }, {
                                label: 'Omschrijving',
                                formatter: 'truncateHtmlAsText',
                                variables: ['notes']
                            }
                        ]
                    }
                },
                hr: {
                    CUSTOM_API: 'dataSelectionApiDataSelection',
                    AUTH_SCOPE: 'HR/R',
                    MAX_AVAILABLE_PAGES: 100,
                    ENDPOINT_PREVIEW: 'dataselectie/hr/',
                    ENDPOINT_MARKERS: 'dataselectie/hr/geolocation/',
                    ENDPOINT_EXPORT: 'dataselectie/hr/export/',
                    ENDPOINT_DETAIL: 'handelsregister/vestiging/',
                    PRIMARY_KEY: 'vestiging_id',
                    TITLE: 'Inschrijvingen',
                    FILTERS: [
                        {
                            slug: 'bijzondere_rechtstoestand',
                            label: 'Bijzondere rechtstoestand'
                        }, {
                            slug: 'hoofdcategorie',
                            label: 'Hoofdcategorie'
                        }, {
                            slug: 'subcategorie',
                            label: 'Subcategorie'
                        }, {
                            slug: 'stadsdeel_naam',
                            label: 'Stadsdeel'
                        }, {
                            slug: 'ggw_naam',
                            label: 'GGW-gebied'
                        }, {
                            slug: 'buurtcombinatie_naam',
                            label: 'Wijk'
                        }, {
                            slug: 'buurt_naam',
                            label: 'Buurt'
                        }, {
                            slug: 'openbare_ruimte',
                            label: 'Openbare ruimte'
                        }, {
                            slug: 'postcode',
                            label: 'Postcode'
                        }
                    ],
                    CONTENT: {
                        TABLE: [
                            {
                                label: 'Handelsnaam',
                                variables: ['handelsnaam']
                            },
                            {
                                label: 'KvK-num.',
                                variables: ['kvk_nummer']
                            },
                            {
                                label: 'SBI-code',
                                variables: ['sbi_code']
                            },
                            {
                                label: 'SBI-omschrijving',
                                variables: ['sbi_omschrijving']
                            },
                            {
                                label: 'Bezoekadres',
                                variables: ['bezoekadres_volledig_adres', 'non_mailing'],
                                formatter: 'hrBezoekadres',
                                template: 'bezoekadres'
                            }
                        ],
                        LIST: [
                            {
                                variables: ['handelsnaam']
                            }
                        ]
                    }
                }
            }
        });
})();
<commit_msg>removed filters: hoofdcategorie and subcategrie tg-4501<commit_after>(function () {
    'use strict';

    angular
        .module('dpDataSelection')
        .constant('DATA_SELECTION_CONFIG', {
            options: {
                MAX_NUMBER_OF_CLUSTERED_MARKERS: 10000
            },
            datasets: {
                bag: {
                    CUSTOM_API: 'dataSelectionApiDataSelection',
                    MAX_AVAILABLE_PAGES: 100,
                    ENDPOINT_PREVIEW: 'dataselectie/bag/',
                    ENDPOINT_MARKERS: 'dataselectie/bag/geolocation/',
                    ENDPOINT_EXPORT: 'dataselectie/bag/export/',
                    ENDPOINT_DETAIL: 'bag/nummeraanduiding/',
                    PRIMARY_KEY: 'nummeraanduiding_id',
                    TITLE: 'Adressen',
                    FILTERS: [
                        {
                            slug: 'stadsdeel_naam',
                            label: 'Stadsdeel'
                        }, {
                            slug: 'ggw_naam',
                            label: 'GGW-gebied'
                        }, {
                            slug: 'buurtcombinatie_naam',
                            label: 'Wijk'
                        }, {
                            slug: 'buurt_naam',
                            label: 'Buurt'
                        }, {
                            slug: 'openbare_ruimte',
                            label: 'Openbare ruimte'
                        }, {
                            slug: 'postcode',
                            label: 'Postcode'
                        }
                    ],
                    CONTENT: {
                        TABLE: [
                            {
                                label: 'Naam openbare ruimte',
                                variables: ['_openbare_ruimte_naam']
                            },
                            {
                                label: 'Num.',
                                variables: ['huisnummer']
                            },
                            {
                                label: 'Let.',
                                variables: ['huisletter']
                            },
                            {
                                label: 'Toev.',
                                variables: ['huisnummer_toevoeging']
                            },
                            {
                                label: 'Postcode',
                                variables: ['postcode']
                            },
                            {
                                label: 'Stadsdeel',
                                variables: ['stadsdeel_naam']
                            },
                            {
                                label: '-code',
                                variables: ['stadsdeel_code']
                            },
                            {
                                label: 'GGW-gebied',
                                variables: ['ggw_naam']
                            },
                            {
                                label: '-code',
                                variables: ['ggw_code']
                            },
                            {
                                label: 'Wijk',
                                variables: ['buurtcombinatie_naam']
                            },
                            {
                                label: '-code',
                                variables: ['buurtcombinatie_code']
                            },
                            {
                                label: 'Buurt',
                                variables: ['buurt_naam']
                            },
                            {
                                label: '-code',
                                variables: ['buurt_code']
                            }
                        ],
                        LIST: [
                            {
                                variables: [
                                    '_openbare_ruimte_naam',
                                    'huisnummer',
                                    'huisletter',
                                    'huisnummer_toevoeging'
                                ],
                                formatter: 'bagAddress'
                            },
                            {
                                variables: [
                                    'ligplaats_id',
                                    'standplaats_id'
                                ],
                                formatter: 'nummeraanduidingType'
                            },
                            {
                                variables: [
                                    'hoofdadres'
                                ],
                                formatter: 'nevenadres'
                            },
                            {
                                variables: [
                                    'status_id'
                                ],
                                formatter: 'verblijfsobjectGevormd'
                            }
                        ]
                    }
                },
                catalogus: {
                    MAX_ITEMS_PER_PAGE: 100,
                    CUSTOM_API: 'dataSelectionApiCkan',
                    ENDPOINT_PREVIEW: 'catalogus/api/3/action/package_search',
                    ENDPOINT_DETAIL: 'catalogus/api/3/action/package_show',
                    PRIMARY_KEY: 'id',
                    TITLE: 'Catalogus',
                    SHOW_FILTER_OPTION_COUNTS: false,
                    FILTERS: [
                        {
                            slug: 'groups',
                            label: 'Thema\'s'
                        }, {
                            slug: 'res_format',
                            label: 'Formaten',
                            formatter: 'lowercase'
                        }, {
                            slug: 'organization',
                            label: 'Gepubliceerd door'
                        }
                    ],
                    CONTENT: {
                        CARDS: [
                            {
                                label: 'Naam',
                                variables: ['title']
                            }, {
                                label: 'Datum',
                                variables: ['metadata_created', 'metadata_modified'],
                                formatter: 'modificationDate'
                            }, {
                                label: 'Formaten',
                                variables: ['resources.format'],
                                formatter: 'aggregate',
                                template: 'file-type'
                            }, {
                                label: 'Labels',
                                variables: ['tags.display_name'],
                                formatter: 'aggregate',
                                template: 'tags'
                            }, {
                                label: 'Omschrijving',
                                formatter: 'truncateHtmlAsText',
                                variables: ['notes']
                            }
                        ]
                    }
                },
                hr: {
                    CUSTOM_API: 'dataSelectionApiDataSelection',
                    AUTH_SCOPE: 'HR/R',
                    MAX_AVAILABLE_PAGES: 100,
                    ENDPOINT_PREVIEW: 'dataselectie/hr/',
                    ENDPOINT_MARKERS: 'dataselectie/hr/geolocation/',
                    ENDPOINT_EXPORT: 'dataselectie/hr/export/',
                    ENDPOINT_DETAIL: 'handelsregister/vestiging/',
                    PRIMARY_KEY: 'vestiging_id',
                    TITLE: 'Inschrijvingen',
                    FILTERS: [
                        {
                            slug: 'bijzondere_rechtstoestand',
                            label: 'Bijzondere rechtstoestand'
                        }, {
                            slug: 'stadsdeel_naam',
                            label: 'Stadsdeel'
                        }, {
                            slug: 'ggw_naam',
                            label: 'GGW-gebied'
                        }, {
                            slug: 'buurtcombinatie_naam',
                            label: 'Wijk'
                        }, {
                            slug: 'buurt_naam',
                            label: 'Buurt'
                        }, {
                            slug: 'openbare_ruimte',
                            label: 'Openbare ruimte'
                        }, {
                            slug: 'postcode',
                            label: 'Postcode'
                        }
                    ],
                    CONTENT: {
                        TABLE: [
                            {
                                label: 'Handelsnaam',
                                variables: ['handelsnaam']
                            },
                            {
                                label: 'KvK-num.',
                                variables: ['kvk_nummer']
                            },
                            {
                                label: 'SBI-code',
                                variables: ['sbi_code']
                            },
                            {
                                label: 'SBI-omschrijving',
                                variables: ['sbi_omschrijving']
                            },
                            {
                                label: 'Bezoekadres',
                                variables: ['bezoekadres_volledig_adres', 'non_mailing'],
                                formatter: 'hrBezoekadres',
                                template: 'bezoekadres'
                            }
                        ],
                        LIST: [
                            {
                                variables: ['handelsnaam']
                            }
                        ]
                    }
                }
            }
        });
})();
<|endoftext|>


<commit_before>/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
 * full list of contributors). Published under the Clear BSD license.
 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
 * full text of the license. */

/**
 * @requires OpenLayers/Format/XLS.js
 * @requires OpenLayers/Format/GML/v3.js
 */

/**
 * Class: OpenLayers.Format.XLS.v1
 * Superclass for XLS version 1 parsers. Only supports GeocodeRequest for now.
 *
 * Inherits from:
 *  - <OpenLayers.Format.XML>
 */
OpenLayers.Format.XLS.v1 = OpenLayers.Class(OpenLayers.Format.XML, {

    /**
     * Property: namespaces
     * {Object} Mapping of namespace aliases to namespace URIs.
     */
    namespaces: {
        xls: "http://www.opengis.net/xls",
        gml: "http://www.opengis.net/gml",
        xsi: "http://www.w3.org/2001/XMLSchema-instance"
    },

    /**
     * Property: regExes
     * Compiled regular expressions for manipulating strings.
     */
    regExes: {
        trimSpace: (/^\s*|\s*$/g),
        removeSpace: (/\s*/g),
        splitSpace: (/\s+/),
        trimComma: (/\s*,\s*/g)
    },

    /**
     * APIProperty: xy
     * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x)
     * Changing is not recommended, a new Format should be instantiated.
     */
    xy: true,

    /**
     * Property: defaultPrefix
     */
    defaultPrefix: "xls",

    /**
     * Property: schemaLocation
     * {String} Schema location for a particular minor version.
     */
    schemaLocation: null,

    /**
     * Constructor: OpenLayers.Format.XLS.v1
     * Instances of this class are not created directly.  Use the
     *     <OpenLayers.Format.XLS> constructor instead.
     *
     * Parameters:
     * options - {Object} An optional object whose properties will be set on
     *     this instance.
     */

    /**
     * Method: read
     *
     * Parameters:
     * data - {DOMElement} An XLS document element.
     * options - {Object} Options for the reader.
     *
     * Returns:
     * {Object} An object representing the XLSResponse.
     */
    read: function(data, options) {
        options = OpenLayers.Util.applyDefaults(options, this.options);
        var xls = {};
        this.readChildNodes(data, xls);
        return xls;
    },

    /**
     * Property: readers
     * Contains public functions, grouped by namespace prefix, that will
     *     be applied when a namespaced node is found matching the function
     *     name.  The function will be applied in the scope of this parser
     *     with two arguments: the node being read and a context object passed
     *     from the parent.
     */
    readers: {
        "xls": {
            "XLS": function(node, xls) {
                xls.version = node.getAttribute("version");
                this.readChildNodes(node, xls);
            },
            "Response": function(node, xls) {
               this.readChildNodes(node, xls);
            },
            "GeocodeResponse": function(node, xls) {
               xls.responseLists = [];
               this.readChildNodes(node, xls);
            },
            "GeocodeResponseList": function(node, xls) {
                var responseList = {
                    features: [],
                    numberOfGeocodedAddresses:
                        parseInt(node.getAttribute("numberOfGeocodedAddresses"))
                };
                xls.responseLists.push(responseList);
                this.readChildNodes(node, responseList);
            },
            "GeocodedAddress": function(node, responseList) {
                var feature = new OpenLayers.Feature.Vector();
                responseList.features.push(feature);
                this.readChildNodes(node, feature);
                // post-process geometry
                feature.geometry = feature.components[0];
            },
            "GeocodeMatchCode": function(node, feature) {
                feature.attributes.matchCode = {
                    accuracy: parseFloat(node.getAttribute("accuracy")),
                    matchType: node.getAttribute("matchType")
                };
            },
            "Address": function(node, feature) {
                var address = {
                    countryCode: node.getAttribute("countryCode"),
                    addressee: node.getAttribute("addressee"),
                    street: [],
                    place: []
                };
                feature.attributes.address = address;
                this.readChildNodes(node, address);
            },
            "freeFormAddress": function(node, address) {
                address.freeFormAddress = this.getChildValue(node);
            },
            "StreetAddress": function(node, address) {
                this.readChildNodes(node, address);
            },
            "Building": function(node, address) {
                address.building = {
                    'number': node.getAttribute("number"),
                    subdivision: node.getAttribute("subdivision"),
                    buildingName: node.getAttribute("buildingName")
                };
            },
            "Street": function(node, address) {
                // only support the built-in primitive type for now
                address.street.push(this.getChildValue(node));
            },
            "Place": function(node, address) {
                // type is one of CountrySubdivision,
                // CountrySecondarySubdivision, Municipality or
                // MunicipalitySubdivision
                address.place[node.getAttribute("type")] =
                    this.getChildValue(node);
            },
            "PostalCode": function(node, address) {
                address.postalCode = this.getChildValue(node);
            }
        },
        "gml": OpenLayers.Format.GML.v3.prototype.readers.gml
    },

    /**
     * Method: write
     *
     * Parameters:
     * request - {Object} An object representing the geocode request.
     *
     * Returns:
     * {DOMElement} The root of an XLS document.
     */
    write: function(request) {
        return this.writers.xls.XLS.apply(this, [request]);
    },

    /**
     * Property: writers
     * As a compliment to the readers property, this structure contains public
     *     writing functions grouped by namespace alias and named like the
     *     node names they produce.
     */
    writers: {
        "xls": {
            "XLS": function(request) {
                var root = this.createElementNSPlus(
                    "xls:XLS",
                    {attributes: {
                        "version": this.VERSION,
                        "xsi:schemaLocation": this.schemaLocation
                    }}
                );
                this.writeNode("RequestHeader", request.header, root);
                this.writeNode("Request", request, root);
                return root;
            },
            "RequestHeader": function(header) {
                return this.createElementNSPlus("xls:RequestHeader");
            },
            "Request": function(request) {
                var node = this.createElementNSPlus("xls:Request", {
                    attributes: {
                        methodName: "GeocodeRequest",
                        requestID: request.requestID || "",
                        version: this.VERSION
                    }
                });
                this.writeNode("GeocodeRequest", request.addresses, node);
                return node;
            },
            "GeocodeRequest": function(addresses) {
                var node = this.createElementNSPlus("xls:GeocodeRequest");
                for (var i=0, len=addresses.length; i<len; i++) {
                    this.writeNode("Address", addresses[i], node);
                }
                return node;
            },
            "Address": function(address) {
                var node = this.createElementNSPlus("xls:Address", {
                    attributes: {
                        countryCode: address.countryCode
                    }
                });
                if (address.freeFormAddress) {
                    this.writeNode("freeFormAddess", address.freeFormAddress, node);
                } else {
                    if (address.street) {
                        this.writeNode("StreetAddress", address, node);
                    }
                    if (address.municipality) {
                        this.writeNode("Municipality", address.municipality, node);
                    }
                    if (address.countrySubdivision) {
                        this.writeNode("CountrySubdivision", address.countrySubdivision, node);
                    }
                    if (address.postalCode) {
                        this.writeNode("PostalCode", address.postalCode, node);
                    }
                }
                return node;
            },
            "freeFormAddress": function(freeFormAddress) {
                return this.createElementNSPlus("freeFormAddress",
                    {value: freeFormAddress});
            },
            "StreetAddress": function(address) {
                var node = this.createElementNSPlus("xls:StreetAddress");
                if (address.building) {
                    this.writeNode(node, "Building", address.building);
                }
                var street = address.street;
                if (!(OpenLayers.Util.isArray(street))) {
                    street = [street];
                }
                for (var i=0, len=street.length; i < len; i++) {
                    this.writeNode("Street", street[i], node);
                }
                return node;
            },
            "Building": function(building) {
                return this.createElementNSPlus("xls:Building", {
                    attributes: {
                        "number": building["number"],
                        "subdivision": building.subdivision,
                        "buildingName": building.buildingName
                    }
                });
            },
            "Street": function(street) {
                return this.createElementNSPlus("xls:Street", {value: street});
            },
            "Municipality": function(municipality) {
                return this.createElementNSPlus("xls:Place", {
                    attributes: {
                        type: "Municipality"
                    },
                    value: municipality
                });
            },
            "CountrySubdivision": function(countrySubdivision) {
                return this.createElementNSPlus("xls:Place", {
                    attributes: {
                        type: "CountrySubdivision"
                    },
                    value: countrySubdivision
                });
            },
            "PostalCode": function(postalCode) {
                return this.createElementNSPlus("xls:PostalCode", {
                    value: postalCode
                });
            }
        }
    },

    CLASS_NAME: "OpenLayers.Format.XLS.v1"

});
<commit_msg>Fixing typo<commit_after>/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
 * full list of contributors). Published under the Clear BSD license.
 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
 * full text of the license. */

/**
 * @requires OpenLayers/Format/XLS.js
 * @requires OpenLayers/Format/GML/v3.js
 */

/**
 * Class: OpenLayers.Format.XLS.v1
 * Superclass for XLS version 1 parsers. Only supports GeocodeRequest for now.
 *
 * Inherits from:
 *  - <OpenLayers.Format.XML>
 */
OpenLayers.Format.XLS.v1 = OpenLayers.Class(OpenLayers.Format.XML, {

    /**
     * Property: namespaces
     * {Object} Mapping of namespace aliases to namespace URIs.
     */
    namespaces: {
        xls: "http://www.opengis.net/xls",
        gml: "http://www.opengis.net/gml",
        xsi: "http://www.w3.org/2001/XMLSchema-instance"
    },

    /**
     * Property: regExes
     * Compiled regular expressions for manipulating strings.
     */
    regExes: {
        trimSpace: (/^\s*|\s*$/g),
        removeSpace: (/\s*/g),
        splitSpace: (/\s+/),
        trimComma: (/\s*,\s*/g)
    },

    /**
     * APIProperty: xy
     * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x)
     * Changing is not recommended, a new Format should be instantiated.
     */
    xy: true,

    /**
     * Property: defaultPrefix
     */
    defaultPrefix: "xls",

    /**
     * Property: schemaLocation
     * {String} Schema location for a particular minor version.
     */
    schemaLocation: null,

    /**
     * Constructor: OpenLayers.Format.XLS.v1
     * Instances of this class are not created directly.  Use the
     *     <OpenLayers.Format.XLS> constructor instead.
     *
     * Parameters:
     * options - {Object} An optional object whose properties will be set on
     *     this instance.
     */

    /**
     * Method: read
     *
     * Parameters:
     * data - {DOMElement} An XLS document element.
     * options - {Object} Options for the reader.
     *
     * Returns:
     * {Object} An object representing the XLSResponse.
     */
    read: function(data, options) {
        options = OpenLayers.Util.applyDefaults(options, this.options);
        var xls = {};
        this.readChildNodes(data, xls);
        return xls;
    },

    /**
     * Property: readers
     * Contains public functions, grouped by namespace prefix, that will
     *     be applied when a namespaced node is found matching the function
     *     name.  The function will be applied in the scope of this parser
     *     with two arguments: the node being read and a context object passed
     *     from the parent.
     */
    readers: {
        "xls": {
            "XLS": function(node, xls) {
                xls.version = node.getAttribute("version");
                this.readChildNodes(node, xls);
            },
            "Response": function(node, xls) {
               this.readChildNodes(node, xls);
            },
            "GeocodeResponse": function(node, xls) {
               xls.responseLists = [];
               this.readChildNodes(node, xls);
            },
            "GeocodeResponseList": function(node, xls) {
                var responseList = {
                    features: [],
                    numberOfGeocodedAddresses:
                        parseInt(node.getAttribute("numberOfGeocodedAddresses"))
                };
                xls.responseLists.push(responseList);
                this.readChildNodes(node, responseList);
            },
            "GeocodedAddress": function(node, responseList) {
                var feature = new OpenLayers.Feature.Vector();
                responseList.features.push(feature);
                this.readChildNodes(node, feature);
                // post-process geometry
                feature.geometry = feature.components[0];
            },
            "GeocodeMatchCode": function(node, feature) {
                feature.attributes.matchCode = {
                    accuracy: parseFloat(node.getAttribute("accuracy")),
                    matchType: node.getAttribute("matchType")
                };
            },
            "Address": function(node, feature) {
                var address = {
                    countryCode: node.getAttribute("countryCode"),
                    addressee: node.getAttribute("addressee"),
                    street: [],
                    place: []
                };
                feature.attributes.address = address;
                this.readChildNodes(node, address);
            },
            "freeFormAddress": function(node, address) {
                address.freeFormAddress = this.getChildValue(node);
            },
            "StreetAddress": function(node, address) {
                this.readChildNodes(node, address);
            },
            "Building": function(node, address) {
                address.building = {
                    'number': node.getAttribute("number"),
                    subdivision: node.getAttribute("subdivision"),
                    buildingName: node.getAttribute("buildingName")
                };
            },
            "Street": function(node, address) {
                // only support the built-in primitive type for now
                address.street.push(this.getChildValue(node));
            },
            "Place": function(node, address) {
                // type is one of CountrySubdivision,
                // CountrySecondarySubdivision, Municipality or
                // MunicipalitySubdivision
                address.place[node.getAttribute("type")] =
                    this.getChildValue(node);
            },
            "PostalCode": function(node, address) {
                address.postalCode = this.getChildValue(node);
            }
        },
        "gml": OpenLayers.Format.GML.v3.prototype.readers.gml
    },

    /**
     * Method: write
     *
     * Parameters:
     * request - {Object} An object representing the geocode request.
     *
     * Returns:
     * {DOMElement} The root of an XLS document.
     */
    write: function(request) {
        return this.writers.xls.XLS.apply(this, [request]);
    },

    /**
     * Property: writers
     * As a compliment to the readers property, this structure contains public
     *     writing functions grouped by namespace alias and named like the
     *     node names they produce.
     */
    writers: {
        "xls": {
            "XLS": function(request) {
                var root = this.createElementNSPlus(
                    "xls:XLS",
                    {attributes: {
                        "version": this.VERSION,
                        "xsi:schemaLocation": this.schemaLocation
                    }}
                );
                this.writeNode("RequestHeader", request.header, root);
                this.writeNode("Request", request, root);
                return root;
            },
            "RequestHeader": function(header) {
                return this.createElementNSPlus("xls:RequestHeader");
            },
            "Request": function(request) {
                var node = this.createElementNSPlus("xls:Request", {
                    attributes: {
                        methodName: "GeocodeRequest",
                        requestID: request.requestID || "",
                        version: this.VERSION
                    }
                });
                this.writeNode("GeocodeRequest", request.addresses, node);
                return node;
            },
            "GeocodeRequest": function(addresses) {
                var node = this.createElementNSPlus("xls:GeocodeRequest");
                for (var i=0, len=addresses.length; i<len; i++) {
                    this.writeNode("Address", addresses[i], node);
                }
                return node;
            },
            "Address": function(address) {
                var node = this.createElementNSPlus("xls:Address", {
                    attributes: {
                        countryCode: address.countryCode
                    }
                });
                if (address.freeFormAddress) {
                    this.writeNode("freeFormAddress", address.freeFormAddress, node);
                } else {
                    if (address.street) {
                        this.writeNode("StreetAddress", address, node);
                    }
                    if (address.municipality) {
                        this.writeNode("Municipality", address.municipality, node);
                    }
                    if (address.countrySubdivision) {
                        this.writeNode("CountrySubdivision", address.countrySubdivision, node);
                    }
                    if (address.postalCode) {
                        this.writeNode("PostalCode", address.postalCode, node);
                    }
                }
                return node;
            },
            "freeFormAddress": function(freeFormAddress) {
                return this.createElementNSPlus("freeFormAddress",
                    {value: freeFormAddress});
            },
            "StreetAddress": function(address) {
                var node = this.createElementNSPlus("xls:StreetAddress");
                if (address.building) {
                    this.writeNode(node, "Building", address.building);
                }
                var street = address.street;
                if (!(OpenLayers.Util.isArray(street))) {
                    street = [street];
                }
                for (var i=0, len=street.length; i < len; i++) {
                    this.writeNode("Street", street[i], node);
                }
                return node;
            },
            "Building": function(building) {
                return this.createElementNSPlus("xls:Building", {
                    attributes: {
                        "number": building["number"],
                        "subdivision": building.subdivision,
                        "buildingName": building.buildingName
                    }
                });
            },
            "Street": function(street) {
                return this.createElementNSPlus("xls:Street", {value: street});
            },
            "Municipality": function(municipality) {
                return this.createElementNSPlus("xls:Place", {
                    attributes: {
                        type: "Municipality"
                    },
                    value: municipality
                });
            },
            "CountrySubdivision": function(countrySubdivision) {
                return this.createElementNSPlus("xls:Place", {
                    attributes: {
                        type: "CountrySubdivision"
                    },
                    value: countrySubdivision
                });
            },
            "PostalCode": function(postalCode) {
                return this.createElementNSPlus("xls:PostalCode", {
                    value: postalCode
                });
            }
        }
    },

    CLASS_NAME: "OpenLayers.Format.XLS.v1"

});
<|endoftext|>