<commit_before>import {ViewResources} from './view-resources';
import {ViewFactory} from './view-factory';
import {BindingLanguage} from './binding-language';
import {ViewCompileInstruction, BehaviorInstruction, TargetInstruction} from './instructions';
import {inject} from 'aurelia-dependency-injection';
import {DOM, FEATURE} from 'aurelia-pal';
import {ShadowDOM} from './shadow-dom';

let nextInjectorId = 0;
function getNextInjectorId() {
  return ++nextInjectorId;
}

function configureProperties(instruction, resources) {
  let type = instruction.type;
  let attrName = instruction.attrName;
  let attributes = instruction.attributes;
  let property;
  let key;
  let value;

  let knownAttribute = resources.mapAttribute(attrName);
  if (knownAttribute && attrName in attributes && knownAttribute !== attrName) {
    attributes[knownAttribute] = attributes[attrName];
    delete attributes[attrName];
  }

  for (key in attributes) {
    value = attributes[key];

    if (value !== null && typeof value === 'object') {
      property = type.attributes[key];

      if (property !== undefined) {
        value.targetProperty = property.name;
      } else {
        value.targetProperty = key;
      }
    }
  }
}

let lastAUTargetID = 0;
function getNextAUTargetID() {
  return (++lastAUTargetID).toString();
}

function makeIntoInstructionTarget(element) {
  let value = element.getAttribute('class');
  let auTargetID = getNextAUTargetID();

  element.setAttribute('class', (value ? value + ' au-target' : 'au-target'));
  element.setAttribute('au-target-id', auTargetID);

  return auTargetID;
}

function makeShadowSlot(compiler, resources, node, instructions, parentInjectorId) {
  let auShadowSlot = DOM.createElement('au-shadow-slot');
  DOM.replaceNode(auShadowSlot, node);

  let auTargetID = makeIntoInstructionTarget(auShadowSlot);
  let instruction = TargetInstruction.shadowSlot(parentInjectorId);

  instruction.slotName = node.getAttribute('name') || ShadowDOM.defaultSlotKey;
  instruction.slotDestination = node.getAttribute('slot');

  if (node.innerHTML.trim()) {
    let fragment = DOM.createDocumentFragment();
    let child;

    while (child = node.firstChild) {
      fragment.appendChild(child);
    }

    instruction.slotFallbackFactory = compiler.compile(fragment, resources);
  }

  instructions[auTargetID] = instruction;

  return auShadowSlot;
}

/**
* Compiles html templates, dom fragments and strings into ViewFactory instances, capable of instantiating Views.
*/
@inject(BindingLanguage, ViewResources)
export class ViewCompiler {
  /**
  * Creates an instance of ViewCompiler.
  * @param bindingLanguage The default data binding language and syntax used during view compilation.
  * @param resources The global resources used during compilation when none are provided for compilation.
  */
  constructor(bindingLanguage: BindingLanguage, resources: ViewResources) {
    this.bindingLanguage = bindingLanguage;
    this.resources = resources;
  }

  /**
  * Compiles an html template, dom fragment or string into ViewFactory instances, capable of instantiating Views.
  * @param source The template, fragment or string to compile.
  * @param resources The view resources used during compilation.
  * @param compileInstruction A set of instructions that customize how compilation occurs.
  * @return The compiled ViewFactory.
  */
  compile(source: Element|DocumentFragment|string, resources?: ViewResources, compileInstruction?: ViewCompileInstruction): ViewFactory {
    resources = resources || this.resources;
    compileInstruction = compileInstruction || ViewCompileInstruction.normal;
    source = typeof source === 'string' ? DOM.createTemplateFromMarkup(source) : source;

    let content;
    let part;
    let cacheSize;

    if (source.content) {
      part = source.getAttribute('part');
      cacheSize = source.getAttribute('view-cache');
      content = DOM.adoptNode(source.content);
    } else {
      content = source;
    }

    compileInstruction.targetShadowDOM = compileInstruction.targetShadowDOM && FEATURE.shadowDOM;
    resources._invokeHook('beforeCompile', content, resources, compileInstruction);

    let instructions = {};
    this._compileNode(content, resources, instructions, source, 'root', !compileInstruction.targetShadowDOM);

    let firstChild = content.firstChild;
    if (firstChild && firstChild.nodeType === 1) {
      let targetId = firstChild.getAttribute('au-target-id');
      if (targetId) {
        let ins = instructions[targetId];

        if (ins.shadowSlot || ins.lifting || (ins.elementInstruction !== null && !ins.elementInstruction.anchorIsContainer)) {
          content.insertBefore(DOM.createComment('view'), firstChild);
        }
      }
    }

    let factory = new ViewFactory(content, instructions, resources);

    factory.surrogateInstruction = compileInstruction.compileSurrogate ? this._compileSurrogate(source, resources) : null;
    factory.part = part;

    if (cacheSize) {
      factory.setCacheSize(cacheSize);
    }

    resources._invokeHook('afterCompile', factory);

    return factory;
  }

  _compileNode(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) {
    switch (node.nodeType) {
    case 1: //element node
      return this._compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM);
    case 3: //text node
      //use wholeText to retrieve the textContent of all adjacent text nodes.
      let expression = resources.getBindingLanguage(this.bindingLanguage).inspectTextContent(resources, node.wholeText);
      if (expression) {
        let marker = DOM.createElement('au-marker');
        let auTargetID = makeIntoInstructionTarget(marker);
        (node.parentNode || parentNode).insertBefore(marker, node);
        node.textContent = ' ';
        instructions[auTargetID] = TargetInstruction.contentExpression(expression);
        //remove adjacent text nodes.
        while (node.nextSibling && node.nextSibling.nodeType === 3) {
          (node.parentNode || parentNode).removeChild(node.nextSibling);
        }
      } else {
        //skip parsing adjacent text nodes.
        while (node.nextSibling && node.nextSibling.nodeType === 3) {
          node = node.nextSibling;
        }
      }
      return node.nextSibling;
    case 11: //document fragment node
      let currentChild = node.firstChild;
      while (currentChild) {
        currentChild = this._compileNode(currentChild, resources, instructions, node, parentInjectorId, targetLightDOM);
      }
      break;
    default:
      break;
    }

    return node.nextSibling;
  }

  _compileSurrogate(node, resources) {
    let tagName = node.tagName.toLowerCase();
    let attributes = node.attributes;
    let bindingLanguage = resources.getBindingLanguage(this.bindingLanguage);
    let knownAttribute;
    let property;
    let instruction;
    let i;
    let ii;
    let attr;
    let attrName;
    let attrValue;
    let info;
    let type;
    let expressions = [];
    let expression;
    let behaviorInstructions = [];
    let values = {};
    let hasValues = false;
    let providers = [];

    for (i = 0, ii = attributes.length; i < ii; ++i) {
      attr = attributes[i];
      attrName = attr.name;
      attrValue = attr.value;

      info = bindingLanguage.inspectAttribute(resources, tagName, attrName, attrValue);
      type = resources.getAttribute(info.attrName);

      if (type) { //do we have an attached behavior?
        knownAttribute = resources.mapAttribute(info.attrName); //map the local name to real name
        if (knownAttribute) {
          property = type.attributes[knownAttribute];

          if (property) { //if there's a defined property
            info.defaultBindingMode = property.defaultBindingMode; //set the default binding mode

            if (!info.command && !info.expression) { // if there is no command or detected expression
              info.command = property.hasOptions ? 'options' : null; //and it is an optons property, set the options command
            }
          }
        }
      }

      instruction = bindingLanguage.createAttributeInstruction(resources, node, info, undefined, type);

      if (instruction) { //HAS BINDINGS
        if (instruction.alteredAttr) {
          type = resources.getAttribute(instruction.attrName);
        }

        if (instruction.discrete) { //ref binding or listener binding
          expressions.push(instruction);
        } else { //attribute bindings
          if (type) { //templator or attached behavior found
            instruction.type = type;
            configureProperties(instruction, resources);

            if (type.liftsContent) { //template controller
              throw new Error('You cannot place a template controller on a surrogate element.');
            } else { //attached behavior
              behaviorInstructions.push(instruction);
            }
          } else { //standard attribute binding
            expressions.push(instruction.attributes[instruction.attrName]);
          }
        }
      } else { //NO BINDINGS
        if (type) { //templator or attached behavior found
          instruction = BehaviorInstruction.attribute(attrName, type);
          instruction.attributes[resources.mapAttribute(attrName)] = attrValue;

          if (type.liftsContent) { //template controller
            throw new Error('You cannot place a template controller on a surrogate element.');
          } else { //attached behavior
            behaviorInstructions.push(instruction);
          }
        } else if (attrName !== 'id' && attrName !== 'part' && attrName !== 'replace-part') {
          hasValues = true;
          values[attrName] = attrValue;
        }
      }
    }

    if (expressions.length || behaviorInstructions.length || hasValues) {
      for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) {
        instruction = behaviorInstructions[i];
        instruction.type.compile(this, resources, node, instruction);
        providers.push(instruction.type.target);
      }

      for (i = 0, ii = expressions.length; i < ii; ++i) {
        expression =  expressions[i];
        if (expression.attrToRemove !== undefined) {
          node.removeAttribute(expression.attrToRemove);
        }
      }

      return TargetInstruction.surrogate(providers, behaviorInstructions, expressions, values);
    }

    return null;
  }

  _compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) {
    let tagName = node.tagName.toLowerCase();
    let attributes = node.attributes;
    let expressions = [];
    let expression;
    let behaviorInstructions = [];
    let providers = [];
    let bindingLanguage = resources.getBindingLanguage(this.bindingLanguage);
    let liftingInstruction;
    let viewFactory;
    let type;
    let elementInstruction;
    let elementProperty;
    let i;
    let ii;
    let attr;
    let attrName;
    let attrValue;
    let instruction;
    let info;
    let property;
    let knownAttribute;
    let auTargetID;
    let injectorId;

    if (tagName === 'slot') {
      if (targetLightDOM) {
        node = makeShadowSlot(this, resources, node, instructions, parentInjectorId);
      }
      return node.nextSibling;
    } else if (tagName === 'template') {
      viewFactory = this.compile(node, resources);
      viewFactory.part = node.getAttribute('part');
    } else {
      type = resources.getElement(node.getAttribute('as-element') || tagName);
      if (type) {
        elementInstruction = BehaviorInstruction.element(node, type);
        type.processAttributes(this, resources, node, attributes, elementInstruction);
        behaviorInstructions.push(elementInstruction);
      }
    }

    for (i = 0, ii = attributes.length; i < ii; ++i) {
      attr = attributes[i];
      attrName = attr.name;
      attrValue = attr.value;
      info = bindingLanguage.inspectAttribute(resources, tagName, attrName, attrValue);

      if (targetLightDOM && info.attrName === 'slot') {
        info.attrName = attrName = 'au-slot';
      }

      type = resources.getAttribute(info.attrName);
      elementProperty = null;

      if (type) { //do we have an attached behavior?
        knownAttribute = resources.mapAttribute(info.attrName); //map the local name to real name
        if (knownAttribute) {
          property = type.attributes[knownAttribute];

          if (property) { //if there's a defined property
            info.defaultBindingMode = property.defaultBindingMode; //set the default binding mode

            if (!info.command && !info.expression) { // if there is no command or detected expression
              info.command = property.hasOptions ? 'options' : null; //and it is an optons property, set the options command
            }
          }
        }
      } else if (elementInstruction) { //or if this is on a custom element
        elementProperty = elementInstruction.type.attributes[info.attrName];
        if (elementProperty) { //and this attribute is a custom property
          info.defaultBindingMode = elementProperty.defaultBindingMode; //set the default binding mode
        }
      }

      if (elementProperty) {
        instruction = bindingLanguage.createAttributeInstruction(resources, node, info, elementInstruction);
      } else {
        instruction = bindingLanguage.createAttributeInstruction(resources, node, info, undefined, type);
      }

      if (instruction) { //HAS BINDINGS
        if (instruction.alteredAttr) {
          type = resources.getAttribute(instruction.attrName);
        }

        if (instruction.discrete) { //ref binding or listener binding
          expressions.push(instruction);
        } else { //attribute bindings
          if (type) { //templator or attached behavior found
            instruction.type = type;
            configureProperties(instruction, resources);

            if (type.liftsContent) { //template controller
              instruction.originalAttrName = attrName;
              liftingInstruction = instruction;
              break;
            } else { //attached behavior
              behaviorInstructions.push(instruction);
            }
          } else if (elementProperty) { //custom element attribute
            elementInstruction.attributes[info.attrName].targetProperty = elementProperty.name;
          } else { //standard attribute binding
            expressions.push(instruction.attributes[instruction.attrName]);
          }
        }
      } else { //NO BINDINGS
        if (type) { //templator or attached behavior found
          instruction = BehaviorInstruction.attribute(attrName, type);
          instruction.attributes[resources.mapAttribute(attrName)] = attrValue;

          if (type.liftsContent) { //template controller
            instruction.originalAttrName = attrName;
            liftingInstruction = instruction;
            break;
          } else { //attached behavior
            behaviorInstructions.push(instruction);
          }
        } else if (elementProperty) { //custom element attribute
          elementInstruction.attributes[attrName] = attrValue;
        }

        //else; normal attribute; do nothing
      }
    }

    if (liftingInstruction) {
      liftingInstruction.viewFactory = viewFactory;
      node = liftingInstruction.type.compile(this, resources, node, liftingInstruction, parentNode);
      auTargetID = makeIntoInstructionTarget(node);
      instructions[auTargetID] = TargetInstruction.lifting(parentInjectorId, liftingInstruction);
    } else {
      if (expressions.length || behaviorInstructions.length) {
        injectorId = behaviorInstructions.length ? getNextInjectorId() : false;

        for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) {
          instruction = behaviorInstructions[i];
          instruction.type.compile(this, resources, node, instruction, parentNode);
          providers.push(instruction.type.target);
        }

        for (i = 0, ii = expressions.length; i < ii; ++i) {
          expression =  expressions[i];
          if (expression.attrToRemove !== undefined) {
            node.removeAttribute(expression.attrToRemove);
          }
        }

        auTargetID = makeIntoInstructionTarget(node);
        instructions[auTargetID] = TargetInstruction.normal(
          injectorId,
          parentInjectorId,
          providers,
          behaviorInstructions,
          expressions,
          elementInstruction
        );
      }

      if (elementInstruction && elementInstruction.skipContentProcessing) {
        return node.nextSibling;
      }

      let currentChild = node.firstChild;
      while (currentChild) {
        currentChild = this._compileNode(currentChild, resources, instructions, node, injectorId || parentInjectorId, targetLightDOM);
      }
    }

    return node.nextSibling;
  }
}
<commit_msg>fix(view-compiler): account for undefined element instruction<commit_after>import {ViewResources} from './view-resources';
import {ViewFactory} from './view-factory';
import {BindingLanguage} from './binding-language';
import {ViewCompileInstruction, BehaviorInstruction, TargetInstruction} from './instructions';
import {inject} from 'aurelia-dependency-injection';
import {DOM, FEATURE} from 'aurelia-pal';
import {ShadowDOM} from './shadow-dom';

let nextInjectorId = 0;
function getNextInjectorId() {
  return ++nextInjectorId;
}

function configureProperties(instruction, resources) {
  let type = instruction.type;
  let attrName = instruction.attrName;
  let attributes = instruction.attributes;
  let property;
  let key;
  let value;

  let knownAttribute = resources.mapAttribute(attrName);
  if (knownAttribute && attrName in attributes && knownAttribute !== attrName) {
    attributes[knownAttribute] = attributes[attrName];
    delete attributes[attrName];
  }

  for (key in attributes) {
    value = attributes[key];

    if (value !== null && typeof value === 'object') {
      property = type.attributes[key];

      if (property !== undefined) {
        value.targetProperty = property.name;
      } else {
        value.targetProperty = key;
      }
    }
  }
}

let lastAUTargetID = 0;
function getNextAUTargetID() {
  return (++lastAUTargetID).toString();
}

function makeIntoInstructionTarget(element) {
  let value = element.getAttribute('class');
  let auTargetID = getNextAUTargetID();

  element.setAttribute('class', (value ? value + ' au-target' : 'au-target'));
  element.setAttribute('au-target-id', auTargetID);

  return auTargetID;
}

function makeShadowSlot(compiler, resources, node, instructions, parentInjectorId) {
  let auShadowSlot = DOM.createElement('au-shadow-slot');
  DOM.replaceNode(auShadowSlot, node);

  let auTargetID = makeIntoInstructionTarget(auShadowSlot);
  let instruction = TargetInstruction.shadowSlot(parentInjectorId);

  instruction.slotName = node.getAttribute('name') || ShadowDOM.defaultSlotKey;
  instruction.slotDestination = node.getAttribute('slot');

  if (node.innerHTML.trim()) {
    let fragment = DOM.createDocumentFragment();
    let child;

    while (child = node.firstChild) {
      fragment.appendChild(child);
    }

    instruction.slotFallbackFactory = compiler.compile(fragment, resources);
  }

  instructions[auTargetID] = instruction;

  return auShadowSlot;
}

/**
* Compiles html templates, dom fragments and strings into ViewFactory instances, capable of instantiating Views.
*/
@inject(BindingLanguage, ViewResources)
export class ViewCompiler {
  /**
  * Creates an instance of ViewCompiler.
  * @param bindingLanguage The default data binding language and syntax used during view compilation.
  * @param resources The global resources used during compilation when none are provided for compilation.
  */
  constructor(bindingLanguage: BindingLanguage, resources: ViewResources) {
    this.bindingLanguage = bindingLanguage;
    this.resources = resources;
  }

  /**
  * Compiles an html template, dom fragment or string into ViewFactory instances, capable of instantiating Views.
  * @param source The template, fragment or string to compile.
  * @param resources The view resources used during compilation.
  * @param compileInstruction A set of instructions that customize how compilation occurs.
  * @return The compiled ViewFactory.
  */
  compile(source: Element|DocumentFragment|string, resources?: ViewResources, compileInstruction?: ViewCompileInstruction): ViewFactory {
    resources = resources || this.resources;
    compileInstruction = compileInstruction || ViewCompileInstruction.normal;
    source = typeof source === 'string' ? DOM.createTemplateFromMarkup(source) : source;

    let content;
    let part;
    let cacheSize;

    if (source.content) {
      part = source.getAttribute('part');
      cacheSize = source.getAttribute('view-cache');
      content = DOM.adoptNode(source.content);
    } else {
      content = source;
    }

    compileInstruction.targetShadowDOM = compileInstruction.targetShadowDOM && FEATURE.shadowDOM;
    resources._invokeHook('beforeCompile', content, resources, compileInstruction);

    let instructions = {};
    this._compileNode(content, resources, instructions, source, 'root', !compileInstruction.targetShadowDOM);

    let firstChild = content.firstChild;
    if (firstChild && firstChild.nodeType === 1) {
      let targetId = firstChild.getAttribute('au-target-id');
      if (targetId) {
        let ins = instructions[targetId];

        if (ins.shadowSlot || ins.lifting || (ins.elementInstruction && !ins.elementInstruction.anchorIsContainer)) {
          content.insertBefore(DOM.createComment('view'), firstChild);
        }
      }
    }

    let factory = new ViewFactory(content, instructions, resources);

    factory.surrogateInstruction = compileInstruction.compileSurrogate ? this._compileSurrogate(source, resources) : null;
    factory.part = part;

    if (cacheSize) {
      factory.setCacheSize(cacheSize);
    }

    resources._invokeHook('afterCompile', factory);

    return factory;
  }

  _compileNode(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) {
    switch (node.nodeType) {
    case 1: //element node
      return this._compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM);
    case 3: //text node
      //use wholeText to retrieve the textContent of all adjacent text nodes.
      let expression = resources.getBindingLanguage(this.bindingLanguage).inspectTextContent(resources, node.wholeText);
      if (expression) {
        let marker = DOM.createElement('au-marker');
        let auTargetID = makeIntoInstructionTarget(marker);
        (node.parentNode || parentNode).insertBefore(marker, node);
        node.textContent = ' ';
        instructions[auTargetID] = TargetInstruction.contentExpression(expression);
        //remove adjacent text nodes.
        while (node.nextSibling && node.nextSibling.nodeType === 3) {
          (node.parentNode || parentNode).removeChild(node.nextSibling);
        }
      } else {
        //skip parsing adjacent text nodes.
        while (node.nextSibling && node.nextSibling.nodeType === 3) {
          node = node.nextSibling;
        }
      }
      return node.nextSibling;
    case 11: //document fragment node
      let currentChild = node.firstChild;
      while (currentChild) {
        currentChild = this._compileNode(currentChild, resources, instructions, node, parentInjectorId, targetLightDOM);
      }
      break;
    default:
      break;
    }

    return node.nextSibling;
  }

  _compileSurrogate(node, resources) {
    let tagName = node.tagName.toLowerCase();
    let attributes = node.attributes;
    let bindingLanguage = resources.getBindingLanguage(this.bindingLanguage);
    let knownAttribute;
    let property;
    let instruction;
    let i;
    let ii;
    let attr;
    let attrName;
    let attrValue;
    let info;
    let type;
    let expressions = [];
    let expression;
    let behaviorInstructions = [];
    let values = {};
    let hasValues = false;
    let providers = [];

    for (i = 0, ii = attributes.length; i < ii; ++i) {
      attr = attributes[i];
      attrName = attr.name;
      attrValue = attr.value;

      info = bindingLanguage.inspectAttribute(resources, tagName, attrName, attrValue);
      type = resources.getAttribute(info.attrName);

      if (type) { //do we have an attached behavior?
        knownAttribute = resources.mapAttribute(info.attrName); //map the local name to real name
        if (knownAttribute) {
          property = type.attributes[knownAttribute];

          if (property) { //if there's a defined property
            info.defaultBindingMode = property.defaultBindingMode; //set the default binding mode

            if (!info.command && !info.expression) { // if there is no command or detected expression
              info.command = property.hasOptions ? 'options' : null; //and it is an optons property, set the options command
            }
          }
        }
      }

      instruction = bindingLanguage.createAttributeInstruction(resources, node, info, undefined, type);

      if (instruction) { //HAS BINDINGS
        if (instruction.alteredAttr) {
          type = resources.getAttribute(instruction.attrName);
        }

        if (instruction.discrete) { //ref binding or listener binding
          expressions.push(instruction);
        } else { //attribute bindings
          if (type) { //templator or attached behavior found
            instruction.type = type;
            configureProperties(instruction, resources);

            if (type.liftsContent) { //template controller
              throw new Error('You cannot place a template controller on a surrogate element.');
            } else { //attached behavior
              behaviorInstructions.push(instruction);
            }
          } else { //standard attribute binding
            expressions.push(instruction.attributes[instruction.attrName]);
          }
        }
      } else { //NO BINDINGS
        if (type) { //templator or attached behavior found
          instruction = BehaviorInstruction.attribute(attrName, type);
          instruction.attributes[resources.mapAttribute(attrName)] = attrValue;

          if (type.liftsContent) { //template controller
            throw new Error('You cannot place a template controller on a surrogate element.');
          } else { //attached behavior
            behaviorInstructions.push(instruction);
          }
        } else if (attrName !== 'id' && attrName !== 'part' && attrName !== 'replace-part') {
          hasValues = true;
          values[attrName] = attrValue;
        }
      }
    }

    if (expressions.length || behaviorInstructions.length || hasValues) {
      for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) {
        instruction = behaviorInstructions[i];
        instruction.type.compile(this, resources, node, instruction);
        providers.push(instruction.type.target);
      }

      for (i = 0, ii = expressions.length; i < ii; ++i) {
        expression =  expressions[i];
        if (expression.attrToRemove !== undefined) {
          node.removeAttribute(expression.attrToRemove);
        }
      }

      return TargetInstruction.surrogate(providers, behaviorInstructions, expressions, values);
    }

    return null;
  }

  _compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) {
    let tagName = node.tagName.toLowerCase();
    let attributes = node.attributes;
    let expressions = [];
    let expression;
    let behaviorInstructions = [];
    let providers = [];
    let bindingLanguage = resources.getBindingLanguage(this.bindingLanguage);
    let liftingInstruction;
    let viewFactory;
    let type;
    let elementInstruction;
    let elementProperty;
    let i;
    let ii;
    let attr;
    let attrName;
    let attrValue;
    let instruction;
    let info;
    let property;
    let knownAttribute;
    let auTargetID;
    let injectorId;

    if (tagName === 'slot') {
      if (targetLightDOM) {
        node = makeShadowSlot(this, resources, node, instructions, parentInjectorId);
      }
      return node.nextSibling;
    } else if (tagName === 'template') {
      viewFactory = this.compile(node, resources);
      viewFactory.part = node.getAttribute('part');
    } else {
      type = resources.getElement(node.getAttribute('as-element') || tagName);
      if (type) {
        elementInstruction = BehaviorInstruction.element(node, type);
        type.processAttributes(this, resources, node, attributes, elementInstruction);
        behaviorInstructions.push(elementInstruction);
      }
    }

    for (i = 0, ii = attributes.length; i < ii; ++i) {
      attr = attributes[i];
      attrName = attr.name;
      attrValue = attr.value;
      info = bindingLanguage.inspectAttribute(resources, tagName, attrName, attrValue);

      if (targetLightDOM && info.attrName === 'slot') {
        info.attrName = attrName = 'au-slot';
      }

      type = resources.getAttribute(info.attrName);
      elementProperty = null;

      if (type) { //do we have an attached behavior?
        knownAttribute = resources.mapAttribute(info.attrName); //map the local name to real name
        if (knownAttribute) {
          property = type.attributes[knownAttribute];

          if (property) { //if there's a defined property
            info.defaultBindingMode = property.defaultBindingMode; //set the default binding mode

            if (!info.command && !info.expression) { // if there is no command or detected expression
              info.command = property.hasOptions ? 'options' : null; //and it is an optons property, set the options command
            }
          }
        }
      } else if (elementInstruction) { //or if this is on a custom element
        elementProperty = elementInstruction.type.attributes[info.attrName];
        if (elementProperty) { //and this attribute is a custom property
          info.defaultBindingMode = elementProperty.defaultBindingMode; //set the default binding mode
        }
      }

      if (elementProperty) {
        instruction = bindingLanguage.createAttributeInstruction(resources, node, info, elementInstruction);
      } else {
        instruction = bindingLanguage.createAttributeInstruction(resources, node, info, undefined, type);
      }

      if (instruction) { //HAS BINDINGS
        if (instruction.alteredAttr) {
          type = resources.getAttribute(instruction.attrName);
        }

        if (instruction.discrete) { //ref binding or listener binding
          expressions.push(instruction);
        } else { //attribute bindings
          if (type) { //templator or attached behavior found
            instruction.type = type;
            configureProperties(instruction, resources);

            if (type.liftsContent) { //template controller
              instruction.originalAttrName = attrName;
              liftingInstruction = instruction;
              break;
            } else { //attached behavior
              behaviorInstructions.push(instruction);
            }
          } else if (elementProperty) { //custom element attribute
            elementInstruction.attributes[info.attrName].targetProperty = elementProperty.name;
          } else { //standard attribute binding
            expressions.push(instruction.attributes[instruction.attrName]);
          }
        }
      } else { //NO BINDINGS
        if (type) { //templator or attached behavior found
          instruction = BehaviorInstruction.attribute(attrName, type);
          instruction.attributes[resources.mapAttribute(attrName)] = attrValue;

          if (type.liftsContent) { //template controller
            instruction.originalAttrName = attrName;
            liftingInstruction = instruction;
            break;
          } else { //attached behavior
            behaviorInstructions.push(instruction);
          }
        } else if (elementProperty) { //custom element attribute
          elementInstruction.attributes[attrName] = attrValue;
        }

        //else; normal attribute; do nothing
      }
    }

    if (liftingInstruction) {
      liftingInstruction.viewFactory = viewFactory;
      node = liftingInstruction.type.compile(this, resources, node, liftingInstruction, parentNode);
      auTargetID = makeIntoInstructionTarget(node);
      instructions[auTargetID] = TargetInstruction.lifting(parentInjectorId, liftingInstruction);
    } else {
      if (expressions.length || behaviorInstructions.length) {
        injectorId = behaviorInstructions.length ? getNextInjectorId() : false;

        for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) {
          instruction = behaviorInstructions[i];
          instruction.type.compile(this, resources, node, instruction, parentNode);
          providers.push(instruction.type.target);
        }

        for (i = 0, ii = expressions.length; i < ii; ++i) {
          expression =  expressions[i];
          if (expression.attrToRemove !== undefined) {
            node.removeAttribute(expression.attrToRemove);
          }
        }

        auTargetID = makeIntoInstructionTarget(node);
        instructions[auTargetID] = TargetInstruction.normal(
          injectorId,
          parentInjectorId,
          providers,
          behaviorInstructions,
          expressions,
          elementInstruction
        );
      }

      if (elementInstruction && elementInstruction.skipContentProcessing) {
        return node.nextSibling;
      }

      let currentChild = node.firstChild;
      while (currentChild) {
        currentChild = this._compileNode(currentChild, resources, instructions, node, injectorId || parentInjectorId, targetLightDOM);
      }
    }

    return node.nextSibling;
  }
}
<|endoftext|>


<commit_before>import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import { GenericCard } from './../components/GenericCard'
import { Helmet } from 'react-helmet'

class Posters extends Component {
  constructor (props) {
    super(props)
    this.state = {
      topCoord: null
    }
  }
  componentDidMount () {
    const thisElement = ReactDOM.findDOMNode(this)
    const top = thisElement.getBoundingClientRect().top
    this.setState({ topCoord: top })
  }
  render () {
    return (
      <div
        className='container valign-wrapper'
        style={{
          marginBottom: 0,
          minHeight: `calc(100vh - ${this.state.topCoord || '64'}px)`
        }}
      >
        <Helmet>
          <title>Posters | Resource Center</title>
        </Helmet>

Poster Resources

            <GenericCard
              hoverable
              link='https://www.canva.com/'
              cardTitle='Create Your Own'
            >
              Canva.com is a free graphic design tool with an easy to use
              drag-and-drop interface and access to over a million photographs,
              graphics, and fonts. It is used by non-designers as well as
              professionals.
            </GenericCard>

            <GenericCard
              link='/poster-videos'
              cardTitle='Video Tutorials'
              hoverable
            >
              Learn how to create posters in Powerpoint, Publisher, Photoshop,
              and InDesign.
            </GenericCard>

            <GenericCard cardTitle='Student Design'>
              Starting fall 2017 semester, students with graphic design
              experience will be available to create your flyer or poster.
              Contact Vicki Bell, Print Services Manager at Ext. 6354, for
              pricing and more information.
            </GenericCard>

            <GenericCard cardTitle='Professional Design'>
              Marie Highfield ’91 (740-266-4926 /{' '}

                mariehighfield@sbcglobal.net
              ) is a freelance graphic designer who lives in Steubenville
              and does many design projects for the University.
            </GenericCard>

            <GenericCard cardTitle='Printing'>
              Franciscan University Mail and Print Services prices are well
              below those of area printers. They print in a variety of formats
              including table tents, flyers, and posters in sizes from 8-1/2x11”
              to 24x36” or bigger. Contact Mail and Print Services for a pricing
              sheet and format guidelines. The manager is Vicki Bell (740-283-6354{' '}
              /{' '}

                mailservices@franciscan.edu
              ).
            </GenericCard>

            <GenericCard cardTitle='University Logo'>
              For all projects, please include the official Franciscan
              University logo, either in full color or one color of your choice.
            </GenericCard>

    )
  }
}

export default Posters
<commit_msg>Add link to posters logo card<commit_after>import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import { GenericCard } from './../components/GenericCard'
import { Helmet } from 'react-helmet'

class Posters extends Component {
  constructor (props) {
    super(props)
    this.state = {
      topCoord: null
    }
  }
  componentDidMount () {
    const thisElement = ReactDOM.findDOMNode(this)
    const top = thisElement.getBoundingClientRect().top
    this.setState({ topCoord: top })
  }
  render () {
    return (
      <div
        className='container valign-wrapper'
        style={{
          marginBottom: 0,
          minHeight: `calc(100vh - ${this.state.topCoord || '64'}px)`
        }}
      >
        <Helmet>
          <title>Posters | Resource Center</title>
        </Helmet>

Poster Resources

            <GenericCard
              hoverable
              link='https://www.canva.com/'
              cardTitle='Create Your Own'
            >
              Canva.com is a free graphic design tool with an easy to use
              drag-and-drop interface and access to over a million photographs,
              graphics, and fonts. It is used by non-designers as well as
              professionals.
            </GenericCard>

            <GenericCard
              link='/poster-videos'
              cardTitle='Video Tutorials'
              hoverable
            >
              Learn how to create posters in Powerpoint, Publisher, Photoshop,
              and InDesign.
            </GenericCard>

            <GenericCard cardTitle='Student Design'>
              Starting fall 2017 semester, students with graphic design
              experience will be available to create your flyer or poster.
              Contact Vicki Bell, Print Services Manager at Ext. 6354, for
              pricing and more information.
            </GenericCard>

            <GenericCard cardTitle='Professional Design'>
              Marie Highfield ’91 ( 740-266-4926 /{' '}

                mariehighfield@sbcglobal.net
              {' '}
              ) is a freelance graphic designer who lives in Steubenville and
              does many design projects for the University.
            </GenericCard>

            <GenericCard cardTitle='Printing'>
              Franciscan University Mail and Print Services prices are well
              below those of area printers. They print in a variety of formats
              including table tents, flyers, and posters in sizes from 8-1/2x11”
              to 24x36” or bigger. Contact Mail and Print Services for a pricing
              sheet and format guidelines. The manager is Vicki Bell (740-283-6354{' '}
              /{' '}

                mailservices@franciscan.edu
              ).
            </GenericCard>

            <GenericCard cardTitle='University Logo' hoverable link='/logos'>
              For all projects, please include the official Franciscan
              University logo, either in full color or one color of your choice.
            </GenericCard>

    )
  }
}

export default Posters
<|endoftext|>


<commit_before>import F from "./firebase/init.js"
// import _ from "ramda"
import Cookies from "browser-cookies"

F.onAuthStateChanged()
 // .filter(_.compose(_.not, _.isNil))
 .observe({
   value: user => {

     console.log("onAuthStateChanged", !!user)

     if (user) {
       Cookies.set("firebase_uid", user.uid, {expires: 30})
     } else {
       Cookies.erase("firebase_uid")
     }

     // return window.ga('set', 'userId', user.uid)

   },
 })

<commit_msg>* ga track userid<commit_after>import F from "./firebase/init.js"
import Cookies from "browser-cookies"

F.onAuthStateChanged()
 .observe({
   value: user => {

     console.log("onAuthStateChanged", !!user)

     if (user) {
       Cookies.set("firebase_uid", user.uid, {expires: 30})
     } else {
       Cookies.erase("firebase_uid")
     }
   },
 })

<|endoftext|>


<commit_before>/* eslint-disable react/default-props-match-prop-types */
/* eslint-disable react/forbid-prop-types */
/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2019
 */

import React from 'react';
import PropTypes from 'prop-types';

import IonIcon from 'react-native-vector-icons/Ionicons';
import FAIcon from 'react-native-vector-icons/FontAwesome';
import FA5Icon from 'react-native-vector-icons/FontAwesome5';
import EvilIcon from 'react-native-vector-icons/EvilIcons';
import EntypoIcon from 'react-native-vector-icons/Entypo';
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';

import {
  WHITE,
  FINALISE_GREEN,
  SUSSOL_ORANGE,
  FINALISED_RED,
  DARK_GREY,
  dataTableColors,
} from '../globalStyles';

export const SortAscIcon = () => <FAIcon name="sort-asc" size={15} style={{ marginRight: 10 }} />;
export const SortNeutralIcon = () => <FAIcon name="sort" size={15} style={{ marginRight: 10 }} />;
export const SortDescIcon = () => <FAIcon name="sort-desc" size={15} style={{ marginRight: 10 }} />;

export const CheckedIcon = () => (
  <IonIcon name="md-radio-button-on" size={15} color={dataTableColors.checkableCellChecked} />
);

export const UncheckedIcon = () => (
  <IonIcon name="md-radio-button-off" size={15} color={SUSSOL_ORANGE} />
);

export const DisabledCheckedIcon = () => (
  <IonIcon name="md-radio-button-on" size={15} color={dataTableColors.checkableCellDisabled} />
);
export const DisabledUncheckedIcon = () => <MaterialIcon name="cancel" size={15} />;

export const OpenModalIcon = () => (
  <FAIcon name="angle-double-up" size={20} color={SUSSOL_ORANGE} />
);

export const MagnifyingGlassIcon = React.memo(({ size, color }) => (
  <EvilIcon name="search" size={size} color={color} />
));
MagnifyingGlassIcon.propTypes = { size: PropTypes.number, color: PropTypes.string };
MagnifyingGlassIcon.defaultProps = { size: 40, color: SUSSOL_ORANGE };

export const CancelIcon = React.memo(() => (
  <EntypoIcon name="cross" color={FINALISED_RED} size={25} />
));

export const CloseIcon = ({ size, color }) => <IonIcon name="md-close" size={size} color={color} />;
CloseIcon.defaultProps = { color: WHITE, size: 36 };
CloseIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const ExpandIcon = React.memo(() => (
  <FAIcon name="external-link" size={16} color={SUSSOL_ORANGE} />
));

export const ConfirmIcon = React.memo(({ style }) => <FAIcon name="check-circle" style={style} />);
ConfirmIcon.defaultProps = { style: { color: FINALISE_GREEN, fontSize: 40 } };
ConfirmIcon.propTypes = { style: PropTypes.object };

export const LockIcon = React.memo(({ style }) => <FAIcon name="lock" size={28} style={style} />);
LockIcon.defaultProps = { style: { color: FINALISED_RED } };
LockIcon.propTypes = { style: PropTypes.object };

export const ChevronDownIcon = React.memo(({ color, size, style }) => (
  <FA5Icon name="chevron-down" color={color} size={size} style={style} />
));
ChevronDownIcon.defaultProps = { color: WHITE, size: 20, style: {} };
ChevronDownIcon.propTypes = {
  color: PropTypes.string,
  size: PropTypes.number,
  style: PropTypes.object,
};

export const PencilIcon = React.memo(({ color, size }) => (
  <FAIcon name="pencil" color={color} size={size} />
));
PencilIcon.defaultProps = { color: WHITE, size: 20 };
PencilIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const HistoryIcon = ({ color, size }) => (
  <FA5Icon name="history" size={size} color={color} />
);
HistoryIcon.defaultProps = { color: WHITE, size: 20 };
HistoryIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const ChevronRightIcon = () => (
  <FA5Icon name="chevron-right" color={SUSSOL_ORANGE} size={20} />
);

export const FavouriteStarIcon = () => <FAIcon name="star-o" color={SUSSOL_ORANGE} size={20} />;
export const BurgerMenuIcon = () => <EntypoIcon name="menu" color={SUSSOL_ORANGE} size={30} />;
export const AddIcon = ({ size, color }) => <IonIcon name="ios-add" size={size} color={color} />;
AddIcon.defaultProps = { color: WHITE, size: 30 };
AddIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const MinusIcon = ({ size, color }) => (
  <IonIcon name="ios-remove" size={size} color={color} />
);
MinusIcon.defaultProps = { color: WHITE, size: 30 };
MinusIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const CalendarIcon = () => <FAIcon name="calendar" size={20} color={WHITE} />;

export const BackIcon = () => <FAIcon name="chevron-left" size={16} color="black" />;

export const CloudIcon = ({ color, size, style }) => (
  <IonIcon name="md-cloud" size={size} color={color} style={style} />
);
CloudIcon.defaultProps = { color: DARK_GREY, size: 30, style: {} };
CloudIcon.propTypes = { color: PropTypes.string, size: PropTypes.number, style: PropTypes.object };

export const ArrowIcon = ({ color, size, style }) => (
  <FAIcon name="exchange" size={size} style={style} color={color} />
);
ArrowIcon.defaultProps = { color: DARK_GREY, size: 16, style: { marginLeft: 10 } };
ArrowIcon.propTypes = { color: PropTypes.string, size: PropTypes.number, style: PropTypes.object };

export const WifiIcon = ({ color, size, style }) => (
  <IonIcon name="logo-rss" size={size} style={style} color={color} />
);
WifiIcon.defaultProps = { color: DARK_GREY, size: 22, style: { marginLeft: 10 } };
WifiIcon.propTypes = { color: PropTypes.string, size: PropTypes.number, style: PropTypes.object };

export const TemperatureIcon = ({ color, size, style }) => (
  <FA5Icon name="temperature-high" size={size} style={style} color={color} />
);
TemperatureIcon.defaultProps = { color: DARK_GREY, size: 25, style: { marginLeft: 10 } };
TemperatureIcon.propTypes = {
  color: PropTypes.string,
  size: PropTypes.number,
  style: PropTypes.object,
};
<commit_msg>Add HazardIcon<commit_after>/* eslint-disable react/default-props-match-prop-types */
/* eslint-disable react/forbid-prop-types */
/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2019
 */

import React from 'react';
import PropTypes from 'prop-types';

import IonIcon from 'react-native-vector-icons/Ionicons';
import FAIcon from 'react-native-vector-icons/FontAwesome';
import FA5Icon from 'react-native-vector-icons/FontAwesome5';
import EvilIcon from 'react-native-vector-icons/EvilIcons';
import EntypoIcon from 'react-native-vector-icons/Entypo';
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';

import {
  WHITE,
  FINALISE_GREEN,
  SUSSOL_ORANGE,
  FINALISED_RED,
  DARK_GREY,
  dataTableColors,
} from '../globalStyles';

export const SortAscIcon = () => <FAIcon name="sort-asc" size={15} style={{ marginRight: 10 }} />;
export const SortNeutralIcon = () => <FAIcon name="sort" size={15} style={{ marginRight: 10 }} />;
export const SortDescIcon = () => <FAIcon name="sort-desc" size={15} style={{ marginRight: 10 }} />;

export const CheckedIcon = () => (
  <IonIcon name="md-radio-button-on" size={15} color={dataTableColors.checkableCellChecked} />
);

export const UncheckedIcon = () => (
  <IonIcon name="md-radio-button-off" size={15} color={SUSSOL_ORANGE} />
);

export const DisabledCheckedIcon = () => (
  <IonIcon name="md-radio-button-on" size={15} color={dataTableColors.checkableCellDisabled} />
);
export const DisabledUncheckedIcon = () => <MaterialIcon name="cancel" size={15} />;

export const OpenModalIcon = () => (
  <FAIcon name="angle-double-up" size={20} color={SUSSOL_ORANGE} />
);

export const MagnifyingGlassIcon = React.memo(({ size, color }) => (
  <EvilIcon name="search" size={size} color={color} />
));
MagnifyingGlassIcon.propTypes = { size: PropTypes.number, color: PropTypes.string };
MagnifyingGlassIcon.defaultProps = { size: 40, color: SUSSOL_ORANGE };

export const CancelIcon = React.memo(() => (
  <EntypoIcon name="cross" color={FINALISED_RED} size={25} />
));

export const CloseIcon = ({ size, color }) => <IonIcon name="md-close" size={size} color={color} />;
CloseIcon.defaultProps = { color: WHITE, size: 36 };
CloseIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const ExpandIcon = React.memo(() => (
  <FAIcon name="external-link" size={16} color={SUSSOL_ORANGE} />
));

export const ConfirmIcon = React.memo(({ style }) => <FAIcon name="check-circle" style={style} />);
ConfirmIcon.defaultProps = { style: { color: FINALISE_GREEN, fontSize: 40 } };
ConfirmIcon.propTypes = { style: PropTypes.object };

export const LockIcon = React.memo(({ style }) => <FAIcon name="lock" size={28} style={style} />);
LockIcon.defaultProps = { style: { color: FINALISED_RED } };
LockIcon.propTypes = { style: PropTypes.object };

export const ChevronDownIcon = React.memo(({ color, size, style }) => (
  <FA5Icon name="chevron-down" color={color} size={size} style={style} />
));
ChevronDownIcon.defaultProps = { color: WHITE, size: 20, style: {} };
ChevronDownIcon.propTypes = {
  color: PropTypes.string,
  size: PropTypes.number,
  style: PropTypes.object,
};

export const PencilIcon = React.memo(({ color, size }) => (
  <FAIcon name="pencil" color={color} size={size} />
));
PencilIcon.defaultProps = { color: WHITE, size: 20 };
PencilIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const HistoryIcon = ({ color, size }) => (
  <FA5Icon name="history" size={size} color={color} />
);
HistoryIcon.defaultProps = { color: WHITE, size: 20 };
HistoryIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const ChevronRightIcon = () => (
  <FA5Icon name="chevron-right" color={SUSSOL_ORANGE} size={20} />
);

export const FavouriteStarIcon = () => <FAIcon name="star-o" color={SUSSOL_ORANGE} size={20} />;
export const BurgerMenuIcon = () => <EntypoIcon name="menu" color={SUSSOL_ORANGE} size={30} />;
export const AddIcon = ({ size, color }) => <IonIcon name="ios-add" size={size} color={color} />;
AddIcon.defaultProps = { color: WHITE, size: 30 };
AddIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const MinusIcon = ({ size, color }) => (
  <IonIcon name="ios-remove" size={size} color={color} />
);
MinusIcon.defaultProps = { color: WHITE, size: 30 };
MinusIcon.propTypes = { color: PropTypes.string, size: PropTypes.number };

export const CalendarIcon = () => <FAIcon name="calendar" size={20} color={WHITE} />;

export const BackIcon = () => <FAIcon name="chevron-left" size={16} color="black" />;

export const CloudIcon = ({ color, size, style }) => (
  <IonIcon name="md-cloud" size={size} color={color} style={style} />
);
CloudIcon.defaultProps = { color: DARK_GREY, size: 30, style: {} };
CloudIcon.propTypes = { color: PropTypes.string, size: PropTypes.number, style: PropTypes.object };

export const ArrowIcon = ({ color, size, style }) => (
  <FAIcon name="exchange" size={size} style={style} color={color} />
);
ArrowIcon.defaultProps = { color: DARK_GREY, size: 16, style: { marginLeft: 10 } };
ArrowIcon.propTypes = { color: PropTypes.string, size: PropTypes.number, style: PropTypes.object };

export const WifiIcon = ({ color, size, style }) => (
  <IonIcon name="logo-rss" size={size} style={style} color={color} />
);
WifiIcon.defaultProps = { color: DARK_GREY, size: 22, style: { marginLeft: 10 } };
WifiIcon.propTypes = { color: PropTypes.string, size: PropTypes.number, style: PropTypes.object };

export const TemperatureIcon = ({ color, size, style }) => (
  <FA5Icon name="temperature-high" size={size} style={style} color={color} />
);
TemperatureIcon.defaultProps = { color: DARK_GREY, size: 25, style: { marginLeft: 10 } };
TemperatureIcon.propTypes = {
  color: PropTypes.string,
  size: PropTypes.number,
  style: PropTypes.object,
};

export const HazardIcon = ({ color, size, style }) => (
  <FA5Icon name="exclamation-triangle" size={size} style={style} color={color} />
);
HazardIcon.defaultProps = { color: SUSSOL_ORANGE, size: 25, style: {} };
HazardIcon.propTypes = {
  color: PropTypes.string,
  size: PropTypes.number,
  style: PropTypes.object,
};
<|endoftext|>


<commit_before>//= require ember
//= require ember-data
//= require ./contact

Frabjous.Presence = DS.Model.extend({
  from:      DS.attr('jidString'),
  to:        DS.attr('jidString'),
  type:      DS.attr('string'),
  status:    DS.attr('string'),
  show:      DS.attr('string'),
  subject:   DS.attr('string'),
  priority:  DS.attr('number'),
  contact:   DS.belongsTo('Frabjous.Contact'),
  didLoad: function(){
    var contact;
    var type              = Frabjous.Contact;
    var contact_id        = this.get('from').toString();
    var contact_client_id = Frabjous.Store.clientIdForId(type, contact_id);

    if( Ember.none(contact_client_id) ){
      // No contact exists, so create one
      Frabjous.Store.load(type,{jid: this.get('from'), _presence_history:[this.get('id')]});
      contact = Frabjous.Store.find(type,contact_id);
    }else{
      // Update contact
      contact = Frabjous.Store.find(type,contact_id);
      contact.get('_presence_history').addObject(this);
    }

    this.set('contact',contact);
  }
});

Frabjous.Contact.reopen({
  // Allows me to override the ordering in XEP-0203, I don't like this method
  _presence_history: DS.hasMany('Frabjous.Presence'),
  presence_history: function(){ return this.get('_presence_history'); }.property('_presence_history'),
  presence: function(){
    return this.get('presence_history').get('lastObject');
  }.property('presence_history')
});

Frabjous.Parser.register("Presence", function(stanza){

  if( stanza.is_presence() ){
    var parsed = {};
    parsed.id       = stanza.id();
    parsed.from     = stanza.from();
    parsed.to       = stanza.to();
    parsed.type     = stanza.type();
    parsed.show     = stanza.root().find('show').text();
    parsed.status   = stanza.root().find('status').text();
    parsed.priority = parseInt(stanza.root().find('priority').text(),10) || 0;
    parsed.frabjous_type = Frabjous.Presence;
    return parsed;
  }

});<commit_msg>Tidy: Shortened code for contact loading with presence<commit_after>//= require ember
//= require ember-data
//= require ./contact

Frabjous.Presence = DS.Model.extend({
  from:      DS.attr('jidString'),
  to:        DS.attr('jidString'),
  type:      DS.attr('string'),
  status:    DS.attr('string'),
  show:      DS.attr('string'),
  subject:   DS.attr('string'),
  priority:  DS.attr('number'),
  contact:   DS.belongsTo('Frabjous.Contact'),
  didLoad: function(){
    var contact;
    var type      = Frabjous.Contact;
    var id        = this.get('from').toString();
    var client_id = Frabjous.Store.clientIdForId(type, id);

    if( Ember.none(client_id) ){
      // No contact exists, so create one
      Frabjous.Store.load(type,{jid: id, _presence_history:[this.get('id')]});
      contact = Frabjous.Store.find(type,id);
    }else{
      // Update contact
      contact = Frabjous.Store.find(type,id);
      contact.get('_presence_history').addObject(this);
    }

    this.set('contact',contact);
  }
});

Frabjous.Contact.reopen({
  // Allows me to override the ordering in XEP-0203, I don't like this method
  _presence_history: DS.hasMany('Frabjous.Presence'),
  presence_history: function(){ return this.get('_presence_history'); }.property('_presence_history'),
  presence: function(){
    return this.get('presence_history').get('lastObject');
  }.property('presence_history')
});

Frabjous.Parser.register("Presence", function(stanza){

  if( stanza.is_presence() ){
    var parsed = {};
    parsed.id       = stanza.id();
    parsed.from     = stanza.from();
    parsed.to       = stanza.to();
    parsed.type     = stanza.type();
    parsed.show     = stanza.root().find('show').text();
    parsed.status   = stanza.root().find('status').text();
    parsed.priority = parseInt(stanza.root().find('priority').text(),10) || 0;
    parsed.frabjous_type = Frabjous.Presence;
    return parsed;
  }

});<|endoftext|>


<commit_before>'use strict';

var util = require('gulp-util');

module.exports = {
    dev_path: './src/',
    dist_path: './dist/',
    doc_path: './doc/',
    module: {
        name: 'pentaho-angular-toolkit',
        dist_path: 'module_dist',
        files: [
            'README.md',
            'LICENSE',
            'dist/**/*',
            'module_tmp/**/.*',
            'module_tmp/**/*'
        ]
    },
    log:log
};

/**
* Log a message or series of messages using chalk's blue color.
* Can pass in a string, object or array.
*/
function log(msg) {
    if (typeof(msg) === 'object') {
        for (var item in msg) {
            if (msg.hasOwnProperty(item)) {
                util.log(util.colors.blue(msg[item]));
            }
        }
    } else {
        util.log(util.colors.blue(msg));
    }
}
<commit_msg>Changed path of module resources folder from module_tmp to module_res.<commit_after>'use strict';

var util = require('gulp-util');

module.exports = {
    dev_path: './src/',
    dist_path: './dist/',
    doc_path: './doc/',
    module: {
        name: 'pentaho-angular-toolkit',
        dist_path: 'module_dist',
        files: [
            'README.md',
            'LICENSE',
            'dist/**/*',
            'module_res/**/.*',
            'module_res/**/*'
        ]
    },
    log:log
};

/**
* Log a message or series of messages using chalk's blue color.
* Can pass in a string, object or array.
*/
function log(msg) {
    if (typeof(msg) === 'object') {
        for (var item in msg) {
            if (msg.hasOwnProperty(item)) {
                util.log(util.colors.blue(msg[item]));
            }
        }
    } else {
        util.log(util.colors.blue(msg));
    }
}
<|endoftext|>


<commit_before>var decodeEntities = (function() {
    // this prevents any overhead from creating the object each time
    var element = document.createElement('div');

    function decodeHTMLEntities (str) {
        if(str && typeof str === 'string') {
            // strip script/html tags
            str = str.replace(/


<commit_before>var game = new Phaser.Game(500, 400, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render});

function preload()
{
	//game.load.image("checker", "assets/checker.png");
	game.load.atlas('game', 'assets/data/game.png', 'assets/data/game.json');
	game.load.atlas('enemy', 'assets/data/enemy.png', 'assets/data/enemy.json');
	//game.load.atlasXML('enemy', 'assets/data/enemy.png', 'assets/data/enemy.xml');

	currentState = States.LOAD;
}

var States =
{
    LOAD:0,
    START:1,
    GAME:2,
    WIN:3,
    END:4,
    FINISH:5,
    RESTART:6
};

var player;
var enemy;
var currentState;
var gameObjects;
function create()
{
	game.physics.startSystem(Phaser.Physics.ARCADE);
	gameObjects = game.add.group();

	enemy = game.add.sprite( game.world.centerX, game.world.centerY, 'enemy');

	game.physics.arcade.enable([enemy]);

	enemy.body.collideWorldBounds = true;
	enemy.animations.add('death', Phaser.Animation.generateFrameNames('enemyDeath_', 0, 15, '.png', 2), 12, false);
	enemy.animations.add('idle', Phaser.Animation.generateFrameNames('enemyIdle_',0,3,'.png',2).concat(Phaser.Animation.generateFrameNames('enemyIdle_',3,0,'.png',2)), 6, true);
	enemy.animations.play('idle');
    enemy.anchor.setTo(0.5,1);
    enemy.scale.setTo(2);
    enemy.scale.x *= -1;

	currentState = States.GAME;
}

function update()
{
	if(game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
		enemy.animations.play('death').onComplete.add(onEnemyDeath, this);
}

function onEnemyDeath()
{
	enemy.animations.play('idle');
}

function onPlayerHit(_ball, _player)
{
	currentState = States.END;
	ball.kill();
	console.log('muriendo');
	player.animations.getAnimation('death').onComplete.add(onPlayerDeath, this);
	player.animations.play('death');
}

var title;
function onPlayerDeath()
{
	title = game.add.sprite(game.world.centerX, 150, 'game');
	title.animations.add('show', [2,3,4], 10, true);
	title.animations.play('show');
	title.anchor.setTo(0.5, 0.5);
	title.scale.setTo(2);

	gameObjects.add(title);

	game.time.events.add(Phaser.Timer.SECOND * 2, onRestart, this);
}

function onRestart()
{
	gameObjects.destroy(true);
	create();
}

var canHit;
function onHitComplete()
{
	canHit = true;
}

var playerSpeed = 150;
var jumpSpeed = 400;
var lastDirection = 0;
var velocity = new Phaser.Point();

function ShowIntro()
{
	enemy.animations.play('show');
	currentState = States.START;
}

function onEnemyShowLooped()
{
	enemyShowCounts--;
	if (enemyShowCounts <= 0) {
		enemy.animations.play('idle');
		player.animations.play('surprise');
		game.time.events.add(Phaser.Timer.SECOND * 1, startGame, this);
	}
}

var enemyShowCounts = 3;
function startGame()
{
	player.animations.play('idle');
	enemy.animations.play('walk');
	currentState = States.GAME;
}

function winGame()
{
	win = true;
	enemy.body.velocity.x = 0;
	enemy.animations.play('idle');
}

function showOutro()
{
	currentState = States.WIN;
	player.body.velocity.x = 0;
	player.animations.play('idle');
	velocity.setTo(0);

	meteorite = game.add.sprite((player.x + game.width / 2) - 50, 35, 'meteorite');
	game.physics.arcade.enable(meteorite);

	meteorite.body.collideWorldBounds = true;
	meteorite.animations.add('show',[0, 1,2,3,4,5,6,7,8,9], 5, true);
    meteorite.animations.play('show');
    meteorite.body.setSize(20, 20, 0, 0);

	gameObjects.add(meteorite);

	game.time.events.add(Phaser.Timer.SECOND * 1, onShowOutro, this);
}

var meteorite;
var meteoriteSpeed = 200;
function onShowOutro()
{
	currentState = States.FINISH;

	direction = new Phaser.Point(player.x - meteorite.x, (player.y - 32) - meteorite.y);
	direction = Phaser.Point.normalize(direction);

	enemy.animations.play('death');
	player.animations.play('idleStay');
}

function onPlayerCollide(_meteorite, _player)
{
	currentState = States.RESTART;
	meteorite.kill();

	player.body.velocity.setTo(0);
	player.animations.getAnimation('death').onComplete.add(onPlayerDeath, this);
	player.animations.play('death');
}

var direction;
var win = false;
var winPosition = 1200;
var stopPosition = 1400;
/* function update()
{
	if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
	{
		canHit = false;
		player.animations.play('hit');
	}
	game.physics.arcade.collide(player, platform, stepOnPlatform, null, this);
	game.physics.arcade.collide(enemy, player, onPlayerReached, null, this);

	if (currentState == States.FINISH)
	{
		meteorite.body.velocity.x = direction.x * meteoriteSpeed;
		meteorite.body.velocity.y = direction.y * meteoriteSpeed;
		game.physics.arcade.collide(meteorite, player, onPlayerCollide, null, this);
	}

	if (currentState == States.GAME)
	{
		if (player.x >= winPosition)
		{
			winGame();
		}

		if (player.x >= stopPosition)
		{
			showOutro();
			return;
		}

		player.body.velocity.x = 0;
		velocity.setTo(0);

		// if (game.input.keyboard.isDown(Phaser.Keyboard.A))
	 //    {
	 //        velocity.x = -1;
	 //    }
	   	if (game.input.keyboard.isDown(Phaser.Keyboard.D))
	    {
	        velocity.x = 1;
	    }
	    // if (game.input.keyboard.isDown(Phaser.Keyboard.S)) {
	    // 	velocity.y = 1;
	    // }
	    // if (game.input.keyboard.isDown(Phaser.Keyboard.W)) {
	    // 	velocity.y = -1;
	    // }

	    if (velocity.x != 0)
	    {
		    if (velocity.x > 0)
		    {
		    	player.animations.play('walk');
		    	if (player.scale.x < 0)
		   			flip();
		    	lastDirection = 0;
		    }
		   	else if (velocity.x < 0)
		   	{
		   		player.animations.play('walk');
		   		if (player.scale.x > 0)
		   			flip();
		   		lastDirection = 1;
		   	}
		}
		// else
		// {
		// 	if (velocity.y > 0)
		//     {
		//     	player.animations.play((lastDirection == 0) ? 'walk' : 'walk');
		//     }
		//    	else if (velocity.y < 0)
		//    	{
		//    		player.animations.play((lastDirection == 0) ? 'walk' : 'walk');
		//    	}
		// }

		velocity = Phaser.Point.normalize(velocity);
		velocity.x *= playerSpeed;
		player.body.velocity.x = velocity.x;

		if(!win)
			enemy.body.velocity.x = playerSpeed;

	   	if(game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) && onFloor) {
	   		onFloor = false;
	   		player.body.velocity.y = -jumpSpeed;
	    } else{
	    	if (velocity.x == 0)
		    {
		        //  Stand still
		        player.animations.play('idle');
		    }
	    }
	}
} */

function onPlayerReached(_enemy, _player)
{
	console.log('asd');
	currentState = States.END;
	player.kill();
	enemy.body.velocity.setTo(0);
	enemy.animations.play('idle');
	onPlayerDeath();
}

var onFloor = false;
function stepOnPlatform(_player, _platform)
{
	player.body.velocity.y = 0;
	onFloor = true;
}

function flip()
{
	player.scale.x *= -1;
}

function render() {
	//game.debug.body(player);
 //    game.debug.body(enemy);
 //    if (meteorite != null)
 //    	game.debug.body(meteorite);

 //    var zone = game.camera.deadzone;
 //    game.context.fillStyle = 'rgba(255,0,0,0.6)';
 //    game.context.fillRect(zone.x, zone.y, zone.width, zone.height);

 //    game.debug.spriteInfo(enemy, 32, 32);
 //    game.debug.spriteInfo(player, 400, 32);
}
<commit_msg>Explosion Test<commit_after>var game = new Phaser.Game(500, 400, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render});

function preload()
{
	//game.load.image("checker", "assets/checker.png");
	game.load.atlas('game', 'assets/data/game.png', 'assets/data/game.json');
	game.load.atlas('enemy', 'assets/data/enemy.png', 'assets/data/enemy.json');
	game.load.atlas('explosion', 'assets/data/explosion.png', 'assets/data/explosion.json')
	//game.load.atlasXML('enemy', 'assets/data/enemy.png', 'assets/data/enemy.xml');

	currentState = States.LOAD;
}

var States =
{
    LOAD:0,
    START:1,
    GAME:2,
    WIN:3,
    END:4,
    FINISH:5,
    RESTART:6
};

var player;
var enemy;
var currentState;
var gameObjects;
function create()
{
	game.physics.startSystem(Phaser.Physics.ARCADE);
	gameObjects = game.add.group();

	enemy = game.add.sprite( game.world.centerX, game.world.centerY, 'enemy');

	game.physics.arcade.enable([enemy]);

	enemy.body.collideWorldBounds = true;
	enemy.animations.add('death', Phaser.Animation.generateFrameNames('enemyDeath_', 0, 15, '.png', 2), 12, false);
	enemy.animations.add('idle', Phaser.Animation.generateFrameNames('enemyIdle_',0,3,'.png',2).concat(Phaser.Animation.generateFrameNames('enemyIdle_',3,0,'.png',2)), 6, true);
	enemy.animations.play('idle');
    enemy.anchor.setTo(0.5,1);
    enemy.scale.setTo(2);
    enemy.scale.x *= -1;

	var explosion = game.add.sprite( game.world.centerX, 400, 'explosion');
	explosion.animations.add('explode').onComplete.add(onExplosionComplete,explosion);
	explosion.animations.play('explode', 30, true);
	explosion.anchor.setTo(0.5,1);
	explosion.scale.setTo(5);

	currentState = States.GAME;
}

function onExplosionComplete(_explosion)
{
	_explosion.kill();
}

function update()
{
	if(game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
		enemy.animations.play('death').onComplete.add(onEnemyDeath, this);
}

function onEnemyDeath()
{
	enemy.animations.play('idle');
}

function onPlayerHit(_ball, _player)
{
	currentState = States.END;
	ball.kill();
	console.log('muriendo');
	player.animations.getAnimation('death').onComplete.add(onPlayerDeath, this);
	player.animations.play('death');
}

var title;
function onPlayerDeath()
{
	title = game.add.sprite(game.world.centerX, 150, 'game');
	title.animations.add('show', [2,3,4], 10, true);
	title.animations.play('show');
	title.anchor.setTo(0.5, 0.5);
	title.scale.setTo(2);

	gameObjects.add(title);

	game.time.events.add(Phaser.Timer.SECOND * 2, onRestart, this);
}

function onRestart()
{
	gameObjects.destroy(true);
	create();
}

var canHit;
function onHitComplete()
{
	canHit = true;
}

var playerSpeed = 150;
var jumpSpeed = 400;
var lastDirection = 0;
var velocity = new Phaser.Point();

function ShowIntro()
{
	enemy.animations.play('show');
	currentState = States.START;
}

function onEnemyShowLooped()
{
	enemyShowCounts--;
	if (enemyShowCounts <= 0) {
		enemy.animations.play('idle');
		player.animations.play('surprise');
		game.time.events.add(Phaser.Timer.SECOND * 1, startGame, this);
	}
}

var enemyShowCounts = 3;
function startGame()
{
	player.animations.play('idle');
	enemy.animations.play('walk');
	currentState = States.GAME;
}

function winGame()
{
	win = true;
	enemy.body.velocity.x = 0;
	enemy.animations.play('idle');
}

function showOutro()
{
	currentState = States.WIN;
	player.body.velocity.x = 0;
	player.animations.play('idle');
	velocity.setTo(0);

	meteorite = game.add.sprite((player.x + game.width / 2) - 50, 35, 'meteorite');
	game.physics.arcade.enable(meteorite);

	meteorite.body.collideWorldBounds = true;
	meteorite.animations.add('show',[0, 1,2,3,4,5,6,7,8,9], 5, true);
    meteorite.animations.play('show');
    meteorite.body.setSize(20, 20, 0, 0);

	gameObjects.add(meteorite);

	game.time.events.add(Phaser.Timer.SECOND * 1, onShowOutro, this);
}

var meteorite;
var meteoriteSpeed = 200;
function onShowOutro()
{
	currentState = States.FINISH;

	direction = new Phaser.Point(player.x - meteorite.x, (player.y - 32) - meteorite.y);
	direction = Phaser.Point.normalize(direction);

	enemy.animations.play('death');
	player.animations.play('idleStay');
}

function onPlayerCollide(_meteorite, _player)
{
	currentState = States.RESTART;
	meteorite.kill();

	player.body.velocity.setTo(0);
	player.animations.getAnimation('death').onComplete.add(onPlayerDeath, this);
	player.animations.play('death');
}

var direction;
var win = false;
var winPosition = 1200;
var stopPosition = 1400;
/* function update()
{
	if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
	{
		canHit = false;
		player.animations.play('hit');
	}
	game.physics.arcade.collide(player, platform, stepOnPlatform, null, this);
	game.physics.arcade.collide(enemy, player, onPlayerReached, null, this);

	if (currentState == States.FINISH)
	{
		meteorite.body.velocity.x = direction.x * meteoriteSpeed;
		meteorite.body.velocity.y = direction.y * meteoriteSpeed;
		game.physics.arcade.collide(meteorite, player, onPlayerCollide, null, this);
	}

	if (currentState == States.GAME)
	{
		if (player.x >= winPosition)
		{
			winGame();
		}

		if (player.x >= stopPosition)
		{
			showOutro();
			return;
		}

		player.body.velocity.x = 0;
		velocity.setTo(0);

		// if (game.input.keyboard.isDown(Phaser.Keyboard.A))
	 //    {
	 //        velocity.x = -1;
	 //    }
	   	if (game.input.keyboard.isDown(Phaser.Keyboard.D))
	    {
	        velocity.x = 1;
	    }
	    // if (game.input.keyboard.isDown(Phaser.Keyboard.S)) {
	    // 	velocity.y = 1;
	    // }
	    // if (game.input.keyboard.isDown(Phaser.Keyboard.W)) {
	    // 	velocity.y = -1;
	    // }

	    if (velocity.x != 0)
	    {
		    if (velocity.x > 0)
		    {
		    	player.animations.play('walk');
		    	if (player.scale.x < 0)
		   			flip();
		    	lastDirection = 0;
		    }
		   	else if (velocity.x < 0)
		   	{
		   		player.animations.play('walk');
		   		if (player.scale.x > 0)
		   			flip();
		   		lastDirection = 1;
		   	}
		}
		// else
		// {
		// 	if (velocity.y > 0)
		//     {
		//     	player.animations.play((lastDirection == 0) ? 'walk' : 'walk');
		//     }
		//    	else if (velocity.y < 0)
		//    	{
		//    		player.animations.play((lastDirection == 0) ? 'walk' : 'walk');
		//    	}
		// }

		velocity = Phaser.Point.normalize(velocity);
		velocity.x *= playerSpeed;
		player.body.velocity.x = velocity.x;

		if(!win)
			enemy.body.velocity.x = playerSpeed;

	   	if(game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) && onFloor) {
	   		onFloor = false;
	   		player.body.velocity.y = -jumpSpeed;
	    } else{
	    	if (velocity.x == 0)
		    {
		        //  Stand still
		        player.animations.play('idle');
		    }
	    }
	}
} */

function onPlayerReached(_enemy, _player)
{
	console.log('asd');
	currentState = States.END;
	player.kill();
	enemy.body.velocity.setTo(0);
	enemy.animations.play('idle');
	onPlayerDeath();
}

var onFloor = false;
function stepOnPlatform(_player, _platform)
{
	player.body.velocity.y = 0;
	onFloor = true;
}

function flip()
{
	player.scale.x *= -1;
}

function render() {
	//game.debug.body(player);
 //    game.debug.body(enemy);
 //    if (meteorite != null)
 //    	game.debug.body(meteorite);

 //    var zone = game.camera.deadzone;
 //    game.context.fillStyle = 'rgba(255,0,0,0.6)';
 //    game.context.fillRect(zone.x, zone.y, zone.width, zone.height);

 //    game.debug.spriteInfo(enemy, 32, 32);
 //    game.debug.spriteInfo(player, 400, 32);
}
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');
var cdnizer = require('gulp-cdnizer');

gulp.task('cdnize', ['wiredep'], function () {
  return gulp.src('src/*.html')
  .pipe(cdnizer({
    //configure cdnizer's version and naming settings
    allowRev: false, //stricter version matching
    allowMin: true, //request minified files
    relativeRoot: 'src/', //asset root directory
    fallbackTest: '<script>if(!(${ test })) cdnizerLoad("${ filepathRel }");</script>',
    files: [
      //manual cdn configuations for all dependencies,
      //including tests for missing individual angular modules
      {
        file: '**/angular/angular.js',
        cdn: 'google:angular:${ filenameMin }'
      },
      {
        file: '**/angular-sanitize/*.js',
        package: 'angular-sanitize',
        cdn: 'google:angular:${ filenameMin }',
        test: 'testModule("ngSanitize")'
      },
      {
        file: '**/angular-touch/*.js',
        package: 'angular-touch',
        cdn: 'google:angular:${ filenameMin }',
        test: 'testModule("ngTouch")'
      },
      {
        file: '**/angular-messages/*.js',
        package: 'angular-messages',
        cdn: 'google:angular:${ filenameMin }',
        test: 'testModule("ngMessages")'
      },
      {
        file: '**/angular-bootstrap/*.js',
        package: 'angular-bootstrap',
        cdn: 'cdnjs:angular-ui-bootstrap:${ filenameMin }',
        test: 'testModule("ui.bootstrap")'
      },
      {
        file: '**/lodash/*.js',
        package: 'lodash',
        cdn: 'cdnjs:lodash.js:${ filenameMin }',
        test: 'window._'
      },
      {
        file: '**/angular-dialog-service/**/*.js',
        package: 'angular-dialog-service',
        cdn: 'cdnjs:angular-dialog-service:${ filenameMin }',
        test: 'testModule("dialogs.main")'
      },
      {
        file: '**/angular-dialog-service/**/*.css',
        package: 'angular-dialog-service',
        cdn: 'cdnjs:angular-dialog-service:${ filenameMin }',
      },
      {
        file: '**/ui-router-extras/**/*.js',
        package: 'ui-router-extras',
        cdn: '//cdnjs.cloudflare.com/ajax/libs/ui-router-extras/${ version }/${ filenameMin }',
        test: 'testModule("ct.ui.router.extras")'
      },
      // {
      //   file: '**/angulartics-google-analytics/**/*.js',
      //   cdn: '//cdnjs.cloudflare.com/ajax/libs/angulartics-google-analytics/0.1.1/${ filenameMin }',
      //   test: 'testModule("angulartics.google.analytics")'
      // },
      {
        file: '**/ngDialog/**/*.js',
        package: 'ngDialog',
        cdn: 'cdnjs:ng-dialog:js/${ filenameMin }',
        test: 'testModule("ngDialog")'
      },
      {
        file:'**/ngDialog/**/*.css',
        package: 'ngDialog',
        cdn: 'cdnjs:ng-dialog:css/${ filenameMin }'
      },
      {
        file: '**/ment.io/**/*.js',
        package: 'ment.io',
        cdn: '//cdn.jsdelivr.net/angular.ment-io/${ version }/${ filenameMin }',
        test: 'testModule("mentio")'
      },
      {
        file: '**/angular-resource/*.js',
        package: 'angular-resource',
        cdn: 'google:angular:${ filenameMin }',
        test: 'testModule("ngResource")'
      },
      {
        file: '**/angular-translate/*.js',
        package: 'angular-translate',
        cdn: '//cdn.jsdelivr.net/angular.translate/${ version }/${ filenameMin }',
        test: 'testModule("pascalprecht.translate")'
      },
      {
        file: '**/waypoints/**/*.js',
        package: 'waypoints',
        cdn: 'cdnjs:waypoints:${ filename }',
        test: 'Waypoint'
      },
      {
        file: '**/angular-ui-grid/**/*.js',
        package: 'angular-ui-grid',
        cdn: 'cdnjs:angular-ui-grid:${ filenameMin }',
        test: 'testModule("ui.grid")'
      },
      {
        file: '**/angular-loading-bar/**/*.js',
        package: 'angular-loading-bar',
        cdn: 'cdnjs:angular-loading-bar:${ filenameMin }',
        test: 'testModule("angular-loading-bar")'
      },
      {
        file: '**/angular-loading-bar/**/*.css',
        package: 'angular-loading-bar',
        cdn: 'cdnjs:angular-loading-bar:${ filenameMin }',
      },
      {
        file: '**/angular-ui-router/**/*.js',
        package: 'angular-ui-router',
        cdn: 'cdnjs:angular-ui-router:${ filenameMin }',
        test: 'testModule("ui.router")'
      },
      {
        file: '**/api-check/**/*.js',
        package: 'api-check',
        cdn: 'cdnjs:api-check:${ filenameMin }',
        test: 'window.apiCheck'
      },
      {
        file: '**/angular-formly/**/*.js',
        package: 'angular-formly',
        cdn: 'cdnjs:angular-formly:${ filenameMin }',
        test: 'testModule("formly")'
      },
      {
        file: '**/angulartics/**/*.js',
        package: 'angulartics',
        cdn: 'cdnjs:angulartics:${ filenameMin }',
        test: 'testModule("angulartics")'
      },
      {
        file: '**/angular-scroll/*.js',
        package: 'angular-scroll',
        cdn: 'cdnjs:angular-scroll:${ filenameMin }',
        test: 'testModule("duScroll")'
      },
      {
        file: '**/angular-elastic/*.js',
        package: 'angular-elastic',
        cdn: 'cdnjs:angular-elastic:${ filenameMin }',
        test: 'testModule("monospaced.elastic")'
      },
      {
        file: '**/angular-formly-templates-bootstrap/**/*.js',
        package: 'angular-formly-templates-bootstrap',
        cdn: 'cdnjs:angular-formly-templates-bootstrap:${ filenameMin }',
        test: 'testModule("formlyBootstrap")'
      },
      {
        file: '**/d3/*.js',
        package: 'd3',
        cdn: 'cdnjs:d3:${ filenameMin }',
        test: 'window.d3'
      },
      {
        file : '**/dimple/**/*.js',
        package: 'dimple',
        cdn: '//cdnjs.cloudflare.com/ajax/libs/dimple/${ version }/dimple.latest.min.js',
        test: 'window.dimple'
      }
    ]
  }))

    .pipe(gulp.dest('.tmp'))
});
<commit_msg>Switched to using cloudflare's cdn for serving all vendor libraries<commit_after>'use strict';

var gulp = require('gulp');
var cdnizer = require('gulp-cdnizer');

gulp.task('cdnize', ['wiredep'], function () {
  return gulp.src('src/*.html')
  .pipe(cdnizer({
    //configure cdnizer's version and naming settings
    allowRev: false, //stricter version matching
    allowMin: true, //request minified files
    relativeRoot: 'src/', //asset root directory
    fallbackTest: '<script>if(!(${ test })) cdnizerLoad("${ filepathRel }");</script>',
    files: [
      //manual cdn configuations for all dependencies,
      //including tests for missing individual angular modules
      {
        file: '**/angular/angular.js',
        package: 'angular',
        // cdn: 'cdnjs:angular:${ filenameMin }'
        cdn: '//cdnjs.cloudflare.com/ajax/libs/angular.js/${ version }/${ filenameMin }',
      },
      {
        file: '**/angular-sanitize/*.js',
        package: 'angular-sanitize',
        cdn: '//cdnjs.cloudflare.com/ajax/libs/angular.js/${ version }/${ filenameMin }',
        test: 'testModule("ngSanitize")'
      },
      {
        file: '**/angular-touch/*.js',
        package: 'angular-touch',
        cdn: '//cdnjs.cloudflare.com/ajax/libs/angular.js/${ version }/${ filenameMin }',
        test: 'testModule("ngTouch")'
      },
      {
        file: '**/angular-messages/*.js',
        package: 'angular-messages',
        cdn: '//cdnjs.cloudflare.com/ajax/libs/angular.js/${ version }/${ filenameMin }',
        test: 'testModule("ngMessages")'
      },
      {
        file: '**/angular-bootstrap/*.js',
        package: 'angular-bootstrap',
        cdn: 'cdnjs:angular-ui-bootstrap:${ filenameMin }',
        test: 'testModule("ui.bootstrap")'
      },
      {
        file: '**/lodash/*.js',
        package: 'lodash',
        cdn: 'cdnjs:lodash.js:${ filenameMin }',
        test: 'window._'
      },
      {
        file: '**/angular-dialog-service/**/*.js',
        package: 'angular-dialog-service',
        cdn: 'cdnjs:angular-dialog-service:${ filenameMin }',
        test: 'testModule("dialogs.main")'
      },
      {
        file: '**/angular-dialog-service/**/*.css',
        package: 'angular-dialog-service',
        cdn: 'cdnjs:angular-dialog-service:${ filenameMin }',
      },
      {
        file: '**/ui-router-extras/**/*.js',
        package: 'ui-router-extras',
        cdn: '//cdnjs.cloudflare.com/ajax/libs/ui-router-extras/${ version }/${ filenameMin }',
        test: 'testModule("ct.ui.router.extras")'
      },
      // {
      //   file: '**/angulartics-google-analytics/**/*.js',
      //   cdn: '//cdnjs.cloudflare.com/ajax/libs/angulartics-google-analytics/0.1.1/${ filenameMin }',
      //   test: 'testModule("angulartics.google.analytics")'
      // },
      {
        file: '**/ngDialog/**/*.js',
        package: 'ngDialog',
        cdn: 'cdnjs:ng-dialog:js/${ filenameMin }',
        test: 'testModule("ngDialog")'
      },
      {
        file:'**/ngDialog/**/*.css',
        package: 'ngDialog',
        cdn: 'cdnjs:ng-dialog:css/${ filenameMin }'
      },
      {
        file: '**/ment.io/**/*.js',
        package: 'ment.io',
        cdn: '//cdn.jsdelivr.net/angular.ment-io/${ version }/${ filenameMin }',
        test: 'testModule("mentio")'
      },
      {
        file: '**/angular-resource/*.js',
        package: 'angular-resource',
        cdn: '//cdnjs.cloudflare.com/ajax/libs/angular.js/${ version }/${ filenameMin }',
        test: 'testModule("ngResource")'
      },
      {
        file: '**/angular-translate/*.js',
        package: 'angular-translate',
        cdn: '//cdn.jsdelivr.net/angular.translate/${ version }/${ filenameMin }',
        test: 'testModule("pascalprecht.translate")'
      },
      {
        file: '**/waypoints/**/*.js',
        package: 'waypoints',
        cdn: 'cdnjs:waypoints:${ filename }',
        test: 'Waypoint'
      },
      {
        file: '**/angular-ui-grid/**/*.js',
        package: 'angular-ui-grid',
        cdn: 'cdnjs:angular-ui-grid:${ filenameMin }',
        test: 'testModule("ui.grid")'
      },
      {
        file: '**/angular-loading-bar/**/*.js',
        package: 'angular-loading-bar',
        cdn: 'cdnjs:angular-loading-bar:${ filenameMin }',
        test: 'testModule("angular-loading-bar")'
      },
      {
        file: '**/angular-loading-bar/**/*.css',
        package: 'angular-loading-bar',
        cdn: 'cdnjs:angular-loading-bar:${ filenameMin }',
      },
      {
        file: '**/angular-ui-router/**/*.js',
        package: 'angular-ui-router',
        cdn: 'cdnjs:angular-ui-router:${ filenameMin }',
        test: 'testModule("ui.router")'
      },
      {
        file: '**/api-check/**/*.js',
        package: 'api-check',
        cdn: 'cdnjs:api-check:${ filenameMin }',
        test: 'window.apiCheck'
      },
      {
        file: '**/angular-formly/**/*.js',
        package: 'angular-formly',
        cdn: 'cdnjs:angular-formly:${ filenameMin }',
        test: 'testModule("formly")'
      },
      {
        file: '**/angulartics/**/*.js',
        package: 'angulartics',
        cdn: 'cdnjs:angulartics:${ filenameMin }',
        test: 'testModule("angulartics")'
      },
      {
        file: '**/angular-scroll/*.js',
        package: 'angular-scroll',
        cdn: 'cdnjs:angular-scroll:${ filenameMin }',
        test: 'testModule("duScroll")'
      },
      {
        file: '**/angular-elastic/*.js',
        package: 'angular-elastic',
        cdn: 'cdnjs:angular-elastic:${ filenameMin }',
        test: 'testModule("monospaced.elastic")'
      },
      {
        file: '**/angular-formly-templates-bootstrap/**/*.js',
        package: 'angular-formly-templates-bootstrap',
        cdn: 'cdnjs:angular-formly-templates-bootstrap:${ filenameMin }',
        test: 'testModule("formlyBootstrap")'
      },
      {
        file: '**/d3/*.js',
        package: 'd3',
        cdn: 'cdnjs:d3:${ filenameMin }',
        test: 'window.d3'
      },
      {
        file : '**/dimple/**/*.js',
        package: 'dimple',
        cdn: '//cdnjs.cloudflare.com/ajax/libs/dimple/${ version }/dimple.latest.min.js',
        test: 'window.dimple'
      }
    ]
  }))

    .pipe(gulp.dest('.tmp'))
});
<|endoftext|>


<commit_before><commit_msg>Update dendro js<commit_after><|endoftext|>


<commit_before>//////////////////////////////////////////////////////////////////////////////
// Gather influence pairs into a list
function gatherInfluence (files) {
  return new Promise ( (resolve, reject) => {
    let [
      roguelikeInfluences,
      roguelikelikeInfluences,
      releasedYears
    ] = files;

    // Remove last empty row
    roguelikeInfluences = roguelikeInfluences.slice(0, -1);
    roguelikelikeInfluences = roguelikelikeInfluences.slice(0, -1);

    // transform influences into JSON
    roguelikeInfluences.forEach(r => {
      r.Influences = JSON.parse(r.Influences);
      r.Inferred_Roguelike_Influences = JSON.parse(r.Inferred_Roguelike_Influences);
      r.Inferred_Roguelikelike_Influences = JSON.parse(r.Inferred_Roguelikelike_Influences);
      r.Inferred_Other_Influences = JSON.parse(r.Inferred_Other_Influences);
    });

    roguelikelikeInfluences.forEach(r => {
      r.Influences = JSON.parse(r.Influences);
      r.Inferred_Roguelike_Influences = JSON.parse(r.Inferred_Roguelike_Influences);
      r.Inferred_Roguelikelike_Influences = JSON.parse(r.Inferred_Roguelikelike_Influences);
      r.Inferred_Other_Influences = JSON.parse(r.Inferred_Other_Influences);
    });

    // Loop through the influence dataset and make data rows for arcs
    const influences = [];

    roguelikeInfluences.forEach(r => {
      r.Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          // Temporary patching games out of roguelike list
          if (i === 'Diablo' || i === 'Diablo II' || i === 'Spelunky' || i === 'The Binding of Isaac') {
            influences.push({
              titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
              categoryA: 'roguelike', categoryB: 'roguelikelike', type: 'known',
            });
          } else {
            influences.push({
              titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
              categoryA: 'roguelike', categoryB: 'roguelike', type: 'known',
            });
          }
        }
      });

      r.Inferred_Roguelike_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelike', categoryB: 'roguelike',  type: 'inferred',
          });
        }
      });

      r.Inferred_Roguelikelike_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelike', categoryB: 'roguelikelike',  type: 'inferred',
          });
        }
      });

      r.Inferred_Other_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelike', categoryB: 'other',  type: 'inferred',
          });
        }
      });

    });

    roguelikelikeInfluences.forEach(r => {
      r.Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          // Temporary patching Spelunky out of roguelike list
          if (i === 'Spelunky' || i === 'Diablo II') {
            influences.push({
              titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
              categoryA: 'roguelikelike', categoryB: 'roguelikelike',  type: 'known',
            });
          } else {
            influences.push({
              titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
              categoryA: 'roguelikelike', categoryB: 'roguelike',  type: 'known',
            });
          }
        }
      });

      r.Inferred_Roguelike_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelikelike', categoryB: 'roguelike',  type: 'inferred',
          });
        }
      });

      r.Inferred_Roguelikelike_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelikelike', categoryB: 'roguelikelike',  type: 'inferred',
          });
        }
      });

      r.Inferred_Other_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelikelike', categoryB: 'other',  type: 'inferred',
          });
        }
      });

    });

    function validYears (a, b) {
      return releasedYears[a]
              && releasedYears[b]
              && releasedYears[a] !== 1000
              && releasedYears[b] !== 1000;
    }

    const output = [
      roguelikeInfluences,
      roguelikelikeInfluences,
      releasedYears,
      influences,
    ];

    resolve(output);
  });
}

function filterRoguelike (influences) {
  return influences.filter(r => {
    return r.categoryA === 'roguelike';
  });
}

function filterByName (influences, name) {
  return influences.filter(r => {
    return r.titleA === name || r.titleB === name;
  });
}

function filterKnown (influences) {
  return influences.filter(r => {
    return r.type === 'known';
  });
}

function filterRoguelikeInfluence (influences) {
  return influences.filter(r => {
    return r.categoryB === 'roguelike';
  });
}

function filterRoguelikelikeInGenre (influences) {
  return influences.filter(r => {
    return r.categoryA === 'roguelikelike' && r.categoryB === 'roguelikelike';
  });
}

function onlyUnique (value, index, self) {
  return self.indexOf(value) === index;
}

function filterUniquePosition (positions) {
  const memory = new Set();
  const filtered = [];
  positions.forEach(r => {
    const id = `${r.x},${r.y}`;
    if (!memory.has(id)) {
      filtered.push(r);
    }
    memory.add(id);
  });
  return filtered;
}

function sign (x) {
  if (x === 0) return 0;
  else return x / Math.abs(x);
}

const roguelike_universe_metadata = {
  author: 'Xavier Ho',
  email: 'contact@xavierho.com',
  author_website: 'https://jumptoglide.com',
  github_website: 'https://github.com/Spaxe/roguelike-universe',
  project_website: 'https://spaxe.github.io/roguelike-universe',
  license: 'Unless otherwise specified, Creative Commons Non-Commercial applies',
  license_url: 'https://creativecommons.org/licenses/by-nc/3.0/',
  acknowledgement: 'RogueTemple and RogueBasin contributors',
  download_date: new Date(),
};<commit_msg>Fixed #1<commit_after>//////////////////////////////////////////////////////////////////////////////
// Gather influence pairs into a list
function gatherInfluence (files) {
  return new Promise ( (resolve, reject) => {
    let [
      roguelikeInfluences,
      roguelikelikeInfluences,
      releasedYears
    ] = files;

    // Remove last empty row
    roguelikeInfluences = roguelikeInfluences.slice(0, -1);
    roguelikelikeInfluences = roguelikelikeInfluences.slice(0, -1);

    // transform influences into JSON
    roguelikeInfluences.forEach(r => {
      r.Influences = JSON.parse(r.Influences);
      r.Inferred_Roguelike_Influences = JSON.parse(r.Inferred_Roguelike_Influences);
      r.Inferred_Roguelikelike_Influences = JSON.parse(r.Inferred_Roguelikelike_Influences);
      r.Inferred_Other_Influences = JSON.parse(r.Inferred_Other_Influences);
    });

    roguelikelikeInfluences.forEach(r => {
      r.Influences = JSON.parse(r.Influences);
      r.Inferred_Roguelike_Influences = JSON.parse(r.Inferred_Roguelike_Influences);
      r.Inferred_Roguelikelike_Influences = JSON.parse(r.Inferred_Roguelikelike_Influences);
      r.Inferred_Other_Influences = JSON.parse(r.Inferred_Other_Influences);
    });

    // Loop through the influence dataset and make data rows for arcs
    const influences = [];

    roguelikeInfluences.forEach(r => {
      r.Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          // Temporary patching games out of roguelike list
          // TODO: Consolidate the list of games, and have a field for genre such as roguelike/roguelike-like
          if (i === 'Diablo' || i === 'Diablo II' || i === 'Spelunky' || i === 'The Binding of Isaac') {
            influences.push({
              titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
              categoryA: 'roguelike', categoryB: 'roguelikelike', type: 'known',
            });
          } else {
            influences.push({
              titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
              categoryA: 'roguelike', categoryB: 'roguelike', type: 'known',
            });
          }
        }
      });

      r.Inferred_Roguelike_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelike', categoryB: 'roguelike',  type: 'inferred',
          });
        }
      });

      r.Inferred_Roguelikelike_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelike', categoryB: 'roguelikelike',  type: 'inferred',
          });
        }
      });

      r.Inferred_Other_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelike', categoryB: 'other',  type: 'inferred',
          });
        }
      });

    });

    roguelikelikeInfluences.forEach(r => {
      r.Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          // Temporary patching Spelunky out of roguelike list
          if (i === 'Spelunky' || i === 'Diablo II') {
            influences.push({
              titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
              categoryA: 'roguelikelike', categoryB: 'roguelikelike',  type: 'known',
            });
          } else {
            influences.push({
              titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
              categoryA: 'roguelikelike', categoryB: 'roguelike',  type: 'known',
            });
          }
        }
      });

      r.Inferred_Roguelike_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelikelike', categoryB: 'roguelike',  type: 'inferred',
          });
        }
      });

      r.Inferred_Roguelikelike_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelikelike', categoryB: 'roguelikelike',  type: 'inferred',
          });
        }
      });

      r.Inferred_Other_Influences.forEach(i => {
        if (validYears(r.Name, i)) {
          influences.push({
            titleA: r.Name, titleB: i, yearA: releasedYears[r.Name], yearB: releasedYears[i],
            categoryA: 'roguelikelike', categoryB: 'other',  type: 'inferred',
          });
        }
      });

    });

    function validYears (a, b) {
      return releasedYears[a]
              && releasedYears[b]
              && releasedYears[a] !== 1000
              && releasedYears[b] !== 1000;
    }

    const output = [
      roguelikeInfluences,
      roguelikelikeInfluences,
      releasedYears,
      influences,
    ];

    resolve(output);
  });
}

function filterRoguelike (influences) {
  return influences.filter(r => {
    return r.categoryA === 'roguelike';
  });
}

function filterByName (influences, name) {
  return influences.filter(r => {
    return r.titleA === name || r.titleB === name;
  });
}

function filterKnown (influences) {
  return influences.filter(r => {
    return r.type === 'known';
  });
}

function filterRoguelikeInfluence (influences) {
  return influences.filter(r => {
    return r.categoryB === 'roguelike';
  });
}

function filterRoguelikelikeInGenre (influences) {
  return influences.filter(r => {
    return r.categoryA === 'roguelikelike' && r.categoryB === 'roguelikelike';
  });
}

function onlyUnique (value, index, self) {
  return self.indexOf(value) === index;
}

function filterUniquePosition (positions) {
  const memory = new Set();
  const filtered = [];
  positions.forEach(r => {
    const id = `${r.x},${r.y}`;
    if (!memory.has(id)) {
      filtered.push(r);
    }
    memory.add(id);
  });
  return filtered;
}

function sign (x) {
  if (x === 0) return 0;
  else return x / Math.abs(x);
}

const roguelike_universe_metadata = {
  author: 'Xavier Ho',
  email: 'contact@xavierho.com',
  author_website: 'https://jumptoglide.com',
  github_website: 'https://github.com/Spaxe/roguelike-universe',
  project_website: 'https://spaxe.github.io/roguelike-universe',
  license: 'Unless otherwise specified, Creative Commons Non-Commercial applies',
  license_url: 'https://creativecommons.org/licenses/by-nc/3.0/',
  acknowledgement: 'RogueTemple and RogueBasin contributors',
  download_date: new Date(),
};<|endoftext|>