<commit_before>describe("About Expects", function() {

  //We shall contemplate truth by testing reality, via spec expectations.
  it("should expect true", function() {
    expect(true).toBeTruthy(); //This should be true
  });

  //To understand reality, we must compare our expectations against reality.
  it("should expect equality", function () {
	  var expectedValue = 2;
	  var actualValue = 1 + 1;

	  expect(actualValue === expectedValue).toBeTruthy();
  });

  //Some ways of asserting equality are better than others.
  it("should assert equality a better way", function () {
	  var expectedValue = 2;
	  var actualValue = 1 + 1;

  // toEqual() compares using common sense equality.
	  expect(actualValue).toEqual(expectedValue);
  });

  //Sometimes you need to be really exact about what you "type".
  it("should assert equality with ===", function () {
	  var expectedValue = FILL_ME_IN;
	  var actualValue = (1 + 1).toString();

  // toBe() will always use === to compare.
	  expect(actualValue).toBe(expectedValue);
  });

  //Sometimes we will ask you to fill in the values.
  it("should have filled in values", function () {
	  expect(1 + 1).toEqual(FILL_ME_IN);
  });
});
<commit_msg>set expected value to "2" to match expectation<commit_after>describe("About Expects", function() {

  //We shall contemplate truth by testing reality, via spec expectations.
  it("should expect true", function() {
    expect(true).toBeTruthy(); //This should be true
  });

  //To understand reality, we must compare our expectations against reality.
  it("should expect equality", function () {
	  var expectedValue = 2;
	  var actualValue = 1 + 1;

	  expect(actualValue === expectedValue).toBeTruthy();
  });

  //Some ways of asserting equality are better than others.
  it("should assert equality a better way", function () {
	  var expectedValue = 2;
	  var actualValue = 1 + 1;

  // toEqual() compares using common sense equality.
	  expect(actualValue).toEqual(expectedValue);
  });

  //Sometimes you need to be really exact about what you "type".
  it("should assert equality with ===", function () {
	  var expectedValue = "2";
	  var actualValue = (1 + 1).toString();

  // toBe() will always use === to compare.
	  expect(actualValue).toBe(expectedValue);
  });

  //Sometimes we will ask you to fill in the values.
  it("should have filled in values", function () {
	  expect(1 + 1).toEqual(FILL_ME_IN);
  });
});
<|endoftext|>


<commit_before>// Copyright 2014-2015 runtime.js project authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var assertError = require('assert-error');
var IP4Address = require('./ip4-address');
var portUtils = require('./port-utils');
var PortPool = require('./port-pool');
var udpTransmit = require('./udp-transmit');
var netError = require('./net-error');
var EventController = require('event-controller');
var typeutils = require('typeutils');
var route = require('./route');

var ports = new PortPool();

function UDPSocket() {
  this._intf = null;
  this._port = 0;
  this.onReceive = new EventController();
}

UDPSocket.prototype.send = function(ip, port, u8) {
  assertError(ip instanceof IP4Address, netError.E_IPADDRESS_EXPECTED);
  assertError(portUtils.isPort(port), netError.E_INVALID_PORT);
  assertError(u8 instanceof Uint8Array, netError.E_TYPEDARRAY_EXPECTED);

  var intf = this._intf || null;

  var viaIP;
  if (ip.isBroadcast()) {
    viaIP = ip;
  } else {
    var routingEntry = route.lookup(ip);
    if (!routingEntry) {
      throw netError.E_NO_ROUTE_TO_HOST;
    }

    viaIP = routingEntry.gateway;
    if (!intf) {
      intf = routingEntry.intf;
    }
  }

  if (!this._port) {
    this._port = ports.getEphemeral(this);
    if (!this._port) {
      throw netError.E_NO_FREE_PORT;
    }
  }

  udpTransmit(intf, ip, viaIP, this._port, port, u8);
};

UDPSocket.prototype.bind = function(port) {
  assertError(portUtils.isPort(port), netError.E_INVALID_PORT);

  if (!ports.alloc(port, this)) {
    throw netError.E_ADDRESS_IN_USE;
  }

  this._port = port;
};

UDPSocket.prototype.bindToInterface = function(intf, port) {
  if (!intf) {
    throw netError.E_INTERFACE_EXPECTED;
  }

  this._intf = intf;
  if (port) {
    this.bind(port);
  }
};

UDPSocket.lookupReceive = function(destPort) {
  return ports.get(destPort) || null;
};

module.exports = UDPSocket;
<commit_msg>es6 UDPSocket<commit_after>// Copyright 2014-2015 runtime.js project authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';
var assertError = require('assert-error');
var IP4Address = require('./ip4-address');
var portUtils = require('./port-utils');
var PortPool = require('./port-pool');
var udpTransmit = require('./udp-transmit');
var netError = require('./net-error');
var EventController = require('event-controller');
var typeutils = require('typeutils');
var route = require('./route');

var ports = new PortPool();

class UDPSocket {
  constructor(protocol) {
    this._protocol = protocol || 'ip4';
    this._intf = null;
    this._port = 0;
    this.onReceive = new EventController();
  }

  send(ip, port, u8) {
    assertError(ip instanceof IP4Address, netError.E_IPADDRESS_EXPECTED);
    assertError(portUtils.isPort(port), netError.E_INVALID_PORT);
    assertError(u8 instanceof Uint8Array, netError.E_TYPEDARRAY_EXPECTED);

    var intf = this._intf || null;

    var viaIP;
    if (ip.isBroadcast()) {
      viaIP = ip;
    } else {
      var routingEntry = route.lookup(ip);
      if (!routingEntry) {
        throw netError.E_NO_ROUTE_TO_HOST;
      }

      viaIP = routingEntry.gateway;
      if (!intf) {
        intf = routingEntry.intf;
      }
    }

    if (!this._port) {
      this._port = ports.getEphemeral(this);
      if (!this._port) {
        throw netError.E_NO_FREE_PORT;
      }
    }

    udpTransmit(intf, ip, viaIP, this._port, port, u8);
  }

  bind(port) {
    assertError(portUtils.isPort(port), netError.E_INVALID_PORT);

    if (!ports.alloc(port, this)) {
      throw netError.E_ADDRESS_IN_USE;
    }

    this._port = port;
  }

  bindToInterface(intf, port) {
    if (!intf) {
      throw netError.E_INTERFACE_EXPECTED;
    }

    this._intf = intf;
    if (port) {
      this.bind(port);
    }
  }

  static lookupReceive(destPort) {
    return ports.get(destPort) || null;
  }
}

module.exports = UDPSocket;
<|endoftext|>


<commit_before>//initialize variables
var firstName = "";
var dob = "";
var cocktail = "";
//var dobValidationMsg = "DOB is not in proper format!";
var age = 0;

//submit button click listener
$("#startAssesment").on("click", function(){
  //prevent page from refreshing
  event.preventDefault();

  //remove the p tag if it exists
  $("#dob-validation-msg").remove();

  //grab the dob provided by user
  firstName = $("#name-input").val().trim();
  dob = $("#birth-input").val().trim();
  dobMoment = moment(dob).format("MM DD YYYY");
  age = moment().diff(dobMoment, "years");

  console.log("firstName : " + firstName);
  console.log("dob : " + dob);
  console.log("age : " + age);

  //validate if first name was provided
  if (firstName === "") {
    var validation = $("
").attr("id", "firstName-validation-msg").text("Please provide your first name!");

    //display the validation message
    $("#name-label").append(validation);
  }
  //validate if the dob is in the proper format, the front-end framework will return an empty string as the value if the improper format is provided
  else if (dob === "" || dob.toLowerCase() === "invalid date" ||dob.split("/")[0] === "" || dob.split("/")[1] === "" || dob.split("/")[2]) {
    //create a new p tag and the validation message
    var validation = $("
").attr("id", "dob-validation-msg").text("DOB is not in proper format!");

    //display the validation message  between the dob label and input text box
    $("#dob-label").append(validation);
  }
  //else if the user is < 21, they cannot use the app
  else if (age < 21) {
    var validation = $("
").attr("id", "dob-validation-msg").text("You are too young to be drinking cocktails, " + firstName + "!");

    //display underage notification
    $("#dob-label").append(validation);
  } //else move on to next page
  else {
    //empty out anything inside a row div
    $(".panel").empty();
  }

});<commit_msg>completed page 2 javascript logic<commit_after>//initialize variables
var firstName = "";
var dob = "";
var age = 0;
var cocktail = "";
var zodiacSign = "";

//submit button click listener
$("#startAssesment").on("click", function(){
  //prevent page from refreshing
  event.preventDefault();

  //remove the p tag if it exists
  $("#dob-validation-msg").remove();

  //grab the dob provided by user
  firstName = $("#name-input").val().trim();
  dob = $("#birth-input").val().trim();
  dobMoment = moment({month : parseInt(dob.split("-")[1] - 1), day : parseInt(dob.split("-")[2]), year : parseInt(dob.split("-")[0])}).format("MM DD YYYY");
  age = moment().diff(dobMoment, "years");

  console.log("firstName : " + firstName);
  console.log("dob : " + dob);
  console.log("dob moment: " + dobMoment);
  console.log("age : " + age);

  //validate if first name was provided
  if (firstName === "") {
    var validation = $("
").attr("id", "firstName-validation-msg").text("Please provide your first name!");

    //display the validation message
    $("#name-label").append(validation);
  }
  //validate if the dob is in the proper format, the front-end framework will return an empty string as the value if the improper format is provided
  else if (dob === "" || dob.toLowerCase() === "invalid date" ||dob.split("/")[0] === "" || dob.split("/")[1] === "" || dob.split("/")[2]) {
    //create a new p tag and the validation message
    var validation = $("
").attr("id", "dob-validation-msg").text("DOB is not in proper format!");

    //display the validation message  between the dob label and input text box
    $("#dob-label").append(validation);
  }
  //else if the user is < 21, they cannot use the app
  else if (age < 21) {
    var validation = $("
").attr("id", "dob-validation-msg").text("You are too young to be drinking cocktails, " + firstName + "!");

    //display underage notification
    $("#dob-label").append(validation);
  } //else move on to next page
  else {
    //empty out anything inside row div
    $(".row").empty();

    //create the grid
    var col1 = $("
").addClass("col-xs-12 col-sm-12 col-md-2");
    var col2 = $("
").addClass("col-xs-12 col-sm-12 col-md-8").attr("id", "div-content");
    var col3 = $("
").addClass("col-xs-12 col-sm-12 col-md-2");

    var col2Row1 = $("
").addClass("row").attr("id", "row1");
    var col2Row2 = $("
").addClass("row").attr("id", "row2");
    var col2Row3 = $("
").addClass("row").attr("id", "row3");
    var col2Row4 = $("
").addClass("row").attr("id", "row4");
    var col2Row5 = $("
").addClass("row").attr("id", "row5");

    col2Row1.append($("
"));
    col2Row2.append($("
"));
    col2Row3.append($("
"));
    //col2Row4.append($("
"));
    col2Row5.append($("
"));

    $(".row").append(col1);
    $(".row").append(col2)
    $(".row").append(col3);

    $("#div-content").append(col2Row1,col2Row2,col2Row3,col2Row4,col2Row5);
    // $("#row1").append($("
"));
    // $("#row1").append($("
"));
    // $("#row1").append($("
"));

    //get the zodiac sign based on dob
    zodiacSign = getZodiacSign(dob);
    console.log(zodiacSign);

    //display zodiac sign
    //$("#row1").empty();
    $("#col2-row1").append("
Hello " + zodiacSign + "!
");

    //display zodiac image
    //$("#row2").empty();
    var img = $("");
    img.attr("src", "http://via.placeholder.com/150x150").attr("alt", "zodiac sign thumbnail");

    $("#col2-row2").append(img);

    //display horoscope details
    //create variables
    var color = "";
    var compatibility = "";
    var horoscope = "";
    var luckyNumber = "";
    var luckyTime = "";
    var mood = "";

    //create placeholders for horoscope info
    var p1 = $("
").attr("id", "date");
    var p2 = $("
").attr("id", "color");
    var p3 = $("
").attr("id", "compatibility");
    var p4 = $("
").attr("id", "horoscope");
    var p5 = $("
").attr("id", "lucky-number");
    var p6 = $("
").attr("id", "lucky-time");
    var p7 = $("
").attr("id", "mood");

    //$("#row3").empty();
    $("#col2-row3").append(p1, p2, p3, p4, p5, p6, p7);

    var day = "today";
    var queryURL = "https://aztro.herokuapp.com?sign=" + zodiacSign + "&day=" + day;

    $.ajax({
      method : "POST",
      url : queryURL
    }).done(function(response){
      // console.log(response);
      // console.log(response.description);
      $("#date").text('Date : ' + response.current_date);
      $("#color").text('Color : ' + response.color);
      $("#compatibility").text('Compatibility : ' + response.compatibility);
      $("#horoscope").text('Horoscope : ' + response.description);
      $("#lucky-number").text('Lucky Number : ' + response.lucky_number);
      $("#lucky-time").text('Lucky Time : ' + response.lucky_time);
      $("#mood").text('Mood : ' + response.mood);
    });

    //display yesterday, today and tomorrow buttons

    //creat the divs for the buttons
    var col1Div = $("
");
    col1Div.addClass("col-xs-4");
    col1Div.attr("id", "col-div-1");

    var col2Div = $("
");
    col2Div.addClass("col-xs-4");
    col2Div.attr("id", "col-div-2");

    var col3Div = $("
");
    col3Div.addClass("col-xs-4");
    col3Div.attr("id", "col-div-3");

    //$("#row4").empty();
    $("#row4").append(col1Div, col2Div, col3Div);

    //create the yesterday button
    var bntYest = $("<button>");
    bntYest.addClass("btn btn-default start");
    bntYest.attr("id", "btn-yest");
    bntYest.attr("type", "submit");
    bntYest.text("Yesterday");

    //append the yesterday button
    $("#col-div-1").append(bntYest);

    //create the today button
    var bntToday = $("<button>");
    bntToday.addClass("btn btn-default start");
    bntToday.attr("id", "btn-today");
    bntToday.attr("type", "submit");
    bntToday.text("Today");

     //append the today button
    $("#col-div-2").append(bntToday);

    //create the tomorrow button
    var bntTomorrow = $("<button>");
    bntTomorrow.addClass("btn btn-default start");
    bntTomorrow.attr("id", "btn-tomorrow");
    bntTomorrow.attr("type", "submit");
    bntTomorrow.text("Tomorrow");

    //append the tomorrow button
    $("#col-div-3").append(bntTomorrow);

    //display random cocktail button
    var bntRandom = $("<button>");
    bntRandom.addClass("btn btn-default start");
    bntRandom.attr("id", "btn-random");
    bntRandom.attr("type", "submit");
    bntRandom.text("Get A Random Cocktail");

    // $("#row5").append($("
"));
    $("#col2-row5").append(bntRandom);

  }

  function getZodiacSign(date) {
    var mmdd = parseMMDD(date);
    mmdd = parseInt(mmdd);

    console.log(mmdd);

    if (mmdd >= 321 && mmdd <= 419) {
      return "Aries";
    } else if (mmdd >= 420 && mmdd <= 520) {
      return "Taurus";
    } else if (mmdd >= 521 && mmdd <= 620) {
      return "Gemini";
    } else if (mmdd >= 621 && mmdd <= 722) {
      return "Cancer";
    } else if (mmdd >= 723 && mmdd <= 822) {
      return "Leo";
    } else if (mmdd >= 823 && mmdd <= 922) {
      return "Virgo";
    } else if (mmdd >= 923 && mmdd <= 1022) {
      return "Libra";
    } else if (mmdd >= 1023 && mmdd <= 1121) {
      return "Scorpio";
    } else if (mmdd >= 1122 && mmdd <= 1221) {
      return "Sagittarius";
    } else if (mmdd >= 1222 && mmdd <= 119) {
      return "Capricorn";
    } else if (mmdd >= 120 && mmdd <= 118) {
      return "Aquarius";
    } else if (mmdd >= 119 && mmdd <= 320) {
      return "Pisces";
    } else {
      return 'error!';
    }
  }

  function parseMMDD(date) {
    var mm = date.split("-")[1];
    var dd = date.split("-")[2];

    return mm + dd;
  }

});<|endoftext|>


<commit_before>var path = require('path');

var secondLastSlash = function(path) {
  var split = path.split('/');

  return split.splice(split.length - 2).join('/');
};

/*
  Generates concate bundle array to ensure proper ordering
 *
 * @param {Array}  -  array of paths to concat with string '<%= config.guts %>/assets/js/'
 * @returns
 */

var makeBundlePaths = function makeBundlePaths(pathsArr) {
  return pathsArr.reduce(function(map, jsPath) {
    var concatPath,
      exclude = false;

    if(jsPath[0] === '!') {
      exclude = true;
      jsPath = jsPath.substr(1);
    }

    concatPath = path.join( (exclude ? '!' : '') + '<%= config.guts %>/assets/js/', jsPath);

    map.push(concatPath);
    return map;
  }, []);
};

var omBundlePaths = [
  'om/libraries/jquery.cookie.js',
  'om/utils/get-url-parameter.js',
  'om/utils/uri.js',
  'om/utils/trim-mixpanel-cookie.js',
  'om/services/source.js',
  'om/utils/trim-url.js',
  'om/utils/oform-globals.js',
  'om/libraries/oform.min.js',
  'om/global.js'
];

<<<<<<< HEAD
var bundlePaths = [
  'utils/translation.js',
  'utils/oform_globals.js',
  'utils/check_complex_password.js',
  'utils/equal_height_grid.js',
  'utils/get_url_parameter.js',
  'utils/uri.js',
  'utils/trim-mixpanel-cookie.js',
  'utils/guid_sprintf.js',
  'utils/form_helper_factory.js',
  'utils/form_helpers/*.js',
  'utils/trim_url.js',
  'global.js',
  'components/*.js',
  'services/*.js'
];

=======
>>>>>>> parent of 02ff14c... Revert "add resolveLoader paths to webpack.config"
module.exports = function(grunt, options){
  var lastTarget;
  var processBundleName = function (src, filepath) {
    var updatedSrc;
    if(lastTarget !== grunt.task.current.target) {
      updatedSrc = 'var targetName = "' + grunt.task.current.target + '";\n\n' + src;
    }
    lastTarget = grunt.task.current.target;

    return updatedSrc || src;
  };

  return {
    namespaceOMPages: {
      options: {
        banner: '<%= grunt.config.get("concat_banner") %>',
        footer: '<%= grunt.config.get("concat_footer") %>',
        process: function(src, filepath) {
          return 'var targetName = "' + grunt.task.current.target + '" + "--" +  "' + secondLastSlash(filepath) + '";\n\n' + src;
        }
      },
      src: ['pages/*.js', 'layouts/*.js'],
      expand: true,
      cwd: '<%= config.guts %>/assets/js/om/',
      dest: '<%= config.dist %>/assets/js/om/'
    },
    jqueryModernizr: {
      src: [
        '<%= config.guts %>/assets/js/libraries/jquery-2.1.1.min.js',
        '<%= config.temp %>/assets/js/libraries/modernizr.2.8.3.min.js',
        '<%= config.bowerDir %>/jquery-cookie/jquery.cookie.js'
      ],
      expand: false,
      flatten: true,
      isFile: true,
      dest: '<%= config.dist %>/assets/js/libraries/jquery-modernizr.min.js'
    },
    omBundle: {
      options: {
        banner: '<%= grunt.config.get("concat_banner") %>',
        footer: '<%= grunt.config.get("concat_footer") %>',
        process: processBundleName
      },
      files: {
        '<%= config.dist %>/assets/js/om/bundle.js': makeBundlePaths(omBundlePaths)
      }
    },
    jqueryModernizrOM: {
      src: [
        '<%= config.guts %>/assets/js/libraries/jquery-1.6.4.min.js',
        '<%= config.temp %>/assets/js/libraries/modernizr.2.8.3.min.js'
      ],
      expand: false,
      flatten: true,
      isFile: true,
      dest: '<%= config.dist %>/assets/js/libraries/jquery-modernizr-om.min.js'
    }
  };
};
<commit_msg>resolve merge conflict in concat<commit_after>var path = require('path');

var secondLastSlash = function(path) {
  var split = path.split('/');

  return split.splice(split.length - 2).join('/');
};

/*
  Generates concate bundle array to ensure proper ordering
 *
 * @param {Array}  -  array of paths to concat with string '<%= config.guts %>/assets/js/'
 * @returns
 */

var makeBundlePaths = function makeBundlePaths(pathsArr) {
  return pathsArr.reduce(function(map, jsPath) {
    var concatPath,
      exclude = false;

    if(jsPath[0] === '!') {
      exclude = true;
      jsPath = jsPath.substr(1);
    }

    concatPath = path.join( (exclude ? '!' : '') + '<%= config.guts %>/assets/js/', jsPath);

    map.push(concatPath);
    return map;
  }, []);
};

var omBundlePaths = [
  'om/libraries/jquery.cookie.js',
  'om/utils/get-url-parameter.js',
  'om/utils/uri.js',
  'om/utils/trim-mixpanel-cookie.js',
  'om/services/source.js',
  'om/utils/trim-url.js',
  'om/utils/oform-globals.js',
  'om/libraries/oform.min.js',
  'om/global.js'
];

module.exports = function(grunt, options){
  var lastTarget;
  var processBundleName = function (src, filepath) {
    var updatedSrc;
    if(lastTarget !== grunt.task.current.target) {
      updatedSrc = 'var targetName = "' + grunt.task.current.target + '";\n\n' + src;
    }
    lastTarget = grunt.task.current.target;

    return updatedSrc || src;
  };

  return {
    namespaceOMPages: {
      options: {
        banner: '<%= grunt.config.get("concat_banner") %>',
        footer: '<%= grunt.config.get("concat_footer") %>',
        process: function(src, filepath) {
          return 'var targetName = "' + grunt.task.current.target + '" + "--" +  "' + secondLastSlash(filepath) + '";\n\n' + src;
        }
      },
      src: ['pages/*.js', 'layouts/*.js'],
      expand: true,
      cwd: '<%= config.guts %>/assets/js/om/',
      dest: '<%= config.dist %>/assets/js/om/'
    },
    jqueryModernizr: {
      src: [
        '<%= config.guts %>/assets/js/libraries/jquery-2.1.1.min.js',
        '<%= config.temp %>/assets/js/libraries/modernizr.2.8.3.min.js',
        '<%= config.bowerDir %>/jquery-cookie/jquery.cookie.js'
      ],
      expand: false,
      flatten: true,
      isFile: true,
      dest: '<%= config.dist %>/assets/js/libraries/jquery-modernizr.min.js'
    },
    omBundle: {
      options: {
        banner: '<%= grunt.config.get("concat_banner") %>',
        footer: '<%= grunt.config.get("concat_footer") %>',
        process: processBundleName
      },
      files: {
        '<%= config.dist %>/assets/js/om/bundle.js': makeBundlePaths(omBundlePaths)
      }
    },
    jqueryModernizrOM: {
      src: [
        '<%= config.guts %>/assets/js/libraries/jquery-1.6.4.min.js',
        '<%= config.temp %>/assets/js/libraries/modernizr.2.8.3.min.js'
      ],
      expand: false,
      flatten: true,
      isFile: true,
      dest: '<%= config.dist %>/assets/js/libraries/jquery-modernizr-om.min.js'
    }
  };
};
<|endoftext|>


<commit_before>describe("About Objects", function () {

  describe("Properties", function () {
    var meglomaniac;

    beforeEach(function () {
       meglomaniac = {  mastermind: "Joker", henchwoman: "Harley" };
    });

    it("should confirm objects are collections of properties", function () {
      expect(meglomaniac.mastermind).toBe(FILL_ME_IN);
    });

    it("should confirm that properties are case sensitive", function () {
      expect(meglomaniac.henchwoman).toBe(FILL_ME_IN);
      expect(meglomaniac.henchWoman).toBe(FILL_ME_IN);
    });
  });

  it("should know properties that are functions act like methods", function () {
    var meglomaniac = {
      mastermind : "Brain",
      henchman: "Pinky",
      battleCry: function (noOfBrains) {
        return "They are " + this.henchman + " and the" +
          Array(noOfBrains + 1).join(" " + this.mastermind);
      }
    };

    var battleCry = meglomaniac.battleCry(4);
    expect(FILL_ME_IN).toMatch(battleCry);
  });

  it("should confirm that when a function is attached to an object, 'this' refers to the object", function () {
    var currentDate = new Date()
    var currentYear = (currentDate.getFullYear());
    var meglomaniac = {
      mastermind: "James Wood",
      henchman: "Adam West",
      birthYear: 1970,
      calculateAge: function () {
        return currentYear - this.birthYear;
      }
    };

    expect(currentYear).toBe(FILL_ME_IN);
    expect(meglomaniac.calculateAge()).toBe(FILL_ME_IN);
  });

  describe("'in' keyword", function () {
    var meglomaniac;
    beforeEach(function () {
      meglomaniac = {
        mastermind: "The Monarch",
        henchwoman: "Dr Girlfriend",
        theBomb: true
      };
    });

    it("should have the bomb", function () {

      var hasBomb = "theBomb" in meglomaniac;

      expect(hasBomb).toBe(FILL_ME_IN);
    });

    it("should not have the detonator however", function () {

      var hasDetonator = "theDetonator" in meglomaniac;

      expect(hasDetonator).toBe(FILL_ME_IN);
    });
  });

  it("should know that properties can be added and deleted", function () {
    var meglomaniac = { mastermind : "Agent Smith", henchman: "Agent Smith" };

    expect("secretary" in meglomaniac).toBe(FILL_ME_IN);

    meglomaniac.secretary = "Agent Smith";
    expect("secretary" in meglomaniac).toBe(FILL_ME_IN);

    delete meglomaniac.henchman;
    expect("henchman" in meglomaniac).toBe(FILL_ME_IN);
  });

  it("should use prototype to add to all objects", function () {
    function Circle(radius)
    {
      this.radius = radius;
    }

    var simpleCircle = new Circle(10);
    var colouredCircle = new Circle(5);
    colouredCircle.colour = "red";

    expect(simpleCircle.colour).toBe(FILL_ME_IN);
    expect(colouredCircle.colour).toBe(FILL_ME_IN);

    Circle.prototype.describe = function () {
      return "This circle has a radius of: " + this.radius;
    };

    expect(simpleCircle.describe()).toBe(FILL_ME_IN);
    expect(colouredCircle.describe()).toBe(FILL_ME_IN);
  });
});
<commit_msg>Finished AboutObject koan.<commit_after>describe("About Objects", function () {

  describe("Properties", function () {
    var meglomaniac;

    beforeEach(function () {
       meglomaniac = {  mastermind: "Joker", henchwoman: "Harley" };
    });

    it("should confirm objects are collections of properties", function () {
      expect(meglomaniac.mastermind).toBe('Joker');
    });

    it("should confirm that properties are case sensitive", function () {
      expect(meglomaniac.henchwoman).toBe('Harley');
      expect(meglomaniac.henchWoman).toBe(undefined);
    });
  });

  it("should know properties that are functions act like methods", function () {
    var meglomaniac = {
      mastermind : "Brain",
      henchman: "Pinky",
      battleCry: function (noOfBrains) {
        return "They are " + this.henchman + " and the" +
          Array(noOfBrains + 1).join(" " + this.mastermind);
      }
    };

    var battleCry = meglomaniac.battleCry(4);
    expect('They are Pinky and the Brain Brain Brain Brain').toMatch(battleCry);
  });

  it("should confirm that when a function is attached to an object, 'this' refers to the object", function () {
    var currentDate = new Date()
    var currentYear = (currentDate.getFullYear());
    var meglomaniac = {
      mastermind: "James Wood",
      henchman: "Adam West",
      birthYear: 1970,
      calculateAge: function () {
        return currentYear - this.birthYear;
      }
    };

    expect(currentYear).toBe(2014);
    expect(meglomaniac.calculateAge()).toBe(44);
  });

  describe("'in' keyword", function () {
    var meglomaniac;
    beforeEach(function () {
      meglomaniac = {
        mastermind: "The Monarch",
        henchwoman: "Dr Girlfriend",
        theBomb: true
      };
    });

    it("should have the bomb", function () {

      var hasBomb = "theBomb" in meglomaniac;

      expect(hasBomb).toBe(true);
    });

    it("should not have the detonator however", function () {

      var hasDetonator = "theDetonator" in meglomaniac;

      expect(hasDetonator).toBe(false);
    });
  });

  it("should know that properties can be added and deleted", function () {
    var meglomaniac = { mastermind : "Agent Smith", henchman: "Agent Smith" };

    expect("secretary" in meglomaniac).toBe(false);

    meglomaniac.secretary = "Agent Smith";
    expect("secretary" in meglomaniac).toBe(true);

    delete meglomaniac.henchman;
    expect("henchman" in meglomaniac).toBe(false);
  });

  it("should use prototype to add to all objects", function () {
    function Circle(radius)
    {
      this.radius = radius;
    }

    var simpleCircle = new Circle(10);
    var colouredCircle = new Circle(5);
    colouredCircle.colour = "red";

    expect(simpleCircle.colour).toBe(undefined);
    expect(colouredCircle.colour).toBe('red');

    Circle.prototype.describe = function () {
      return "This circle has a radius of: " + this.radius;
    };

    expect(simpleCircle.describe()).toBe('This circle has a radius of: 10');
    expect(colouredCircle.describe()).toBe('This circle has a radius of: 5');
  });
});
<|endoftext|>


<commit_before>import 'babel-polyfill';
const moment = require('moment')

const startOfFYGen = () => {
  const now = new Date();
  const month = now.getMonth();
  if (month >= 6) {  // js months [0,11]; 6 => July; days are [1,31] // facepalm
    return new Date(now.getFullYear(), 6, 1);
  }
  return new Date(now.getFullYear() - 1, 6, 1);
}

const startOfFY = startOfFYGen();
console.log('Start of FY', startOfFY);

const isThisFY = x => (x >= startOfFY);

const pushCoords = (d, data, filter = () => true) => {
  if (filter(d.ts, d.amount)) {
    data.x.push(d.ts);
    data.y.push(d.amount);
  }
};

const pushCoordsCumulative = (d, data, filter = () => true) => {
  const last = R.last(data.y) || 0.0;
  pushCoords({...d, amount: last + d.amount}, data, filter);
}

export const processDonationGraphs = function (data) {
  const isValidDate = d => !isNaN(d.getTime())
  const donationLog = R.pipe(
    R.map((obj) => ({...obj, ts: isValidDate(moment(obj.date).toDate()) ? moment(obj.date).toDate() : tsToDate(obj.ts), amount: parseFloat(obj.amount)})),
    R.sort((o1, o2) => o1.ts.getTime() - o2.ts.getTime()),
  )(data.data.donations);

  console.log('Donation Log: ', donationLog);

  const stdScatter = {
    x: [], y: [], type: 'scatter',
    mode: 'markers', marker: {size: 10}
  }
  const stdCumulative = {x: [], y: [], type: 'scatter', mode: 'lines+markers', marker: {size: 6, symbol: "diamond-open"}}

  const donationsAll = R.clone(stdScatter)
  const donationsFY = R.clone(stdScatter)
  const donationsCumulativeAll = R.clone(stdCumulative)
  const donationsCumulativeFY = R.clone(stdCumulative)
  const donationsByStateAll = {};
  const donationsByStateCumulativeAll = {};
  const donationsByStateFY = {}
  const donationsByStateCumulativeFY = {}

  const ensureKeyOrClone = (obj, branch, toClone) => {
    if (obj[branch] === undefined)
      obj[branch] = R.clone(toClone)
  }

  R.map(d => {
    pushCoords(d, donationsAll);
    pushCoords(d, donationsFY, isThisFY);

    ensureKeyOrClone(donationsByStateAll, d.branch, stdScatter)
    ensureKeyOrClone(donationsByStateFY, d.branch, stdScatter)
    pushCoords(d, donationsByStateAll[d.branch]);
    pushCoords(d, donationsByStateFY[d.branch], isThisFY);

    ensureKeyOrClone(donationsByStateCumulativeFY, d.branch, stdCumulative)
    ensureKeyOrClone(donationsByStateCumulativeAll, d.branch, stdCumulative)
    pushCoordsCumulative(d, donationsByStateCumulativeAll[d.branch])
    pushCoordsCumulative(d, donationsByStateCumulativeFY[d.branch], isThisFY)
  }, donationLog);

  let lastY = 0;
  R.map(([x, y]) => {
    let next = lastY + y;
    donationsCumulativeAll.x.push(x);
    donationsCumulativeAll.y.push(next);
    lastY = next;
  }, R.zip(donationsAll.x, donationsAll.y));

  lastY = 0;
  R.map(([x, y]) => {
    let next = lastY + y;
    donationsCumulativeFY.x.push(x);
    donationsCumulativeFY.y.push(next);
    lastY = next;
  }, R.zip(donationsFY.x, donationsFY.y));

  const dataDonationsByStateCumulativeAll = [];
  const dataDonationsByStateCumulativeFY = [];
  const dataDonationsByStateAll = [];
  const dataDonationsByStateFY = [];
  const prepJuriData = (dataObj, dataList) => R.mapObjIndexed((v, k, obj) => dataList.push({...v, name: k}), dataObj);
  prepJuriData(donationsByStateCumulativeAll, dataDonationsByStateCumulativeAll);
  prepJuriData(donationsByStateCumulativeFY, dataDonationsByStateCumulativeFY);
  prepJuriData(donationsByStateAll, dataDonationsByStateAll);
  prepJuriData(donationsByStateFY, dataDonationsByStateFY);

  console.log('DATA -> Donations sigma by state', dataDonationsByStateCumulativeAll);
  console.log('DATA -> Donations Cumulative:', donationsCumulativeAll);
  console.log('DATA -> Donations By Juri:', dataDonationsByStateAll);

  Plotly.newPlot('donationGraphCumulativeFY', [donationsCumulativeFY], {
    title: "Cumulative Donations (this FY)",
    yaxis: {'rangemode': 'tozero', title: '$ AUD'},
    xaxis: {title: 'Date'}
  });

  Plotly.newPlot('donationGraphCumulativeStateFY', dataDonationsByStateCumulativeFY, {
    title: "Cumulative Donations by Branch (this FY)",
    yaxis: {'rangemode': 'tozero', title: '$ AUD'},
    xaxis: {title: 'Date'}
  });

  Plotly.newPlot('donationGraphByStateFY', dataDonationsByStateFY, {
    title: "Donations by Branch (this FY)",
    yaxis: {'rangemode': 'tozero', 'title': '$ AUD'},
    xaxis: {title: 'Date'}
  })

  Plotly.newPlot('donationGraphCumulative', [donationsCumulativeAll], {
    title: "Cumulative Donations (All)",
    yaxis: {'rangemode': 'tozero', title: '$ AUD'},
    xaxis: {title: 'Date'}
  });

  Plotly.newPlot('donationGraphCumulativeState', dataDonationsByStateCumulativeAll, {
    title: "Cumulative Donations by Branch (All)",
    yaxis: {'rangemode': 'tozero', title: '$ AUD'},
    xaxis: {title: 'Date'}
  });

  Plotly.newPlot('donationGraphByState', dataDonationsByStateAll, {
    title: "Donations by Branch (All)",
    yaxis: {'rangemode': 'tozero', 'title': '$ AUD'},
    xaxis: {title: 'Date'}
  })

  return donationLog;
}
<commit_msg>make individual donations on a log scale<commit_after>import 'babel-polyfill';
const moment = require('moment')

const startOfFYGen = () => {
  const now = new Date();
  const month = now.getMonth();
  if (month >= 6) {  // js months [0,11]; 6 => July; days are [1,31] // facepalm
    return new Date(now.getFullYear(), 6, 1);
  }
  return new Date(now.getFullYear() - 1, 6, 1);
}

const startOfFY = startOfFYGen();
console.log('Start of FY', startOfFY);

const isThisFY = x => (x >= startOfFY);

const pushCoords = (d, data, filter = () => true) => {
  if (filter(d.ts, d.amount)) {
    data.x.push(d.ts);
    data.y.push(d.amount);
  }
};

const pushCoordsCumulative = (d, data, filter = () => true) => {
  const last = R.last(data.y) || 0.0;
  pushCoords({...d, amount: last + d.amount}, data, filter);
}

export const processDonationGraphs = function (data) {
  const isValidDate = d => !isNaN(d.getTime())
  const donationLog = R.pipe(
    R.map((obj) => ({...obj, ts: isValidDate(moment(obj.date).toDate()) ? moment(obj.date).toDate() : tsToDate(obj.ts), amount: parseFloat(obj.amount)})),
    R.sort((o1, o2) => o1.ts.getTime() - o2.ts.getTime()),
  )(data.data.donations);

  console.log('Donation Log: ', donationLog);

  const stdScatter = {
    x: [], y: [], type: 'scatter',
    mode: 'markers', marker: {size: 10}
  }
  const stdCumulative = {x: [], y: [], type: 'scatter', mode: 'lines+markers', marker: {size: 6, symbol: "diamond-open"}}

  const donationsAll = R.clone(stdScatter)
  const donationsFY = R.clone(stdScatter)
  const donationsCumulativeAll = R.clone(stdCumulative)
  const donationsCumulativeFY = R.clone(stdCumulative)
  const donationsByStateAll = {};
  const donationsByStateCumulativeAll = {};
  const donationsByStateFY = {}
  const donationsByStateCumulativeFY = {}

  const ensureKeyOrClone = (obj, branch, toClone) => {
    if (obj[branch] === undefined)
      obj[branch] = R.clone(toClone)
  }

  R.map(d => {
    pushCoords(d, donationsAll);
    pushCoords(d, donationsFY, isThisFY);

    ensureKeyOrClone(donationsByStateAll, d.branch, stdScatter)
    ensureKeyOrClone(donationsByStateFY, d.branch, stdScatter)
    pushCoords(d, donationsByStateAll[d.branch]);
    pushCoords(d, donationsByStateFY[d.branch], isThisFY);

    ensureKeyOrClone(donationsByStateCumulativeFY, d.branch, stdCumulative)
    ensureKeyOrClone(donationsByStateCumulativeAll, d.branch, stdCumulative)
    pushCoordsCumulative(d, donationsByStateCumulativeAll[d.branch])
    pushCoordsCumulative(d, donationsByStateCumulativeFY[d.branch], isThisFY)
  }, donationLog);

  let lastY = 0;
  R.map(([x, y]) => {
    let next = lastY + y;
    donationsCumulativeAll.x.push(x);
    donationsCumulativeAll.y.push(next);
    lastY = next;
  }, R.zip(donationsAll.x, donationsAll.y));

  lastY = 0;
  R.map(([x, y]) => {
    let next = lastY + y;
    donationsCumulativeFY.x.push(x);
    donationsCumulativeFY.y.push(next);
    lastY = next;
  }, R.zip(donationsFY.x, donationsFY.y));

  const dataDonationsByStateCumulativeAll = [];
  const dataDonationsByStateCumulativeFY = [];
  const dataDonationsByStateAll = [];
  const dataDonationsByStateFY = [];
  const prepJuriData = (dataObj, dataList) => R.mapObjIndexed((v, k, obj) => dataList.push({...v, name: k}), dataObj);
  prepJuriData(donationsByStateCumulativeAll, dataDonationsByStateCumulativeAll);
  prepJuriData(donationsByStateCumulativeFY, dataDonationsByStateCumulativeFY);
  prepJuriData(donationsByStateAll, dataDonationsByStateAll);
  prepJuriData(donationsByStateFY, dataDonationsByStateFY);

  console.log('DATA -> Donations sigma by state', dataDonationsByStateCumulativeAll);
  console.log('DATA -> Donations Cumulative:', donationsCumulativeAll);
  console.log('DATA -> Donations By Juri:', dataDonationsByStateAll);

  Plotly.newPlot('donationGraphCumulativeFY', [donationsCumulativeFY], {
    title: "Cumulative Donations (this FY)",
    yaxis: {'rangemode': 'tozero', title: '$ AUD'},
    xaxis: {title: 'Date'}
  });

  Plotly.newPlot('donationGraphCumulativeStateFY', dataDonationsByStateCumulativeFY, {
    title: "Cumulative Donations by Branch (this FY)",
    yaxis: {'rangemode': 'tozero', title: '$ AUD'},
    xaxis: {title: 'Date'}
  });

  Plotly.newPlot('donationGraphByStateFY', dataDonationsByStateFY, {
    title: "Donations by Branch (this FY)",
    yaxis: {'rangemode': 'tozero', 'title': '$ AUD (log)', type: 'log'},
    xaxis: {title: 'Date'}
  })

  Plotly.newPlot('donationGraphCumulative', [donationsCumulativeAll], {
    title: "Cumulative Donations (All)",
    yaxis: {'rangemode': 'tozero', title: '$ AUD'},
    xaxis: {title: 'Date'}
  });

  Plotly.newPlot('donationGraphCumulativeState', dataDonationsByStateCumulativeAll, {
    title: "Cumulative Donations by Branch (All)",
    yaxis: {'rangemode': 'tozero', title: '$ AUD'},
    xaxis: {title: 'Date'}
  });

  Plotly.newPlot('donationGraphByState', dataDonationsByStateAll, {
    title: "Donations by Branch (All)",
    yaxis: {'rangemode': 'tozero', 'title': '$ AUD (log)', type: 'log'},
    xaxis: {title: 'Date'}
  })

  return donationLog;
}
<|endoftext|>


<commit_before>"use strict";

var gulp = require("gulp");
var autoprefixer = require("gulp-autoprefixer");
var less = require("gulp-less");
var minifyCss = require("gulp-minify-css");
var path = require("path");
var rename = require("gulp-rename");
var sourcemaps = require("gulp-sourcemaps");

var handleErrors = require("../util/handleErrors");
var config = require("../config");

gulp.task("less", [ "lessDev", "lessProd", "lessIe" ]);

gulp.task("lessDev", function() {
    gulp.src(path.join(config.root, "less", "main.less"))
    .pipe(sourcemaps.init())
    .pipe(less())
    .pipe(autoprefixer())
    .on("error", handleErrors.warning)
    .pipe(sourcemaps.write("../maps"))
    .pipe(gulp.dest(path.join(config.buildPath(), "css")));
});

gulp.task("lessProd", function() {
    gulp.src(path.join(config.root, "less", "main.less"))
    .pipe(less())
    .pipe(autoprefixer())
    .on("error", handleErrors.warning)
    .pipe(minifyCss())
    .on("error", handleErrors.warning)
    .pipe(rename("main-min.css"))
    .pipe(gulp.dest(path.join(config.buildPath(), "css")));
});

gulp.task("lessIe", function() {
    gulp.src(path.join(config.root, "less", "ie.less"))
    .pipe(less())
    .on("error", handleErrors.warning)
    .pipe(gulp.dest(path.join(config.buildPath(), "css")));
});
<commit_msg>Code cleanup<commit_after>"use strict";

var gulp = require("gulp");
var autoprefixer = require("gulp-autoprefixer");
var less = require("gulp-less");
var minifyCss = require("gulp-minify-css");
var path = require("path");
var rename = require("gulp-rename");
var sourcemaps = require("gulp-sourcemaps");

var handleErrors = require("../util/handleErrors");
var config = require("../config");

gulp.task("less", [ "lessDev", "lessProd", "lessIe" ]);

gulp.task("lessDev", function() {
    gulp.src(path.join(config.root, "less", "main.less"))
    .pipe(sourcemaps.init())
    .pipe(less())
    .on("error", handleErrors.warning)
    .pipe(autoprefixer())
    .pipe(sourcemaps.write("../maps"))
    .pipe(gulp.dest(path.join(config.buildPath(), "css")));
});

gulp.task("lessProd", function() {
    gulp.src(path.join(config.root, "less", "main.less"))
    .pipe(less())
    .on("error", handleErrors.warning)
    .pipe(autoprefixer())
    .pipe(minifyCss())
    .pipe(rename("main-min.css"))
    .pipe(gulp.dest(path.join(config.buildPath(), "css")));
});

gulp.task("lessIe", function() {
    gulp.src(path.join(config.root, "less", "ie.less"))
    .pipe(less())
    .on("error", handleErrors.warning)
    .pipe(gulp.dest(path.join(config.buildPath(), "css")));
});
<|endoftext|>


<commit_before>'use strict';

app.controller('party/profile', [
  '$scope', 'displayService', 'party', 'pageService','constantService', 'modelService',
  function ($scope, display, party, page, constants, models) {
    var getUsers = function(volumes){

      var users = {};

      users.otherCollaborators = [];
      users.sponsors = $scope.party.parents;
      console.log($scope.party);

      users.databrary = _.filter($scope.party.children, function(i) {
        return i.site > page.constants.permission.NONE && i.party.id != models.Login.user.id;
      });

      users.labOnly = _.filter($scope.party.children, function(i) {
        return i.site === page.constants.permission.NONE && i.party.id !== models.Login.user.id;
      });

      var tempArray = _($scope.volumes.individual).pluck('access').flatten().uniq(function(i){
        return i.party.id;
      }).filter(function(i){
        return i.party.id != models.Login.user.id;
      }).value();

      var arrayOfEverything = users.sponsors.concat(users.databrary).concat(users.labOnly);

      users.otherCollaborators = _.filter(tempArray, function(i){
        return !(_.find(arrayOfEverything, function(j){
          return i.party.id === j.party.id;
        }));
      });

      // users.otherCollaborators = _(volumes).pluck('access').flatten().uniq(function(i) {
      //   return i.party.id;
      // }).filter(function(u) {
      //   return u.individual >= constants.permission.READ && u.party.id !== models.Login.user.id;
      // }).value();
      // The "value()" call is to actually force theb chain to work.

      var filterOnId = function(i) {
        return i.party.id;
      };

      var getDisplayName = function(i) {
        return i.party.alias || i.party.name;
      };

      _.each(users, function(_value, key) {
        users[key] = _(users[key]).uniq(filterOnId).sortBy(getDisplayName).value();
      });

      return users;
    };

    $scope.unselectAll = function() {

      // This is a quick helper function to make sure that the isSelected
      // class is set to empty and to avoid repeating code.
      var unSetSelected = function(v) {
        v.isSelected = '';
        if(v.v !== undefined) {

          v.v = _.map(v.v, function(a) {
            a.isSelected = '';
            return a;
          });
        }

        return v;
      };

      $scope.volumes.individual = _.map($scope.volumes.individual, unSetSelected);

      $scope.volumes.collaborator = _.map($scope.volumes.collaborator, unSetSelected);

      $scope.volumes.inherited = _.map($scope.volumes.inherited, unSetSelected);

      $scope.users.sponsors = _.map($scope.users.sponsors, unSetSelected);

      $scope.users.databrary = _.map($scope.users.databrary, unSetSelected);

      $scope.users.labOnly = _.map($scope.users.labOnly, unSetSelected);

      $scope.users.otherCollaborators = _.map($scope.users.otherCollaborators, unSetSelected);

    };

    $scope.clickVolume = function(volume) {

      $scope.unselectAll();
      volume.isSelected = 'volumeSelected';
      volume = _.flatten([volume.v || volume]);

      _.each(volume, function(vol) {
        _.each(vol.access, function(acc) {
          var userSelectFunction = function(user, index, array) {
            if(user.party.id == acc.party.id) {
              array[index].isSelected = 'userSelected';
            }
          };

          _.each($scope.users.sponsors,userSelectFunction);
          _.each($scope.users.databrary,userSelectFunction);
          _.each($scope.users.labOnly,userSelectFunction);
          _.each($scope.users.otherCollaborators,userSelectFunction);

        });
      });
    };

    // This should take in a user, then select volumes on each thing.
    $scope.clickUser = function(user) {
      $scope.unselectAll();
      user.isSelected = 'userSelected';
      var i;

      var compareFunction = function(value, key, array) {
        for(var j = 0; j < value.access.length; j++) {
          if(value.access[j].party.id === user.party.id) {
            array[key].isSelected = 'volumeSelected';
          }
        }
      };

      _.each($scope.volumes.individual, compareFunction);
      _.each($scope.volumes.collaborator, compareFunction);

      for(i = 0; i < $scope.volumes.inherited.length; i++) {
        _.each($scope.volumes.inherited[i].v, compareFunction);
      }
    };

    var getParents = function(parents) {
      return _.compact(_.map(parents, function(p) {
        if(p.member) {
          return _.zipObject(['p', 'v'], [p, []]);
        }
      }));
    };

    var getVolumes = function(volumes) {
      var tempVolumes = _.zipObject(['individual', 'collaborator'], [[], []]);

      tempVolumes.inherited = getParents(party.parents);

      _.each(volumes, function(v) {

        var isCurrent = _.find(v.access, function(r) {
          return r.party.id === models.Login.user.id;
        });

        if(isCurrent && isCurrent.individual == page.constants.permission.ADMIN) {
          // The "mini-object" with v and [v] is to make sure that the data is all
          // shaped the same, making looping over it *substantially* simpler.
          tempVolumes.individual.push(v);
        } else if(isCurrent) {
          tempVolumes.collaborator.push(v);
        } else {
          for (var i = 0; i < v.access.length; i++) {
            for (var j = 0; j < tempVolumes.inherited.length; j++) {
              if (v.access[i].children && v.access[i].party.id === tempVolumes.inherited[j].p.party.id) {
                tempVolumes.inherited[j].v.push(v);
              }
            }
          }
        }
      });

      var getDisplayName = function(i) {
        return i.alias || i.name;
      };

      tempVolumes.individual = _.sortBy(tempVolumes.individual, getDisplayName);
      tempVolumes.collaborator = _.sortBy(tempVolumes.collaborator, getDisplayName);

      return tempVolumes;

    };

    $scope.party = party;
    $scope.volumes = getVolumes(party.volumes);
    $scope.users = getUsers(party.volumes);

    console.log("Constants: ",constants);
    console.log($scope.users);

    $scope.page = page;
    $scope.profile = page.$location.path() === '/profile';
    display.title = party.name;

  }
]);
<commit_msg>Make names sort by lastname.<commit_after>'use strict';

app.controller('party/profile', [
  '$scope', 'displayService', 'party', 'pageService','constantService', 'modelService',
  function ($scope, display, party, page, constants, models) {
    var getUsers = function(volumes){

      var users = {};

      users.otherCollaborators = [];
      users.sponsors = $scope.party.parents;
      console.log($scope.party);

      users.databrary = _.filter($scope.party.children, function(i) {
        return i.site > page.constants.permission.NONE && i.party.id != models.Login.user.id;
      });

      users.labOnly = _.filter($scope.party.children, function(i) {
        return i.site === page.constants.permission.NONE && i.party.id !== models.Login.user.id;
      });

      var tempArray = _($scope.volumes.individual).pluck('access').flatten().uniq(function(i){
        return i.party.id;
      }).filter(function(i){
        return i.party.id != models.Login.user.id;
      }).value();

      var arrayOfEverything = users.sponsors.concat(users.databrary).concat(users.labOnly);

      users.otherCollaborators = _.filter(tempArray, function(i){
        return !(_.find(arrayOfEverything, function(j){
          return i.party.id === j.party.id;
        }));
      });

      // users.otherCollaborators = _(volumes).pluck('access').flatten().uniq(function(i) {
      //   return i.party.id;
      // }).filter(function(u) {
      //   return u.individual >= constants.permission.READ && u.party.id !== models.Login.user.id;
      // }).value();
      // The "value()" call is to actually force theb chain to work.

      var filterOnId = function(i) {
        return i.party.id;
      };

      var sorter = function(i){
        return i.party.sortname;
      };

      console.log(users);
      _.each(users, function(_value, key) {
        users[key] = _(users[key]).uniq(filterOnId).sortBy(sorter).value();
      });

      return users;
    };

    $scope.unselectAll = function() {

      // This is a quick helper function to make sure that the isSelected
      // class is set to empty and to avoid repeating code.
      var unSetSelected = function(v) {
        v.isSelected = '';
        if(v.v !== undefined) {

          v.v = _.map(v.v, function(a) {
            a.isSelected = '';
            return a;
          });
        }

        return v;
      };

      $scope.volumes.individual = _.map($scope.volumes.individual, unSetSelected);

      $scope.volumes.collaborator = _.map($scope.volumes.collaborator, unSetSelected);

      $scope.volumes.inherited = _.map($scope.volumes.inherited, unSetSelected);

      $scope.users.sponsors = _.map($scope.users.sponsors, unSetSelected);

      $scope.users.databrary = _.map($scope.users.databrary, unSetSelected);

      $scope.users.labOnly = _.map($scope.users.labOnly, unSetSelected);

      $scope.users.otherCollaborators = _.map($scope.users.otherCollaborators, unSetSelected);

    };

    $scope.clickVolume = function(volume) {

      $scope.unselectAll();
      volume.isSelected = 'volumeSelected';
      volume = _.flatten([volume.v || volume]);

      _.each(volume, function(vol) {
        _.each(vol.access, function(acc) {
          var userSelectFunction = function(user, index, array) {
            if(user.party.id == acc.party.id) {
              array[index].isSelected = 'userSelected';
            }
          };

          _.each($scope.users.sponsors,userSelectFunction);
          _.each($scope.users.databrary,userSelectFunction);
          _.each($scope.users.labOnly,userSelectFunction);
          _.each($scope.users.otherCollaborators,userSelectFunction);

        });
      });
    };

    // This should take in a user, then select volumes on each thing.
    $scope.clickUser = function(user) {
      $scope.unselectAll();
      user.isSelected = 'userSelected';
      var i;

      var compareFunction = function(value, key, array) {
        for(var j = 0; j < value.access.length; j++) {
          if(value.access[j].party.id === user.party.id) {
            array[key].isSelected = 'volumeSelected';
          }
        }
      };

      _.each($scope.volumes.individual, compareFunction);
      _.each($scope.volumes.collaborator, compareFunction);

      for(i = 0; i < $scope.volumes.inherited.length; i++) {
        _.each($scope.volumes.inherited[i].v, compareFunction);
      }
    };

    var getParents = function(parents) {
      return _.compact(_.map(parents, function(p) {
        if(p.member) {
          return _.zipObject(['p', 'v'], [p, []]);
        }
      }));
    };

    var getVolumes = function(volumes) {
      var tempVolumes = _.zipObject(['individual', 'collaborator'], [[], []]);

      tempVolumes.inherited = getParents(party.parents);

      _.each(volumes, function(v) {

        var isCurrent = _.find(v.access, function(r) {
          return r.party.id === models.Login.user.id;
        });

        if(isCurrent && isCurrent.individual == page.constants.permission.ADMIN) {
          // The "mini-object" with v and [v] is to make sure that the data is all
          // shaped the same, making looping over it *substantially* simpler.
          tempVolumes.individual.push(v);
        } else if(isCurrent) {
          tempVolumes.collaborator.push(v);
        } else {
          for (var i = 0; i < v.access.length; i++) {
            for (var j = 0; j < tempVolumes.inherited.length; j++) {
              if (v.access[i].children && v.access[i].party.id === tempVolumes.inherited[j].p.party.id) {
                tempVolumes.inherited[j].v.push(v);
              }
            }
          }
        }

      });

      var getDisplayName = function(i) {
        return i.alias || i.name;
      };

      tempVolumes.individual = _.sortBy(tempVolumes.individual, getDisplayName);
      tempVolumes.collaborator = _.sortBy(tempVolumes.collaborator, getDisplayName);

      return tempVolumes;

    };

    $scope.party = party;
    $scope.volumes = getVolumes(party.volumes);
    $scope.users = getUsers(party.volumes);

    console.log("Constants: ",constants);
    console.log($scope.users);

    $scope.page = page;
    $scope.profile = page.$location.path() === '/profile';
    display.title = party.name;

  }
]);
<|endoftext|>


<commit_before>$(document).ready(function() {
  add_inline_editing();
  $('#issue-form').bind('submit', function(e){
    var next_status_id = $('#issue_status_id').val();
    if ((next_status_id != current_status_id) &&
        ($.inArray(parseInt(next_status_id), window.issue_workflow_list) != -1) &&
        $('#has_resources').val() == '0') {
      alert('You need to add estimation before moving to this status.');
      $('#estimation').focus();
      e.preventDefault();
      $(e.target).removeAttr('data-submitted');
      return false;
    }
  });

  $('#new_issue_resource').bind('submit', function() {
    $('input.button', $(this)).attr('disabled', true);
    return true;
  });

  window.current_status_id = $('#issue_status_id').val();
});

function add_inline_editing() {
  $('.resource_estimation_editable').each(function(element) {
    var $editable_element = $(this);
    var id = $editable_element.data('resource-id');
    $editable_element.editable('/issue_resources/' + id, {
        onblur : 'submit',
        method : 'PUT',
        ajaxoptions : {type : 'PUT'},
        name : 'issue_resource[estimation]',
        tooltip   : "Click to edit...",
        'event' : 'editable'
    });
    $('#cell-' + id).live('click', function() {
      $editable_element.trigger('editable');
      $('input', $editable_element).trigger('focus').trigger('select');

    })
  });
}
<commit_msg>Changed live method call with on (removed in JQuery 1.9)<commit_after>$(document).ready(function() {
  add_inline_editing();
  $('#issue-form').bind('submit', function(e){
    var next_status_id = $('#issue_status_id').val();
    if ((next_status_id != current_status_id) &&
        ($.inArray(parseInt(next_status_id), window.issue_workflow_list) != -1) &&
        $('#has_resources').val() == '0') {
      alert('You need to add estimation before moving to this status.');
      $('#estimation').focus();
      e.preventDefault();
      $(e.target).removeAttr('data-submitted');
      return false;
    }
  });

  $('#new_issue_resource').bind('submit', function() {
    $('input.button', $(this)).attr('disabled', true);
    return true;
  });

  window.current_status_id = $('#issue_status_id').val();
});

function add_inline_editing() {
  $('.resource_estimation_editable').each(function(element) {
    var $editable_element = $(this);
    var id = $editable_element.data('resource-id');
    $editable_element.editable('/issue_resources/' + id, {
        onblur : 'submit',
        method : 'PUT',
        ajaxoptions : {type : 'PUT'},
        name : 'issue_resource[estimation]',
        tooltip   : "Click to edit...",
        'event' : 'editable'
    });
    $('#cell-' + id).on('click', function() {
      $editable_element.trigger('editable');
      $('input', $editable_element).trigger('focus').trigger('select');

    })
  });
}
<|endoftext|>


<commit_before>module.exports = {
  options: {
    shorthandCompacting: false,
    roundingPrecision: -1,
    sourceMap: true
  },
  target: {
    files: {
      'dist/emp3-map/emp3-leaflet/emp3-leaflet.min.css': [
        "src/mapengine/leaflet/css/leaflet.css",
        "src/mapengine/leaflet/css/MarkerCluster.css",
        "src/mapengine/leaflet/css/MarkerCluster.Default.css",
        "src/mapengine/leaflet/css/leaflet-eng.css"
      ],
      'dist/emp3-map/emp3-cesium/emp3-cesium.min.css': [
        "src/mapengine/cesium/js/lib/cesium/Cesium.css",
        "src/mapengine/cesium/js/lib/cesium/Widgets/widgets.css",
        "src/mapengine/cesium/js/lib/cesium/editors/drawHelper/DrawHelper.css",
        "src/mapengine/cesium/js/lib/cesium/Widgets/BaseLayerPicker/BaseLayerPicker.css"
      ]
    }
  }
};
<commit_msg>fixed missing minified CSS in release validation tool<commit_after>module.exports = {
  options: {
    shorthandCompacting: false,
    roundingPrecision: -1,
    sourceMap: true
  },
  target: {
    files: {
      'dist/emp3-map/emp3-leaflet/emp3-leaflet.min.css': [
        "src/mapengine/leaflet/css/leaflet.css",
        "src/mapengine/leaflet/css/MarkerCluster.css",
        "src/mapengine/leaflet/css/MarkerCluster.Default.css",
        "src/mapengine/leaflet/css/leaflet-eng.css"
      ],
      'dist/emp3/emp3-leaflet/emp3-leaflet.min.css': [
        "src/mapengine/leaflet/css/leaflet.css",
        "src/mapengine/leaflet/css/MarkerCluster.css",
        "src/mapengine/leaflet/css/MarkerCluster.Default.css",
        "src/mapengine/leaflet/css/leaflet-eng.css"
      ],
      'dist/emp3-map/emp3-cesium/emp3-cesium.min.css': [
        "src/mapengine/cesium/js/lib/cesium/Cesium.css",
        "src/mapengine/cesium/js/lib/cesium/Widgets/widgets.css",
        "src/mapengine/cesium/js/lib/cesium/editors/drawHelper/DrawHelper.css",
        "src/mapengine/cesium/js/lib/cesium/Widgets/BaseLayerPicker/BaseLayerPicker.css"
      ],
      'dist/emp3/emp3-cesium/emp3-cesium.min.css': [
        "src/mapengine/cesium/js/lib/cesium/Cesium.css",
        "src/mapengine/cesium/js/lib/cesium/Widgets/widgets.css",
        "src/mapengine/cesium/js/lib/cesium/editors/drawHelper/DrawHelper.css",
        "src/mapengine/cesium/js/lib/cesium/Widgets/BaseLayerPicker/BaseLayerPicker.css"
      ]
    }
  }
};
<|endoftext|>


<commit_before>var gulp         = require('gulp');
var jshint       = require('gulp-jshint');
var reload       = require('browser-sync').reload;
var handleErrors = require('../util/handleErrors');

var paths = projectConfig.paths;

gulp.task('lint', function () {
  return gulp.src([ paths['scripts'] ])
    .pipe(handleErrors())
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(reload());
});
<commit_msg>Add forgotten stream option to `lint` reload.<commit_after>var gulp         = require('gulp');
var jshint       = require('gulp-jshint');
var reload       = require('browser-sync').reload;
var handleErrors = require('../util/handleErrors');

var paths = projectConfig.paths;

gulp.task('lint', function () {
  return gulp.src([ paths['scripts'] ])
    .pipe(handleErrors())
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(reload({ stream: true }));
});
<|endoftext|>


<commit_before>app.controller('settingsProfile' , function ($scope, $document, $sessionStorage, api) {
    $scope.$storage = $sessionStorage;
    $scope.imgSrc = 'assets/img/jobs.png';
    $scope.showName = 'Visningsnamn';
    $scope.userName = 'Username';
    $scope.yourEmail = 'namn.efternamn@exempel.com';
    $scope.yourInfo = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec malesuada, est vitae commodo dapibus, ipsum velit euismod nibh, sit amet efficitur justo est ac augue.';
    console.log($scope.lightTheme);
    $scope.test = function () {

    };

    $scope.updateSettings = function() {
        api.users.update().then(function(response) {
            $scope.$storage.user = response.data;
        });
    }
});
<commit_msg>Reset settings form when not saving<commit_after>app.controller('settingsProfile' , function ($scope, $document, $sessionStorage, api) {
    $scope.$storage = $sessionStorage;

    $scope.resetSettings = function() {
        api.users.get($scope.$storage.user._id).then(function(response){
            $scope.$storage.user = response.data;
        });
    }

    $scope.updateSettings = function() {
        api.users.update().then(function(response) {
            $scope.$storage.user = response.data;
        });
    }
});
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');

var $ = require('gulp-load-plugins')();

var wiredep = require('wiredep');
var karma = require('karma');
var concat = require('concat-stream');
var _ = require('lodash');

module.exports = function(options) {
  function listFiles(callback) {
    var wiredepOptions = _.extend({}, options.wiredep, {
      dependencies: true,
      devDependencies: true
    });
    var bowerDeps = wiredep(wiredepOptions);

    var specFiles = [
      options.src + '/**/*.test.js',
      options.src + '/**/*.mock.js'
    ];

    var htmlFiles = [
      options.src + '/**/*.html'
    ];

    var srcFiles = [
      options.src + '/**/*.js',
      options.tmp + '/**/*.js',
      '!' + options.src + '/bower/**/*.js'
    ].concat(specFiles.map(function(file) {
      return '!' + file;
    }));

    gulp.src(srcFiles)
      .pipe(concat(function(files) {
        callback(bowerDeps.js
          .concat(_.pluck(files, 'path'))
          .concat(htmlFiles)
          .concat(specFiles));
      }));
  }

  function runTests (singleRun, done) {
    listFiles(function(files) {
      karma.server.start({
        configFile: __dirname + '/../karma.conf.js',
        files: files,
        singleRun: singleRun,
        autoWatch: !singleRun
      }, done);
    });
  }

  gulp.task('test', ['scripts'], function(done) {
    runTests(true, done);
  });
  gulp.task('test:auto', ['watch'], function(done) {
    runTests(false, done);
  });
};
<commit_msg>Added ng constant generation to test command for travis:TOTEM-115<commit_after>'use strict';

var gulp = require('gulp');

var $ = require('gulp-load-plugins')();

var wiredep = require('wiredep');
var karma = require('karma');
var concat = require('concat-stream');
var _ = require('lodash');

module.exports = function(options) {
  function listFiles(callback) {
    var wiredepOptions = _.extend({}, options.wiredep, {
      dependencies: true,
      devDependencies: true
    });
    var bowerDeps = wiredep(wiredepOptions);

    var specFiles = [
      options.src + '/**/*.test.js',
      options.src + '/**/*.mock.js'
    ];

    var htmlFiles = [
      options.src + '/**/*.html'
    ];

    var srcFiles = [
      options.src + '/**/*.js',
      options.tmp + '/**/*.js',
      '!' + options.src + '/bower/**/*.js'
    ].concat(specFiles.map(function(file) {
      return '!' + file;
    }));

    gulp.src(srcFiles)
      .pipe(concat(function(files) {
        callback(bowerDeps.js
          .concat(_.pluck(files, 'path'))
          .concat(htmlFiles)
          .concat(specFiles));
      }));
  }

  function runTests (singleRun, done) {
    listFiles(function(files) {
      karma.server.start({
        configFile: __dirname + '/../karma.conf.js',
        files: files,
        singleRun: singleRun,
        autoWatch: !singleRun
      }, done);
    });
  }

  gulp.task('test', ['config', 'scripts'], function(done) {
    runTests(true, done);
  });
  gulp.task('test:auto', ['watch'], function(done) {
    runTests(false, done);
  });
};
<|endoftext|>


<commit_before>import config from 'config'
import ajax from 'please-ajax'
import sniffer from 'sniffer'
import classes from 'dom-classes'
import create from 'dom-create-element'
import gsap from 'gsap'

class Preloader {

	constructor(onComplete) {

		this.preloaded = onComplete
		this.view = config.view
		this.el = null
	}

	init(req, done) {

		classes.add(config.body, 'is-loading')

    ajax.get(`${config.BASE}data/data.json`, {
      success: (object) => {
        window._data = object.data
        done()
      }
    })

		config.infos = sniffer.getInfos()

		this.createDOM()

		done()
	}

	createDOM() {

		const page = this.view.firstChild

		this.el = create({
			selector: 'div',
			styles: 'preloader',
			html: `

Preloader

			`
		})

		config.body.appendChild(this.el)
	}

	resize(width, height) {

		config.width = width
		config.height = height
	}

	animateIn(req, done) {

		const tl = new TimelineMax({ paused: true, onComplete: () => {
			done()
			this.preloaded()
		}})
		tl.to(this.el, 1, {autoAlpha: 1})
		tl.restart()
	}

	animateOut(req, done) {

		const tl = new TimelineMax({ paused: true, onComplete: done })
		tl.to(this.el, 1, {autoAlpha: 0})
		tl.restart()
	}

	destroy(req, done) {

		classes.add(config.body, 'is-loaded')
		classes.remove(config.body, 'is-loading')

		config.body.removeChild(this.el)

		done()
	}
}

module.exports = Preloader
<commit_msg>deleted sniffer from preloader<commit_after>import config from 'config'
import ajax from 'please-ajax'
import classes from 'dom-classes'
import create from 'dom-create-element'
import gsap from 'gsap'

class Preloader {

	constructor(onComplete) {

		this.preloaded = onComplete
		this.view = config.view
		this.el = null
	}

	init(req, done) {

		classes.add(config.body, 'is-loading')

    ajax.get(`${config.BASE}data/data.json`, {
      success: (object) => {
        window._data = object.data
        done()
      }
    })

		this.createDOM()

		done()
	}

	createDOM() {

		const page = this.view.firstChild

		this.el = create({
			selector: 'div',
			styles: 'preloader',
			html: `

Preloader

			`
		})

		config.body.appendChild(this.el)
	}

	resize(width, height) {

		config.width = width
		config.height = height
	}

	animateIn(req, done) {

		const tl = new TimelineMax({ paused: true, onComplete: () => {
			done()
			this.preloaded()
		}})
		tl.to(this.el, 1, {autoAlpha: 1})
		tl.restart()
	}

	animateOut(req, done) {

		const tl = new TimelineMax({ paused: true, onComplete: done })
		tl.to(this.el, 1, {autoAlpha: 0})
		tl.restart()
	}

	destroy(req, done) {

		classes.add(config.body, 'is-loaded')
		classes.remove(config.body, 'is-loading')

		config.body.removeChild(this.el)

		done()
	}
}

module.exports = Preloader
<|endoftext|>


<commit_before>/*!
 * FileInput Serbian Translations
 *
 * This file must be loaded after 'fileinput.js'. Patterns in braces '{}', or
 * any HTML markup tags in the messages must not be converted or translated.
 *
 * @see http://github.com/kartik-v/bootstrap-fileinput
 * @author Milos Stojanovic <stojanovic.loshmi@gmail.com>
 *
 * NOTE: this file must be saved in UTF-8 encoding.
 */
(function ($) {
    "use strict";

    $.fn.fileinput.locales._LANG_ = {
        fileSingle: 'datoteka',
        filePlural: 'datoteke',
        browseLabel: 'Izaberi …',
        removeLabel: 'Ukloni',
        removeTitle: 'Ukloni označene datoteke',
        cancelLabel: 'Odustani',
        cancelTitle: 'Prekini trenutno otpremanje',
        uploadLabel: 'Otpremi',
        uploadTitle: 'Otpremi označene datoteke',
        msgSizeTooLarge: 'Datoteka "{name}" ({size} KB) prekoračuje maksimalnu dozvoljenu veličinu datoteke od {maxSize} KB. Molimo pokušajte ponovo!',
        msgFilesTooLess: 'Morate odabrati najmanje {n} {files} za otpremanje. Molimo pokušajte ponovo!',
        msgFilesTooMany: 'Broj datoteka označenih za otpremanje ({n}) prekoračuje maksimalni dozvoljeni limit od {m}. Molimo pokušajte ponovo!',
        msgFileNotFound: 'Datoteka "{name}" nije pronađena!',
        msgFileSecured: 'Datoteku "{name}" nije moguće pročitati zbog bezbednosnih ograničenja.',
        msgFileNotReadable: 'Datoteku "{name}" nije moguće pročitati.',
        msgFilePreviewAborted: 'Generisanje prikaza nije moguće za "{name}".',
        msgFilePreviewError: 'Došlo je do greške prilikom čitanja datoteke "{name}".',
        msgInvalidFileType: 'Datoteka "{name}" je pogrešnog formata. Dozvoljeni formati su "{types}".',
        msgInvalidFileExtension: 'Ekstenzija datoteke "{name}" nije dozvoljena. Dozvoljene ekstenzije su "{extensions}".',
        msgValidationError: 'Greška prilikom otpremanja fajla',
        msgLoading: 'Učitavanje datoteke {index} od {files} …',
        msgProgress: 'Učitavanje datoteke {index} od {files} - {name} - {percent}% završeno.',
        msgSelected: '{n} datoteka je označeno',
        msgFoldersNotAllowed: 'Moguće je prevlačiti samo datoteke! Preskočeno je {n} fascikla.',
        dropZoneTitle: 'Prevucite datoteke ovde …'
    };

    $.extend($.fn.fileinput.defaults, $.fn.fileinput.locales._LANG_);
})(window.jQuery);
<commit_msg>Replace _LANG_ tag with sr<commit_after>/*!
 * FileInput Serbian Translations
 *
 * This file must be loaded after 'fileinput.js'. Patterns in braces '{}', or
 * any HTML markup tags in the messages must not be converted or translated.
 *
 * @see http://github.com/kartik-v/bootstrap-fileinput
 * @author Milos Stojanovic <stojanovic.loshmi@gmail.com>
 *
 * NOTE: this file must be saved in UTF-8 encoding.
 */
(function ($) {
    "use strict";

    $.fn.fileinput.locales.sr = {
        fileSingle: 'datoteka',
        filePlural: 'datoteke',
        browseLabel: 'Izaberi …',
        removeLabel: 'Ukloni',
        removeTitle: 'Ukloni označene datoteke',
        cancelLabel: 'Odustani',
        cancelTitle: 'Prekini trenutno otpremanje',
        uploadLabel: 'Otpremi',
        uploadTitle: 'Otpremi označene datoteke',
        msgSizeTooLarge: 'Datoteka "{name}" ({size} KB) prekoračuje maksimalnu dozvoljenu veličinu datoteke od {maxSize} KB. Molimo pokušajte ponovo!',
        msgFilesTooLess: 'Morate odabrati najmanje {n} {files} za otpremanje. Molimo pokušajte ponovo!',
        msgFilesTooMany: 'Broj datoteka označenih za otpremanje ({n}) prekoračuje maksimalni dozvoljeni limit od {m}. Molimo pokušajte ponovo!',
        msgFileNotFound: 'Datoteka "{name}" nije pronađena!',
        msgFileSecured: 'Datoteku "{name}" nije moguće pročitati zbog bezbednosnih ograničenja.',
        msgFileNotReadable: 'Datoteku "{name}" nije moguće pročitati.',
        msgFilePreviewAborted: 'Generisanje prikaza nije moguće za "{name}".',
        msgFilePreviewError: 'Došlo je do greške prilikom čitanja datoteke "{name}".',
        msgInvalidFileType: 'Datoteka "{name}" je pogrešnog formata. Dozvoljeni formati su "{types}".',
        msgInvalidFileExtension: 'Ekstenzija datoteke "{name}" nije dozvoljena. Dozvoljene ekstenzije su "{extensions}".',
        msgValidationError: 'Greška prilikom otpremanja fajla',
        msgLoading: 'Učitavanje datoteke {index} od {files} …',
        msgProgress: 'Učitavanje datoteke {index} od {files} - {name} - {percent}% završeno.',
        msgSelected: '{n} datoteka je označeno',
        msgFoldersNotAllowed: 'Moguće je prevlačiti samo datoteke! Preskočeno je {n} fascikla.',
        dropZoneTitle: 'Prevucite datoteke ovde …'
    };

    $.extend($.fn.fileinput.defaults, $.fn.fileinput.locales._LANG_);
})(window.jQuery);
<|endoftext|>


<commit_before>"use strict";

const path = require('path');
const gulp = require('gulp');
const gutil = require('gulp-util');
const mochelec = require('gulp-mochelec');
const notifier = require('node-notifier');
const notify = require('gulp-notify');
const through = require('through2');

const TIMEOUT_PASS = 2000;
const TIMEOUT_FAIL = 4000;
const IMAGE_PASS = path.join(__dirname, 'img/pass.png');
const IMAGE_FAIL = path.join(__dirname, 'img/fail.png');

function notifyFailure(err) {
	gutil.log("Failure: " + err.message);
	notifier.notify({
		'expire-time': TIMEOUT_FAIL,
		icon: IMAGE_FAIL,
		title: "Failed",
		message: err.message
	});
}

function notifyPass() {
	return through.obj((file, enc, cb) => {
		notifier.notify({
			'expire-time': TIMEOUT_PASS,
			icon: IMAGE_PASS,
			title: "Pass",
			message: "All unit tests passed."
		});
		cb(null, file);
	});
}

gulp.task('test', () => {
	gulp.src('./test/test-dom-util.js', { read: false })
		.pipe(mochelec({
			renderer: true,
		}))
		.on('error', notifyFailure)
		.pipe(notifyPass())
});

gulp.task('test:watch', ['test'], () => {
	gulp.watch(['index.js', './lib/**/*.js', './test/*.js'], ['test']);
});
<commit_msg>Run all unit tests with `gulp test`<commit_after>"use strict";

const path = require('path');
const gulp = require('gulp');
const gutil = require('gulp-util');
const mochelec = require('gulp-mochelec');
const notifier = require('node-notifier');
const notify = require('gulp-notify');
const through = require('through2');

const TIMEOUT_PASS = 2000;
const TIMEOUT_FAIL = 4000;
const IMAGE_PASS = path.join(__dirname, 'img/pass.png');
const IMAGE_FAIL = path.join(__dirname, 'img/fail.png');

function notifyFailure(err) {
	gutil.log("Failure: " + err.message);
	notifier.notify({
		'expire-time': TIMEOUT_FAIL,
		icon: IMAGE_FAIL,
		title: "Failed",
		message: err.message
	});
}

function notifyPass() {
	return through.obj((file, enc, cb) => {
		notifier.notify({
			'expire-time': TIMEOUT_PASS,
			icon: IMAGE_PASS,
			title: "Pass",
			message: "All unit tests passed."
		});
		cb(null, file);
	});
}

gulp.task('test', () => {
	gulp.src('./test/*.js', { read: false })
		.pipe(mochelec({
			renderer: true,
		}))
		.on('error', notifyFailure)
		.pipe(notifyPass())
});

gulp.task('test:watch', ['test'], () => {
	gulp.watch(['index.js', './lib/**/*.js', './test/*.js'], ['test']);
});
<|endoftext|>