<commit_before>main();

function main() {

  // socket connection to http server
  socket = io();
  socket.on('message', console.dir);
  socket.send('ping');

  // display command results received from robot
  socket.on('command result', (data)=>{
    console.dir(data);
    addMessage(data, false);
  });

  // render map data received from robot
  socket.on('map data', (data)=>{
    console.dir(data);
    addShapeVoxels(data);
  });

  // render map data received from robot
  socket.on('robot position', (pos)=>{
    console.dir(pos);
    moveRobotVoxel(pos);
  });

  // remove selection because its task has been completed
  socket.on('delete selection', (index)=>{
    console.dir(index);
    deleteSelection(selections, index);
  });

  // remove voxels corresponding to successfully dug blocks
  socket.on('dig success', (pos)=>{
    console.dir(pos);
    var voxel = voxelMap.get(pos.x, pos.y, pos.z);
    removeVoxel(pos.x, pos.y, pos.z, voxel);
  });

  // render inventory data received from robot
  socket.on('inventory data', (data)=>{
    console.dir(data);
    renderInventory(data);
  });

  selectStart.addEventListener('input', ()=>{removeSelectBox(); requestRender()});
  selectEnd.addEventListener('input', ()=>{removeSelectBox(); requestRender()});

  // for some reason the click event fires before the checked attribute changes
  // can't find an event for when that attribute changes, so we use setTimeout
  var moveToolLabel = document.getElementById('moveTool').parentElement;
  moveToolLabel.addEventListener('click', (e)=>{
    selectStart.clear();
    selectEnd.clear();
    removeSelectBox();
    setTimeout(requestRender, 10);
  });
  var moveToolLabel = document.getElementById('selectTool').parentElement;
  moveToolLabel.addEventListener('click', (e)=>{
    setTimeout(requestRender, 10);
  });

  initPointerLock();
  initCommandInput();
  initMoveOnClick();
  initSelectArea();

}

/**
 * Allows specifying an area of voxels. Used for digging.
 */
function initSelectArea() {
  renderer.domElement.addEventListener('click', ()=>{
    var selectToolActive = document.getElementById('selectTool').checked;
    if (controls.enabled && selectToolActive) {
      if (!selectStart.isComplete()) {
        selectStart.setFromVector(rollOverMesh.position);
      }
      else if (!selectEnd.isComplete()) {
        selectEnd.setFromVector(rollOverMesh.position);
      }
      else {
        var v1 = selectStart.getVector();
        var v2 = selectEnd.getVector();

        var selection = makeBoxAround(v1, v2, rollOverMaterial);
        scene.add(selection);
        var selectionIndex = addSelection(selections, selection);

        var v1Lua = vectorToLuaString(getWorldCoord(v1));
        var v2Lua = vectorToLuaString(getWorldCoord(v2));
        var scanLevel = document.getElementById('scanWhileMoving').value;

        var luaString = 'return dig.digArea(' + [v1Lua, v2Lua, selectionIndex, scanLevel] + ');';
        addMessage(luaString, true);
        socket.emit('command', luaString);

        selectStart.clear();
        selectEnd.clear();
      }
    }
  });
}

/**
 * Adds command sending functionality to the command input.
 */
function initCommandInput() {

  var commandInput = document.getElementById('commandInput');
  commandInput.addEventListener("keydown", (event)=>{
    var runInTerminal = document.getElementById('runInTerminal');
    if (event.keyCode == 13) { // enter
      event.preventDefault();
      var baseText = event.target.value;
      var commandText = baseText;
      if (runInTerminal.checked) {
        commandText = "runInTerminal('" + commandText + "')";
      }
      commandText = "return " + commandText;

      // display command
      addMessage(baseText, true, runInTerminal.checked);

      // send command to the web server
      socket.emit('command', commandText);

      // clear input text
      event.target.value = '';
    }
    else if (event.key == "Tab") {
      event.preventDefault();
      runInTerminal.checked = !runInTerminal.checked;
    }
  });

}

/**
 * Sends a command to robots telling them to move to the coordinate clicked on.
 */
function initMoveOnClick() {
  renderer.domElement.addEventListener('click', ()=>{
    var moveToolActive = document.getElementById('moveTool').checked;
    if (controls.enabled && moveToolActive) {
      var coord = getWorldCoord(rollOverMesh.position);
      console.log(coord);
      var scanLevel = document.getElementById('scanWhileMoving').value;
      var luaString = 'return mas.to(' + [coord.x, coord.y, coord.z, scanLevel] + ');'
      addMessage(luaString, true);
      socket.emit('command', luaString);
    }
  });
}

/**
 * Used to display on the web client commands sent to and received from robots.
 * @param {string | any[]} data
 * @param {boolean} isInput
 * @param {boolean} checked
 */
function addMessage(data, isInput, checked) {

  var element = document.createElement('div');
  element.classList.add('message');

  if (isInput) {
    var subClass = 'input';
    element.setAttribute("data-checked", checked);

    element.addEventListener('click', (event)=>{

      var commandInput = document.getElementById('commandInput');
      commandInput.value = event.target.firstChild.textContent;
      commandInput.focus();

      var checkData = event.target.getAttribute("data-checked");
      var wasChecked = checkData == "true" ? true : false;
      var runInTerminal = document.getElementById("runInTerminal");
      runInTerminal.checked = wasChecked;

    });

    element.appendChild(document.createTextNode(data));
  }

  else {
    var subClass = 'output';
    element.appendChild(renderCommandResponse(data));
  }

  element.classList.add(subClass);
  document.getElementById('messageContainer').insertBefore(element, commandInput);
  document.getElementById('messageContainer').insertBefore(document.createElement('br'), commandInput);

}

/**
 * Used by addMessage to ensure newlines in messages sent from robots display properly in the web client.
 * @param {any[]} data
 * @returns {HTMLDivElement}
 */
function renderCommandResponse(data) {
  var outputMessageDiv = document.createElement('div');
  var text = data[0] + '\n' + data[1];
  for (line of text.split('\n')) {
    outputMessageDiv.appendChild(document.createTextNode(line));
    outputMessageDiv.appendChild(document.createElement('br'));
  }
  outputMessageDiv.lastChild.remove();
  return outputMessageDiv;
}

/**
 * Allows enabling and disabling of the camera controls.
 */
function initPointerLock() {
  // locking/unlocking the cursor, enabling/disabling controls
  if ('pointerLockElement' in document) {

    var element = renderer.domElement;

    function pointerLockChangeCB(event) {
      if (document.pointerLockElement === element) {controls.enabled = true;}
      else {
        controls.enabled = false;
        document.getElementById('commandInput').focus();
      }
    }

    // Hook pointer lock state change events
    document.addEventListener( 'pointerlockchange', pointerLockChangeCB, false );
    document.addEventListener( 'pointerlockerror', console.dir, false );

    element.addEventListener('click', function(event) {
      element.requestPointerLock();
    }, false);

  }
  else {alert("Your browser doesn't seem to support Pointer Lock API");}
}

/**
 * Creates an interactive visual representation of an inventory.
 * @param {object} inventoryData
 * @returns {HTMLTableElement}
 */
function renderInventory(inventoryData) {
  var table = document.createElement('table');
  var numCols = 4;
  var numRows = inventoryData.size / 4;
  for (var i = 0; i < numRows; i++) {
    var row = table.insertRow(-1);
    for (var j = 0; j < numCols; j++) {
      var cell = row.insertCell(-1);
      cell.addEventListener('click', changeSelectedSlot);
      cell.addEventListener('dragover', allowDrop);
      cell.addEventListener('drop', itemDrop);
      cell.addEventListener('dragstart', itemDragStart);
      cell.setAttribute('draggable', true);
      var slotNumber = (i * numCols) + j + 1;
      cell.setAttribute('data-slotNumber', slotNumber);
      if (inventoryData.selected == slotNumber) {
        cell.setAttribute('data-selected', true);
      }
      var slotData = inventoryData.contents[slotNumber - 1];
      if (slotData) {
        cell.appendChild(renderItem(slotData));
      }
    }
  }

  var inventoryContainer = document.getElementById('inventoryContainer');
  if (inventoryContainer.firstChild) {inventoryContainer.removeChild(inventoryContainer.firstChild);}
  inventoryContainer.appendChild(table);

  return table;
}

/**
 * Creates a visual representation of an item.
 * @param {object} itemData
 * @returns {HTMLDivElement}
 */
function renderItem(itemData) {
  var itemDiv = document.createElement('div');

  itemDiv.appendChild(document.createTextNode(itemData.label));
  itemDiv.appendChild(document.createElement('br'));
  itemDiv.appendChild(document.createTextNode(itemData.size));
  itemDiv.itemData = itemData;

  return itemDiv;
}

var dragStartElement;
var itemSwapStorage;

/**
 * Stores item data for transfer.
 * @param {Event} e
 */
function itemDragStart(e) {
  dragStartElement = this;
  if (e.ctrlKey) {
    e.dataTransfer.setData('text/plain', 'split');
  }
  else if (e.altKey) {
    e.dataTransfer.setData('text/plain', 'merge');
  }
  else {
    e.dataTransfer.setData('text/plain', 'swap');
  }
}

/**
 * Transfers item data.
 * @param {Event} e
 */
function itemDrop(e) {
  if (dragStartElement != this) {
    var operation = e.dataTransfer.getData('text');
    if (operation == 'swap') {
      swapCells(dragStartElement, this);
    }
    else if (operation == 'split') {
      splitCell(dragStartElement, this, parseInt(prompt('Number of items to move:')));
    }
    else if (operation == 'merge') {
      mergeCells(dragStartElement, this);
    }
  }
}

/**
 * Allows table cells to receive drops.
 * @param {Event} e
 */
function allowDrop(e) {
  e.preventDefault();
}

/**
 * Changes which inventory slot is selected.
 * @param {Event} e
 */
function changeSelectedSlot(e) {
  this.parentElement.parentElement.querySelector('[data-selected=true]').removeAttribute('data-selected');
  this.setAttribute('data-selected', true);
  var luaString = 'return robot.select(' + this.getAttribute('data-slotnumber') + ');';
  addMessage(luaString, true);
  socket.emit('command', luaString);
}

/**
 * Exchanges the children of two table cells. Used to swap item slots.
 * @param {HTMLTableCellElement} cell1
 * @param {HTMLTableCellElement} cell2
 */
function swapCells(cell1, cell2) {
  if (cell1.firstChild) {
    var itemSwapStorage = cell1.firstChild;
    cell1.removeChild(cell1.firstChild);
    if (cell2.firstChild) {cell1.appendChild(cell2.firstChild);}
    if (itemSwapStorage) {cell2.appendChild(itemSwapStorage);}

    var luaArgs = [cell1.getAttribute('data-slotnumber'), cell2.getAttribute('data-slotnumber')];
    var luaString = 'return inv.swap(' + luaArgs + ');';
    addMessage(luaString, true);
    socket.emit('command', luaString);
  }
}

/**
 * Moves amount items from fromCell to toCell.
 * @param {HTMLTableCellElement} fromCell
 * @param {HTMLTableCellElement} toCell
 * @param {number} amount
 */
function splitCell(fromCell, toCell, amount) {
  var success = true;

  if (fromCell.firstChild) {
    var itemData = fromCell.firstChild.itemData;
    if (amount < 1) {;}
    else if (toCell.firstChild) {success = false;}
    else if (amount >= itemData.size) {swapCells(fromCell, toCell);}
    else {
      var newItemData = Object.assign({}, itemData);

      itemData.size -= amount;
      fromCell.removeChild(fromCell.firstChild);
      fromCell.appendChild(renderItem(itemData));

      newItemData.size = amount;
      toCell.appendChild(renderItem(newItemData));

      var luaArgs = [fromCell.getAttribute('data-slotnumber'), toCell.getAttribute('data-slotnumber'), amount];
      var luaString = 'return inv.transfer(' + luaArgs + ');'
      addMessage(luaString, true);
      socket.emit('command', luaString);
    }
  }
  else {success = false;}

  return success;
}

function mergeCells(fromCell, toCell) {
  var success = false;

  if (!fromCell.firstChild) {;}
  else {
    if (!toCell.firstChild) {
      swapCells(fromCell, toCell);
      success = true;
    }
    else {
      var data1 = fromCell.firstChild.itemData;
      var data2 = toCell.firstChild.itemData;
      if (data1.name == data2.name &&
          !data1.damage && !data2.damage &&
          !data1.hasTag && !data2.hasTag) {
        var data2Space = data2.maxSize - data2.size;
        if (data1.size <= data2Space) {
          data2.size += data1.size;
          fromCell.removeChild(fromCell.firstChild);
          toCell.removeChild(toCell.firstChild);
          toCell.appendChild(renderItem(data2));
          success = true;

          var luaArgs = [fromCell.getAttribute('data-slotnumber'), toCell.getAttribute('data-slotnumber'), data1.size];
          var luaString = 'return inv.transfer(' + luaArgs + ');'
          addMessage(luaString, true);
          socket.emit('command', luaString);
        }
        else {
          data2.size += data2Space;
          data1.size -= data2Space;
          fromCell.removeChild(fromCell.firstChild);
          fromCell.appendChild(renderItem(data1));
          toCell.removeChild(toCell.firstChild);
          toCell.appendChild(renderItem(data2));
          success = true;

          var luaArgs = [fromCell.getAttribute('data-slotnumber'), toCell.getAttribute('data-slotnumber'), data2Space];
          var luaString = 'return inv.transfer(' + luaArgs + ');'
          addMessage(luaString, true);
          socket.emit('command', luaString);
        }

      }
      else {;}
    }
  }

  return success;
}<commit_msg>allow transfer to cells of same type<commit_after>main();

function main() {

  // socket connection to http server
  socket = io();
  socket.on('message', console.dir);
  socket.send('ping');

  // display command results received from robot
  socket.on('command result', (data)=>{
    console.dir(data);
    addMessage(data, false);
  });

  // render map data received from robot
  socket.on('map data', (data)=>{
    console.dir(data);
    addShapeVoxels(data);
  });

  // render map data received from robot
  socket.on('robot position', (pos)=>{
    console.dir(pos);
    moveRobotVoxel(pos);
  });

  // remove selection because its task has been completed
  socket.on('delete selection', (index)=>{
    console.dir(index);
    deleteSelection(selections, index);
  });

  // remove voxels corresponding to successfully dug blocks
  socket.on('dig success', (pos)=>{
    console.dir(pos);
    var voxel = voxelMap.get(pos.x, pos.y, pos.z);
    removeVoxel(pos.x, pos.y, pos.z, voxel);
  });

  // render inventory data received from robot
  socket.on('inventory data', (data)=>{
    console.dir(data);
    renderInventory(data);
  });

  selectStart.addEventListener('input', ()=>{removeSelectBox(); requestRender()});
  selectEnd.addEventListener('input', ()=>{removeSelectBox(); requestRender()});

  // for some reason the click event fires before the checked attribute changes
  // can't find an event for when that attribute changes, so we use setTimeout
  var moveToolLabel = document.getElementById('moveTool').parentElement;
  moveToolLabel.addEventListener('click', (e)=>{
    selectStart.clear();
    selectEnd.clear();
    removeSelectBox();
    setTimeout(requestRender, 10);
  });
  var moveToolLabel = document.getElementById('selectTool').parentElement;
  moveToolLabel.addEventListener('click', (e)=>{
    setTimeout(requestRender, 10);
  });

  initPointerLock();
  initCommandInput();
  initMoveOnClick();
  initSelectArea();

}

/**
 * Allows specifying an area of voxels. Used for digging.
 */
function initSelectArea() {
  renderer.domElement.addEventListener('click', ()=>{
    var selectToolActive = document.getElementById('selectTool').checked;
    if (controls.enabled && selectToolActive) {
      if (!selectStart.isComplete()) {
        selectStart.setFromVector(rollOverMesh.position);
      }
      else if (!selectEnd.isComplete()) {
        selectEnd.setFromVector(rollOverMesh.position);
      }
      else {
        var v1 = selectStart.getVector();
        var v2 = selectEnd.getVector();

        var selection = makeBoxAround(v1, v2, rollOverMaterial);
        scene.add(selection);
        var selectionIndex = addSelection(selections, selection);

        var v1Lua = vectorToLuaString(getWorldCoord(v1));
        var v2Lua = vectorToLuaString(getWorldCoord(v2));
        var scanLevel = document.getElementById('scanWhileMoving').value;

        var luaString = 'return dig.digArea(' + [v1Lua, v2Lua, selectionIndex, scanLevel] + ');';
        addMessage(luaString, true);
        socket.emit('command', luaString);

        selectStart.clear();
        selectEnd.clear();
      }
    }
  });
}

/**
 * Adds command sending functionality to the command input.
 */
function initCommandInput() {

  var commandInput = document.getElementById('commandInput');
  commandInput.addEventListener("keydown", (event)=>{
    var runInTerminal = document.getElementById('runInTerminal');
    if (event.keyCode == 13) { // enter
      event.preventDefault();
      var baseText = event.target.value;
      var commandText = baseText;
      if (runInTerminal.checked) {
        commandText = "runInTerminal('" + commandText + "')";
      }
      commandText = "return " + commandText;

      // display command
      addMessage(baseText, true, runInTerminal.checked);

      // send command to the web server
      socket.emit('command', commandText);

      // clear input text
      event.target.value = '';
    }
    else if (event.key == "Tab") {
      event.preventDefault();
      runInTerminal.checked = !runInTerminal.checked;
    }
  });

}

/**
 * Sends a command to robots telling them to move to the coordinate clicked on.
 */
function initMoveOnClick() {
  renderer.domElement.addEventListener('click', ()=>{
    var moveToolActive = document.getElementById('moveTool').checked;
    if (controls.enabled && moveToolActive) {
      var coord = getWorldCoord(rollOverMesh.position);
      console.log(coord);
      var scanLevel = document.getElementById('scanWhileMoving').value;
      var luaString = 'return mas.to(' + [coord.x, coord.y, coord.z, scanLevel] + ');'
      addMessage(luaString, true);
      socket.emit('command', luaString);
    }
  });
}

/**
 * Used to display on the web client commands sent to and received from robots.
 * @param {string | any[]} data
 * @param {boolean} isInput
 * @param {boolean} checked
 */
function addMessage(data, isInput, checked) {

  var element = document.createElement('div');
  element.classList.add('message');

  if (isInput) {
    var subClass = 'input';
    element.setAttribute("data-checked", checked);

    element.addEventListener('click', (event)=>{

      var commandInput = document.getElementById('commandInput');
      commandInput.value = event.target.firstChild.textContent;
      commandInput.focus();

      var checkData = event.target.getAttribute("data-checked");
      var wasChecked = checkData == "true" ? true : false;
      var runInTerminal = document.getElementById("runInTerminal");
      runInTerminal.checked = wasChecked;

    });

    element.appendChild(document.createTextNode(data));
  }

  else {
    var subClass = 'output';
    element.appendChild(renderCommandResponse(data));
  }

  element.classList.add(subClass);
  document.getElementById('messageContainer').insertBefore(element, commandInput);
  document.getElementById('messageContainer').insertBefore(document.createElement('br'), commandInput);

}

/**
 * Used by addMessage to ensure newlines in messages sent from robots display properly in the web client.
 * @param {any[]} data
 * @returns {HTMLDivElement}
 */
function renderCommandResponse(data) {
  var outputMessageDiv = document.createElement('div');
  var text = data[0] + '\n' + data[1];
  for (line of text.split('\n')) {
    outputMessageDiv.appendChild(document.createTextNode(line));
    outputMessageDiv.appendChild(document.createElement('br'));
  }
  outputMessageDiv.lastChild.remove();
  return outputMessageDiv;
}

/**
 * Allows enabling and disabling of the camera controls.
 */
function initPointerLock() {
  // locking/unlocking the cursor, enabling/disabling controls
  if ('pointerLockElement' in document) {

    var element = renderer.domElement;

    function pointerLockChangeCB(event) {
      if (document.pointerLockElement === element) {controls.enabled = true;}
      else {
        controls.enabled = false;
        document.getElementById('commandInput').focus();
      }
    }

    // Hook pointer lock state change events
    document.addEventListener( 'pointerlockchange', pointerLockChangeCB, false );
    document.addEventListener( 'pointerlockerror', console.dir, false );

    element.addEventListener('click', function(event) {
      element.requestPointerLock();
    }, false);

  }
  else {alert("Your browser doesn't seem to support Pointer Lock API");}
}

/**
 * Creates an interactive visual representation of an inventory.
 * @param {object} inventoryData
 * @returns {HTMLTableElement}
 */
function renderInventory(inventoryData) {
  var table = document.createElement('table');
  var numCols = 4;
  var numRows = inventoryData.size / 4;
  for (var i = 0; i < numRows; i++) {
    var row = table.insertRow(-1);
    for (var j = 0; j < numCols; j++) {
      var cell = row.insertCell(-1);
      cell.addEventListener('click', changeSelectedSlot);
      cell.addEventListener('dragover', allowDrop);
      cell.addEventListener('drop', itemDrop);
      cell.addEventListener('dragstart', itemDragStart);
      cell.setAttribute('draggable', true);
      var slotNumber = (i * numCols) + j + 1;
      cell.setAttribute('data-slotNumber', slotNumber);
      if (inventoryData.selected == slotNumber) {
        cell.setAttribute('data-selected', true);
      }
      var slotData = inventoryData.contents[slotNumber - 1];
      if (slotData) {
        cell.appendChild(renderItem(slotData));
      }
    }
  }

  var inventoryContainer = document.getElementById('inventoryContainer');
  if (inventoryContainer.firstChild) {inventoryContainer.removeChild(inventoryContainer.firstChild);}
  inventoryContainer.appendChild(table);

  return table;
}

/**
 * Creates a visual representation of an item.
 * @param {object} itemData
 * @returns {HTMLDivElement}
 */
function renderItem(itemData) {
  var itemDiv = document.createElement('div');

  itemDiv.appendChild(document.createTextNode(itemData.label));
  itemDiv.appendChild(document.createElement('br'));
  itemDiv.appendChild(document.createTextNode(itemData.size));
  itemDiv.itemData = itemData;

  return itemDiv;
}

var dragStartElement;
var itemSwapStorage;

/**
 * Stores item data for transfer.
 * @param {Event} e
 */
function itemDragStart(e) {
  dragStartElement = this;
  if (e.ctrlKey) {
    e.dataTransfer.setData('text/plain', 'split');
  }
  else if (e.altKey) {
    e.dataTransfer.setData('text/plain', 'merge');
  }
  else {
    e.dataTransfer.setData('text/plain', 'swap');
  }
}

/**
 * Transfers item data.
 * @param {Event} e
 */
function itemDrop(e) {
  if (dragStartElement != this) {
    var operation = e.dataTransfer.getData('text');
    if (operation == 'swap') {
      swapCells(dragStartElement, this);
    }
    else if (operation == 'split') {
      splitCell(dragStartElement, this, parseInt(prompt('Number of items to move:')));
    }
    else if (operation == 'merge') {
      mergeCells(dragStartElement, this);
    }
  }
}

/**
 * Allows table cells to receive drops.
 * @param {Event} e
 */
function allowDrop(e) {
  e.preventDefault();
}

/**
 * Changes which inventory slot is selected.
 * @param {Event} e
 */
function changeSelectedSlot(e) {
  this.parentElement.parentElement.querySelector('[data-selected=true]').removeAttribute('data-selected');
  this.setAttribute('data-selected', true);
  var luaString = 'return robot.select(' + this.getAttribute('data-slotnumber') + ');';
  addMessage(luaString, true);
  socket.emit('command', luaString);
}

/**
 * Exchanges the children of two table cells. Used to swap item slots.
 * @param {HTMLTableCellElement} cell1
 * @param {HTMLTableCellElement} cell2
 */
function swapCells(cell1, cell2) {
  if (cell1.firstChild) {
    var itemSwapStorage = cell1.firstChild;
    cell1.removeChild(cell1.firstChild);
    if (cell2.firstChild) {cell1.appendChild(cell2.firstChild);}
    if (itemSwapStorage) {cell2.appendChild(itemSwapStorage);}

    var luaArgs = [cell1.getAttribute('data-slotnumber'), cell2.getAttribute('data-slotnumber')];
    var luaString = 'return inv.swap(' + luaArgs + ');';
    addMessage(luaString, true);
    socket.emit('command', luaString);
  }
}

/**
 * Moves amount items from fromCell to toCell.
 * @param {HTMLTableCellElement} fromCell
 * @param {HTMLTableCellElement} toCell
 * @param {number} amount
 */
function splitCell(fromCell, toCell, amount) {
  var success = true;

  if (fromCell.firstChild) {
    var itemData = fromCell.firstChild.itemData;
    if (amount < 1) {;}
    else if (toCell.firstChild) {success = mergeCells(fromCell, toCell);}
    else if (amount >= itemData.size) {swapCells(fromCell, toCell);}
    else {
      var newItemData = Object.assign({}, itemData);

      itemData.size -= amount;
      fromCell.removeChild(fromCell.firstChild);
      fromCell.appendChild(renderItem(itemData));

      newItemData.size = amount;
      toCell.appendChild(renderItem(newItemData));

      var luaArgs = [fromCell.getAttribute('data-slotnumber'), toCell.getAttribute('data-slotnumber'), amount];
      var luaString = 'return inv.transfer(' + luaArgs + ');'
      addMessage(luaString, true);
      socket.emit('command', luaString);
    }
  }
  else {success = false;}

  return success;
}

function mergeCells(fromCell, toCell) {
  var success = false;

  if (!fromCell.firstChild) {;}
  else {
    if (!toCell.firstChild) {
      swapCells(fromCell, toCell);
      success = true;
    }
    else {
      var data1 = fromCell.firstChild.itemData;
      var data2 = toCell.firstChild.itemData;
      if (data1.name == data2.name &&
          !data1.damage && !data2.damage &&
          !data1.hasTag && !data2.hasTag) {
        var data2Space = data2.maxSize - data2.size;
        if (data1.size <= data2Space) {
          data2.size += data1.size;
          fromCell.removeChild(fromCell.firstChild);
          toCell.removeChild(toCell.firstChild);
          toCell.appendChild(renderItem(data2));
          success = true;

          var luaArgs = [fromCell.getAttribute('data-slotnumber'), toCell.getAttribute('data-slotnumber'), data1.size];
          var luaString = 'return inv.transfer(' + luaArgs + ');'
          addMessage(luaString, true);
          socket.emit('command', luaString);
        }
        else {
          data2.size += data2Space;
          data1.size -= data2Space;
          fromCell.removeChild(fromCell.firstChild);
          fromCell.appendChild(renderItem(data1));
          toCell.removeChild(toCell.firstChild);
          toCell.appendChild(renderItem(data2));
          success = true;

          var luaArgs = [fromCell.getAttribute('data-slotnumber'), toCell.getAttribute('data-slotnumber'), data2Space];
          var luaString = 'return inv.transfer(' + luaArgs + ');'
          addMessage(luaString, true);
          socket.emit('command', luaString);
        }

      }
      else {;}
    }
  }

  return success;
}<|endoftext|>


<commit_before>// jscs:disable
(function(){

  /**
   * Base service class for services with pagination
   *   getList
   *   $get
   *   $delete
   *   $create
   *   operation
   */

  angular.module('ncsaas')
    .service('baseServiceClass', ['$q', 'currentStateService', '$resource', 'ENV', baseServiceClass]);
  function baseServiceClass($q, currentStateService, $resource, ENV) {
    // pageSize, page, pages - default variables, you can change this in your init method or call this._super() in init
    var BaseServiceClass = Class.extend({
      pageSize:null,
      page:null,
      pages:null,
      currentStateService:null,
      endpoint:null,
      customerName:null,

      init:function(){
        this.pageSize = 10;
        this.page = 1;
        this.pages = null;
        this.currentStateService = currentStateService;
      },

      getList:function(filter) {
        var vm = this;
        var deferred = $q.defer();
        filter = filter || {};
        var queryList = function() {
          filter.page = vm.page;
          /*jshint camelcase: false */
          filter.page_size = vm.pageSize;
          vm.getFactory(true).query(filter,function(response, responseHeaders){
            var header = responseHeaders(),
              objQuantity = !header['x-result-count'] ? null : header['x-result-count'];
            if (objQuantity) {
              vm.pages = Math.ceil(objQuantity/vm.pageSize);
            }
            deferred.resolve(response);
          }, function(err) {
            deferred.reject(err);
          });
        };

        if (vm.currentStateService == null) {
          queryList();
        } else {
          vm.currentStateService.getCustomer().then(function (response) {
            /*jshint camelcase: false */
            filter.customer_name = (this.customerName) ? this.customerName() : response.name;
            queryList();
          }, function (err) {
            deferred.reject(err);
          });
        }

        return deferred.promise;
      },

      $create:function() {
        var Instance = this.getFactory(false);
        return new Instance();
      },

      $delete:function(uuid) {
        var deferred = $q.defer();
        this.getFactory(false).remove({}, {uuid: uuid}).$promise.then(function(response) {
          deferred.resolve(response);
        }, function(err) {
          deferred.reject(err);
        });
        return deferred.promise;
      },

      operation:function(operation, uuid) {
        var deferred = $q.defer();
        this.getFactory(false).operation({uuid: uuid, operation: operation}).$promise.then(function(response){
          deferred.resolve(response);
        }, function(err) {
          deferred.reject(err);
        });
        return deferred.promise;
      },

      getFactory:function(isList) {
        /*jshint camelcase: false */
        return $resource(ENV.apiEndpoint + 'api' + this.getEndpoint(isList) + ':UUID/', {UUID:'@uuid',
            page_size:'@page_size', page:'@page'},
          {
            operation: {
              method:'POST',
              url:ENV.apiEndpoint + 'api' + this.getEndpoint(isList) + ':UUID/:operation/',
              params: {UUID:'@uuid', operation:'@operation'}
            },
          }
        );
      },

      $get:function(uuid) {
        return this.getFactory(false).get({}, {uuid: uuid}).$promise;
      },

      getEndpoint:function(isList) {
        return this.endpoint;
      }
    });

    return BaseServiceClass;
  }
})();
<commit_msg>Add helper function to base service (saas-176)<commit_after>// jscs:disable
(function(){

  /**
   * Base service class for services with pagination
   *   getList
   *   $get
   *   $delete
   *   $create
   *   operation
   */

  angular.module('ncsaas')
    .service('baseServiceClass', ['$q', 'currentStateService', '$resource', 'ENV', baseServiceClass]);
  function baseServiceClass($q, currentStateService, $resource, ENV) {
    // pageSize, page, pages - default variables, you can change this in your init method or call this._super() in init
    var BaseServiceClass = Class.extend({
      pageSize:null,
      page:null,
      pages:null,
      currentStateService:null,
      endpoint:null,
      customerName:null,

      init:function() {
        this.pageSize = 10;
        this.page = 1;
        this.pages = null;
        this.currentStateService = currentStateService;
      },

      getList:function(filter) {
        var vm = this;
        var deferred = $q.defer();
        filter = filter || {};
        var queryList = function() {
          filter.page = vm.page;
          /*jshint camelcase: false */
          filter.page_size = vm.pageSize;
          vm.getFactory(true).query(filter, function(response, responseHeaders) {
            var header = responseHeaders(),
              objQuantity = !header['x-result-count'] ? null : header['x-result-count'];
            if (objQuantity) {
              vm.pages = Math.ceil(objQuantity/vm.pageSize);
            }
            deferred.resolve(response);
          }, function(err) {
            deferred.reject(err);
          });
        };

        if (vm.currentStateService == null) {
          queryList();
        } else {
          vm.currentStateService.getCustomer().then(function (response) {
            /*jshint camelcase: false */
            filter.customer_name = (this.customerName) ? this.customerName() : response.name;
            queryList();
          }, function (err) {
            deferred.reject(err);
          });
        }

        return deferred.promise;
      },

      $create:function() {
        var Instance = this.getFactory(false);
        return new Instance();
      },

      $delete:function(uuid) {
        var deferred = $q.defer();
        this.getFactory(false).remove({}, {uuid: uuid}).$promise.then(function(response) {
          deferred.resolve(response);
        }, function(err) {
          deferred.reject(err);
        });
        return deferred.promise;
      },

      operation:function(operation, uuid) {
        var deferred = $q.defer();
        this.getFactory(false).operation({uuid: uuid, operation: operation}).$promise.then(function(response){
          deferred.resolve(response);
        }, function(err) {
          deferred.reject(err);
        });
        return deferred.promise;
      },

      getFactory:function(isList, endpoint) {
        endpoint = endpoint || this.getEndpoint(isList);
        /*jshint camelcase: false */
        return $resource(ENV.apiEndpoint + 'api' + endpoint + ':UUID/', {UUID:'@uuid',
            page_size:'@page_size', page:'@page'},
          {
            operation: {
              method:'POST',
              url:ENV.apiEndpoint + 'api' + endpoint + ':UUID/:operation/',
              params: {UUID:'@uuid', operation:'@operation'}
            },
          }
        );
      },

      $get:function(uuid) {
        return this.getFactory(false).get({}, {uuid: uuid}).$promise;
      },

      getEndpoint:function(isList) {
        return this.endpoint;
      },

      // helper, that adds functions to promise
      chainFunctionsToPromise:function(promise, functions) {
        var deferred = $q.defer();
        promise.then(
          function(response) {
            for (var i=0; i < functions.length; i++) {
              var f = functions[i];
              f(response);
              deferred.resolve(response);
            }
          },
          function(error) {
            deferred.reject(error);
          }
        );
        return deferred.promise;
      }

    });

    return BaseServiceClass;
  }
})();
<|endoftext|>


<commit_before>const mapStyle = [
  {
    featureType: "administrative",
    elementType: "all",
    stylers: [
      {
        saturation: "-100"
      }
    ]
  },
  {
    featureType: "administrative.province",
    elementType: "all",
    stylers: [
      {
        visibility: "off"
      }
    ]
  },
  {
    featureType: "landscape",
    elementType: "all",
    stylers: [
      {
        saturation: -100
      },
      {
        lightness: 65
      },
      {
        visibility: "on"
      }
    ]
  },
  {
    featureType: "poi",
    elementType: "all",
    stylers: [
      {
        saturation: -100
      },
      {
        lightness: "50"
      },
      {
        visibility: "simplified"
      }
    ]
  },
  {
    featureType: "road",
    elementType: "all",
    stylers: [
      {
        saturation: "-100"
      }
    ]
  },
  {
    featureType: "road.highway",
    elementType: "all",
    stylers: [
      {
        visibility: "simplified"
      }
    ]
  },
  {
    featureType: "road.arterial",
    elementType: "all",
    stylers: [
      {
        lightness: "30"
      }
    ]
  },
  {
    featureType: "road.local",
    elementType: "all",
    stylers: [
      {
        lightness: "40"
      }
    ]
  },
  {
    featureType: "transit",
    elementType: "all",
    stylers: [
      {
        saturation: -100
      },
      {
        visibility: "simplified"
      }
    ]
  },
  {
    featureType: "water",
    elementType: "geometry",
    stylers: [
      {
        hue: "#ffff00"
      },
      {
        lightness: -25
      },
      {
        saturation: -97
      }
    ]
  },
  {
    featureType: "water",
    elementType: "geometry.fill",
    stylers: [
      {
        lightness: "52"
      },
      {
        color: "#c2cacc;"
      }
    ]
  },
  {
    featureType: "water",
    elementType: "labels",
    stylers: [
      {
        lightness: -25
      },
      {
        saturation: -100
      }
    ]
  }
];

export default mapStyle;
<commit_msg>remove equator and intl date line from map<commit_after>const mapStyle = [
  {
    featureType: "administrative",
    elementType: "all",
    stylers: [
      {
        saturation: "-100",
      },
    ],
  },
  {
    featureType: "administrative",
    elementType: "geometry",
    stylers: [{ visibility: "off" }],
  },
  {
    featureType: "administrative.country",
    elementType: "geometry.stroke",
    stylers: [{ visibility: "on" }],
  },
  {
    featureType: "administrative.province",
    elementType: "geometry.stroke",
    stylers: [{ visibility: "on" }],
  },
  {
    featureType: "administrative.locality",
    elementType: "geometry.stroke",
    stylers: [{ visibility: "on" }],
  },
  {
    featureType: "administrative.neighborhood",
    elementType: "geometry.stroke",
    stylers: [{ visibility: "on" }],
  },
  {
    featureType: "administrative.land_parcel",
    elementType: "geometry.stroke",
    stylers: [{ visibility: "on" }],
  },
  {
    featureType: "administrative.province",
    elementType: "all",
    stylers: [{ visibility: "off" }],
  },
  {
    featureType: "landscape",
    elementType: "all",
    stylers: [
      {
        saturation: -100,
      },
      {
        lightness: 65,
      },
      {
        visibility: "on",
      },
    ],
  },
  {
    featureType: "poi",
    elementType: "all",
    stylers: [
      {
        saturation: -100,
      },
      {
        lightness: "50",
      },
      {
        visibility: "simplified",
      },
    ],
  },
  {
    featureType: "road",
    elementType: "all",
    stylers: [
      {
        saturation: "-100",
      },
    ],
  },
  {
    featureType: "road.highway",
    elementType: "all",
    stylers: [
      {
        visibility: "simplified",
      },
    ],
  },
  {
    featureType: "road.arterial",
    elementType: "all",
    stylers: [
      {
        lightness: "30",
      },
    ],
  },
  {
    featureType: "road.local",
    elementType: "all",
    stylers: [
      {
        lightness: "40",
      },
    ],
  },
  {
    featureType: "transit",
    elementType: "all",
    stylers: [
      {
        saturation: -100,
      },
      {
        visibility: "simplified",
      },
    ],
  },
  {
    featureType: "water",
    elementType: "geometry",
    stylers: [
      {
        hue: "#C3CACB",
      },
      {
        lightness: -25,
      },
      {
        saturation: -92,
      },
    ],
  },
  {
    featureType: "water",
    elementType: "geometry.fill",
    stylers: [
      {
        lightness: "40",
      },
      {
        color: "#C3CACB;",
      },
    ],
  },
  {
    featureType: "water",
    elementType: "labels",
    stylers: [
      {
        lightness: -25,
      },
      {
        saturation: -100,
      },
    ],
  },
];

export default mapStyle;
<|endoftext|>


<commit_before>//
//     nodemavens
//     Copyright(c) 2014 Matt Hernandez <matt@modulus.io>
//     MIT Licensed
//

var blacklist = JSON.parse(process.env.BLACKLIST || '[]');

module.exports = function(app, controller) {

  //
  // Disallow blacklisted IPs and verify the session count.
  //
  app.all('/*', function(req, res, next) {
    if ('POST' === req.method) {

      if (!req.headers['x-forwarded-for']) {
        return next();
      }

      var ips = req.headers['x-forwarded-for'].split(',')
        , ua  = req.headers['user-agent'];

      console.log(new Date().toString(), ips);

      var blocked = blacklist.some(function(ip) {
        return ips.indexOf(ip) >= 0;
      });

      if (blocked || !ua || ua.indexOf('curl') >= 0) {
        res.statusCode = 403;
        return res.json();
      }

      if (req.session.count) {
        if (req.session.count === 5) {
          return res.json({
            error: 'Whoa! That\'s a little too much love... you\'re making people uncomfortable...'
          });
        } else {
          req.session.count++;
        }
      } else {
        req.session.count = 1;
      }
    }

    next();
  });

  //
  // GET index.
  //
  app.get('/', function(req, res) {
    res.sendfile('./server/views/index.html');
  });

  //
  // API routes.
  // ===========
  //

  //
  // GET the most recent mavens.
  //
  app.get('/api/mavens/recent', function(req, res) {
    controller.getRecent()
      .then(function(mavens) {
        res.json(mavens);
      })
      .fail(function(err) {
        res.json({ error: err.message });
      })
      .done();
  });

  //
  // GET mavens.
  //
  app.get('/api/mavens/:username?', function(req, res) {
    controller.get(req.params.username)
      .then(function(mavens) {
        res.json(mavens);
      })
      .fail(function(err) {
        res.json({ error: err.message });
      })
      .done();
  });

  //
  // Create/POST a maven.
  //
  app.post('/api/mavens', function(req, res) {
    controller.create(req.body.username)
      .then(function(maven) {
        res.json(maven);
      })
      .fail(function(err) {
        res.json({ error: err.message });
      })
      .done();
  });

  //
  // Vote for a maven.
  //
  app.post('/api/mavens/:username/love', function(req, res) {
    controller.love(req.params.username)
      .then(function(maven) {
        res.json(maven);
      })
      .fail(function(err) {
        res.json({ error: err.message });
      })
      .done();
  });
};
<commit_msg>auth: fix `x-forwarded-for` hold<commit_after>//
//     nodemavens
//     Copyright(c) 2014 Matt Hernandez <matt@modulus.io>
//     MIT Licensed
//

var blacklist = JSON.parse(process.env.BLACKLIST || '[]');

module.exports = function(app, controller) {

  //
  // Disallow blacklisted IPs and verify the session count.
  //
  app.all('/*', function(req, res, next) {
    if ('POST' === req.method) {

      if (!req.headers['x-forwarded-for']) {
        res.statusCode = 500;
        return res.json();
      }

      var ips = req.headers['x-forwarded-for'].split(',')
        , ua  = req.headers['user-agent'];

      console.log(new Date().toString(), ips);

      var blocked = blacklist.some(function(ip) {
        return ips.indexOf(ip) >= 0;
      });

      if (blocked || !ua || ua.indexOf('curl') >= 0) {
        res.statusCode = 403;
        return res.json();
      }

      if (req.session.count) {
        if (req.session.count === 5) {
          return res.json({
            error: 'Whoa! That\'s a little too much love... you\'re making people uncomfortable...'
          });
        } else {
          req.session.count++;
        }
      } else {
        req.session.count = 1;
      }
    }

    next();
  });

  //
  // GET index.
  //
  app.get('/', function(req, res) {
    res.sendfile('./server/views/index.html');
  });

  //
  // API routes.
  // ===========
  //

  //
  // GET the most recent mavens.
  //
  app.get('/api/mavens/recent', function(req, res) {
    controller.getRecent()
      .then(function(mavens) {
        res.json(mavens);
      })
      .fail(function(err) {
        res.json({ error: err.message });
      })
      .done();
  });

  //
  // GET mavens.
  //
  app.get('/api/mavens/:username?', function(req, res) {
    controller.get(req.params.username)
      .then(function(mavens) {
        res.json(mavens);
      })
      .fail(function(err) {
        res.json({ error: err.message });
      })
      .done();
  });

  //
  // Create/POST a maven.
  //
  app.post('/api/mavens', function(req, res) {
    controller.create(req.body.username)
      .then(function(maven) {
        res.json(maven);
      })
      .fail(function(err) {
        res.json({ error: err.message });
      })
      .done();
  });

  //
  // Vote for a maven.
  //
  app.post('/api/mavens/:username/love', function(req, res) {
    controller.love(req.params.username)
      .then(function(maven) {
        res.json(maven);
      })
      .fail(function(err) {
        res.json({ error: err.message });
      })
      .done();
  });
};
<|endoftext|>


<commit_before>// Loading Screen

$(window).load(function() {

  "use strict";

  // Loading Elements

  $(".loading-overlay .spinner").fadeOut(2000, function() {

    // Show The Scroll

    $("body").css("overflow", "auto");

    $(this).parent().fadeOut(2000, function() {

      $(this).remove();
    });
  });
  $('#pinatalink').click(function(){
    window.location='http://localhost:8080/pinatafc';
  });
  $('#kidmotolink').click(function(){
  window.location='http://localhost:8080/kidmoto';
  });
  $('#flydoclink').click(function(){
    window.location='http://localhost:8080/flydoc';
  });
  //Login Elements
  $('.logout').click(function(){
    window.location='http://localhost:8080';
  });
  $('.modal-footer').click(function() {
    if ($("#uPassword").val() === '') {
      alert('No password');
    } else {
      window.location='http://localhost:8080/profile';
    }

  });
});
<commit_msg>changin local to actual url<commit_after>// Loading Screen

$(window).load(function() {

  "use strict";

  // Loading Elements

  $(".loading-overlay .spinner").fadeOut(2000, function() {

    // Show The Scroll

    $("body").css("overflow", "auto");

    $(this).parent().fadeOut(2000, function() {

      $(this).remove();
    });
  });
  $('#pinatalink').click(function(){
    window.location='https://incuvest-181515.appspot.com/pinatafc';
  });
  $('#kidmotolink').click(function(){
  window.location='https://incuvest-181515.appspot.com/kidmoto';
  });
  $('#flydoclink').click(function(){
    window.location='https://incuvest-181515.appspot.com/flydoc';
  });
  //Login Elements
  $('.logout').click(function(){
    window.location='https://incuvest-181515.appspot.com';
  });
  $('.modal-footer').click(function() {
    if ($("#uPassword").val() === '') {
      alert('No password');
    } else {
      window.location='https://incuvest-181515.appspot.com/profile';
    }

  });
});
<|endoftext|>


<commit_before>// module.exports = function(app, passport) {
//   app.post('/login', passport.authenticate('local', {
//     successReturnToOrRedirect: './',
//     failureRedirect: '../login'
//   }));
// };

module.exports = function(app, passport){
  app.post('/login', function(req, res, next) {
    passport.authenticate('local', function(err, user, info) {
      if (err) { return next(err); }
      if (!user) {
        if (/json/.test(req.headers.accept)) {
          res.send({ status: 'no user' });
          return;
        }
        return res.redirect('/login');
      }
      req.logIn(user, function(err) {
        if (err) { return next(err); }

        if (/json/.test(req.headers.accept)) {
          res.send({ status: 'logged in' });
          return;
        }

        return res.redirect('./');
      });
    })(req, res, next);
  });
}<commit_msg>redirect was wrong in login.js<commit_after>// module.exports = function(app, passport) {
//   app.post('/login', passport.authenticate('local', {
//     successReturnToOrRedirect: './',
//     failureRedirect: '../login'
//   }));
// };

module.exports = function(app, passport){
  app.post('/login', function(req, res, next) {
    passport.authenticate('local', function(err, user, info) {
      if (err) { return next(err); }
      if (!user) {
        if (/json/.test(req.headers.accept)) {
          res.send({ status: 'no user' });
          return;
        }
        return res.redirect('./login');
      }
      req.logIn(user, function(err) {
        if (err) { return next(err); }

        if (/json/.test(req.headers.accept)) {
          res.send({ status: 'logged in' });
          return;
        }

        return res.redirect('./');
      });
    })(req, res, next);
  });
}<|endoftext|>


<commit_before>var DeveloperPlayground = DeveloperPlayground || {};

DeveloperPlayground.MapView = Backbone.View.extend({
    el: '#map-view',

    events: {
        'click #map-view' : 'getBounds'
    },

    setCollection: function(options){
        this.collection = options.collection;
        console.log("setCollection: ", this.collection);
        this.listenTo(this.collection, 'add', this.addFeature);
        this.listenTo(this.collection, 'sync', this.addFeatureGroup);
        this.collection.each(this.addFeature, this);
        if (this.collection.length > 0) {
            this.addFeatureGroup();
        }
    },

    render: function() {
        this.featuregroup = new L.featureGroup();
        this.markerclustergroup = new L.MarkerClusterGroup();
        this.map = L.map('map-view').setView([37.749, -122.443], 9);
        L.tileLayer('https://{s}.tiles.mapbox.com/v3/randyme.4d62ee7c/{z}/{x}/{y}.png', {
            maxZoom: 18,
            attribution: '© OpenStreetMap contributors'
        })
            .addTo(this.map);
        return this;
    },

    getBounds: function() {
        this.bounds=this.map.getBounds();
        this.bBoxString=this.bounds.toBBoxString();
        return this.bBoxString;
    },

    addFeature: function(feature) {
        this.collection = feature.collection;

        if (feature.get('display') !== false) {
            var s = {
                'type': 'Feature',
                'name': feature.attributes.name,
                'geometry':feature.attributes.geometry,
            };
            L.geoJson(s, {
                onEachFeature: this.onEachFeature,
                style: this.styleEachFeature
            })
            // .addTo(this.featuregroup);
            .addTo(this.markerclustergroup);

        }

        return this;
    },

    styleEachFeature: function(feature) {
        // var stopIcon = L.icon({
        //     iconUrl: "/assets/images/dot2a.png",
        //     iconSize:     [15, 15], // size of the icon
        //     iconAnchor:   [5, 5], // point of the icon which will correspond to marker's location
        //     popupAnchor:  [5, 5] // point from which the popup should open relative to the iconAnchor
        // });

        var operatorStyle = {
            color: "#dd339c",
            fillColor: "#dd339c",
            weight: 3,
            opacity: .8,
            fillOpacity: .3,
            className: 'blah'
            // icon: stopIcon,
        };

        var routeStyle = {
            color: "#7720f2",
            weight: 3,
            opacity: 1,
            className: 'blah'
            // icon: stopIcon,
        };

        var geom_type = feature.geometry.type.toLowerCase();

        if ( geom_type === 'polygon') {
            return operatorStyle;
        } else if (geom_type == 'point') {
            return {};
        } else if (geom_type.indexOf('line') !== -1) {
            // styles.color = "#f34";
            return routeStyle;
        }
        return {};
    },

    onEachFeature: function(feature, layer) {

        var stopIcon = L.icon({
            iconUrl: "/assets/images/dot2a.png",
            iconSize:     [15, 15], // size of the icon
            iconAnchor:   [5, 5], // point of the icon which will correspond to marker's location
            popupAnchor:  [5, 5] // point from which the popup should open relative to the iconAnchor
        });

        var geom_type = feature.geometry.type.toLowerCase();

        // if ( geom_type === 'polygon') {
        //     // layer.bindPopup(feature.name);
        // } else if (geom_type == 'point') {
        //     // layer.bindPopup('stop');
        //     layer.setIcon(stopIcon);
        // } else if (geom_type.indexOf('line') !== -1) {
        //     // layer.bindPopup('route');
        // }

        if (geom_type == 'point') {
            layer.setIcon(stopIcon);
        }

        layer.bindPopup(feature.name);

    },

    addFeatureGroup: function() {
        console.log('add');
        // this.featuregroup.addTo(this.map);
        this.markerclustergroup.addTo(this.map);
        // this.map.fitBounds(this.featuregroup.getBounds());
        this.map.fitBounds(this.markerclustergroup.getBounds());

    }

});

<commit_msg>adding custom markerclustering<commit_after>var DeveloperPlayground = DeveloperPlayground || {};

DeveloperPlayground.MapView = Backbone.View.extend({
    el: '#map-view',

    events: {
        'click #map-view' : 'getBounds'
    },

    setCollection: function(options){
        this.collection = options.collection;
        console.log("setCollection: ", this.collection);
        this.listenTo(this.collection, 'add', this.addFeature);
        this.listenTo(this.collection, 'sync', this.addFeatureGroup);
        this.collection.each(this.addFeature, this);
        if (this.collection.length > 0) {
            this.addFeatureGroup();
        }
    },

    render: function() {
        // this.featuregroup = new L.featureGroup();
        this.markerclustergroup = new L.MarkerClusterGroup({
            maxClusterRadius: 120,
            iconCreateFunction: function (cluster) {
                var markers = cluster.getAllChildMarkers();
                var n = 0;
                for (var i = 0; i < markers.length; i++) {
                    n += markers[i].number;
                }
                return L.divIcon({ html: n, className: 'mycluster', iconSize: L.point(40, 40) });
            }
        });
        this.map = L.map('map-view').setView([37.749, -122.443], 9);
        L.tileLayer('https://{s}.tiles.mapbox.com/v3/randyme.4d62ee7c/{z}/{x}/{y}.png', {
            maxZoom: 18,
            attribution: '© OpenStreetMap contributors'
        })
            .addTo(this.map);
        return this;
    },

    getBounds: function() {
        this.bounds=this.map.getBounds();
        this.bBoxString=this.bounds.toBBoxString();
        return this.bBoxString;
    },

    addFeature: function(feature) {
        this.collection = feature.collection;

        if (feature.get('display') !== false) {
            var s = {
                'type': 'Feature',
                'name': feature.attributes.name,
                'geometry':feature.attributes.geometry,
            };
            L.geoJson(s, {
                onEachFeature: this.onEachFeature,
                style: this.styleEachFeature
            })
            // .addTo(this.featuregroup);
            .addTo(this.markerclustergroup);

        }

        return this;
    },

    styleEachFeature: function(feature) {

        var operatorStyle = {
            color: "#dd339c",
            fillColor: "#dd339c",
            weight: 3,
            opacity: .8,
            fillOpacity: .3,
            className: 'blah'
        };

        var routeStyle = {
            color: "#7720f2",
            weight: 3,
            opacity: 1,
            className: 'blah'
        };

        var geom_type = feature.geometry.type.toLowerCase();

        if ( geom_type === 'polygon') {
            return operatorStyle;
        } else if (geom_type == 'point') {
            return {};
        } else if (geom_type.indexOf('line') !== -1) {
            // styles.color = "#f34";
            return routeStyle;
        }
        return {};
    },

    onEachFeature: function(feature, layer) {

        var stopIcon = L.icon({
            iconUrl: "/assets/images/dot2a.png",
            iconSize:     [15, 15], // size of the icon
            iconAnchor:   [5, 5], // point of the icon which will correspond to marker's location
            popupAnchor:  [5, 5] // point from which the popup should open relative to the iconAnchor
        });

        var geom_type = feature.geometry.type.toLowerCase();

        if (geom_type == 'point') {
            layer.setIcon(stopIcon);
        }

        layer.bindPopup(feature.name);
    },

    addFeatureGroup: function() {
        console.log('add');
        // this.featuregroup.addTo(this.map);
        this.markerclustergroup.addTo(this.map);
        // this.map.fitBounds(this.featuregroup.getBounds());
        this.map.fitBounds(this.markerclustergroup.getBounds());

    }

});

<|endoftext|>


<commit_before>wwm.shell = (function () {
	var cfMap = {
		$con: $('#whenwemeet'),
		$view: $('#view'),
		$modal: $('#modal')
	};
	function onPopstate(e) {
		var state = e.originalEvent.state;
		var mod = state.mod;
		console.log('onpopstate', mod);
		switch (mod) {
			case 'login':
				window.userInfo = state.data;
				localStorage.login = JSON.stringify(state.data);
				localStorage.loginType = state.type;
				wwm.lobby.initModule(wwm.shell.view);
				break;
			case 'directlogin':
				wwm.login.initModule(wwm.shell.view);
				break;
			case 'lobby':
				wwm.lobby.initModule(wwm.shell.view);
				break;
			case 'intro':
				wwm.modal.initModule($('#wwm-intro').html());
				break;
			case 'search':
				wwm.lobby.showSearchResult(state.data);
				break;
			case 'logout':
				delete window.userInfo;
				localStorage.removeItem('login');
				localStorage.removeItem('loginType');
				wwm.login.initModule(wwm.shell.view);
				break;
			case 'room':
				wwm.room.initModule(state.data, 'enter');
				break;
			case 'confirm':
				break;
			default:
				wwm.shell.initModule();
		}
	}
	function onError(errorMsg, url, lineNumber, column, errorObj) {
		if (typeof errorMsg === 'string' && errorMsg.indexOf('Script error.') > -1) {
			return;
		}
		console.log('Error: ', errorMsg, ' Script: ' + url + ' Line: ' + lineNumber + ' Column: ' + column + ' StackTrace: ' + errorObj);
	}
	function drawEqTriangle(ctx, side, cx, cy, color){
		var h = side * (Math.sqrt(3)/2);
		ctx.fillStyle = color;
		ctx.beginPath();
		ctx.moveTo(cx, cy - h / 2);
		ctx.lineTo(cx - side / 2, cy + h / 2);
		ctx.lineTo(cx + side / 2, cy + h / 2);
		ctx.lineTo(cx, cy - h / 2);
		ctx.shadowOffsetX = 1;
		ctx.shadowOffsetY = 3;
		ctx.shadowBlur    = 1;
		ctx.shadowColor   = 'rgb(204, 204, 204)';
		ctx.fill();
	}
	function drawRevEqTriangle(ctx, side, cx, cy, color){
		var h = side * (Math.sqrt(3)/2);
		ctx.fillStyle = color;
		ctx.beginPath();
		ctx.moveTo(cx, cy - h / 2);
		ctx.lineTo(cx - side, cy - h / 2);
		ctx.lineTo(cx - side / 2, cy + h / 2);
		ctx.lineTo(cx, cy - h / 2);
		ctx.shadowOffsetX = 1;
		ctx.shadowOffsetY = 3;
		ctx.shadowBlur    = 1;
		ctx.shadowColor   = 'rgb(204, 204, 204)';
		ctx.fill();
	}
	function showCanvasLogo($target, width) {
		var $logo = $($('#wwm-canvas-logo').html());
		var canvas = $logo[0];
		var ctx = canvas.getContext('2d');
		drawEqTriangle(ctx, 50, canvas.width/2 + 13, canvas.height/2, 'magenta');
		drawRevEqTriangle(ctx, 50, canvas.width/2 + 7, canvas.height/2, 'cyan');
		drawEqTriangle(ctx, 50, canvas.width/2 - 16, canvas.height/2 - 49, 'yellow');
		drawRevEqTriangle(ctx, 50, canvas.width/2 + 36, canvas.height/2 + 49, 'greenyellow');
		$logo.width(width);
		$target.prepend($logo);
	}
	function showSVGLogo($target, width) {
		var $logo = $($('#wwm-svg-logo').html());
		$logo.width(width);
		$target.prepend($logo);
	}

	function initModule() {
		console.log('login', localStorage.login);
		console.log('first', localStorage.first);
		window.onerror = onError;
		$(window).on('popstate', onPopstate);
		var logged = localStorage.login && JSON.parse(localStorage.login);
		var first = localStorage.first && JSON.parse(localStorage.first);
		if (first) {
			history.pushState({mod: 'intro'}, '', '/intro');
		}
		if (logged) {
			history.pushState({mode: 'lobby', id: userInfo.id}, '', '/lobby/' + userInfo.id);
		} else {
			history.pushState({mode: 'directlogin'}, '', '/login');
		}
	}

	return {
		initModule: initModule,
		view: cfMap.$view,
		modal: cfMap.$modal,
		showSVGLogo: showSVGLogo,
		showCanvasLogo: showCanvasLogo
	};
}());
<commit_msg>Update wwm.shell.js<commit_after>wwm.shell = (function () {
	var cfMap = {
		$con: $('#whenwemeet'),
		$view: $('#view'),
		$modal: $('#modal')
	};
	function onPopstate(e) {
		var state = e.originalEvent.state;
		var mod = state.mod;
		console.log('onpopstate', mod);
		switch (mod) {
			case 'login':
				window.userInfo = state.data;
				localStorage.login = JSON.stringify(state.data);
				localStorage.loginType = state.type;
				wwm.lobby.initModule(wwm.shell.view);
				break;
			case 'directlogin':
				wwm.login.initModule(wwm.shell.view);
				break;
			case 'lobby':
				wwm.lobby.initModule(wwm.shell.view);
				break;
			case 'intro':
				wwm.modal.initModule($('#wwm-intro').html());
				break;
			case 'search':
				wwm.lobby.showSearchResult(state.data);
				break;
			case 'logout':
				delete window.userInfo;
				localStorage.removeItem('login');
				localStorage.removeItem('loginType');
				wwm.login.initModule(wwm.shell.view);
				break;
			case 'room':
				wwm.room.initModule(state.data, 'enter');
				break;
			case 'confirm':
				break;
			default:
				wwm.shell.initModule();
		}
	}
	function onError(errorMsg, url, lineNumber, column, errorObj) {
		if (typeof errorMsg === 'string' && errorMsg.indexOf('Script error.') > -1) {
			return;
		}
		console.log('Error: ', errorMsg, ' Script: ' + url + ' Line: ' + lineNumber + ' Column: ' + column + ' StackTrace: ' + errorObj);
	}
	function drawEqTriangle(ctx, side, cx, cy, color){
		var h = side * (Math.sqrt(3)/2);
		ctx.fillStyle = color;
		ctx.beginPath();
		ctx.moveTo(cx, cy - h / 2);
		ctx.lineTo(cx - side / 2, cy + h / 2);
		ctx.lineTo(cx + side / 2, cy + h / 2);
		ctx.lineTo(cx, cy - h / 2);
		ctx.shadowOffsetX = 1;
		ctx.shadowOffsetY = 3;
		ctx.shadowBlur    = 1;
		ctx.shadowColor   = 'rgb(204, 204, 204)';
		ctx.fill();
	}
	function drawRevEqTriangle(ctx, side, cx, cy, color){
		var h = side * (Math.sqrt(3)/2);
		ctx.fillStyle = color;
		ctx.beginPath();
		ctx.moveTo(cx, cy - h / 2);
		ctx.lineTo(cx - side, cy - h / 2);
		ctx.lineTo(cx - side / 2, cy + h / 2);
		ctx.lineTo(cx, cy - h / 2);
		ctx.shadowOffsetX = 1;
		ctx.shadowOffsetY = 3;
		ctx.shadowBlur    = 1;
		ctx.shadowColor   = 'rgb(204, 204, 204)';
		ctx.fill();
	}
	function showCanvasLogo($target, width) {
		var $logo = $($('#wwm-canvas-logo').html());
		var canvas = $logo[0];
		var ctx = canvas.getContext('2d');
		drawEqTriangle(ctx, 50, canvas.width/2 + 13, canvas.height/2, 'magenta');
		drawRevEqTriangle(ctx, 50, canvas.width/2 + 7, canvas.height/2, 'cyan');
		drawEqTriangle(ctx, 50, canvas.width/2 - 16, canvas.height/2 - 49, 'yellow');
		drawRevEqTriangle(ctx, 50, canvas.width/2 + 36, canvas.height/2 + 49, 'greenyellow');
		$logo.width(width);
		$target.prepend($logo);
	}
	function showSVGLogo($target, width) {
		var $logo = $($('#wwm-svg-logo').html());
		$logo.width(width);
		$target.prepend($logo);
	}

	function initModule() {
		console.log('login', localStorage.login);
		console.log('first', localStorage.first);
		window.onerror = onError;
		$(window).on('popstate', onPopstate);
		var logged = localStorage.login && JSON.parse(localStorage.login);
		var first = localStorage.first && JSON.parse(localStorage.first);
		if (first) {
			history.pushState({mod: 'intro'}, '', '/intro');
			wwm.modal.initModule($('#wwm-intro').html());
		}
		if (logged) {
			history.pushState({mode: 'lobby', id: userInfo.id}, '', '/lobby/' + userInfo.id);
			wwm.lobby.initModule(wwm.shell.view);
		} else {
			history.pushState({mode: 'directlogin'}, '', '/login');
			wwm.login.initModule(wwm.shell.view);
		}
	}

	return {
		initModule: initModule,
		view: cfMap.$view,
		modal: cfMap.$modal,
		showSVGLogo: showSVGLogo,
		showCanvasLogo: showCanvasLogo
	};
}());
<|endoftext|>


<commit_before>function Teams() {
    this.teams = [
        {
            id: "Renaissance",
            name: "Renaissance",
            streams: ["StreamR1", "StreamR2", "StreamR3"],
            teamLead: "Aliaksandr Koush",
            qaTeamLead: "Aliaksandra Kutynka",
            developers: [
                "Andrei Osipau2",
                "Dzianis Arlouski",
                "Siarhei Tkachenka",
                "Iryna Kucharenka1",
                "Ivan Izmer",
                "Mark Varabyou",
                "Raman But-Husaim",
                "Siarhei Abrazhevich",
                "Artsiom Rusak",
                "Raman Ivanou",
                "Aliaksandr Koush",
                "Nicolay Kostroma",
                "Valentina Napolnova",
                "Aliaksey Rahatka",
                "Pavel Kastsiuk",
                "Juliana Stolnik",
                "Artsiom Kazlou"
            ],
            testers: [
                "Pavel Vysotsky",
                "Viktoriya Harbatsenkava",
                "Hanna Prykhodzka",
                "Kseniya Kavalchuk",
                "Yuliya Tukaila",
                "Aliaksandra Kutynka"
            ]
        },
        {
            id: "Inspiration",
            name: "Inspiration",
            streams: ["StreamIn1", "StreamIn2", "StreamIn3"],
            teamLead: "Sergey Tischenko",
            qaTeamLead: "Denys Pugachov",
            developers: [
                "Borys Roshal",
                "Denys Poliakov",
                "Kostiantyn Lazurenko",
                "Oleksandr Stukalov",
                "Oleksii Bespalko",
                "Yevhenii Havryliuk",
                "Yuriy Shestyora",
                "Ihor Bershov",
                "Vladyslav Pilhui",
                "Oleksandr Zhyltsov",
                "Oleksii Suriadnyi",
                "Roman Golovchenko",
                "Serhiy Haponenko",
                "Yevhenii Lomov",
                "Ihor Rudchenko",
                "Andrii Savinov",
                "Dmytro Petlia",
                "Olena Ostroverkhova"
            ],
            testers: [
                "Mila Botnar",
                "Yuri Timchenko",
                "Anastasia Kotenyova",
                "Pavlo Golovashchenko",
                "Oleksii Milman",
                "Denys Pugachov"
            ]
        },
        {
            id: "Nova",
            name: "Nova",
            streams: ["StreamN1", "StreamN2", "StreamN3"],
            teamLead: "Heorhi Vilkitski",
            qaTeamLead: "Valiantsina Krautsevich",
            developers: [
                "Andrei Kandybovich",
                "Dzmitry Siamchonak",
                "Mikita Stalpinski",
                "Uladzimir Harabtsou",
                "Aliaksandr Nikulin",
                "Ilya Kazlou1",
                "Katsiaryna Kaliukhovich",
                "Vadzim Vysotski",
                "Edhar Liashok",
                "Raman Prakofyeu",
                "Ruslan Khilmanovich",
                "Anton Kratenok",
                "Siarhei Maksimau1",
                "Dzmitry Chapurok",
                "Evgeny Sinitsyn",
                "Dzmitry Salodki"
            ],
            testers: [
                "Aliaksei Burnosenka",
                "Viktar Mikalayenka",
                "Eugeny Okulik",
                "Yuliya Kalasouskaya",
                "Hanna Maskalenka",
                "Valiantsina Krautsevich"
            ]
        },
        {
            id: "Liberty",
            name: "Liberty",
            streams: ["StreamL1", "StreamL2", "StreamL3"],
            teamLead: "Dzmitry Tabolich",
            qaTeamLead: "Iryna Kutsko",
            developers: [
                "Pavel Naumenka",
                "Sergei Kulick",
                "Volha Shandrokha",
                "Aliaksandr Rusak",
                "Andrei Kasak",
                "Andrei Krasnou",
                "Pavel Krakasevich",
                "Stepan Zelenin",
                "Dzmitry Isachenka",
                "Eugen Surovets",
                "Katsiaryna Tsalabanava",
                "Kate Tsalabanava",
                "Vitali Podobed",
                "Hleb Krotsik",
                "Uladzimir Vysotski"

            ],
            testers: [
                "Anna Novikova",
                "Anton Rapinchuk",
                "Igor Andros",
                "Maria Sobal",
                "Yuliya Karnatsevich",
                "Iryna Kutsko",
                "Natalya Krestelyova"
            ]
        },
        {
            id: "Viva",
            name: "Viva",
            streams: ["StreamV1", "StreamV2", "StreamV3"],
            teamLead: "Valentine Zhuck",
            qaTeamLead: "Katsiaryna Kuchko",
            developers: [
                "Valentine Zhuck",
                "Maryna Furman",
                "Siarhei Zhalezka",
                "Viachaslau Anufryiuk",
                "Yury Yamoryk",
                "Aliaksandr Kladau",
                "Dzmitry Kavaliou",
                "Dzmitry Shynkarou",
                "Maksim Tsikhan",
                "Petr Falitarchyk",
                "Yuri Chupyrkin",
                "Aliaksandr Rykau",
                "Ivan Dziameshka",
                "Siarhei Bahdanovich",
                "Andrei Lysenka",
                "Aleh Dukel",
                "Ivan Yanchuk"
            ],
            testers: [
                "Iryna Koush",
                "Maryia Kireyeva",
                "Iryna Shuliak",
                "Liudmila Barshcheuskaya",
                "Iryna Razorionova",
                "Katsiaryna Kuchko"
            ]
        },
        {
            id: "Elfish",
            name: "Elfish",
            teamLead: "Serhiy Haponenko",
            qaTeamLead: "",
            developers: [
                "Serhiy Haponenko",
                "Allaberdi Hojayev",
                "Bohdan Sorokin",
                "Yevhenii Koliesnik"
            ],
            testers: [
                "Ivan Nalyvaiko",
                "Oleksii Shchelkunov",
                "Valeriia Karabut"
            ]
        },
        {
            id: "TeamAutomation",
            name: "Automation",
            teamLead: "Aliaksandr Basau",
            developers: [
                "Nadzeya Mishurava",
                "Viachaslau Naimovich",
                "Vitali Sonchyk",
                "Katsiaryna Firsava",
                "Katsiaryna Kulbitskaya",
                "Maryia Kashtanava",
                "Rustam Allanazarau"
            ]
        }
    ]
}

exports.AllTeams = new Teams();

exports.OldDevelopers = function oldDevelopers(name) {
    if(name == 'Valentine Zhuck' ||
        name == 'Dzmitry Tabolich' ||
        name == 'Heorhi Vilkitski' ||
        name == "Hanna Kastsian" ||
        name == "Alena Charnova" ||
        name == "Aliaksei Astashkin" ||
        name == "yauheni_lohinau" ||
        name == "Dmytro Komar" ||
        name == "Aliaksei Labachou" ||
        name == "Mariya Babich" ||
        name == "Katsiaryna Sasina" ||
        name == "aliaksei_labachou aliaksei_labachou" ||
        name == undefined) {
        return true;
    }
    return false;
};
<commit_msg>update<commit_after>function Teams() {
    this.teams = [
        {
            id: "Renaissance",
            name: "Renaissance",
            streams: ["StreamR1", "StreamR2", "StreamR3"],
            teamLead: "Aliaksandr Koush",
            qaTeamLead: "Aliaksandra Kutynka",
            developers: [
                "Andrei Osipau2",
                "Dzianis Arlouski",
                "Siarhei Tkachenka",
                "Iryna Kucharenka1",
                "Ivan Izmer",
                "Mark Varabyou",
                "Raman But-Husaim",
                "Siarhei Abrazhevich",
                "Artsiom Rusak",
                "Raman Ivanou",
                "Aliaksandr Koush",
                "Nicolay Kostroma",
                "Valentina Napolnova",
                "Aliaksey Rahatka",
                "Pavel Kastsiuk",
                "Juliana Stolnik",
                "Artsiom Kazlou"
            ],
            testers: [
                "Pavel Vysotsky",
                "Viktoriya Harbatsenkava",
                "Hanna Prykhodzka",
                "Kseniya Kavalchuk",
                "Yuliya Tukaila",
                "Aliaksandra Kutynka"
            ]
        },
        {
            id: "Inspiration",
            name: "Inspiration",
            streams: ["StreamIn1", "StreamIn2", "StreamIn3"],
            teamLead: "Sergey Tischenko",
            qaTeamLead: "Denys Pugachov",
            developers: [
                "Borys Roshal",
                "Denys Poliakov",
                "Kostiantyn Lazurenko",
                "Oleksandr Stukalov",
                "Oleksii Bespalko",
                "Yevhenii Havryliuk",
                "Yuriy Shestyora",
                "Ihor Bershov",
                "Vladyslav Pilhui",
                "Oleksandr Zhyltsov",
                "Oleksii Suriadnyi",
                "Serhiy Haponenko",
                "Yevhenii Lomov",
                "Ihor Rudchenko",
                "Andrii Savinov",
                "Dmytro Petlia",
                "Olena Ostroverkhova"
            ],
            testers: [
                "Mila Botnar",
                "Yuri Timchenko",
                "Anastasia Kotenyova",
                "Pavlo Golovashchenko",
                "Oleksii Milman",
                "Denys Pugachov"
            ]
        },
        {
            id: "Nova",
            name: "Nova",
            streams: ["StreamN1", "StreamN2", "StreamN3"],
            teamLead: "Heorhi Vilkitski",
            qaTeamLead: "Valiantsina Krautsevich",
            developers: [
                "Andrei Kandybovich",
                "Dzmitry Siamchonak",
                "Mikita Stalpinski",
                "Uladzimir Harabtsou",
                "Aliaksandr Nikulin",
                "Ilya Kazlou1",
                "Katsiaryna Kaliukhovich",
                "Vadzim Vysotski",
                "Edhar Liashok",
                "Raman Prakofyeu",
                "Ruslan Khilmanovich",
                "Anton Kratenok",
                "Siarhei Maksimau1",
                "Dzmitry Chapurok",
                "Evgeny Sinitsyn",
                "Dzmitry Salodki"
            ],
            testers: [
                "Aliaksei Burnosenka",
                "Viktar Mikalayenka",
                "Eugeny Okulik",
                "Yuliya Kalasouskaya",
                "Hanna Maskalenka",
                "Valiantsina Krautsevich"
            ]
        },
        {
            id: "Liberty",
            name: "Liberty",
            streams: ["StreamL1", "StreamL2", "StreamL3"],
            teamLead: "Dzmitry Tabolich",
            qaTeamLead: "Iryna Kutsko",
            developers: [
                "Pavel Naumenka",
                "Sergei Kulick",
                "Volha Shandrokha",
                "Aliaksandr Rusak",
                "Andrei Kasak",
                "Andrei Krasnou",
                "Pavel Krakasevich",
                "Stepan Zelenin",
                "Dzmitry Isachenka",
                "Eugen Surovets",
                "Katsiaryna Tsalabanava",
                "Kate Tsalabanava",
                "Vitali Podobed",
                "Hleb Krotsik",
                "Uladzimir Vysotski"
            ],
            testers: [
                "Anna Novikova",
                "Anton Rapinchuk",
                "Igor Andros",
                "Maria Sobal",
                "Yuliya Karnatsevich",
                "Iryna Kutsko",
                "Natalya Krestelyova"
            ]
        },
        {
            id: "Viva",
            name: "Viva",
            streams: ["StreamV1", "StreamV2", "StreamV3"],
            teamLead: "Valentine Zhuck",
            qaTeamLead: "Katsiaryna Kuchko",
            developers: [
                "Valentine Zhuck",
                "Maryna Furman",
                "Siarhei Zhalezka",
                "Viachaslau Anufryiuk",
                "Yury Yamoryk",
                "Aliaksandr Kladau",
                "Dzmitry Kavaliou",
                "Dzmitry Shynkarou",
                "Maksim Tsikhan",
                "Petr Falitarchyk",
                "Yuri Chupyrkin",
                "Aliaksandr Rykau",
                "Ivan Dziameshka",
                "Siarhei Bahdanovich",
                "Andrei Lysenka",
                "Aleh Dukel",
                "Ivan Yanchuk"
            ],
            testers: [
                "Iryna Koush",
                "Maryia Kireyeva",
                "Iryna Shuliak",
                "Liudmila Barshcheuskaya",
                "Iryna Razorionova",
                "Katsiaryna Kuchko"
            ]
        },
        {
            id: "Elfish",
            name: "Elfish",
            teamLead: "Roman Golovchenko",
            qaTeamLead: "",
            developers: [
                "Roman Golovchenko",
                "Allaberdi Hojayev",
                "Bohdan Sorokin",
                "Yevhenii Koliesnik"
            ],
            testers: [
                "Ivan Nalyvaiko",
                "Oleksii Shchelkunov",
                "Valeriia Karabut"
            ]
        },
        {
            id: "TeamAutomation",
            name: "Automation",
            teamLead: "Aliaksandr Basau",
            developers: [
                "Nadzeya Mishurava",
                "Viachaslau Naimovich",
                "Vitali Sonchyk",
                "Katsiaryna Firsava",
                "Katsiaryna Kulbitskaya",
                "Maryia Kashtanava",
                "Rustam Allanazarau"
            ]
        }
    ]
}

exports.AllTeams = new Teams();

exports.OldDevelopers = function oldDevelopers(name) {
    if(name == 'Valentine Zhuck' ||
        name == 'Dzmitry Tabolich' ||
        name == 'Heorhi Vilkitski' ||
        name == "Hanna Kastsian" ||
        name == "Alena Charnova" ||
        name == "Aliaksei Astashkin" ||
        name == "yauheni_lohinau" ||
        name == "Dmytro Komar" ||
        name == "Aliaksei Labachou" ||
        name == "Mariya Babich" ||
        name == "Katsiaryna Sasina" ||
        name == "aliaksei_labachou aliaksei_labachou" ||
        name == undefined) {
        return true;
    }
    return false;
};
<|endoftext|>


<commit_before>// Make the app work as a single-page app on iOS devices
(function(a, b, c) {
    if (c in b && b[c]) {
        var d, e = a.location,
            f = /^(a|html)$/i;
        a.addEventListener("click", function(a) {
            d = a.target;
            while (!f.test(d.nodeName)) d = d.parentNode;
            "href" in d && (chref = d.href).replace(e.href, "").indexOf("#") && (!/^[a-z\+\.\-]+:/i.test(chref) || chref.indexOf(e.protocol + "//" + e.host) === 0) && (a.preventDefault(), e.href = d.href)
        }, !1)
    }
})(document, window.navigator, "standalone");

function init() {
    page = window.location.pathname;

    if (page == "/bucket") {
        setActiveNavigation("bucket");
    } else if (page == "/expense") {
        setActiveNavigation("expense");
    } else if (page == "/income") {
        setActiveNavigation("income");
    } else if (page == "/setting") {
        setActiveNavigation("setting");
    } else if (page == "/log") {
        setActiveNavigation("expense");

        document.getElementById("amount").focus();
    }
}

function setActiveNavigation(button) {
    // Reset all buttons
    document.getElementById("bucket").className = "navigation-button";
    document.getElementById("expense").className = "navigation-button";
    document.getElementById("income").className = "navigation-button";
    document.getElementById("setting").className = "navigation-button";

    // Make the button we care about active
    document.getElementById(button).className += " active";
}

function logExpense() {
    amount = $("#amount").val();
    recipient = $("#recipient").val();
    note = $("#note").val();

    body = {
        amount: amount,
        recipient: recipient,
        note: note
    };

    console.log(JSON.stringify(body));

    $.ajax("/expense", {
        "data": JSON.stringify(body),
        "type": "POST",
        "processData": false,
        "contentType": "application/json"
    }, function(data) {
        console.log(data);
    });
}
<commit_msg>Redirecting after submission<commit_after>// Make the app work as a single-page app on iOS devices
(function(a, b, c) {
    if (c in b && b[c]) {
        var d, e = a.location,
            f = /^(a|html)$/i;
        a.addEventListener("click", function(a) {
            d = a.target;
            while (!f.test(d.nodeName)) d = d.parentNode;
            "href" in d && (chref = d.href).replace(e.href, "").indexOf("#") && (!/^[a-z\+\.\-]+:/i.test(chref) || chref.indexOf(e.protocol + "//" + e.host) === 0) && (a.preventDefault(), e.href = d.href)
        }, !1)
    }
})(document, window.navigator, "standalone");

function init() {
    page = window.location.pathname;

    if (page == "/bucket") {
        setActiveNavigation("bucket");
    } else if (page == "/expense") {
        setActiveNavigation("expense");
    } else if (page == "/income") {
        setActiveNavigation("income");
    } else if (page == "/setting") {
        setActiveNavigation("setting");
    } else if (page == "/log") {
        setActiveNavigation("expense");

        document.getElementById("amount").focus();
    }
}

function setActiveNavigation(button) {
    // Reset all buttons
    document.getElementById("bucket").className = "navigation-button";
    document.getElementById("expense").className = "navigation-button";
    document.getElementById("income").className = "navigation-button";
    document.getElementById("setting").className = "navigation-button";

    // Make the button we care about active
    document.getElementById(button).className += " active";
}

function logExpense() {
    amount = $("#amount").val();
    recipient = $("#recipient").val();
    note = $("#note").val();

    body = {
        amount: amount,
        recipient: recipient,
        note: note
    };

    $.ajax("/expense", {
        "data": JSON.stringify(body),
        "type": "POST",
        "processData": false,
        "contentType": "application/json",
        "success": function(data) {
            window.location.href = "/expense";
        }
    });
}
<|endoftext|>


<commit_before>/**
 * @authors : hoozi
 * @webSite : https://github.com/hoozi
 * @email   : 287036406@qq.com
 * @date    : 2015-06-02 13:15:34
 * @version : 0.0.1
 */
var signUp = angular.module('signUp', []);
signUp.controller('signUpForm', ['$scope', function($scope){

}])

<commit_msg>add submit<commit_after>/**
 * @authors : hoozi
 * @webSite : https://github.com/hoozi
 * @email   : 287036406@qq.com
 * @date    : 2015-06-02 13:15:34
 * @version : 0.0.1
 */
var signUp = angular.module('signUp', []);
signUp.controller('signUpForm', ['$scope', function($scope){
	$scope.submitForm = function(v,event) {

		if(!v) {
			alert("error");
			event.preventDefault(); //标准
       	 	event.returnValue = false //IE
			return false;
		}
	}
}])

<|endoftext|>