<commit_before>/* Pi-hole: A black hole for Internet advertisements
 *  (c) 2017 Pi-hole, LLC (https://pi-hole.net)
 *  Network-wide ad blocking via your own hardware.
 *
 *  This file is copyright under the latest version of the EUPL.
 *  Please see LICENSE file for your rights under this license. */

$(function () {
  $("[data-static]").on("click", function () {
    var row = $(this).closest("tr");
    var mac = row.find("#MAC").text();
    var ip = row.find("#IP").text();
    var host = row.find("#HOST").text();
    $('input[name="AddHostname"]').val(host);
    $('input[name="AddIP"]').val(ip);
    $('input[name="AddMAC"]').val(mac);
  });
});
$(".confirm-poweroff").confirm({
  text: "Are you sure you want to send a poweroff command to your Pi-Hole?",
  title: "Confirmation required",
  confirm: function () {
    $("#poweroffform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, poweroff",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog modal-mg" // Bootstrap classes for mid-size modal
});
$(".confirm-reboot").confirm({
  text: "Are you sure you want to send a reboot command to your Pi-Hole?",
  title: "Confirmation required",
  confirm: function () {
    $("#rebootform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, reboot",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog modal-mg" // Bootstrap classes for mid-size modal
});

$(".confirm-restartdns").confirm({
  text: "Are you sure you want to send a restart command to your DNS server?",
  title: "Confirmation required",
  confirm: function () {
    $("#restartdnsform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, restart DNS",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog modal-mg"
});

$(".confirm-flushlogs").confirm({
  text: "Are you sure you want to flush your logs?",
  title: "Confirmation required",
  confirm: function () {
    $("#flushlogsform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, flush logs",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog modal-mg"
});

$(".confirm-flusharp").confirm({
  text: "Are you sure you want to flush your network table?",
  title: "Confirmation required",
  confirm: function () {
    $("#flusharpform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, flush my network table",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-warning",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog modal-mg"
});

$(".confirm-disablelogging-noflush").confirm({
  text: "Are you sure you want to disable logging?",
  title: "Confirmation required",
  confirm: function () {
    $("#disablelogsform-noflush").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, disable logs",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-warning",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog modal-mg"
});

$(".api-token").confirm({
  text:
    "Make sure that nobody else can scan this code around you. They will have full access to the API without having to know the password. Note that the generation of the QR code will take some time.",
  title: "Confirmation required",
  confirm: function () {
    window.open("scripts/pi-hole/php/api_token.php");
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, show API token",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog modal-mg"
});

$("#DHCPchk").click(function () {
  $("input.DHCPgroup").prop("disabled", !this.checked);
  $("#dhcpnotice").prop("hidden", !this.checked).addClass("lookatme");
});

function loadCacheInfo() {
  $.getJSON("api.php?getCacheInfo", function (data) {
    if ("FTLnotrunning" in data) {
      return;
    }

    // Fill table with obtained values
    $("#cache-size").text(parseInt(data.cacheinfo["cache-size"]));
    $("#cache-inserted").text(parseInt(data.cacheinfo["cache-inserted"]));

    // Highlight early cache removals when present
    var cachelivefreed = parseInt(data.cacheinfo["cache-live-freed"]);
    $("#cache-live-freed").text(cachelivefreed);
    if (cachelivefreed > 0) {
      $("#cache-live-freed").parent("tr").addClass("lookatme");
    } else {
      $("#cache-live-freed").parent("tr").removeClass("lookatme");
    }

    // Update cache info every 10 seconds
    setTimeout(loadCacheInfo, 10000);
  });
}

var leasetable, staticleasetable;
$(document).ready(function () {
  if (document.getElementById("DHCPLeasesTable")) {
    leasetable = $("#DHCPLeasesTable").DataTable({
      dom: "<'row'<'col-sm-12'tr>><'row'<'col-sm-6'i><'col-sm-6'f>>",
      columnDefs: [{ bSortable: false, orderable: false, targets: -1 }],
      paging: false,
      scrollCollapse: true,
      scrollY: "200px",
      scrollX: true,
      order: [[2, "asc"]]
    });
  }

  if (document.getElementById("DHCPStaticLeasesTable")) {
    staticleasetable = $("#DHCPStaticLeasesTable").DataTable({
      dom: "<'row'<'col-sm-12'tr>><'row'<'col-sm-12'i>>",
      columnDefs: [{ bSortable: false, orderable: false, targets: -1 }],
      paging: false,
      scrollCollapse: true,
      scrollY: "200px",
      scrollX: true,
      order: [[2, "asc"]]
    });
  }

  //call draw() on each table... they don't render properly with scrollX and scrollY set... ¯\_(ツ)_/¯
  $('a[data-toggle="tab"]').on("shown.bs.tab", function () {
    leasetable.draw();
    staticleasetable.draw();
  });

  loadCacheInfo();
});

// Handle hiding of alerts
$(function () {
  $("[data-hide]").on("click", function () {
    $(this)
      .closest("." + $(this).attr("data-hide"))
      .hide();
  });
});

// DHCP leases tooltips
$(document).ready(function () {
  $('[data-toggle="tooltip"]').tooltip({ html: true, container: "body" });
});

// Change "?tab=" parameter in URL for save and reload
$(".nav-tabs a").on("shown.bs.tab", function (e) {
  var tab = e.target.hash.substring(1);
  window.history.pushState("", "", "?tab=" + tab);
  if (tab === "piholedhcp") {
    window.location.reload();
  }

  window.scrollTo(0, 0);
});

// Auto dismissal for info notifications
$(document).ready(function () {
  var alInfo = $("#alInfo");
  if (alInfo.length > 0) {
    alInfo.delay(3000).fadeOut(2000, function () {
      alInfo.hide();
    });
  }

  // Disable autocorrect in the search box
  var input = document.querySelector("input[type=search]");
  input.setAttribute("autocomplete", "off");
  input.setAttribute("autocorrect", "off");
  input.setAttribute("autocapitalize", "off");
  input.setAttribute("spellcheck", false);
});
<commit_msg>Update settings.js<commit_after>/* Pi-hole: A black hole for Internet advertisements
 *  (c) 2017 Pi-hole, LLC (https://pi-hole.net)
 *  Network-wide ad blocking via your own hardware.
 *
 *  This file is copyright under the latest version of the EUPL.
 *  Please see LICENSE file for your rights under this license. */

$(function () {
  $("[data-static]").on("click", function () {
    var row = $(this).closest("tr");
    var mac = row.find("#MAC").text();
    var ip = row.find("#IP").text();
    var host = row.find("#HOST").text();
    $('input[name="AddHostname"]').val(host);
    $('input[name="AddIP"]').val(ip);
    $('input[name="AddMAC"]').val(mac);
  });
});
$(".confirm-poweroff").confirm({
  text: "Are you sure you want to send a poweroff command to your Pi-hole?",
  title: "Confirmation required",
  confirm: function () {
    $("#poweroffform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, poweroff",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog"
});
$(".confirm-reboot").confirm({
  text: "Are you sure you want to send a reboot command to your Pi-hole?",
  title: "Confirmation required",
  confirm: function () {
    $("#rebootform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, reboot",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog"
});

$(".confirm-restartdns").confirm({
  text: "Are you sure you want to send a restart command to your DNS server?",
  title: "Confirmation required",
  confirm: function () {
    $("#restartdnsform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, restart DNS",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog"
});

$(".confirm-flushlogs").confirm({
  text: "Are you sure you want to flush your logs?",
  title: "Confirmation required",
  confirm: function () {
    $("#flushlogsform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, flush logs",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog"
});

$(".confirm-flusharp").confirm({
  text: "Are you sure you want to flush your network table?",
  title: "Confirmation required",
  confirm: function () {
    $("#flusharpform").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, flush my network table",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-warning",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog"
});

$(".confirm-disablelogging-noflush").confirm({
  text: "Are you sure you want to disable logging?",
  title: "Confirmation required",
  confirm: function () {
    $("#disablelogsform-noflush").submit();
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, disable logs",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-warning",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog"
});

$(".api-token").confirm({
  text:
    "Make sure that nobody else can scan this code around you. They will have full access to the API without having to know the password. Note that the generation of the QR code will take some time.",
  title: "Confirmation required",
  confirm: function () {
    window.open("scripts/pi-hole/php/api_token.php");
  },
  cancel: function () {
    // nothing to do
  },
  confirmButton: "Yes, show API token",
  cancelButton: "No, go back",
  post: true,
  confirmButtonClass: "btn-danger",
  cancelButtonClass: "btn-success",
  dialogClass: "modal-dialog"
});

$("#DHCPchk").click(function () {
  $("input.DHCPgroup").prop("disabled", !this.checked);
  $("#dhcpnotice").prop("hidden", !this.checked).addClass("lookatme");
});

function loadCacheInfo() {
  $.getJSON("api.php?getCacheInfo", function (data) {
    if ("FTLnotrunning" in data) {
      return;
    }

    // Fill table with obtained values
    $("#cache-size").text(parseInt(data.cacheinfo["cache-size"]));
    $("#cache-inserted").text(parseInt(data.cacheinfo["cache-inserted"]));

    // Highlight early cache removals when present
    var cachelivefreed = parseInt(data.cacheinfo["cache-live-freed"]);
    $("#cache-live-freed").text(cachelivefreed);
    if (cachelivefreed > 0) {
      $("#cache-live-freed").parent("tr").addClass("lookatme");
    } else {
      $("#cache-live-freed").parent("tr").removeClass("lookatme");
    }

    // Update cache info every 10 seconds
    setTimeout(loadCacheInfo, 10000);
  });
}

var leasetable, staticleasetable;
$(document).ready(function () {
  if (document.getElementById("DHCPLeasesTable")) {
    leasetable = $("#DHCPLeasesTable").DataTable({
      dom: "<'row'<'col-sm-12'tr>><'row'<'col-sm-6'i><'col-sm-6'f>>",
      columnDefs: [{ bSortable: false, orderable: false, targets: -1 }],
      paging: false,
      scrollCollapse: true,
      scrollY: "200px",
      scrollX: true,
      order: [[2, "asc"]]
    });
  }

  if (document.getElementById("DHCPStaticLeasesTable")) {
    staticleasetable = $("#DHCPStaticLeasesTable").DataTable({
      dom: "<'row'<'col-sm-12'tr>><'row'<'col-sm-12'i>>",
      columnDefs: [{ bSortable: false, orderable: false, targets: -1 }],
      paging: false,
      scrollCollapse: true,
      scrollY: "200px",
      scrollX: true,
      order: [[2, "asc"]]
    });
  }

  //call draw() on each table... they don't render properly with scrollX and scrollY set... ¯\_(ツ)_/¯
  $('a[data-toggle="tab"]').on("shown.bs.tab", function () {
    leasetable.draw();
    staticleasetable.draw();
  });

  loadCacheInfo();
});

// Handle hiding of alerts
$(function () {
  $("[data-hide]").on("click", function () {
    $(this)
      .closest("." + $(this).attr("data-hide"))
      .hide();
  });
});

// DHCP leases tooltips
$(document).ready(function () {
  $('[data-toggle="tooltip"]').tooltip({ html: true, container: "body" });
});

// Change "?tab=" parameter in URL for save and reload
$(".nav-tabs a").on("shown.bs.tab", function (e) {
  var tab = e.target.hash.substring(1);
  window.history.pushState("", "", "?tab=" + tab);
  if (tab === "piholedhcp") {
    window.location.reload();
  }

  window.scrollTo(0, 0);
});

// Auto dismissal for info notifications
$(document).ready(function () {
  var alInfo = $("#alInfo");
  if (alInfo.length > 0) {
    alInfo.delay(3000).fadeOut(2000, function () {
      alInfo.hide();
    });
  }

  // Disable autocorrect in the search box
  var input = document.querySelector("input[type=search]");
  input.setAttribute("autocomplete", "off");
  input.setAttribute("autocorrect", "off");
  input.setAttribute("autocapitalize", "off");
  input.setAttribute("spellcheck", false);
});
<|endoftext|>


<commit_before>const app = require('../index');
const models = app.set('models');
const moment = require('moment-timezone');
const async = require('async');
const activities = require('../app/constants/activities');
const slackLib = require('../app/lib/slack');

var thisWeekRaw = moment()
    .tz('America/New_York')
    .startOf('isoWeek')
    .add(9, 'hours');
const thisWeek = thisWeekRaw.format();
const lastWeek = thisWeekRaw.subtract(1, 'week').format();

const createdAtClause = {
  $gt: lastWeek,
  $lt: thisWeek
};
const donationClause = {
  createdAt: createdAtClause,
  tags: {
    $contains: ['Donation']
  }
};
const expenseClause = {
  createdAt: createdAtClause,
  amount: {
    $lt: 0
  }
};

async.auto({
  donationCount: cb => {
    models.Transaction
        .count({ where: donationClause })
        .done(cb);
  },

  expenseCount: cb => {
    models.Transaction
        .count({ where: expenseClause })
        .done(cb);
  },

  stripeReceivedCount: cb => {
    models.Activity
        .count({
          where: {
            createdAt: createdAtClause,
            type: activities.WEBHOOK_STRIPE_RECEIVED
          }
        })
        .done(cb);
  },

  donationAmount: cb => {
    models.Transaction
        .aggregate('amount', 'SUM', {
          plain: false,
          group: ['currency'],
          attributes: ['currency'],
          where: donationClause
        })
        .map(row => ' ' + row.SUM + ' ' + row.currency)
        .done(cb);
  },

  expenseAmount: cb => {
    models.Transaction
        .aggregate('amount', 'SUM', {
          plain: false,
          group: ['currency'],
          attributes: ['currency'],
          where: expenseClause
        })
        .map(row => ' ' + -row.SUM + ' ' + row.currency)
        .done(cb);
  }
}, (err, results) => {
  if (err) {
    console.log('err', err);
    process.exit();
  } else {
    const report = transactionReportString(results);

    console.log(report);

    slackLib.postMessage(report)
    .then(() => {
      console.log('Reporting done!');
      process.exit();
    });
  }
});

function transactionReportString(results) {
  return `Summary:
- ${results.donationCount} donations received
- ${results.expenseCount} expenses filed
- ${results.stripeReceivedCount} payments received from Stripe
Details:
- total amount collected:${results.donationAmount}
- total expenses approved:${results.expenseAmount}`;
}<commit_msg>only allow to run the report script weekly on production<commit_after>const app = require('../index');
const models = app.set('models');
const moment = require('moment-timezone');
const async = require('async');
const activities = require('../app/constants/activities');
const slackLib = require('../app/lib/slack');

const today = new Date();

// Heroku scheduler only has daily or hourly cron jobs, we only want to run
// this script once per week on Monday (1). If the day is not Monday on production
// we won't execute the script
if (process.env.NODE_ENV === 'production' && today.getDay() !== 1) {
  console.log('NODE_ENV is production and day is not Monday, script aborted!');
  process.exit();
}

var thisWeekRaw = moment()
    .tz('America/New_York')
    .startOf('isoWeek')
    .add(9, 'hours');
const thisWeek = thisWeekRaw.format();
const lastWeek = thisWeekRaw.subtract(1, 'week').format();

const createdAtClause = {
  $gt: lastWeek,
  $lt: thisWeek
};
const donationClause = {
  createdAt: createdAtClause,
  tags: {
    $contains: ['Donation']
  }
};
const expenseClause = {
  createdAt: createdAtClause,
  amount: {
    $lt: 0
  }
};

async.auto({
  donationCount: cb => {
    models.Transaction
        .count({ where: donationClause })
        .done(cb);
  },

  expenseCount: cb => {
    models.Transaction
        .count({ where: expenseClause })
        .done(cb);
  },

  stripeReceivedCount: cb => {
    models.Activity
        .count({
          where: {
            createdAt: createdAtClause,
            type: activities.WEBHOOK_STRIPE_RECEIVED
          }
        })
        .done(cb);
  },

  donationAmount: cb => {
    models.Transaction
        .aggregate('amount', 'SUM', {
          plain: false,
          group: ['currency'],
          attributes: ['currency'],
          where: donationClause
        })
        .map(row => ' ' + row.SUM + ' ' + row.currency)
        .done(cb);
  },

  expenseAmount: cb => {
    models.Transaction
        .aggregate('amount', 'SUM', {
          plain: false,
          group: ['currency'],
          attributes: ['currency'],
          where: expenseClause
        })
        .map(row => ' ' + -row.SUM + ' ' + row.currency)
        .done(cb);
  }
}, (err, results) => {
  if (err) {
    console.log('err', err);
    process.exit();
  } else {
    const report = transactionReportString(results);

    console.log(report);

    slackLib.postMessage(report)
    .then(() => {
      console.log('Reporting done!');
      process.exit();
    });
  }
});

function transactionReportString(results) {
  return `Summary:
- ${results.donationCount} donations received
- ${results.expenseCount} expenses filed
- ${results.stripeReceivedCount} payments received from Stripe
Details:
- total amount collected:${results.donationAmount}
- total expenses approved:${results.expenseAmount}`;
}<|endoftext|>


<commit_before>exports.config = {
    baseUrl: process.env.SERVER_URL,
    chromeDriver: '../node_modules/protractor/selenium/chromedriver',
    chromeOnly: false,
    rootElement: 'html',
    specs: [ 'specs/**/*.spec.js'],

//    capabilities: {
//      'browserName': 'phantomjs',
//      'phantomjs.binary.path':'../node_modules/phantomjs/lib/phantom/bin/phantomjs'
//    },
    capabilities: {
      'browserName': 'firefox'
    },

    jasmineNodeOpts: {
        onComplete: null,
        isVerbose: true,
        showColors: false,
        includeStackTrace: true,
        defaultTimeoutInterval: 60000
    },

    onPrepare: function(){
        require('protractor-linkuisref-locator')(protractor);

        require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
            '.', true, true, 'protractor-results', true));
    }
};
<commit_msg>refactor(protractor): set browser size to 1280x1024<commit_after>exports.config = {
    baseUrl: process.env.SERVER_URL,
    chromeDriver: '../node_modules/protractor/selenium/chromedriver',
    chromeOnly: false,
    rootElement: 'html',
    specs: [ 'specs/**/*.spec.js'],

//    capabilities: {
//      'browserName': 'phantomjs',
//      'phantomjs.binary.path':'../node_modules/phantomjs/lib/phantom/bin/phantomjs'
//    },
    capabilities: {
      'browserName': 'firefox'
    },

    jasmineNodeOpts: {
        onComplete: null,
        isVerbose: true,
        showColors: false,
        includeStackTrace: true,
        defaultTimeoutInterval: 60000
    },

    onPrepare: function(){
        require('protractor-linkuisref-locator')(protractor);

        require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
            '.', true, true, 'protractor-results', true));

        browser.driver.manage().window().setSize(1280, 1024);
    }
};
<|endoftext|>


<commit_before>function initializeSummary() {
    const token = _.find(window.location.pathname.split('/'), function(e) {
        return _.size(e) == 40;
    });
    const url = `${window.location.origin}/api/v1/summary/${token}`;
    $('#summary').html(`<a href="${url}">${url}</a>`);
};
<commit_msg>First log on personal page<commit_after>function initializeSummary() {
    const token = _.find(window.location.pathname.split('/'), function(e) {
        return _.size(e) == 40;
    });
    const url = `${window.location.origin}/api/v1/summary/${token}`;
    $('#summary').html(`<a href="${url}">${url}</a>`);
    $.getJSON(url, function(data) {
      console.log(data);
    });
};
<|endoftext|>


<commit_before>function add_game_bg(sprite_name){
    //game.stage.backgroundColor = '#DDDDDD';
    var bg = game.add.sprite(0, 0, sprite_name);
    bg.height = game.world.height;
    bg.width = game.width;
    bg.fixedToCamera = true;
}

function get_surrounding_tiles(check_layer, map){
    // Function returns the surrounding tiletypes of a given layer
    // Returns an array of [topRight, topLeft, bottomRight, bottomLeft] tile indices
    player.body.top = player.body.bottom - player.body.height;
    player.body.left = player.body.right - player.body.width;

    var top_y = check_layer.getTileY(player.body.top);
    var bottom_y = check_layer.getTileY(player.body.bottom);
    var right_x = check_layer.getTileX(player.body.right);
    var left_x = check_layer.getTileX(player.body.left);

    return ([map.getTile(left_x, top_y, check_layer), map.getTile(right_x, top_y, check_layer), map.getTile(left_x, bottom_y, check_layer), map.getTile(right_x, bottom_y, check_layer)])
}

// check for ladder collisions - pass in the map name and the layer with the ladders
function checkforladders(map, layer) {
    var tx = layer.getTileX(player.position.x);
    var ty = layer.getTileY(player.position.y);

    var tileType = map.getTile(tx, ty, layer);

    if (tileType != null){
        ladder_function();
    }
}

function ladder_movement(tile_arr){
    bottom_left = tile_arr[2]
    bottom_right = tile_arr[3]
    if (bottom_right || bottom_left) {
        if (bottom_left) {
            var checking = bottom_left;
        } else if (bottom_right) {
            var checking = bottom_right;
        }
        if (checking.index == 5){
            ladder_function();
            if (cursors.up.isDown) {
                player.body.velocity.y = -350;
            }
        } else if (checking.index == 4) {
                   ladder_function()
                   }
    }
}

function ladder_function(){
    if (climb1.isPlaying == false){
        climb1.play();
    }
    player.body.gravity.y = 0;
    if (cursors.up.isDown){
        player.body.velocity.y = -100;
    }
    else if (cursors.down.isDown){
        player.body.velocity.y = 100;
    }
    else{
        player.body.velocity.y = -7;
    }
}

function collideIce(player, layer){
        // tile key:
        // 1,2,3 = no color
        // 5,6,7 = blue
        // 8,9,10 = green
        // 11,12,13 = purple

    var ybelow = icelayer1.getTileY(player.position.y + 33);

    var xbelow = icelayer1.getTileX(player.position.x);
    var tileInfo = iceMap.getTile(xbelow, ybelow, icelayer1);

    if (tileInfo != null){
        var tileiceType = tileInfo.index;
    }
    else{
        tileiceType = 1;
    }

    var tile_dictionary = {1:player.color, 2:player.color, 3:player.color, 5:"blue", 6:"blue", 7:"blue", 8:"green", 9:"green", 10:"green", 11:"purple", 12:"purple", 13:"purple"}

    if (player.body.blocked.down){
        if (player.color != tile_dictionary[tileiceType]){
            console.log(tile_dictionary[tileiceType]);
            console.log(tileiceType);
            deadplayer();
        }
    }
}
<commit_msg>fixed background stretch<commit_after>function add_game_bg(sprite_name){
    //game.stage.backgroundColor = '#DDDDDD';
    var bg = game.add.sprite(0, 0, sprite_name);
    bg.height = game.height;
    bg.width = game.width;
    bg.fixedToCamera = true;
}

function get_surrounding_tiles(check_layer, map){
    // Function returns the surrounding tiletypes of a given layer
    // Returns an array of [topRight, topLeft, bottomRight, bottomLeft] tile indices
    player.body.top = player.body.bottom - player.body.height;
    player.body.left = player.body.right - player.body.width;

    var top_y = check_layer.getTileY(player.body.top);
    var bottom_y = check_layer.getTileY(player.body.bottom);
    var right_x = check_layer.getTileX(player.body.right);
    var left_x = check_layer.getTileX(player.body.left);

    return ([map.getTile(left_x, top_y, check_layer), map.getTile(right_x, top_y, check_layer), map.getTile(left_x, bottom_y, check_layer), map.getTile(right_x, bottom_y, check_layer)])
}

// check for ladder collisions - pass in the map name and the layer with the ladders
function checkforladders(map, layer) {
    var tx = layer.getTileX(player.position.x);
    var ty = layer.getTileY(player.position.y);

    var tileType = map.getTile(tx, ty, layer);

    if (tileType != null){
        ladder_function();
    }
}

function ladder_movement(tile_arr){
    bottom_left = tile_arr[2]
    bottom_right = tile_arr[3]
    if (bottom_right || bottom_left) {
        if (bottom_left) {
            var checking = bottom_left;
        } else if (bottom_right) {
            var checking = bottom_right;
        }
        if (checking.index == 5){
            ladder_function();
            if (cursors.up.isDown) {
                player.body.velocity.y = -350;
            }
        } else if (checking.index == 4) {
                   ladder_function()
                   }
    }
}

function ladder_function(){
    if (climb1.isPlaying == false){
        climb1.play();
    }
    player.body.gravity.y = 0;
    if (cursors.up.isDown){
        player.body.velocity.y = -100;
    }
    else if (cursors.down.isDown){
        player.body.velocity.y = 100;
    }
    else{
        player.body.velocity.y = -7;
    }
}

function collideIce(player, layer){
        // tile key:
        // 1,2,3 = no color
        // 5,6,7 = blue
        // 8,9,10 = green
        // 11,12,13 = purple

    var ybelow = icelayer1.getTileY(player.position.y + 33);

    var xbelow = icelayer1.getTileX(player.position.x);
    var tileInfo = iceMap.getTile(xbelow, ybelow, icelayer1);

    if (tileInfo != null){
        var tileiceType = tileInfo.index;
    }
    else{
        tileiceType = 1;
    }

    var tile_dictionary = {1:player.color, 2:player.color, 3:player.color, 5:"blue", 6:"blue", 7:"blue", 8:"green", 9:"green", 10:"green", 11:"purple", 12:"purple", 13:"purple"}

    if (player.body.blocked.down){
        if (player.color != tile_dictionary[tileiceType]){
            console.log(tile_dictionary[tileiceType]);
            console.log(tileiceType);
            deadplayer();
        }
    }
}
<|endoftext|>


<commit_before>var _ = require('underscore');

var GameServer = function () {
  this.activePlayers = 0;
  this.numberOfRobots = 50;
  this.width = 1280;
  this.height = 640;
  this.spriteSize = 64;
  this.robots = [];
  this.players = {};
};

GameServer.prototype.rand  = function(n){ return Math.floor( Math.random() * n ); };
GameServer.prototype.randX = function() {
  var randx = this.rand(this.maxX()) + this.minX();
  var xoffset = randx % this.spriteSize;
  randx -= xoffset;
  return randx;
};

GameServer.prototype.randY = function() {
  var randy = this.rand(this.maxY()) + this.minY();
  var yoffset = randy % this.spriteSize;
  randy -= yoffset;
  return randy;
};

GameServer.prototype.randDirection = function() {
  var direction = this.rand(5);
  var result;
  if (direction === 0) {
    result = 'Pause';
  } else if (direction === 1) {
    result = 'North';
  } else if (direction === 2) {
    result = 'East';
  } else if (direction === 3) {
    result = 'South';
  } else {
    result = 'West';
  }
  return result;
};

GameServer.prototype.minX = function() { return 0; };
GameServer.prototype.maxX = function() { return this.width - this.spriteSize; };
GameServer.prototype.minY = function() { return 0; };
GameServer.prototype.maxY = function() { return this.height - this.spriteSize; };

GameServer.prototype.initalize = function() {
  this.initRobots();
  setInterval(this.gameTick.bind(this), 500);
};

GameServer.prototype.gameTick = function() {
  this.moveRobots();
  console.log(this.players);
};

GameServer.prototype.initRobots = function() {
  var direction = this.randDirection();
  this.robots = _.map(_.range(this.numberOfRobots), function(value){
    return {
      id: value,
      x: this.randX(),
      y: this.randY(),
      direction: direction
    };
  }.bind(this));
};

GameServer.prototype.getPlayerDirection = function(move) {
  if (move === 87) {
    return 'North';
  } else if (move === 83) {
    return 'South';
  } else if (move === 65) {
    return 'West';
  } else if (move === 68) {
    return 'East';
  } else {
    return 'Pause';
  }
};

GameServer.prototype.movePlayer = function() {
  _.each(this.players, function(player, index, players) {
    this.movePlayer(player);
  }.bind(this));
  io.emit('playerMoves', this.players);
};

GameServer.prototype.movePlayer = function(player) {
  if (player.direction === 'North') {
    player.y = Math.max(player.y - this.spriteSize, this.minY());
  } else if (player.direction === 'South') {
    player.y = Math.min(player.y + this.spriteSize, this.maxY());
  } else if (player.direction === 'West') {
    player.x = Math.max(player.x - this.spriteSize, this.minX());
  } else if (player.direction === 'East') {
    player.x = Math.min(player.x + this.spriteSize, this.maxX());
  }
};

GameServer.prototype.moveRobots = function() {
  _.each(this.robots, function(robot, index, robots) {
    robots[index] = this.moveRobot(robot);
  }.bind(this));
  io.emit('robotMoves', this.robots);
};

GameServer.prototype.moveRobot = function(robot) {
  this.setRobotDirection(robot);
  if (robot.direction === 'North') {
    if (robot.y - this.spriteSize < this.minY()) {
      this.moveRobot(robot);
    } else {
      robot.y -= this.spriteSize;
    }
  } else if (robot.direction === 'South') {
    if (robot.y + this.spriteSize > this.maxY()) {
      this.moveRobot(robot);
    } else {
      robot.y += this.spriteSize;
    }
  } else if (robot.direction === 'West') {
    if (robot.x - this.spriteSize < this.minX()) {
      this.moveRobot(robot);
    } else {
      robot.x -= this.spriteSize;
    }
  } else if (robot.direction === 'East') {
    if (robot.x + this.spriteSize > this.maxX()) {
      this.moveRobot(robot);
    } else {
      robot.x += this.spriteSize;
    }
  }
  return robot;
};

GameServer.prototype.setRobotDirection = function(robot){
  if (this.rand(2) === 1) {
    robot.direction = this.randDirection();
  }
};

GameServer.prototype.addPlayer = function(id) {
  this.players[id] = {
    id: id,
    x: this.randX(),
    y: this.randY(),
    direction: 'Pause'
  };
};

GameServer.prototype.removePlayer = function(id) {
  delete this.players[id];
};

GameServer.prototype.addMove = function (id, move, keyDown) {
  if (keyDown && move === 32) {
    this.players[id].attacking = true;
  } else if (!keyDown && move === 32) {
    this.players[id].attacking = false;
  } else if (keyDown) {
    this.players[id].direction = this.getPlayerDirection(move);
  } else {
    this.players[id].direction = "Pause";
  }
};

module.exports = GameServer;
<commit_msg>removed dead code from move robot logic<commit_after>var _ = require('underscore');

var GameServer = function () {
  this.activePlayers = 0;
  this.numberOfRobots = 50;
  this.width = 1280;
  this.height = 640;
  this.spriteSize = 64;
  this.robots = [];
  this.players = {};
};

GameServer.prototype.rand  = function(n){ return Math.floor( Math.random() * n ); };
GameServer.prototype.randX = function() {
  var randx = this.rand(this.maxX()) + this.minX();
  var xoffset = randx % this.spriteSize;
  randx -= xoffset;
  return randx;
};

GameServer.prototype.randY = function() {
  var randy = this.rand(this.maxY()) + this.minY();
  var yoffset = randy % this.spriteSize;
  randy -= yoffset;
  return randy;
};

GameServer.prototype.randDirection = function() {
  var direction = this.rand(5);
  var result;
  if (direction === 0) {
    result = 'Pause';
  } else if (direction === 1) {
    result = 'North';
  } else if (direction === 2) {
    result = 'East';
  } else if (direction === 3) {
    result = 'South';
  } else {
    result = 'West';
  }
  return result;
};

GameServer.prototype.minX = function() { return 0; };
GameServer.prototype.maxX = function() { return this.width - this.spriteSize; };
GameServer.prototype.minY = function() { return 0; };
GameServer.prototype.maxY = function() { return this.height - this.spriteSize; };

GameServer.prototype.initalize = function() {
  this.initRobots();
  setInterval(this.gameTick.bind(this), 500);
};

GameServer.prototype.gameTick = function() {
  this.moveRobots();
  console.log(this.players);
};

GameServer.prototype.initRobots = function() {
  var direction = this.randDirection();
  this.robots = _.map(_.range(this.numberOfRobots), function(value){
    return {
      id: value,
      x: this.randX(),
      y: this.randY(),
      direction: direction
    };
  }.bind(this));
};

GameServer.prototype.getPlayerDirection = function(move) {
  if (move === 87) {
    return 'North';
  } else if (move === 83) {
    return 'South';
  } else if (move === 65) {
    return 'West';
  } else if (move === 68) {
    return 'East';
  } else {
    return 'Pause';
  }
};

GameServer.prototype.movePlayer = function() {
  _.each(this.players, function(player, index, players) {
    this.movePlayer(player);
  }.bind(this));
  io.emit('playerMoves', this.players);
};

GameServer.prototype.movePlayer = function(player) {
  if (player.direction === 'North') {
    player.y = Math.max(player.y - this.spriteSize, this.minY());
  } else if (player.direction === 'South') {
    player.y = Math.min(player.y + this.spriteSize, this.maxY());
  } else if (player.direction === 'West') {
    player.x = Math.max(player.x - this.spriteSize, this.minX());
  } else if (player.direction === 'East') {
    player.x = Math.min(player.x + this.spriteSize, this.maxX());
  }
};

GameServer.prototype.moveRobots = function() {
  _.each(this.robots, function(robot, index, robots) {
    this.moveRobot(robot);
  }.bind(this));
  io.emit('robotMoves', this.robots);
};

GameServer.prototype.moveRobot = function(robot) {
  this.setRobotDirection(robot);
  if (robot.direction === 'North') {
    if (robot.y - this.spriteSize < this.minY()) {
      this.moveRobot(robot);
    } else {
      robot.y -= this.spriteSize;
    }
  } else if (robot.direction === 'South') {
    if (robot.y + this.spriteSize > this.maxY()) {
      this.moveRobot(robot);
    } else {
      robot.y += this.spriteSize;
    }
  } else if (robot.direction === 'West') {
    if (robot.x - this.spriteSize < this.minX()) {
      this.moveRobot(robot);
    } else {
      robot.x -= this.spriteSize;
    }
  } else if (robot.direction === 'East') {
    if (robot.x + this.spriteSize > this.maxX()) {
      this.moveRobot(robot);
    } else {
      robot.x += this.spriteSize;
    }
  }
};

GameServer.prototype.setRobotDirection = function(robot){
  if (this.rand(2) === 1) {
    robot.direction = this.randDirection();
  }
};

GameServer.prototype.addPlayer = function(id) {
  this.players[id] = {
    id: id,
    x: this.randX(),
    y: this.randY(),
    direction: 'Pause'
  };
};

GameServer.prototype.removePlayer = function(id) {
  delete this.players[id];
};

GameServer.prototype.addMove = function (id, move, keyDown) {
  if (keyDown && move === 32) {
    this.players[id].attacking = true;
  } else if (!keyDown && move === 32) {
    this.players[id].attacking = false;
  } else if (keyDown) {
    this.players[id].direction = this.getPlayerDirection(move);
  } else {
    this.players[id].direction = "Pause";
  }
};

module.exports = GameServer;
<|endoftext|>


<commit_before>// SetIFrameHeight.js
'use strict';

var SetIFrameHeight = function (frame) {
    // fix iFrame height
    // per http://www.dyn-web.com/tutorials/iframes/height/
    function getDocHeight(doc) {
        doc = doc || document;
        // stackoverflow.com/questions/1145850/
        var body = doc.body, html = doc.documentElement;
        var height = Math.max( body.scrollHeight, body.offsetHeight,
            html.clientHeight, html.scrollHeight, html.offsetHeight );
        return height;
    }
    function setIframeHeight(ifrm) {
        var doc = ifrm.contentDocument? ifrm.contentDocument:
            ifrm.contentWindow.document;
        ifrm.style.visibility = 'hidden';
        ifrm.style.height = "10px"; // reset to minimal height ...
        // IE opt. for bing/msn needs a bit added or scrollbar appears
        ifrm.style.height = getDocHeight( doc ) + 4 + "px";
        ifrm.style.visibility = 'visible';
    }

    // this seems hacky...but without the timeout
    // it sets the height before the iframe content
    // has fully rendered, making the height 10px;
    window.setTimeout(function () {
        try {
            setIframeHeight(frame);
        } catch (e) {
            //console.log('iFrame disappeared before it could be re-sized.');
        }
    }, 250);
};

module.exports = SetIFrameHeight;<commit_msg>add extra delay for iframe spacing<commit_after>// SetIFrameHeight.js
'use strict';

var SetIFrameHeight = function (frame) {
    // fix iFrame height
    // per http://www.dyn-web.com/tutorials/iframes/height/
    function getDocHeight(doc) {
        doc = doc || document;
        // stackoverflow.com/questions/1145850/
        var body = doc.body, html = doc.documentElement;
        var height = Math.max( body.scrollHeight, body.offsetHeight,
            html.clientHeight, html.scrollHeight, html.offsetHeight );
        return height;
    }
    function setIframeHeight(ifrm) {
        var doc = ifrm.contentDocument? ifrm.contentDocument:
            ifrm.contentWindow.document;
        ifrm.style.visibility = 'hidden';
        ifrm.style.height = "10px"; // reset to minimal height ...
        // IE opt. for bing/msn needs a bit added or scrollbar appears
        ifrm.style.height = getDocHeight( doc ) + 4 + "px";
        ifrm.style.visibility = 'visible';
    }

    // this seems hacky...but without the timeout
    // it sets the height before the iframe content
    // has fully rendered, making the height 10px;
    window.setTimeout(function () {
        try {
            setIframeHeight(frame);
        } catch (e) {
            //console.log('iFrame disappeared before it could be re-sized.');
        }
    }, 1000);
};

module.exports = SetIFrameHeight;<|endoftext|>


<commit_before>/**
 * @type {{CONNECTIONS_FOLLOWERS_FOLLOWING: string, PROFILE_DATA: string, MESSAGING_DATA: string, THIRD_PARTY_INTEGRATIONS: string, ACTIVITY: string, JOB_APPLICATION_FLOW_DATA: string, ENTERPRISE_PRODUCT_DATA: string, ACCOUNT_STATUS: string, ADDRESS_BOOK_IMPORT_DATA: string, MICROSOFT_DATA: string, SUBSIDIARY_DATA: string, THIRD_PARTY_DATA: string, DEVICE_DATA: string, SEARCH_HISTORY: string, COURSE_VIEWING_HISTORY: string, WVMP: string, PROFILE_VIEWS_BY_ME: string, ADVERTISING_DATA: string, USAGE_ERROR_CONNECTIVITY_DATA: string, OTHER_CLICKSTREAM_BROWSING_DATA: string}}
 */
const datasetClassifiers = {
  CONNECTIONS_FOLLOWERS_FOLLOWING: 'Connections + Followers + Following',
  PROFILE_DATA: 'Profile Data',
  MESSAGING_DATA: 'Messaging Data (Metadata + Content)',
  THIRD_PARTY_INTEGRATIONS: 'Third Party Integrations In Use',
  ACTIVITY: 'Activity (Newsfeed Posts + Shares + Likes)',
  JOB_APPLICATION_FLOW_DATA: 'Job Application Flow Data (Job Application + AWLI + Resumes + Application Answers)',
  ENTERPRISE_PRODUCT_DATA: 'Enterprise Product Data',
  ACCOUNT_STATUS: 'Account Status',
  ADDRESS_BOOK_IMPORT_DATA: 'Address Book Import Data',
  MICROSOFT_DATA: 'Data from Microsoft',
  SUBSIDIARY_DATA: 'Data from companies LinkedIn acquired (Lynda, Slideshare, Connectifier, Bizo, etcetera)',
  THIRD_PARTY_DATA: 'Data from other Third-party Integrations',
  DEVICE_DATA: 'Device Data',
  SEARCH_HISTORY: 'Search History',
  COURSE_VIEWING_HISTORY: 'Course Viewing History',
  WVMP: "Who's Viewed My Profile",
  PROFILE_VIEWS_BY_ME: 'Profile Views (by me)',
  ADVERTISING_DATA: 'Advertising related (LMS) Data',
  USAGE_ERROR_CONNECTIVITY_DATA: 'Usage, Error Reporting, Connectivity Data',
  OTHER_CLICKSTREAM_BROWSING_DATA: 'Other Clickstream Data + Browsing history'
};

export { datasetClassifiers };
<commit_msg>Add settings dataset-level tag. (#549)<commit_after>/**
 * @type {{CONNECTIONS_FOLLOWERS_FOLLOWING: string, PROFILE_DATA: string, MESSAGING_DATA: string, THIRD_PARTY_INTEGRATIONS: string, ACTIVITY: string, JOB_APPLICATION_FLOW_DATA: string, ENTERPRISE_PRODUCT_DATA: string, ACCOUNT_STATUS: string, ADDRESS_BOOK_IMPORT_DATA: string, MICROSOFT_DATA: string, SUBSIDIARY_DATA: string, THIRD_PARTY_DATA: string, DEVICE_DATA: string, SEARCH_HISTORY: string, COURSE_VIEWING_HISTORY: string, WVMP: string, PROFILE_VIEWS_BY_ME: string, ADVERTISING_DATA: string, USAGE_ERROR_CONNECTIVITY_DATA: string, OTHER_CLICKSTREAM_BROWSING_DATA: string}}
 */
const datasetClassifiers = {
  CONNECTIONS_FOLLOWERS_FOLLOWING: 'Connections + Followers + Following',
  PROFILE_DATA: 'Profile Data',
  MESSAGING_DATA: 'Messaging Data (Metadata + Content)',
  THIRD_PARTY_INTEGRATIONS: 'Third Party Integrations In Use',
  ACTIVITY: 'Activity (Newsfeed Posts + Shares + Likes)',
  SETTINGS: 'Settings (Mail Settings, All psettings values)',
  JOB_APPLICATION_FLOW_DATA: 'Job Application Flow Data (Job Application + AWLI + Resumes + Application Answers)',
  ENTERPRISE_PRODUCT_DATA: 'Enterprise Product Data',
  ACCOUNT_STATUS: 'Account Status',
  ADDRESS_BOOK_IMPORT_DATA: 'Address Book Import Data',
  MICROSOFT_DATA: 'Data from Microsoft',
  SUBSIDIARY_DATA: 'Data from companies LinkedIn acquired (Lynda, Slideshare, Connectifier, Bizo, etcetera)',
  THIRD_PARTY_DATA: 'Data from other Third-party Integrations',
  DEVICE_DATA: 'Device Data',
  SEARCH_HISTORY: 'Search History',
  COURSE_VIEWING_HISTORY: 'Course Viewing History',
  WVMP: "Who's Viewed My Profile",
  PROFILE_VIEWS_BY_ME: 'Profile Views (by me)',
  ADVERTISING_DATA: 'Advertising related (LMS) Data',
  USAGE_ERROR_CONNECTIVITY_DATA: 'Usage, Error Reporting, Connectivity Data',
  OTHER_CLICKSTREAM_BROWSING_DATA: 'Other Clickstream Data + Browsing history'
};

export { datasetClassifiers };
<|endoftext|>


<commit_before>/**
 * @author mr.doob / http://mrdoob.com/
 * @author alteredq / http://alteredqualia.com/
 * @author szimek / https://github.com/szimek/
 */

THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter ) {

	this.image = image;

	this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping();

	this.wrapS = wrapS !== undefined ? wrapS : THREE.ClampToEdgeWrapping;
	this.wrapT = wrapT !== undefined ? wrapT : THREE.ClampToEdgeWrapping;

	this.magFilter = magFilter !== undefined ? magFilter : THREE.LinearFilter;
	this.minFilter = minFilter !== undefined ? minFilter : THREE.LinearMipMapLinearFilter;

	this.offset = new THREE.Vector2( 0, 0 );
	this.repeat = new THREE.Vector2( 1, 1 );

	this.needsUpdate = false;

};

THREE.Texture.prototype = {

	clone: function () {

		var clonedTexture = new THREE.Texture( this.image, this.mapping, this.wrapS, this.wrapT, this.magFilter, this.minFilter );

		clonedTexture.offset.copy( this.offset );
		clonedTexture.repeat.copy( this.repeat );

		return clonedTexture;

	},

	constructor : THREE.Texture

};

THREE.MultiplyOperation = 0;
THREE.MixOperation = 1;

// Wrapping modes

THREE.RepeatWrapping = 0;
THREE.ClampToEdgeWrapping = 1;
THREE.MirroredRepeatWrapping = 2;

// Filters

THREE.NearestFilter = 3;
THREE.NearestMipMapNearestFilter = 4;
THREE.NearestMipMapLinearFilter = 5;
THREE.LinearFilter = 6;
THREE.LinearMipMapNearestFilter = 7;
THREE.LinearMipMapLinearFilter = 8;

// Types

THREE.ByteType = 9;
THREE.UnsignedByteType = 10;
THREE.ShortType = 11;
THREE.UnsignedShortType = 12;
THREE.IntType = 13;
THREE.UnsignedIntType = 14;
THREE.FloatType = 15;

// Formats

THREE.AlphaFormat = 16;
THREE.RGBFormat = 17;
THREE.RGBAFormat = 18;
THREE.LuminanceFormat = 19;
THREE.LuminanceAlphaFormat = 20;
<commit_msg>Merging merging<commit_after>/**
 * @author mr.doob / http://mrdoob.com/
 * @author alteredq / http://alteredqualia.com/
 * @author szimek / https://github.com/szimek/
 */

THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter ) {

	this.image = image;

	this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping();

	this.wrapS = wrapS !== undefined ? wrapS : THREE.ClampToEdgeWrapping;
	this.wrapT = wrapT !== undefined ? wrapT : THREE.ClampToEdgeWrapping;

	this.magFilter = magFilter !== undefined ? magFilter : THREE.LinearFilter;
	this.minFilter = minFilter !== undefined ? minFilter : THREE.LinearMipMapLinearFilter;

	this.offset = new THREE.Vector2( 0, 0 );
	this.repeat = new THREE.Vector2( 1, 1 );

	this.needsUpdate = false;

};

THREE.Texture.prototype = {

	clone: function () {

		return new THREE.Texture( this.image, this.mapping, this.wrapS, this.wrapT, this.magFilter, this.minFilter );

	},

	constructor : THREE.Texture

};

THREE.MultiplyOperation = 0;
THREE.MixOperation = 1;

// Wrapping modes

THREE.RepeatWrapping = 0;
THREE.ClampToEdgeWrapping = 1;
THREE.MirroredRepeatWrapping = 2;

// Filters

THREE.NearestFilter = 3;
THREE.NearestMipMapNearestFilter = 4;
THREE.NearestMipMapLinearFilter = 5;
THREE.LinearFilter = 6;
THREE.LinearMipMapNearestFilter = 7;
THREE.LinearMipMapLinearFilter = 8;

// Types

THREE.ByteType = 9;
THREE.UnsignedByteType = 10;
THREE.ShortType = 11;
THREE.UnsignedShortType = 12;
THREE.IntType = 13;
THREE.UnsignedIntType = 14;
THREE.FloatType = 15;

// Formats

THREE.AlphaFormat = 16;
THREE.RGBFormat = 17;
THREE.RGBAFormat = 18;
THREE.LuminanceFormat = 19;
THREE.LuminanceAlphaFormat = 20;
<|endoftext|>


<commit_before>$.fn.userAutocomplete = function () {
  'use strict';

  function formatUser(user) {
    return Select2.util.escapeMarkup(user.email);
  }

  this.select2({
    minimumInputLength: 1,
    multiple: true,
    initSelection: function (element, callback) {
      $.get(Spree.routes.users_api, {
        ids: element.val()
      }, function (data) {
        callback(data.users);
      });
    },
    ajax: {
      url: Spree.routes.users_api,
      datatype: 'json',
      params: { "headers": { "X-Spree-Token": Spree.api_key } },
      data: function (term) {
        return {
          m: 'or',
          email_start: term,
          addresses_firstname_start: term,
          addresses_lastname_start: term
        };
      },
      results: function (data) {
        return {
          results: data.users,
          more: data.current_page < data.pages
        };
      }
    },
    formatResult: formatUser,
    formatSelection: formatUser
  });
};

$(document).ready(function () {
  $('.user_picker').userAutocomplete();
});
<commit_msg>Fix user picker's select2 initial selection<commit_after>$.fn.userAutocomplete = function () {
  'use strict';

  function formatUser(user) {
    return Select2.util.escapeMarkup(user.email);
  }

  this.select2({
    minimumInputLength: 1,
    multiple: true,
    initSelection: function (element, callback) {
      Spree.ajax({
        url: Spree.routes.users_api,
        data: {
          ids: element.val()
        },
        success: function(data) {
          callback(data.users);
        }
      });
    },
    ajax: {
      url: Spree.routes.users_api,
      datatype: 'json',
      params: { "headers": { "X-Spree-Token": Spree.api_key } },
      data: function (term) {
        return {
          m: 'or',
          email_start: term,
          addresses_firstname_start: term,
          addresses_lastname_start: term
        };
      },
      results: function (data) {
        return {
          results: data.users,
          more: data.current_page < data.pages
        };
      }
    },
    formatResult: formatUser,
    formatSelection: formatUser
  });
};

$(document).ready(function () {
  $('.user_picker').userAutocomplete();
});
<|endoftext|>


<commit_before>/**
 *  Copyright (C) 2021 3D Repo Ltd
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

const { v5Path } = require('../../../interop');
const { getTeamspaceList, getCollectionsEndsWith } = require('../utils');

const { find, updateOne } = require(`${v5Path}/handler/db`);
const { logger } = require(`${v5Path}/utils/logger`);

const processModel = async (teamspace, scene) => {
	const meta = await find(teamspace, scene, { type: 'meta', 'metadata.key': { $exists: false } }, { metadata: 1 });
	const proms = meta.map(({ _id, metadata }) => {
		if (!Array.isArray(metadata)) {
			const metaArr = Object.keys(metadata).map((key) => ({ key, value: metadata[key] }));
			return updateOne(teamspace, scene, { _id }, { $set: { metadata: metaArr } });
		}
		return Promise.resolve();
	});
	return Promise.all(proms);
};

const processTeamspace = async (teamspace) => {
	const scenes = await getCollectionsEndsWith(teamspace, '.scene');
	for (const { name } of scenes) {
		logger.logInfo(`\t\t\t${name}`);
		// eslint-disable-next-line no-await-in-loop
		await processModel(teamspace, name);
	}
};

const run = async () => {
	//	const teamspaces = await getTeamspaceList();
	const teamspaces = ['GeometryStreaming3DRepo'];
	for (let i = 0; i < teamspaces.length; ++i) {
		logger.logInfo(`\t\t-${teamspaces[i]}`);
		// eslint-disable-next-line no-await-in-loop
		await processTeamspace(teamspaces[i]);
	}
};

module.exports = run;
<commit_msg>ISSUE #2352 test splitting the promise loop<commit_after>/**
 *  Copyright (C) 2021 3D Repo Ltd
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

const { v5Path } = require('../../../interop');
const { getTeamspaceList, getCollectionsEndsWith } = require('../utils');

const { find, updateOne } = require(`${v5Path}/handler/db`);
const { logger } = require(`${v5Path}/utils/logger`);

const processModel = async (teamspace, scene) => {
	console.log('waiting on query...');
	const meta = await find(teamspace, scene, { type: 'meta', 'metadata.key': { $exists: false } }, { metadata: 1 });
	console.log('query returned, number of nodes: ', meta.length);

	const maxParallel = 2000;
	for (let i = 0; i < meta.length; i += maxParallel) {
		console.log(`i is ${i}`);
		const proms = [];
		for (let j = i; j < i + maxParallel; ++j) {
			console.log(`j is ${j}`);
			const { _id, metadata } = meta[j];
			if (!Array.isArray(metadata)) {
				const metaArr = Object.keys(metadata).map((key) => ({ key, value: metadata[key] }));
				proms.push(updateOne(teamspace, scene, { _id }, { $set: { metadata: metaArr } }));
			}
		}

		await Promise.all(proms);
	}
};

const processTeamspace = async (teamspace) => {
	const scenes = await getCollectionsEndsWith(teamspace, '.scene');
	for (const { name } of scenes) {
		logger.logInfo(`\t\t\t${name}`);
		// eslint-disable-next-line no-await-in-loop
		await processModel(teamspace, name);
	}
};

const run = async () => {
	const teamspaces = ['GeometryStreaming3DRepo'];// await getTeamspaceList();
	for (let i = 0; i < teamspaces.length; ++i) {
		logger.logInfo(`\t\t-${teamspaces[i]}`);
		// eslint-disable-next-line no-await-in-loop
		await processTeamspace(teamspaces[i]);
	}
};

module.exports = run;
<|endoftext|>


<commit_before>var Util = require("./utils.js")

var UpdateApp = function() {
  var util = new Util();
  this.runScript = function(client, userOptions) {

    util.action("Fill in Store Listing", function() {

      selectFields = ['app_type', 'category', 'rating'];
      textFields = ['subtext', 'promo', 'promo_vid', 'website', 'email', 'phone'];

      for (option in userOptions) {
        if (selectFields.indexOf(option) !== -1) {
          client.click('#selectArea_' + option + ' option[value = ' + userOptions[option] + ']')
        }

        else if (textFields.indexOf(option) !== -1) {
          client.setValue('#textArea_' + option, userOptions[option]);
        }

        else if (option === 'privacy') {
          if (option) {
            client.setValue("#textArea_" + option, userOptions[option]);
          }
          else {
            client.click("#privacy_opt_out_id");
          }
        }
      }
    });

    util.action("Remove graphic", function(title) {

      var upload_id = searchForChild('h5', 'innerText', title, 2, 'input', (title+'_online_id').replace(' ', '_'), client);

      client.execute(function(id) {
        var input = document.getElementById(id);
        var x_divs = input.parentElement.parentElement.getElementsByTagName('div');

        for (i in x_divs) {
          d = x_divs[i];
          if (d.innerHTML === '×') {
            d.click();
          }
        }
      }, [upload_id]);
    });

    util.action("Upload graphic", function(title, id, path) {

      var upload_id = searchForChild('h5', 'innerText', title, 2, 'input', id+'_upload', client);

      client.chooseFile("#" + upload_id, path, function(err, res){

      });

      client.execute(function(upload_id, waiting_id){
        var input = document.querySelector("#" + upload_id);
        toWatch = input.parentElement.parentElement.children[2];
        toWatch.id = waiting_id;
      }, [upload_id, id]);
    });

    util.action("Remove screenshots", function(tag) {

      client.execute(function(type) {
        var divs = document.querySelectorAll('b');
        var correct_div = null;
        for (var i =0; i <divs.length; i++) {
          if (divs[i].innerText.trim() === type) {
            correct_div = divs[i];
            break;
          }
        }

        var x_divs = correct_div.parentElement.parentElement.getElementsByTagName('div');
        for (i = 0; i < x_divs.length; i++) {
          if (x_divs[i].innerHTML.charCodeAt(0) === 215) {
            x_divs[i].click();
          }
        }
      }, [tag]);
    });

    util.action("Upload screenshot", function(type, id, path) {

      client.execute(function(type, id){

        var divs = document.querySelectorAll('b');
        var correct_div = null;
        for (var i =0; i <divs.length; i++) {
          if (divs[i].innerText.trim() === type) {
            correct_div = divs[i];
            break;
          }
        }
        var parent = correct_div.parentElement.parentElement;
        var inputs = parent.querySelectorAll('input');
        var input = inputs[inputs.length-1];

        input.id = id + '_upload';

        waiting = input.parentElement.parentElement.children[2];
        waiting.id = id;

      }, [type, id]);

      client.chooseFile("#" + id + '_upload', path, function(err, res){

      });
    });

    util.init(client, userOptions);

    util.step("Log in to page", function() {

    }, function() {
      util.action("Login");
    });

    util.step("Wait for login to complete", function() {
      client.waitFor('table tr a', util.TIMEOUT, util.onTimeout("Wait for login to complete"));
    }, function() {
      util.action("Click on element", ['a', userOptions.title]);
    });

    util.step("Wait for app page to load", function() {
      client.waitFor('ol', util.TIMEOUT, util.onTimeout("Wait for app page to load"));
    }, function() {

    });

    //APK Steps begin here -> might have apk uploaded might not!!
    /*
    util.step("Update APK commence", function() {

    }, function() {
      util.action("Click on element", ['a', 'APK']);
    });

    util.step("Wait for APK page to load", function() {
      client.waitFor('thead', util.TIMEOUT, util.onTimeout("Wait for APK page to load"));
    }, function() {
      util.action("Click on element", ['button', 'Upload new APK to Production']);
    });

    util.step("Wait for APK box", function() {
      client.waitFor('input[type="file"]', util.TIMEOUT, util.onTimeout("Wait for APK box"));
    }, function() {
      //util.action("Upload APK");
    });

    util.step("Wait for APK upload", function() {
      //client.waitForVisible('#apk_uploading_id', util.TIMEOUT * 10, util.onTimeout("Wait for APK upload"));
    }, function() {

    });
*/
    //Store Listing Steps begin here
    util.step("Update Store Listing commence", function() {

    }, function() {
      util.action("Click on element", ['a', 'Store Listing']);
    });

    util.step("Wait for Store Listing page", function() {
      client.waitFor('select', util.TIMEOUT, util.onTimeout("Wait for Store Listing page"));

    }, function() {
      util.action("Set ids for Store Listing");
      util.action("Fill in Store Listing");
    });

    util.step("Upload screenshots and graphics", function() {

    }, function() {

      var screenshot_tags = {
        phone: 'Phone',
        7: '7-inch tablet',
        10: '10-inch tablet'
      };

      for (tag in screenshot_tags) {
        var pathString = userOptions['screenshots_' + tag];

        if (pathString !== undefined) {
          var label = screenshot_tags[tag];
          util.action('Remove screenshots', [label]);
          var paths = pathString.split(',');

          for (i in paths) {
            var id = ('screenshot_' + label + '_' + i).replace(' ', '_');
            path = paths[i];
            util.action('Upload screenshot', [label, id, path]);
          }
        }
      }

      var graphic_tags = {
        'Hi-res icon': userOptions.hi_res,
        'Feature Graphic': userOptions.feat_graphic,
        'Promo Graphic': userOptions.promo_graphic
      }

      for (tag in graphic_tags) {
        graphicsCount = 0;
        var path = graphic_tags[tag];

        if (path !== undefined) {
          util.action("Remove graphic", [tag]);

          var id = "graphic_" + graphicsCount;
          util.action("Upload graphic", [tag, id, path]);
          graphicsCount++;
        }
      }

    });

    util.step("Wait for screenshots and graphics to finish uploading", function() {

      var waiting_id_list = [];
      splitter = ','

      var graphic_items = [userOptions.hi_res, userOptions.feat_graphic, userOptions.promo_graphic];

      for (i in graphic_items) {
        if (graphic_items[i] !== undefined) {
          waiting_id_list[waiting_id_list.length] = 'graphic_' + i;
        }
      }

      var screenshot_items = {
        "Phone" : userOptions.screenshots_phone,
        "7-inch tablet" : userOptions.screenshots_7,
        "10-inch tablet" : userOptions.screenshots_10
      };

      for (i in screenshot_items) {
        if (screenshot_items[i] !== undefined) {
          for (j in screenshot_items[i].split(',')){
            waiting_id_list[waiting_id_list.length] = ('screenshot_' + i + '_' + j).replace(' ', '_');
          }
        }
      }

      for (i in waiting_id_list) {
        var id = waiting_id_list[i];
        client.waitForVisible('#' + id, util.TIMEOUT * 10,
          util.onVisibleTimeout("Wait for screenshots and graphics to finish uploading id = " + id));
      }

    }, function() {
      util.action("Click on element", ['div', 'Save']);
    });

    util.step("Wait for completely saved document", function() {
      client.waitFor('div[data-notification-type="INFO"][aria-hidden="false"]', util.TIMEOUT, util.onTimeout("Wait for completely saved document"));
    }, function() {

    });

    //Pricing & Distribution Steps begin here
    util.step("Update Pricing & Distribution commence", function() {

    }, function() {
      util.action("Click on element", ['a', 'Pricing & Distribution']);
    });

    util.step("Wait for Pricing & Distribution page", function() {
      client.waitFor('colgroup', util.TIMEOUT, util.onTimeout("Wait for Pricing & Distribution page"));
    }, function() {

      //??
      userOptions['opt in'] = '';

      var attribs = ['education', 'opt in', 'locations'];

      for (option in userOptions) {
        if (attribs.indexOf(option) !== -1) {
          util.action("Fill in Pricing & Distribution information - " + option);
        }
      }

      util.action("Click on element", ['div', 'Save']);
    });

    util.step("Wait for completely saved document", function() {
      client.waitFor('div[data-notification-type="INFO"][aria-hidden="false"]', util.TIMEOUT, util.onTimeout("Wait for completely saved document"));
    }, function() {

    });

  }

  return this;
}

exports = module.exports = UpdateApp;<commit_msg>remove graphic updated<commit_after>var Util = require("./utils.js")

var UpdateApp = function() {
  var util = new Util();
  this.runScript = function(client, userOptions) {

    util.action("Fill in Store Listing", function() {

      selectFields = ['app_type', 'category', 'rating'];
      textFields = ['subtext', 'promo', 'promo_vid', 'website', 'email', 'phone'];

      for (option in userOptions) {
        if (selectFields.indexOf(option) !== -1) {
          client.click('#selectArea_' + option + ' option[value = ' + userOptions[option] + ']')
        }

        else if (textFields.indexOf(option) !== -1) {
          client.setValue('#textArea_' + option, userOptions[option]);
        }

        else if (option === 'privacy') {
          if (option) {
            client.setValue("#textArea_" + option, userOptions[option]);
          }
          else {
            client.click("#privacy_opt_out_id");
          }
        }
      }
    });

    util.action("Remove graphic", function(title) {

      var upload_id = searchForChild('h5', 'innerText', title, 2, 'input', (title+'_online_id').replace(' ', '_'), client);

      client.execute(function(id) {
        var input = document.getElementById(id);
        var x_divs = input.parentElement.parentElement.getElementsByTagName('div');

        for (i = 0; i < x_divs.length; i++) {
          if (x_divs[i].innerHTML.charCodeAt(0) === 215) {
            x_divs[i].click();
          }
        }
      }, [upload_id]);
    });

    util.action("Upload graphic", function(title, id, path) {

      var upload_id = searchForChild('h5', 'innerText', title, 2, 'input', id+'_upload', client);

      client.chooseFile("#" + upload_id, path, function(err, res){

      });

      client.execute(function(upload_id, waiting_id){
        var input = document.querySelector("#" + upload_id);
        toWatch = input.parentElement.parentElement.children[2];
        toWatch.id = waiting_id;
      }, [upload_id, id]);
    });

    util.action("Remove screenshots", function(tag) {

      client.execute(function(type) {
        var divs = document.querySelectorAll('b');
        var correct_div = null;
        for (var i =0; i <divs.length; i++) {
          if (divs[i].innerText.trim() === type) {
            correct_div = divs[i];
            break;
          }
        }

        var x_divs = correct_div.parentElement.parentElement.getElementsByTagName('div');
        for (i = 0; i < x_divs.length; i++) {
          if (x_divs[i].innerHTML.charCodeAt(0) === 215) {
            x_divs[i].click();
          }
        }
      }, [tag]);
    });

    util.action("Upload screenshot", function(type, id, path) {

      client.execute(function(type, id){

        var divs = document.querySelectorAll('b');
        var correct_div = null;
        for (var i =0; i <divs.length; i++) {
          if (divs[i].innerText.trim() === type) {
            correct_div = divs[i];
            break;
          }
        }
        var parent = correct_div.parentElement.parentElement;
        var inputs = parent.querySelectorAll('input');
        var input = inputs[inputs.length-1];

        input.id = id + '_upload';

        waiting = input.parentElement.parentElement.children[2];
        waiting.id = id;

      }, [type, id]);

      client.chooseFile("#" + id + '_upload', path, function(err, res){

      });
    });

    util.init(client, userOptions);

    util.step("Log in to page", function() {

    }, function() {
      util.action("Login");
    });

    util.step("Wait for login to complete", function() {
      client.waitFor('table tr a', util.TIMEOUT, util.onTimeout("Wait for login to complete"));
    }, function() {
      util.action("Click on element", ['a', userOptions.title]);
    });

    util.step("Wait for app page to load", function() {
      client.waitFor('ol', util.TIMEOUT, util.onTimeout("Wait for app page to load"));
    }, function() {

    });

    //APK Steps begin here -> might have apk uploaded might not!!
    /*
    util.step("Update APK commence", function() {

    }, function() {
      util.action("Click on element", ['a', 'APK']);
    });

    util.step("Wait for APK page to load", function() {
      client.waitFor('thead', util.TIMEOUT, util.onTimeout("Wait for APK page to load"));
    }, function() {
      util.action("Click on element", ['button', 'Upload new APK to Production']);
    });

    util.step("Wait for APK box", function() {
      client.waitFor('input[type="file"]', util.TIMEOUT, util.onTimeout("Wait for APK box"));
    }, function() {
      //util.action("Upload APK");
    });

    util.step("Wait for APK upload", function() {
      //client.waitForVisible('#apk_uploading_id', util.TIMEOUT * 10, util.onTimeout("Wait for APK upload"));
    }, function() {

    });
*/
    //Store Listing Steps begin here
    util.step("Update Store Listing commence", function() {

    }, function() {
      util.action("Click on element", ['a', 'Store Listing']);
    });

    util.step("Wait for Store Listing page", function() {
      client.waitFor('select', util.TIMEOUT, util.onTimeout("Wait for Store Listing page"));

    }, function() {
      util.action("Set ids for Store Listing");
      util.action("Fill in Store Listing");
    });

    util.step("Upload screenshots and graphics", function() {

    }, function() {

      var screenshot_tags = {
        phone: 'Phone',
        7: '7-inch tablet',
        10: '10-inch tablet'
      };

      for (tag in screenshot_tags) {
        var pathString = userOptions['screenshots_' + tag];

        if (pathString !== undefined) {
          var label = screenshot_tags[tag];
          util.action('Remove screenshots', [label]);
          var paths = pathString.split(',');

          for (i in paths) {
            var id = ('screenshot_' + label + '_' + i).replace(' ', '_');
            path = paths[i];
            util.action('Upload screenshot', [label, id, path]);
          }
        }
      }

      var graphic_tags = {
        'Hi-res icon': userOptions.hi_res,
        'Feature Graphic': userOptions.feat_graphic,
        'Promo Graphic': userOptions.promo_graphic
      }

      for (tag in graphic_tags) {
        graphicsCount = 0;
        var path = graphic_tags[tag];

        if (path !== undefined) {
          util.action("Remove graphic", [tag]);

          var id = "graphic_" + graphicsCount;
          util.action("Upload graphic", [tag, id, path]);
          graphicsCount++;
        }
      }

    });

    util.step("Wait for screenshots and graphics to finish uploading", function() {

      var waiting_id_list = [];
      splitter = ','

      var graphic_items = [userOptions.hi_res, userOptions.feat_graphic, userOptions.promo_graphic];

      for (i in graphic_items) {
        if (graphic_items[i] !== undefined) {
          waiting_id_list[waiting_id_list.length] = 'graphic_' + i;
        }
      }

      var screenshot_items = {
        "Phone" : userOptions.screenshots_phone,
        "7-inch tablet" : userOptions.screenshots_7,
        "10-inch tablet" : userOptions.screenshots_10
      };

      for (i in screenshot_items) {
        if (screenshot_items[i] !== undefined) {
          for (j in screenshot_items[i].split(',')){
            waiting_id_list[waiting_id_list.length] = ('screenshot_' + i + '_' + j).replace(' ', '_');
          }
        }
      }

      for (i in waiting_id_list) {
        var id = waiting_id_list[i];
        client.waitForVisible('#' + id, util.TIMEOUT * 10,
          util.onVisibleTimeout("Wait for screenshots and graphics to finish uploading id = " + id));
      }

    }, function() {
      util.action("Click on element", ['div', 'Save']);
    });

    util.step("Wait for completely saved document", function() {
      client.waitFor('div[data-notification-type="INFO"][aria-hidden="false"]', util.TIMEOUT, util.onTimeout("Wait for completely saved document"));
    }, function() {

    });

    //Pricing & Distribution Steps begin here
    util.step("Update Pricing & Distribution commence", function() {

    }, function() {
      util.action("Click on element", ['a', 'Pricing & Distribution']);
    });

    util.step("Wait for Pricing & Distribution page", function() {
      client.waitFor('colgroup', util.TIMEOUT, util.onTimeout("Wait for Pricing & Distribution page"));
    }, function() {

      //??
      userOptions['opt in'] = '';

      var attribs = ['education', 'opt in', 'locations'];

      for (option in userOptions) {
        if (attribs.indexOf(option) !== -1) {
          util.action("Fill in Pricing & Distribution information - " + option);
        }
      }

      util.action("Click on element", ['div', 'Save']);
    });

    util.step("Wait for completely saved document", function() {
      client.waitFor('div[data-notification-type="INFO"][aria-hidden="false"]', util.TIMEOUT, util.onTimeout("Wait for completely saved document"));
    }, function() {

    });

  }

  return this;
}

exports = module.exports = UpdateApp;<|endoftext|>