<commit_before>// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/jquery-2.0.js
// ==/ClosureCompiler==
//
$(function() {

  var disabled = {
    enabled: false
  };
  var noText = {
    text: null
  };
  var noAnimation = {
    animation: disabled
  };
  var theme = Highcharts.theme;
  var defaults = {
    yAxis: {
      title: noText
    },
    credits: disabled,
    legend: disabled
  };

  function mergeDefaults(config) {
    return $.extend(true, {}, defaults, config);
  }

  if ($('div.rating_history').length) {
    $('div.rating_history').highcharts('StockChart', mergeDefaults({
      rangeSelector: {
        enabled: true,
        selected: 1,
        inputEnabled: false,
        labelStyle: {
          display: 'none'
        }
      },
      xAxis: {
        title: noText,
        labels: disabled,
        lineWidth: 0,
        tickWidth: 0
      },
      scrollbar: disabled,
      series: _.map(lichess_rating_series, function(serie) {
        return {
          name: serie.name,
          type: 'line',
          marker: {
            enabled: true,
            radius: 2
          },
          data: _.map(serie.points, function(r) {
            return [Date.UTC(r[0], r[1], r[2]), r[3]];
          })
        };
      })
    }));
  }

  $('#adv_chart').each(function() {
    var $this = $(this);
    var cpMax = parseInt($this.data('max'), 10) / 100;
    var mid = parseInt($this.data('division-mid'));
    var end = parseInt($this.data('division-end'));

    $(this).highcharts(mergeDefaults({
      series: [{
        name: 'Advantage',
        data: _.map($this.data('rows'), function(row) {
          row.y = row.y / 100;
          return row;
        })
      }],
      chart: {
        type: 'area',
        margin: 0,
        marginTop: 20,
        spacing: [10, 0, 0, 0]
      },
      plotOptions: {
        area: {
          color: theme.colors[7],
          negativeColor: theme.colors[1],
          threshold: 0,
          lineWidth: 1,
          allowPointSelect: true,
          column: noAnimation,
          cursor: 'pointer',
          events: {
            click: function(event) {
              if (event.point) {
                event.point.select();
                lichess.analyse.jump(event.point.x + 1, 0);
              }
            }
          },
          marker: {
            radius: 1,
            states: {
              hover: {
                radius: 3,
                lineColor: '#b57600',
                fillColor: '#ffffff'
              },
              select: {
                radius: 4,
                lineColor: '#b57600',
                fillColor: '#ffffff'
              }
            }
          }
        }
      },
      title: {
        text: $this.data('title'),
        align: 'left',
        y: 5
      },
      xAxis: {
        title: noText,
        labels: disabled,
        lineWidth: 0,
        tickWidth: 0,
        plotLines: [
        {
          label: {
            text: 'Opening',
            verticalAlign: 'top',
            align: 'left',
            x: 10,
            style: {
              color: '#aaa',
              fontWeight: 'bold'
            }
          },
          color: '#30cc4d',
          width: 2,
          value: 0
        },
        {
          label: {
            text: 'Mid-Game',
            verticalAlign: 'top',
            align: 'left',
            x: 10,
            style: {
              color: '#aaa',
              fontWeight: 'bold'
            }
          },
          color: '#3093cc',
          width: (mid == null)? 0 : 2,
          value: mid
        },
        {
          label: {
            text: 'End-Game',
            verticalAlign: 'top',
            align: 'left',
            x: 10,
            style: {
              color: '#aaa',
              fontWeight: 'bold'
            }
          },
          color: '#cc9730',
          width: (end == null)? 0 : 2,
          value: end
        }]
      },
      yAxis: {
        min: -cpMax,
        max: cpMax,
        labels: disabled,
        gridLineWidth: 0
      }
    }));
    lichess.analyse.onChange();
  });

  $.renderMoveTimesChart = function() {
    $('#movetimes_chart:not(.rendered)').each(function() {
      var $this = $(this).addClass('rendered');
      var series = $this.data('series');
      var timeMax = parseInt($this.data('max'), 10);
      $(this).highcharts(mergeDefaults({
        series: [{
          name: 'White',
          data: series.white
        }, {
          name: 'Black',
          data: series.black
        }],
        chart: {
          type: 'area',
          margin: 0,
          marginTop: 0,
          spacing: [0, 0, 0, 0]
        },
        tooltip: {
          formatter: function() {
            var seconds = Math.abs(this.point.y);
            var unit = seconds > 1 ? 'seconds' : 'second';
            var white = this.point.x % 2;
            var dots = white === 0 ? '.' : '...';
            var turn = Math.ceil(this.point.x / 2 + (white ? 0 : 1));
            return turn + dots + ' ' + this.point.name + '
' + seconds + ' ' + unit;
          }
        },
        plotOptions: {
          area: {
            color: theme.colors[7],
            negativeColor: theme.colors[1],
            threshold: 0,
            lineWidth: 1,
            allowPointSelect: true,
            column: noAnimation,
            cursor: 'pointer',
            events: {
              click: function(event) {
                if (event.point) {
                  event.point.select();
                  lichess.analyse.jump(event.point.x + 1, 0);
                }
              }
            },
            marker: {
              radius: 1,
              states: {
                hover: {
                  radius: 3,
                  lineColor: '#b57600',
                  fillColor: '#ffffff'
                },
                select: {
                  radius: 4,
                  lineColor: '#b57600',
                  fillColor: '#ffffff'
                }
              }
            }
          }
        },
        title: {
          text: null
        },
        xAxis: {
          title: noText,
          labels: disabled,
          lineWidth: 0,
          tickWidth: 0
        },
        yAxis: {
          min: -timeMax,
          max: timeMax,
          labels: disabled,
          gridLineWidth: 0
        }
      }));
    });
    lichess.analyse.onChange();
  };
  if ($('#movetimes_chart:visible:not(.rendered)').length) $.renderMoveTimesChart();
});

Highcharts.makeFont = function(size) {
  return size + "px 'Open Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif";
};

Highcharts.theme = (function() {

  var light = $('body').hasClass('light');
  var text = {
    weak: light ? '#a0a0a0' : '#707070',
    strong: light ? '#707070' : '#a0a0a0'
  };
  var line = {
    weak: light ? '#ccc' : '#404040',
    strong: light ? '#a0a0a0' : '#606060'
  };

  return {
    light: light,
    colors: ["#DDDF0D", "#7798BF", "#55BF3B", "#DF5353", "#aaeeee", "#ff0066", "#eeaaee",
      "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"
    ],
    chart: {
      backgroundColor: null,
      borderWidth: 0,
      borderRadius: 0,
      plotBackgroundColor: null,
      plotShadow: false,
      plotBorderWidth: 0
    },
    title: {
      style: {
        font: Highcharts.makeFont(13),
        color: text.strong
      }
    },
    xAxis: {
      gridLineWidth: 0,
      gridLineColor: line.weak,
      lineColor: line.strong,
      tickColor: line.strong,
      labels: {
        style: {
          color: text.weak,
          fontWeight: 'bold'
        }
      },
      title: {
        style: {
          color: text.weak,
          font: Highcharts.makeFont(12)
        }
      }
    },
    yAxis: {
      alternateGridColor: null,
      minorTickInterval: null,
      gridLineColor: line.weak,
      minorGridLineColor: null,
      lineWidth: 0,
      tickWidth: 0,
      labels: {
        style: {
          color: text.weak,
          fontSize: '10px'
        }
      },
      title: {
        style: {
          color: text.weak,
          font: Highcharts.makeFont(12)
        }
      }
    },
    legend: {
      itemStyle: {
        color: text.strong
      },
      itemHiddenStyle: {
        color: text.weak
      }
    },
    labels: {
      style: {
        color: text.strong
      }
    },
    tooltip: {
      backgroundColor: {
        linearGradient: {
          x1: 0,
          y1: 0,
          x2: 0,
          y2: 1
        },
        stops: light ? [
          [0, 'rgba(200, 200, 200, .8)'],
          [1, 'rgba(250, 250, 250, .8)']
        ] : [
          [0, 'rgba(56, 56, 56, .8)'],
          [1, 'rgba(16, 16, 16, .8)']
        ]
      },
      borderWidth: 0,
      style: {
        fontWeight: 'bold',
        color: text.strong
      }
    },
    plotOptions: {
      series: {
        shadow: false,
        nullColor: '#444444'
      },
      line: {
        dataLabels: {
          color: text.strong
        },
        marker: {
          lineColor: text.weak
        }
      },
      spline: {
        marker: {
          lineColor: text.weak
        }
      },
      scatter: {
        marker: {
          lineColor: text.weak
        }
      },
      candlestick: {
        lineColor: text.strong
      }
    },

    // highstock
    rangeSelector: light ? {} : {
      buttonTheme: {
        fill: '#505053',
        stroke: '#000000',
        style: {
          color: '#CCC'
        },
        states: {
          hover: {
            fill: '#707073',
            stroke: '#000000',
            style: {
              color: 'white'
            }
          },
          select: {
            fill: '#000003',
            stroke: '#000000',
            style: {
              color: 'white'
            }
          }
        }
      },
      inputBoxBorderColor: '#505053',
      inputStyle: {
        backgroundColor: '#333',
        color: 'silver'
      },
      labelStyle: {
        color: 'silver'
      }
    },

    navigator: light ? {} : {
      handles: {
        backgroundColor: '#666',
        borderColor: '#AAA'
      },
      outlineColor: '#CCC',
      maskFill: 'rgba(255,255,255,0.1)',
      series: {
        color: '#7798BF',
        lineColor: '#A6C7ED'
      },
      xAxis: {
        gridLineColor: '#505053'
      }
    }
  };
})();
Highcharts.setOptions(Highcharts.theme);
<commit_msg>tweak division display on analysis chart<commit_after>// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/jquery-2.0.js
// ==/ClosureCompiler==
//
$(function() {

  var disabled = {
    enabled: false
  };
  var noText = {
    text: null
  };
  var noAnimation = {
    animation: disabled
  };
  var theme = Highcharts.theme;
  var defaults = {
    yAxis: {
      title: noText
    },
    credits: disabled,
    legend: disabled
  };

  function mergeDefaults(config) {
    return $.extend(true, {}, defaults, config);
  }

  if ($('div.rating_history').length) {
    $('div.rating_history').highcharts('StockChart', mergeDefaults({
      rangeSelector: {
        enabled: true,
        selected: 1,
        inputEnabled: false,
        labelStyle: {
          display: 'none'
        }
      },
      xAxis: {
        title: noText,
        labels: disabled,
        lineWidth: 0,
        tickWidth: 0
      },
      scrollbar: disabled,
      series: _.map(lichess_rating_series, function(serie) {
        return {
          name: serie.name,
          type: 'line',
          marker: {
            enabled: true,
            radius: 2
          },
          data: _.map(serie.points, function(r) {
            return [Date.UTC(r[0], r[1], r[2]), r[3]];
          })
        };
      })
    }));
  }

  $('#adv_chart').each(function() {
    var $this = $(this);
    var cpMax = parseInt($this.data('max'), 10) / 100;
    var mid = parseInt($this.data('division-mid'));
    var end = parseInt($this.data('division-end'));

    $(this).highcharts(mergeDefaults({
      series: [{
        name: 'Advantage',
        data: _.map($this.data('rows'), function(row) {
          row.y = row.y / 100;
          return row;
        })
      }],
      chart: {
        type: 'area',
        margin: 0,
        marginTop: 20,
        spacing: [10, 0, 0, 0]
      },
      plotOptions: {
        area: {
          color: theme.colors[7],
          negativeColor: theme.colors[1],
          threshold: 0,
          lineWidth: 1,
          allowPointSelect: true,
          column: noAnimation,
          cursor: 'pointer',
          events: {
            click: function(event) {
              if (event.point) {
                event.point.select();
                lichess.analyse.jump(event.point.x + 1, 0);
              }
            }
          },
          marker: {
            radius: 1,
            states: {
              hover: {
                radius: 3,
                lineColor: '#b57600',
                fillColor: '#ffffff'
              },
              select: {
                radius: 4,
                lineColor: '#b57600',
                fillColor: '#ffffff'
              }
            }
          }
        }
      },
      title: {
        text: $this.data('title'),
        align: 'left',
        y: 5
      },
      xAxis: {
        title: noText,
        labels: disabled,
        lineWidth: 0,
        tickWidth: 0,
        plotLines: [
        {
          label: {
            text: 'Opening',
            verticalAlign: 'top',
            align: 'left',
            x: 6,
            style: {
              color: Highcharts.theme.lichess.text.weak,
            }
          },
          color: '#30cc4d',
          width: 1,
          value: 0
        },
        {
          label: {
            text: 'Mid-Game',
            verticalAlign: 'top',
            align: 'left',
            x: 6,
            style: {
              color: Highcharts.theme.lichess.text.weak,
            }
          },
          color: '#3093cc',
          width: mid === null ? 0 : 1,
          value: mid
        },
        {
          label: {
            text: 'End-Game',
            verticalAlign: 'top',
            align: 'left',
            x: 6,
            style: {
              color: Highcharts.theme.lichess.text.weak,
            }
          },
          color: '#cc9730',
          width: end === null ? 0 : 1,
          value: end
        }]
      },
      yAxis: {
        min: -cpMax,
        max: cpMax,
        labels: disabled,
        gridLineWidth: 0
      }
    }));
    lichess.analyse.onChange();
  });

  $.renderMoveTimesChart = function() {
    $('#movetimes_chart:not(.rendered)').each(function() {
      var $this = $(this).addClass('rendered');
      var series = $this.data('series');
      var timeMax = parseInt($this.data('max'), 10);
      $(this).highcharts(mergeDefaults({
        series: [{
          name: 'White',
          data: series.white
        }, {
          name: 'Black',
          data: series.black
        }],
        chart: {
          type: 'area',
          margin: 0,
          marginTop: 0,
          spacing: [0, 0, 0, 0]
        },
        tooltip: {
          formatter: function() {
            var seconds = Math.abs(this.point.y);
            var unit = seconds > 1 ? 'seconds' : 'second';
            var white = this.point.x % 2;
            var dots = white === 0 ? '.' : '...';
            var turn = Math.ceil(this.point.x / 2 + (white ? 0 : 1));
            return turn + dots + ' ' + this.point.name + '
' + seconds + ' ' + unit;
          }
        },
        plotOptions: {
          area: {
            color: theme.colors[7],
            negativeColor: theme.colors[1],
            threshold: 0,
            lineWidth: 1,
            allowPointSelect: true,
            column: noAnimation,
            cursor: 'pointer',
            events: {
              click: function(event) {
                if (event.point) {
                  event.point.select();
                  lichess.analyse.jump(event.point.x + 1, 0);
                }
              }
            },
            marker: {
              radius: 1,
              states: {
                hover: {
                  radius: 3,
                  lineColor: '#b57600',
                  fillColor: '#ffffff'
                },
                select: {
                  radius: 4,
                  lineColor: '#b57600',
                  fillColor: '#ffffff'
                }
              }
            }
          }
        },
        title: {
          text: null
        },
        xAxis: {
          title: noText,
          labels: disabled,
          lineWidth: 0,
          tickWidth: 0
        },
        yAxis: {
          min: -timeMax,
          max: timeMax,
          labels: disabled,
          gridLineWidth: 0
        }
      }));
    });
    lichess.analyse.onChange();
  };
  if ($('#movetimes_chart:visible:not(.rendered)').length) $.renderMoveTimesChart();
});

Highcharts.makeFont = function(size) {
  return size + "px 'Open Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif";
};

Highcharts.theme = (function() {

  var light = $('body').hasClass('light');
  var text = {
    weak: light ? '#a0a0a0' : '#707070',
    strong: light ? '#707070' : '#a0a0a0'
  };
  var line = {
    weak: light ? '#ccc' : '#404040',
    strong: light ? '#a0a0a0' : '#606060'
  };

  return {
    light: light,
    lichess: {
      text: text,
      line: line
    },
    colors: ["#DDDF0D", "#7798BF", "#55BF3B", "#DF5353", "#aaeeee", "#ff0066", "#eeaaee",
      "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"
    ],
    chart: {
      backgroundColor: null,
      borderWidth: 0,
      borderRadius: 0,
      plotBackgroundColor: null,
      plotShadow: false,
      plotBorderWidth: 0
    },
    title: {
      style: {
        font: Highcharts.makeFont(13),
        color: text.strong
      }
    },
    xAxis: {
      gridLineWidth: 0,
      gridLineColor: line.weak,
      lineColor: line.strong,
      tickColor: line.strong,
      labels: {
        style: {
          color: text.weak,
          fontWeight: 'bold'
        }
      },
      title: {
        style: {
          color: text.weak,
          font: Highcharts.makeFont(12)
        }
      }
    },
    yAxis: {
      alternateGridColor: null,
      minorTickInterval: null,
      gridLineColor: line.weak,
      minorGridLineColor: null,
      lineWidth: 0,
      tickWidth: 0,
      labels: {
        style: {
          color: text.weak,
          fontSize: '10px'
        }
      },
      title: {
        style: {
          color: text.weak,
          font: Highcharts.makeFont(12)
        }
      }
    },
    legend: {
      itemStyle: {
        color: text.strong
      },
      itemHiddenStyle: {
        color: text.weak
      }
    },
    labels: {
      style: {
        color: text.strong
      }
    },
    tooltip: {
      backgroundColor: {
        linearGradient: {
          x1: 0,
          y1: 0,
          x2: 0,
          y2: 1
        },
        stops: light ? [
          [0, 'rgba(200, 200, 200, .8)'],
          [1, 'rgba(250, 250, 250, .8)']
        ] : [
          [0, 'rgba(56, 56, 56, .8)'],
          [1, 'rgba(16, 16, 16, .8)']
        ]
      },
      borderWidth: 0,
      style: {
        fontWeight: 'bold',
        color: text.strong
      }
    },
    plotOptions: {
      series: {
        shadow: false,
        nullColor: '#444444'
      },
      line: {
        dataLabels: {
          color: text.strong
        },
        marker: {
          lineColor: text.weak
        }
      },
      spline: {
        marker: {
          lineColor: text.weak
        }
      },
      scatter: {
        marker: {
          lineColor: text.weak
        }
      },
      candlestick: {
        lineColor: text.strong
      }
    },

    // highstock
    rangeSelector: light ? {} : {
      buttonTheme: {
        fill: '#505053',
        stroke: '#000000',
        style: {
          color: '#CCC'
        },
        states: {
          hover: {
            fill: '#707073',
            stroke: '#000000',
            style: {
              color: 'white'
            }
          },
          select: {
            fill: '#000003',
            stroke: '#000000',
            style: {
              color: 'white'
            }
          }
        }
      },
      inputBoxBorderColor: '#505053',
      inputStyle: {
        backgroundColor: '#333',
        color: 'silver'
      },
      labelStyle: {
        color: 'silver'
      }
    },

    navigator: light ? {} : {
      handles: {
        backgroundColor: '#666',
        borderColor: '#AAA'
      },
      outlineColor: '#CCC',
      maskFill: 'rgba(255,255,255,0.1)',
      series: {
        color: '#7798BF',
        lineColor: '#A6C7ED'
      },
      xAxis: {
        gridLineColor: '#505053'
      }
    }
  };
})();
Highcharts.setOptions(Highcharts.theme);
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require support
//
//= require shared_mustache
//= require templates
//
//= require live-site-search
//= require search
//= require govuk_toolkit
//= require_tree ./modules
//= require_tree ./components
<commit_msg>Add feedback js to search page<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require support
//
//= require shared_mustache
//= require templates
//
//= require live-site-search
//= require search
//= require govuk_toolkit
//= require_tree ./modules
//= require_tree ./components
//= require govuk_publishing_components/components/feedback
<|endoftext|>


<commit_before>function pageViewModel(gvm) {
    // Page specific i18n bindings
    gvm.title = ko.computed(function(){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n.__("AdminPage");}, gvm);
    gvm.pageHeader = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("UserPermissionsTitle");}, gvm);

    gvm.userName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("UserName");}, gvm);
    gvm.firstName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("Firstname");}, gvm);
    gvm.lastName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("Lastname");}, gvm);
    gvm.userPermissions = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("UserPermissions");}, gvm);
    gvm.userActions = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("UserActions");}, gvm);

    gvm.permissionRole = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("PermissionRole");}, gvm);
    gvm.permissionDescription = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("PermissionDescription");}, gvm);
    fetchUsersData();

    gvm.usersPermissions = ko.observableArray([]);

    gvm.updateUsersPermissions = function(user)
    {
        console.log(user);
        gvm.usersPermissions.push(user);
    }
}

function fetchUsersData()
{
    $.getJSON("/api/alluserswithroles/", function(data)
    {
        $.each(data, function(i, item){
            var permissions = "";
            var current = item.username;
            $.each(data, function(i, item)
            {
                if(item.username == current){
                    permissions += item.role + "\n";
                }
            });
            console.log(item);
            viewModel.updateUsers(new User(item.username, item.firstname, item.lastname, "Test"));
        });
    });
}

function User(username, firstname, lastname, permissions) {
    return {
        username: ko.observable(username),
        firstname: ko.observable(firstname),
        lastname: ko.observable(lastname),
        permissions: ko.observable(permissions)
    };
}<commit_msg>Admin page: get All users roles<commit_after>function pageViewModel(gvm) {
    // Page specific i18n bindings
    gvm.title = ko.computed(function(){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n.__("AdminPage");}, gvm);
    gvm.pageHeader = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("UserPermissionsTitle");}, gvm);

    gvm.userName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("UserName");}, gvm);
    gvm.firstName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("Firstname");}, gvm);
    gvm.lastName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("Lastname");}, gvm);
    gvm.userPermissions = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("UserPermissions");}, gvm);
    gvm.userActions = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("UserActions");}, gvm);

    gvm.permissionRole = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("PermissionRole");}, gvm);
    gvm.permissionDescription = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("PermissionDescription");}, gvm);
    fetchUsersData();

    gvm.usersPermissions = ko.observableArray([]);

    gvm.updateUsersPermissions = function(user)
    {
        console.log(user);
        gvm.usersPermissions.push(user);
    }
}

function fetchUsersData()
{
    $.getJSON("/api/alluserswithroles/", function(data)
    {
        $.each(data, function(i, item){
            var permissions = "";
            var current = item.username;
            $.each(data, function(i, item)
            {
                if(item.username == current){
                    permissions += item.role + "\n";
                }
            });
            console.log(item);
            viewModel.updateUsersPermissions(new User(item.username, item.firstname, item.lastname, permissions));
        });
    });
}

function User(username, firstname, lastname, permissions) {
    return {
        username: ko.observable(username),
        firstname: ko.observable(firstname),
        lastname: ko.observable(lastname),
        permissions: ko.observable(permissions)
    };
}<|endoftext|>


<commit_before>define([
    "intern!object",
    "intern/chai!assert",
    "tests/support/helper"
], function ( registerSuite, assert, testHelper ) {
    /** Opens comics edit dialog for new entity. */
    function openComicEditDialog( context ) {
        return context.setFindTimeout( testHelper.getTimeoutForAjaxRequests() )
            .findByCssSelector( "ul.root-tabs" )
                .setFindTimeout( testHelper.getTimeoutForPageAction() )
                .findByCssSelector( "li.tab.comics" )
                    .click()
                    .end()
                .end()
            /** Wait for comics list to load. */
            .setFindTimeout( testHelper.getTimeoutForAjaxRequests() )
            .findByCssSelector( ".comics-list-loading.ng-hide" )
                .end()
            .setFindTimeout( testHelper.getTimeoutForAjaxRequests() )
            .findByCssSelector( "div[ng-controller=\"ComicsController\"] button.comics-create-open-dialog" )
                .click()
                .end();
    }

    registerSuite({
        name: "Comic: create",

        "Comic can't be created without title and slug.": function () {
            var title = testHelper.getUniqueString();
            var slug = testHelper.getUniqueString();

            return testHelper.cleanupDashboardTest(
                openComicEditDialog(
                    testHelper.getDashboardAuthorizedAsAdmin( this )
                )
                .setFindTimeout( testHelper.getTimeoutForPageAction() )
                .findByCssSelector( "div.comics-dialog" )
                    /** Assert that the "Create" button is still disabled if there's no title and no slug. */
                    .findByCssSelector( "button.comics-create" )
                        .isEnabled()
                        .then( function ( enabled ) {
                            assert.notOk( enabled, "\"Create\" button is disabled." );
                        })
                        .end()
                    .end()
                    /** Type title. */
                    .findById( "comics-title" )
                        .type( title )
                        .end()
                    /** Assert that the "Create" button is still disabled after title was typed. */
                    .findByCssSelector( "button.comics-create" )
                    .isEnabled()
                        .then( function ( enabled ) {
                            assert.notOk( enabled, "\"Create\" button is disabled with only title present." );
                        })
                        .end()
                    /** Clear title. */
                    .findById( "comics-title" )
                        .clearValue()
                        .end()
                    /** Type slug. */
                    .findById( "comics-slug" )
                        .type( title )
                        .end()
                    /**
                     * Assert that the "Create" button is still disabled after title was removed,
                     * and slug was typed.
                     */
                    .findByCssSelector( "button.comics-create" )
                    .isEnabled()
                        .then( function ( enabled ) {
                            assert.notOk( enabled, "\"Create\" button is disabled with only slug present." );
                        })
                        .end()
                    .end()
            );
        },
        "Comic can be created with title and slug.": function () {
            var title = testHelper.getUniqueString();
            var slug = testHelper.getUniqueString();

            return testHelper.cleanupDashboardTest(
                openComicEditDialog(
                    testHelper.getDashboardAuthorizedAsAdmin( this )
                )
                .setFindTimeout( testHelper.getTimeoutForPageAction() )
                .findByCssSelector( "div.comics-dialog" )
                    /** Type title. */
                    .findById( "comics-title" )
                        .type( title )
                        .end()
                    /** Type slug. */
                    .findById( "comics-slug" )
                        .type( title )
                        .end()
                    /** Assert that the "Create" button is now enabled when title and slug were both typed. */
                    .findByCssSelector( "button.comics-create" )
                    .isEnabled()
                        .then( function ( enabled ) {
                            assert.ok( enabled, "\"Create\" button is enabled with title and slug present." );
                        })
                        /** Click "Create" button and wait for success message. */
                        .click()
                        .end()
                    .end()
                .setFindTimeout( testHelper.getTimeoutForAjaxRequests() )
                /** Check if the comics was created. */
                .findByCssSelector( ".alertify-log-success" )
                    .getVisibleText()
                    .then( function ( visibleText ) {
                        assert.equal( visibleText, "Comic was created." );
                    })
                    .end()
                /** Teardown. */
                .then( function () {
                    testHelper.removeEntity( "Comic\\Entity\\Comic", { title: title } );
                })
            );
        }
    });
});
<commit_msg>Logs again<commit_after>define([
    "intern!object",
    "intern/chai!assert",
    "tests/support/helper"
], function ( registerSuite, assert, testHelper ) {
    /** Opens comics edit dialog for new entity. */
    function openComicEditDialog( context ) {
        return context.setFindTimeout( testHelper.getTimeoutForAjaxRequests() )
            .findByCssSelector( "ul.root-tabs" )
            .getLogsFor( "browser" )
            .then( function ( logs ) {
                console.log( logs )
            })
                .setFindTimeout( testHelper.getTimeoutForPageAction() )
                .findByCssSelector( "li.tab.comics" )
                    .click()
                    .end()
                .end()
            /** Wait for comics list to load. */
            .setFindTimeout( testHelper.getTimeoutForAjaxRequests() )
            .findByCssSelector( ".comics-list-loading.ng-hide" )
                .end()
            .setFindTimeout( testHelper.getTimeoutForAjaxRequests() )
            .findByCssSelector( "div[ng-controller=\"ComicsController\"] button.comics-create-open-dialog" )
                .click()
                .end();
    }

    registerSuite({
        name: "Comic: create",

        "Comic can't be created without title and slug.": function () {
            var title = testHelper.getUniqueString();
            var slug = testHelper.getUniqueString();

            return testHelper.cleanupDashboardTest(
                openComicEditDialog(
                    testHelper.getDashboardAuthorizedAsAdmin( this )
                )
                .setFindTimeout( testHelper.getTimeoutForPageAction() )
                .findByCssSelector( "div.comics-dialog" )
                    /** Assert that the "Create" button is still disabled if there's no title and no slug. */
                    .findByCssSelector( "button.comics-create" )
                        .isEnabled()
                        .then( function ( enabled ) {
                            assert.notOk( enabled, "\"Create\" button is disabled." );
                        })
                        .end()
                    .end()
                    /** Type title. */
                    .findById( "comics-title" )
                        .type( title )
                        .end()
                    /** Assert that the "Create" button is still disabled after title was typed. */
                    .findByCssSelector( "button.comics-create" )
                    .isEnabled()
                        .then( function ( enabled ) {
                            assert.notOk( enabled, "\"Create\" button is disabled with only title present." );
                        })
                        .end()
                    /** Clear title. */
                    .findById( "comics-title" )
                        .clearValue()
                        .end()
                    /** Type slug. */
                    .findById( "comics-slug" )
                        .type( title )
                        .end()
                    /**
                     * Assert that the "Create" button is still disabled after title was removed,
                     * and slug was typed.
                     */
                    .findByCssSelector( "button.comics-create" )
                    .isEnabled()
                        .then( function ( enabled ) {
                            assert.notOk( enabled, "\"Create\" button is disabled with only slug present." );
                        })
                        .end()
                    .end()
            );
        },
        "Comic can be created with title and slug.": function () {
            var title = testHelper.getUniqueString();
            var slug = testHelper.getUniqueString();

            return testHelper.cleanupDashboardTest(
                openComicEditDialog(
                    testHelper.getDashboardAuthorizedAsAdmin( this )
                )
                .setFindTimeout( testHelper.getTimeoutForPageAction() )
                .findByCssSelector( "div.comics-dialog" )
                    /** Type title. */
                    .findById( "comics-title" )
                        .type( title )
                        .end()
                    /** Type slug. */
                    .findById( "comics-slug" )
                        .type( title )
                        .end()
                    /** Assert that the "Create" button is now enabled when title and slug were both typed. */
                    .findByCssSelector( "button.comics-create" )
                    .isEnabled()
                        .then( function ( enabled ) {
                            assert.ok( enabled, "\"Create\" button is enabled with title and slug present." );
                        })
                        /** Click "Create" button and wait for success message. */
                        .click()
                        .end()
                    .end()
                .setFindTimeout( testHelper.getTimeoutForAjaxRequests() )
                /** Check if the comics was created. */
                .findByCssSelector( ".alertify-log-success" )
                    .getVisibleText()
                    .then( function ( visibleText ) {
                        assert.equal( visibleText, "Comic was created." );
                    })
                    .end()
                /** Teardown. */
                .then( function () {
                    testHelper.removeEntity( "Comic\\Entity\\Comic", { title: title } );
                })
            );
        }
    });
});
<|endoftext|>


<commit_before>//= require ./array

var
    Iterable;

(function($) {
    "use strict";

    var
        areEquivalents = function(object1, object2) {
            var
                object1Attributes,
                object2Attributes,
                object1Methods,
                object2Methods,
                object1AttributeValue,
                object2AttributeValue,
                iterator,
                count = 0,
                primitiveTypes =
                    /(number|string|boolean|null|undefined|symbol)/,

                callback = function(attribute) {
                    object1AttributeValue = object1[attribute];
                    object2AttributeValue = object2[attribute];

                    if ($.hasSameClass(object1AttributeValue,
                        object2AttributeValue)) {
                        if (typeof object1AttributeValue ==
                            "object") {
                            // recursivity
                            if ($.areEquivalents(
                                object1AttributeValue,
                                object2AttributeValue)) {
                                count += 1;
                            }
                        } else
                            if (object1AttributeValue ==
                            object2AttributeValue) {
                            count += 1;
                        }
                    }
                };

            if (object1 == object2) {
                return true;
            } else if ($.hasSameClass(object1, object2)) {
                if (typeof object1 == "object") {
                    if (object1 instanceof Node) {
                        if (object1.isEqualNode(object2)) {
                            return true;
                        }
                    } else {
                        object1Attributes = $.attributes(object1);
                        object2Attributes = $.attributes(object2);
                        object1Methods = $.methods(object1);
                        object2Methods = $.methods(object2);

                        // if doesn't have attributes
                        if (!object1Attributes.length) {
                            if (object1Methods.length ==
                                object2Methods.length &&
                                // recursivity
                                $.areEquivalents(object1Methods,
                                                 object2Methods)) {
                                return true;
                            }
                        } else if (object1Attributes.length ==
                            object2Attributes.length) {

                            iterator = Iterable.Proxy.new(object1Attributes);

                            iterator.each(callback);

                            return count == object1Attributes.length;
                        }
                    }
                } else {
                    if (primitiveTypes.test(typeof object1)) {
                        return object1 == object2;
                    }
                }
            }

            return false;
        };

    try {
        $.defineProperties($, {

            clone: {
                value: function(object, includeNonEnumerable) {
                    if (typeof includeNonEnumerable != "boolean") {
                        includeNonEnumerable = true;
                    }

                    var
                        clone = {},
                        properties = $.getOwnPropertyNames(object),

                        callback = function(p) {
                            clone[p] = object[p];
                        };

                    if (!includeNonEnumerable) {
                        return Object.assign(clone, object);
                    }

                    try {
                        properties.forEach(callback);
                    } catch(e) {}

                    return clone;
                }
            },

            className: {
                value: function(object) {
                    var
                        pattern = /[a-zA-Z$_][^\]]+/g,
                        string = $.prototype.toString.call(object);

                    if (typeof object == "object" &&
                        $.implementsMethods(object, "toString")) {
                        // if implements, then calls it
                        string = object.toString();
                    }

                    return pattern.exec(string)[0].split(" ")[1];
                }
            },

            classForName: {
                value: function(name) {
                    return window[name];
                }
            },

            hasSameClass: {
                value: function(objects) {
                    var
                        argumentsAsArray = Array.from(arguments),
                        compared = argumentsAsArray[0],
                        count = 0,

                        callback = function(object) {
                            if (!object) {
                                if ($.className(object) ==
                                    $.className(compared)) {
                                    count++;
                                }
                            } else if ($.getPrototypeOf(compared) ==
                                $.getPrototypeOf(object)) {
                                count++;
                            }
                        };

                    argumentsAsArray = argumentsAsArray.slice(1,
                        argumentsAsArray.length);
                    argumentsAsArray.forEach(callback);

                    return count == argumentsAsArray.length;
                }
            },

            areFromClass: {
                value: function(objects, classFunction) {
                    var
                        iterator,
                        argumentsAsArray = Array.from(arguments),
                        count = 0,

                        callback = function(object) {
                            if ($.classForName($.className(object)) ==
                                classFunction) {
                                count++;
                            }
                        };

                    classFunction = argumentsAsArray.last();
                    argumentsAsArray.delete(argumentsAsArray.lastIndex());

                    iterator = Iterable.Proxy.new(argumentsAsArray);
                    iterator.each(callback);

                    return count == argumentsAsArray.length;
                }
            },

            firstKey: {
                value: function(object) {
                    var
                        // Object: javascript literal object
                        keys = Object.keys(object);

                    return keys[0];
                }
            },

            lastKey: {
                value: function(object) {
                    var
                        keys = Object.keys(object);

                    return keys[keys.length - 1];
                }
            },

            normalizedAsLowerCase: {
                value: function(object) {
                    var
                        iterator,
                        attributes = Object.attributes(object),
                        clone = {},

                        callback = function(v, k) {
                            if (typeof v == "string") {
                                clone[k] = v.toLowerCase();
                            }
                        };

                    Object.assign(clone, object);
                    object.length = attributes.length;
                    iterator = Iterable.Proxy.new(clone);

                    iterator.each(callback);

                    return clone;
                }
            },

            firstFromASlice: {
                value: function(object, slice, startingIndex, caseSensitive) {
                    var
                        iterator,
                        key,
                        regexp,
                        attributes = Object.attributes(object),

                        callback = function(k, i) {
                            if (!isNaN(i)) {
                                if (typeof object[k] == "string" &&
                                    i >= startingIndex) {
                                    if (object[k].search(regexp) != -1) {
                                        key = k;
                                        this.finalize();
                                    }
                                }
                            } else if (typeof object[k] == "string") {
                                if (object[k].search(regexp) != -1) {
                                    key = k;
                                    this.finalize();
                                }
                            }
                        };

                    if (typeof startingIndex != "number") {
                        if (typeof startingIndex == "boolean") {
                            caseSensitive = startingIndex;
                        } else if (!caseSensitive || typeof caseSensitive !=
                                   "boolean") {
                            caseSensitive = false;
                        }

                        startingIndex = 0;
                    }

                    slice = slice.trim();

                    if (!caseSensitive) {
                        regexp = new RegExp(slice, "i");
                    } else {
                        regexp = new RegExp(slice);
                    }

                    iterator = Iterable.Proxy.new(attributes);
                    iterator.each(callback);

                    if (key) {
                        return key;
                    }

                    return undefined;
                }
            },

            asCountableLiteral: {
                value: function(collection) {
                    return Iterable.parse(collection);
                }
            },

            // The keys of associative arrays in JS only can be of integer or string kind. The associations that keys are of Integer kind, the items is sorted according the keys (works as HashSet of the Java); the associations that keys are String kind, works as LinkedHashMap, it implements a associative array and maintains the order of entrance on iterate.
            // TreeMap implements a structure based red-black tree (binary search).
            indexOf: {
                value: function(object, value) {
                    var
                        key,
                        iterator,
                        properties = $.keys(object),

                        callback = function(p) {
                            if ($.areEquivalents(object[p], value)) {
                                key = p;
                                this.finalize();
                            }
                        };

                    iterator = Iterable.Proxy.new(properties);
                    iterator.each(callback);

                    if (key) {
                        return key;
                    }

                    return undefined;
                }
            },

            count: {
                value: function(object, item) {
                    var
                        count;

                    if (item) {
                        count = $.values(object).count(item);
                    } else {
                        count = $.keys(object).length;
                    }

                    return count;
                }
            },

            some: {
                value: function(object) {
                    return $.count(object) > 0;
                }
            },

            isEmpty: {
                value: function(object) {
                    return !$.some(object);
                }
            },

            delete: {
                value: function(index, object) {
                    if (delete object[index]) {
                        if (object.hasOwnProperty("length")) {
                            object.length -= 1;
                        }

                        return true;
                    }

                    return false;
                }
            },

            reverse: {
                value: function(object) {
                    var
                        newObject = {},

                        callback = function(k) {
                            newObject[k] = object[k];
                        };

                    $.keys(object).reverse().forEach(callback);

                    return newObject;
                }
            },

            attributes: {
                value: function(object, includeNonEnumerable) {
                    if (typeof includeNonEnumerable != "boolean") {
                        includeNonEnumerable = false;
                    }

                    var
                        clone,
                        properties,
                        attributes = [],

                        callback = function(p) {
                            if (typeof object[p] != "function") {
                                attributes.push(p);
                            }
                        };

                    if (!object) {
                        return [];
                    }

                    clone = Object.clone(object, includeNonEnumerable);

                    if (typeof object != "object" &&
                        typeof object != "function" &&
                        Object.getPrototypeOf(object)) {
                        clone = Object.getPrototypeOf(object);
                    }

                    properties = $.keys(clone);

                    if (includeNonEnumerable) {
                        properties = $.getOwnPropertyNames(clone);
                    }

                    try {
                        properties.forEach(callback);
                    } catch(e) {}

                    return attributes;
                }
            },

            methods: {
                value: function(object, includeNonEnumerable) {
                    if (typeof includeNonEnumerable != "boolean") {
                        includeNonEnumerable = true;
                    }

                    var
                        clone,
                        properties;

                    // otherwise it will give a cascade error
                    if (!object) {
                        return [];
                    }

                    clone = Object.clone(object, includeNonEnumerable);

                    if (typeof object != "object" &&
                        typeof object != "function" &&
                        Object.getPrototypeOf(object)) {
                        clone = Object.getPrototypeOf(object);
                    }

                    properties = $.getOwnPropertyNames(clone);

                    if (!includeNonEnumerable) {
                        properties = $.keys(clone);
                    }

                    return properties.difference($.attributes(object, true));
                }
            },

            hasAttributes: {
                value: function(object, propertyNames) {
                    var
                        argumentsAsArray = Array.from(arguments);

                    propertyNames = argumentsAsArray.slice(1, argumentsAsArray
                                                           .length);

                    return $.attributes(object, true).includes(propertyNames);
                }
            },

            implementsMethods: {
                value: function(object, propertyNames) {
                    var
                        argumentsAsArray = Array.from(arguments);

                    propertyNames = argumentsAsArray.slice(1, argumentsAsArray
                                                           .length);

                    return $.methods(object, true).includes(propertyNames);
                }
            },

            areEquivalents: {
                value: areEquivalents
            }

        });
    } catch(e) {}

})(Object);
<commit_msg>improves Object<commit_after>//= require ./array

var
    Iterable;

(function($) {
    "use strict";

    var
        areEquivalents = function(object1, object2) {
            var
                object1Attributes,
                object2Attributes,
                object1Methods,
                object2Methods,
                object1AttributeValue,
                object2AttributeValue,
                iterator,
                count = 0,
                primitiveTypes =
                    /(number|string|boolean|null|undefined|symbol)/,

                callback = function(attribute) {
                    object1AttributeValue = object1[attribute];
                    object2AttributeValue = object2[attribute];

                    if ($.hasSameClass(object1AttributeValue,
                        object2AttributeValue)) {
                        if (typeof object1AttributeValue ==
                            "object") {
                            // recursivity
                            if ($.areEquivalents(
                                object1AttributeValue,
                                object2AttributeValue)) {
                                count += 1;
                            }
                        } else
                            if (object1AttributeValue ==
                            object2AttributeValue) {
                            count += 1;
                        }
                    }
                };

            if (object1 === object2) {
                return true;
            } else if ($.hasSameClass(object1, object2)) {
                if (typeof object1 == "object") {
                    if (object1 instanceof Node) {
                        if (object1.isEqualNode(object2)) {
                            return true;
                        }
                    } else {
                        object1Attributes = $.attributes(object1);
                        object2Attributes = $.attributes(object2);
                        object1Methods = $.methods(object1);
                        object2Methods = $.methods(object2);

                        // if doesn't have attributes
                        if (!object1Attributes.length) {
                            if (object1Methods.length ==
                                object2Methods.length &&
                                // recursivity
                                $.areEquivalents(object1Methods,
                                                 object2Methods)) {
                                return true;
                            }
                        } else if (object1Attributes.length ==
                            object2Attributes.length) {

                            iterator = Iterable.Proxy.new(object1Attributes);

                            iterator.each(callback);

                            return count == object1Attributes.length;
                        }
                    }
                } else {
                    if (primitiveTypes.test(typeof object1)) {
                        return object1 === object2;
                    }
                }
            }

            return false;
        };

    try {
        $.defineProperties($, {

            clone: {
                value: function(object, includeNonEnumerable) {
                    if (typeof includeNonEnumerable != "boolean") {
                        includeNonEnumerable = true;
                    }

                    var
                        clone = {},
                        properties = $.getOwnPropertyNames(object),

                        callback = function(p) {
                            clone[p] = object[p];
                        };

                    if (!includeNonEnumerable) {
                        return Object.assign(clone, object);
                    }

                    try {
                        properties.forEach(callback);
                    } catch(e) {}

                    return clone;
                }
            },

            className: {
                value: function(object) {
                    var
                        pattern = /[a-zA-Z$_][^\]]+/g,
                        string = $.prototype.toString.call(object);

                    if (typeof object == "object" &&
                        $.implementsMethods(object, "toString")) {
                        // if implements, then calls it
                        string = object.toString();
                    }

                    return pattern.exec(string)[0].split(" ")[1];
                }
            },

            classForName: {
                value: function(name) {
                    return window[name];
                }
            },

            hasSameClass: {
                value: function(objects) {
                    var
                        argumentsAsArray = Array.from(arguments),
                        compared = argumentsAsArray[0],
                        count = 0,

                        callback = function(object) {
                            if (!object) {
                                if ($.className(object) ==
                                    $.className(compared)) {
                                    count++;
                                }
                            } else if ($.getPrototypeOf(compared) ==
                                $.getPrototypeOf(object)) {
                                count++;
                            }
                        };

                    argumentsAsArray = argumentsAsArray.slice(1,
                        argumentsAsArray.length);
                    argumentsAsArray.forEach(callback);

                    return count == argumentsAsArray.length;
                }
            },

            belongToClass: {
                value: function(objects, classFunction) {
                    var
                        iterator,
                        argumentsAsArray = Array.from(arguments),
                        count = 0,

                        callback = function(object) {
                            if ($.classForName($.className(object)) ==
                                classFunction) {
                                count++;
                            }
                        };

                    classFunction = argumentsAsArray.last();
                    argumentsAsArray.pop();

                    iterator = Iterable.Proxy.new(argumentsAsArray);
                    iterator.each(callback);

                    return count == argumentsAsArray.length;
                }
            },

            firstKey: {
                value: function(object) {
                    var
                        // Object: javascript literal object
                        keys = Object.keys(object);

                    return keys[0];
                }
            },

            lastKey: {
                value: function(object) {
                    var
                        keys = Object.keys(object);

                    return keys[keys.length - 1];
                }
            },

            normalizedAsLowerCase: {
                value: function(object) {
                    var
                        iterator,
                        attributes = Object.attributes(object),
                        clone = {},

                        callback = function(v, k) {
                            if (typeof v == "string") {
                                clone[k] = v.toLowerCase();
                            }
                        };

                    Object.assign(clone, object);
                    object.length = attributes.length;
                    iterator = Iterable.Proxy.new(clone);

                    iterator.each(callback);

                    return clone;
                }
            },

            firstFromASlice: {
                value: function(object, slice, startingIndex, caseSensitive) {
                    var
                        iterator,
                        key,
                        regexp,
                        attributes = Object.attributes(object),

                        callback = function(k, i) {
                            if (!isNaN(i)) {
                                if (typeof object[k] == "string" &&
                                    i >= startingIndex) {
                                    if (object[k].search(regexp) != -1) {
                                        key = k;
                                        this.finalize();
                                    }
                                }
                            } else if (typeof object[k] == "string") {
                                if (object[k].search(regexp) != -1) {
                                    key = k;
                                    this.finalize();
                                }
                            }
                        };

                    if (typeof startingIndex != "number") {
                        if (typeof startingIndex == "boolean") {
                            caseSensitive = startingIndex;
                        } else if (!caseSensitive || typeof caseSensitive !=
                                   "boolean") {
                            caseSensitive = false;
                        }

                        startingIndex = 0;
                    }

                    slice = slice.trim();

                    if (!caseSensitive) {
                        regexp = new RegExp(slice, "i");
                    } else {
                        regexp = new RegExp(slice);
                    }

                    iterator = Iterable.Proxy.new(attributes);
                    iterator.each(callback);

                    if (key) {
                        return key;
                    }

                    return undefined;
                }
            },

            asCountableLiteral: {
                value: function(collection) {
                    return Iterable.parse(collection);
                }
            },

            // The keys of associative arrays in JS only can be of integer or string kind. The associations that keys are of Integer kind, the items is sorted according the keys (works as HashSet of the Java); the associations that keys are String kind, works as LinkedHashMap, it implements a associative array and maintains the order of entrance on iterate.
            // TreeMap implements a structure based red-black tree (binary search).
            indexOf: {
                value: function(object, value) {
                    var
                        key,
                        iterator,
                        properties = $.keys(object),

                        callback = function(p) {
                            if ($.areEquivalents(object[p], value)) {
                                key = p;
                                this.finalize();
                            }
                        };

                    iterator = Iterable.Proxy.new(properties);
                    iterator.each(callback);

                    if (key) {
                        return key;
                    }

                    return undefined;
                }
            },

            count: {
                value: function(object, item) {
                    var
                        count;

                    if (item) {
                        count = $.values(object).count(item);
                    } else {
                        count = $.keys(object).length;
                    }

                    return count;
                }
            },

            some: {
                value: function(object) {
                    return $.count(object) > 0;
                }
            },

            isEmpty: {
                value: function(object) {
                    return !$.some(object);
                }
            },

            delete: {
                value: function(index, object) {
                    if (delete object[index]) {
                        if (object.hasOwnProperty("length")) {
                            object.length -= 1;
                        }

                        return true;
                    }

                    return false;
                }
            },

            reverse: {
                value: function(object) {
                    var
                        newObject = {},

                        callback = function(k) {
                            newObject[k] = object[k];
                        };

                    $.keys(object).reverse().forEach(callback);

                    return newObject;
                }
            },

            attributes: {
                value: function(object, includeNonEnumerable) {
                    if (typeof includeNonEnumerable != "boolean") {
                        includeNonEnumerable = false;
                    }

                    var
                        clone,
                        properties,
                        attributes = [],

                        callback = function(p) {
                            return typeof object[p] != "function";
                        };

                    if (!object) {
                        return [];
                    }

                    clone = Object.clone(object, includeNonEnumerable);

                    if (typeof object != "object" &&
                        typeof object != "function" &&
                        Object.getPrototypeOf(object)) {
                        clone = Object.getPrototypeOf(object);
                    }

                    properties = $.keys(clone);

                    if (includeNonEnumerable) {
                        properties = $.getOwnPropertyNames(clone);
                    }

                    try {
                        attributes = properties.filter(callback);
                    } catch(e) {}

                    return attributes;
                }
            },

            methods: {
                value: function(object, includeNonEnumerable) {
                    if (typeof includeNonEnumerable != "boolean") {
                        includeNonEnumerable = true;
                    }

                    var
                        clone,
                        properties;

                    // otherwise it will give a cascade error
                    if (!object) {
                        return [];
                    }

                    clone = Object.clone(object, includeNonEnumerable);

                    if (typeof object != "object" &&
                        typeof object != "function" &&
                        Object.getPrototypeOf(object)) {
                        clone = Object.getPrototypeOf(object);
                    }

                    properties = $.keys(clone);

                    if (includeNonEnumerable) {
                        properties = $.getOwnPropertyNames(clone);
                    }

                    return properties.difference($.attributes(object, true));
                }
            },

            hasAttributes: {
                value: function(object, attributes) {
                    var
                        count = 0,
                        argumentsAsArray = Array.from(arguments),
                        researchedAttributes = argumentsAsArray
                            .slice(1, argumentsAsArray.length);

                    attributes = $.attributes(object, true);

                    researchedAttributes.forEach(function(attribute) {
                        if (attributes.includes(attribute)) {
                            count++;
                        }
                    });

                    return count == researchedAttributes.length;
                }
            },

            implementsMethods: {
                value: function(object, methods) {
                    var
                        count = 0,
                        argumentsAsArray = Array.from(arguments),
                        researchedMethods = argumentsAsArray
                            .slice(1, argumentsAsArray.length);

                    methods = $.methods(object);
                    researchedMethods.forEach(function(method) {
                        if (methods.includes(method)) {
                            count++;
                        }
                    });

                    return count == researchedMethods.length;
                }
            },

            areEquivalents: {
                value: areEquivalents
            }

        });
    } catch(e) {}

})(Object);
<|endoftext|>


<commit_before>const assert = require('assert')
const validate = require('validate.js')
const occupy = require('../services/occupy-pane')
const mLoc = require('../services/max-location')

module.exports = function locationChanger (state, implementation) {
  return ({
    changeLocation: function changeLocation (x, y) {
      assert(validate.isInteger(x), `${x} is not numeric`)
      assert(validate.isInteger(y), `${y} is not numeric`)
      assert(state.grid.width >= state.width + x, 'location is outside of grid')
      assert(state.grid.height >= state.height + y, 'location is outside of grid')
      assert(x >= 0, 'location is outside of grid')
      assert(y >= 0, 'location is outside of grid')
      occupy(
        state.grid,
        Object.assign({}, state, {x, y})
      )
      state.x = x
      state.y = y
      if (implementation && typeof implementation.changeSize === 'function') {
        implementation.changeLocation(state, x, y)
      }
    },
    maxLoc: function maxSize (directions) {
      assert(validate.isObject(directions), `${directions} shold be an object`)
      const changed = Object.keys(directions)
        .filter(d => d)
        .filter(d => {
          if (d === 'up' || d === 'down') {
            const { y } = mLoc(state, d)
            state.y = y
          } else if (d === 'left' || d === 'right') {
            const { x } = mLoc(state, d)
            state.x = x
          } else {
            throw new Error(`${d} should be one of 'up/down/left/right'`)
          }
          return true
        })
      if (changed && implementation && typeof implementation.changeBounds === 'function') {
        implementation.changeBounds(state)
      }
    }
  })
}
<commit_msg>feat: throw off the edge of the grid<commit_after>const assert = require('assert')
const validate = require('validate.js')
const occupy = require('../services/occupy-pane')
const mLoc = require('../services/max-location')

module.exports = function locationChanger (state, implementation) {
  return ({
    changeLocation: function changeLocation (x, y) {
      assert(validate.isInteger(x), `${x} is not numeric`)
      assert(validate.isInteger(y), `${y} is not numeric`)
      assert(state.grid.width >= state.width + x, 'location is outside of grid')
      assert(state.grid.height >= state.height + y, 'location is outside of grid')
      assert(x >= 0, 'location is outside of grid')
      assert(y >= 0, 'location is outside of grid')
      occupy(
        state.grid,
        Object.assign({}, state, {x, y})
      )
      state.x = x
      state.y = y
      if (implementation && typeof implementation.changeSize === 'function') {
        implementation.changeLocation(state, x, y)
      }
    },
    maxLoc: function maxLoc (directions) {
      assert(validate.isObject(directions), `${directions} shold be an object`)
      const changed = Object.keys(directions)
        .filter(d => d)
        .filter(d => {
          if (d === 'up' || d === 'down') {
            const { y } = mLoc(state, d)
            if (state.y === y) throw new Error('location blocked')
            state.y = y
          } else if (d === 'left' || d === 'right') {
            const { x } = mLoc(state, d)
            if (state.x === x) throw new Error('location blocked')
            state.x = x
          } else {
            throw new Error(`${d} should be one of 'up/down/left/right'`)
          }
          return true
        })
      if (changed && implementation && typeof implementation.changeBounds === 'function') {
        implementation.changeBounds(state)
      }
    }
  })
}
<|endoftext|>


<commit_before>// var gulp = require("gulp");
// var babel = require("gulp-babel");
//
// gulp.task("default", function () {
//   return gulp.src("./uninvisible.js")
//     .pipe(babel())
//     .pipe(gulp.dest("dist/compiled"));
// });
'use strict';

const gulp = require('gulp');
const babel = require('gulp-babel');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const fs = require("fs");

gulp.task('bab', bab);
gulp.task('babel', babelate);
gulp.task('default', ['bab', 'babel'], bundle);

function bab(done){
    let stream = gulp.src('./src/*.js')
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(gulp.dest('dist/compiled'));
	stream.on('end', done);
}

function babelate(done){
    let stream = gulp.src('./uninvisible.js')
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(gulp.dest('dist/compiled'));
	stream.on('end', done);
};

function bundle(done) {
  var browserifyOptions = {
    entries: ['./dist/compiled/uninvisible.js'],
    standalone: "UnInVisible",
    // debug: true
  };

  var b = browserify(browserifyOptions);

  var stream = b.bundle()
    .pipe(source('uninvisible.js'))
    .pipe(buffer())
    .pipe(gulp.dest('dist'));

    stream.on('end', done);
}
<commit_msg>minify javascript<commit_after>'use strict';
// TODO sass and copy css into dist

var gulp = require('gulp');
var babel = require('gulp-babel');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var minify = require('gulp-minify');

gulp.task('babelifySource', babelifySource);
gulp.task('babelifyIndex', babelifyIndex);
gulp.task('bundle', ['babelifySource', 'babelifyIndex'], bundle);
gulp.task('default', ['bundle']);

function babelifySource(done){
    var stream = gulp.src('./src/*.js')
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(gulp.dest('dist/compiled'));
	stream.on('end', done);
}

function babelifyIndex(done){
    var stream = gulp.src('./uninvisible.js')
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(gulp.dest('dist/compiled'));
	stream.on('end', done);
}

function bundle(done) {
  var browserifyOptions = {
    entries: ['./dist/compiled/uninvisible.js'],
    standalone: "UnInVisible",
    // debug: true
  };

  var b = browserify(browserifyOptions);

  var stream = b.bundle()
    .pipe(source('uninvisible.js'))
    .pipe(buffer())
    .pipe(minify())
    .pipe(gulp.dest('dist'));

    stream.on('end', done);
}
<|endoftext|>


<commit_before>// Notifies about Jenkins build errors via Jenkins Notification Plugin
//
// Dependencies:
//   "url": ""
//   "querystring": ""
//   "colors" : ""
//
// Configuration:
//   Just put this url <HUBOT_URL>:<PORT>/hubot/jenkins-notify?room=<room> to your Jenkins
//   Notification config. See here: https://wiki.jenkins-ci.org/display/JENKINS/Notification+Plugin
//
// Commands:
//   None
//
// URLS:
//   POST /hubot/jenkins-notify?room=<room>[&type=<type>]
//
// Authors:
//   spajus, cmckendry, andromedado, JasonSmiley

var url = require('url');
var querystring = require('querystring');
var http = require('http');
var colors = require('colors');
var util = require('util');

var DeDupeSounds = true;//If True, then, for example, mothra may only place once per "IntervalMinutes"
var IntervalMinutes = 30;
var MaxSoundsPerInterval = 2;//For any given interval, there will be no more than this number of jenkins sounds
//10 - 1 = One Sound per ten minutes
//30 - 2 = For any given half hour, at most two sounds will play
var soundsSoFar = 0;
var deDuper = {};

var logger = (function () {
    var logger = require('./support/logger');
    logger.buildSound = function (what) {
        var args = [].slice.call(arguments);
        if (args.length > 1) {
            what = util.format.apply(util, arguments);
        }
        var str = util.format('[%d/%d Build Sounds]'.cyan, soundsSoFar, MaxSoundsPerInterval);
        console.log('%s : %s', str, what);
        if (DeDupeSounds) {
            logger.minorInfo(JSON.stringify(deDuper));
        }
    };
    return logger;
}());

function makeSound (urlOfSound) {
    if (!(/http/.test(urlOfSound))) {
        urlOfSound = 'http://xserve:5051/' + urlOfSound;
    }

    if (soundsSoFar >= MaxSoundsPerInterval) {
        logger.buildSound('No available slots for %s', urlOfSound);
        return;
    }
    if (DeDupeSounds && deDuper[urlOfSound]) {
        logger.buildSound('Enforcing de-dupe for %s', urlOfSound);
        return;
    }
    deDuper[urlOfSound] = new Date();
    soundsSoFar += 1;
    logger.buildSound('Slot taken by %s', urlOfSound);
    setTimeout(function () {
        soundsSoFar -= 1;
        deDuper[urlOfSound] = void 0;
        logger.buildSound('Slot opened up!');
    }, IntervalMinutes * 60 * 1000);

    http.get(urlOfSound, function(res) {
        return logger.requestResolution(urlOfSound, res.statusCode);
    });
}

module.exports = function(robot) {

    var foo = {};

    return robot.router.post("/hubot/jenkins-notify", function(req, res) {
        var build, data, envelope, query, room;
        foo.failing = foo.failing || [];
        query = querystring.parse(url.parse(req.url).query);
        res.end('');
        envelope = {};
        envelope.user = {};
        if (query.room) {
            envelope.room = query.room;
        }
        if (query.type) {
            envelope.user.type = query.type;
        }
        room = 'dev';
        try {
            data = req.body;
            logger.build('%s - #%s: %s', data.name, data.build.number, (data.build.status || data.build.phase || '[unknown state]'));
            if (data.build.phase === 'STARTED') {
                if (data.name.match(/mothra.*qa/i)) {
                    makeSound('mothra-qa');
                }
            }
            if (data.build.phase === 'COMPLETED') {
                // Notify QA when QA builds complete
                if (data.name.match(/.*qa.*/i) && !data.name.match(/.*selenium.*/i) && !data.name.match(/.*godzilla.*/i)) {
                    var qaMsg = data.name + " build #" + data.build.number + " : " + data.build.status + " -- " + data.build.full_url;
                    logger.minorInfo("Notifying QA: %s", qaMsg);
                    robot.messageRoom('#qa', qaMsg);
                }
                // Notify the release channel when stage or prod get built
                if (data.name.match(/.*stage.*/i) && !data.name.match(/.*selenium.*/i) && !data.name.match(/.*godzilla.*/i)) {
                    var qaMsg = data.name + " build #" + data.build.number + " : " + data.build.status + " -- " + data.build.full_url;
                    logger.minorInfo("Notifying Relase Channel: %s", qaMsg);
                    robot.messageRoom('#release', qaMsg);
                }
                if (data.name.match(/.*prod.*/i) && !data.name.match(/.*selenium.*/i) && !data.name.match(/.*godzilla.*/i) && !data.name.match(/.*everything except.*/i)) {
                    var qaMsg = data.name + " build #" + data.build.number + " : " + data.build.status + " -- " + data.build.full_url;
                    logger.minorInfo("Notifying Relase Channel: %s", qaMsg);
                    robot.messageRoom('#release', qaMsg);
                }
                if (data.build.status === 'FAILURE') {
                    if (foo.failing.indexOf(data.name) >= 0) {
                        build = "is still";
                    } else {
                        build = "started";
                    }
                    robot.messageRoom(room, "" + data.name + " build #" + data.build.number + " " + build + " failing (" + (encodeURI(data.build.full_url)) + ")");
                    if (foo.failing.indexOf(data.name) < 0) {
                        foo.failing.push(data.name);
                    }
                    if (data.name.match(/mothra.*qa/i)) {
                        robot.messageRoom('#dev', "Mothra has the upper hand!");
                        robot.messageRoom('#dev', "http://i.imgur.com/CoqJxBx.gif");
                    }
                    if (data.name === 'MechaGodzilla .com (Prod)') {
                        makeSound('mechawins');
                        robot.messageRoom('#dev', "Mecha Godzilla is winning!:poop::poop::poop:");
                        robot.messageRoom('#dev', "http://i.imgur.com/AoeZXir.gif");
                    }
                }
                if (data.build.status === 'SUCCESS') {
                    if (data.name === '1stdibs.com Deploy Production PROD PROD PROD PROD' && data.parameters.Hotfix === 'true') {
                        makeSound('shipit');
                        robot.messageRoom("#release", "1stdibs.com hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.name === 'Admin-v2 Deploy (PROD)' && data.parameters.Hotfix === 'true') {
                        makeSound('shipit-adminv2');
                        robot.messageRoom("#release", "Admin v2 hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.name === 'Admin-v1 Deploy (PROD) (RACKSPACE)' && data.parameters.Hotfix === 'true') {
                        makeSound('shipit-adminv1');
                        robot.messageRoom("#release", "Admin v1 hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.name === 'JAVA-InventoryService (Hotfix to Prod)') {
                        makeSound('shipit-inventory');
                        robot.messageRoom("#release", "Inventory service hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.name === 'JAVA-IdentityService (Hotfix to Prod)') {
                        makeSound('shipit-identity');
                        robot.messageRoom("#release", "Identity service hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.build && data.build.parameters && data.build.parameters.SERVER_HOSTNAME === 'deathstar.1stdibs.com') {
                        makeSound('deathstar');
                        robot.messageRoom("#dev", "The Death Star is now fully armed and operational");
                    }
                    if (data.name === 'MechaGodzilla .com (Prod)') {
                        makeSound('mechaloses');
                        robot.messageRoom('#dev', "Mecha Godzilla has been defeated!:excited_tomato::excited_tomato::excited_tomato:");
                        robot.messageRoom('#dev', "http://i.imgur.com/t8tLizl.gif");
                    }
                }
            }
        } catch (error) {
            logger.error(error, req.body);
        }
    });
};

<commit_msg>jenkins notifier bugfix<commit_after>// Notifies about Jenkins build errors via Jenkins Notification Plugin
//
// Dependencies:
//   "url": ""
//   "querystring": ""
//   "colors" : ""
//
// Configuration:
//   Just put this url <HUBOT_URL>:<PORT>/hubot/jenkins-notify?room=<room> to your Jenkins
//   Notification config. See here: https://wiki.jenkins-ci.org/display/JENKINS/Notification+Plugin
//
// Commands:
//   None
//
// URLS:
//   POST /hubot/jenkins-notify?room=<room>[&type=<type>]
//
// Authors:
//   spajus, cmckendry, andromedado, JasonSmiley

var url = require('url');
var querystring = require('querystring');
var http = require('http');
var colors = require('colors');
var util = require('util');

var DeDupeSounds = true;//If True, then, for example, mothra may only place once per "IntervalMinutes"
var IntervalMinutes = 30;
var MaxSoundsPerInterval = 2;//For any given interval, there will be no more than this number of jenkins sounds
//10 - 1 = One Sound per ten minutes
//30 - 2 = For any given half hour, at most two sounds will play
var soundsSoFar = 0;
var deDuper = {};

var logger = (function () {
    var logger = require('./support/logger');
    logger.buildSound = function (what) {
        var args = [].slice.call(arguments);
        if (args.length > 1) {
            what = util.format.apply(util, arguments);
        }
        var str = util.format('[%d/%d Build Sounds]'.cyan, soundsSoFar, MaxSoundsPerInterval);
        console.log('%s : %s', str, what);
        if (DeDupeSounds) {
            logger.minorInfo(JSON.stringify(deDuper));
        }
    };
    return logger;
}());

function makeSound (urlOfSound) {
    if (!(/http/.test(urlOfSound))) {
        urlOfSound = 'http://xserve:5051/' + urlOfSound;
    }

    if (soundsSoFar >= MaxSoundsPerInterval) {
        logger.buildSound('No available slots for %s', urlOfSound);
        return;
    }
    if (DeDupeSounds && deDuper[urlOfSound]) {
        logger.buildSound('Enforcing de-dupe for %s', urlOfSound);
        return;
    }
    deDuper[urlOfSound] = new Date();
    soundsSoFar += 1;
    logger.buildSound('Slot taken by %s', urlOfSound);
    setTimeout(function () {
        soundsSoFar -= 1;
        deDuper[urlOfSound] = void 0;
        logger.buildSound('Slot opened up!');
    }, IntervalMinutes * 60 * 1000);

    http.get(urlOfSound, function(res) {
        return logger.requestResolution(urlOfSound, res.statusCode);
    });
}

module.exports = function(robot) {

    var foo = {};

    return robot.router.post("/hubot/jenkins-notify", function(req, res) {
        var build, data, envelope, query, room, params;
        foo.failing = foo.failing || [];
        query = querystring.parse(url.parse(req.url).query);
        res.end('');
        envelope = {};
        envelope.user = {};
        if (query.room) {
            envelope.room = query.room;
        }
        if (query.type) {
            envelope.user.type = query.type;
        }
        room = 'dev';
        try {
            data = req.body;
            params = (data && data.parameters) || {};
            logger.build('%s - #%s: %s', data.name, data.build.number, (data.build.status || data.build.phase || '[unknown state]'));
            if (data.build.phase === 'STARTED') {
                if (data.name.match(/mothra.*qa/i)) {
                    makeSound('mothra-qa');
                }
            }
            if (data.build.phase === 'COMPLETED') {
                // Notify QA when QA builds complete
                if (data.name.match(/.*qa.*/i) && !data.name.match(/.*selenium.*/i) && !data.name.match(/.*godzilla.*/i)) {
                    var qaMsg = data.name + " build #" + data.build.number + " : " + data.build.status + " -- " + data.build.full_url;
                    logger.minorInfo("Notifying QA: %s", qaMsg);
                    robot.messageRoom('#qa', qaMsg);
                }
                // Notify the release channel when stage or prod get built
                if (data.name.match(/.*stage.*/i) && !data.name.match(/.*selenium.*/i) && !data.name.match(/.*godzilla.*/i)) {
                    var qaMsg = data.name + " build #" + data.build.number + " : " + data.build.status + " -- " + data.build.full_url;
                    logger.minorInfo("Notifying Relase Channel: %s", qaMsg);
                    robot.messageRoom('#release', qaMsg);
                }
                if (data.name.match(/.*prod.*/i) && !data.name.match(/.*selenium.*/i) && !data.name.match(/.*godzilla.*/i) && !data.name.match(/.*everything except.*/i)) {
                    var qaMsg = data.name + " build #" + data.build.number + " : " + data.build.status + " -- " + data.build.full_url;
                    logger.minorInfo("Notifying Relase Channel: %s", qaMsg);
                    robot.messageRoom('#release', qaMsg);
                }
                if (data.build.status === 'FAILURE') {
                    if (foo.failing.indexOf(data.name) >= 0) {
                        build = "is still";
                    } else {
                        build = "started";
                    }
                    robot.messageRoom(room, "" + data.name + " build #" + data.build.number + " " + build + " failing (" + (encodeURI(data.build.full_url)) + ")");
                    if (foo.failing.indexOf(data.name) < 0) {
                        foo.failing.push(data.name);
                    }
                    if (data.name.match(/mothra.*qa/i)) {
                        robot.messageRoom('#dev', "Mothra has the upper hand!");
                        robot.messageRoom('#dev', "http://i.imgur.com/CoqJxBx.gif");
                    }
                    if (data.name === 'MechaGodzilla .com (Prod)') {
                        makeSound('mechawins');
                        robot.messageRoom('#dev', "Mecha Godzilla is winning!:poop::poop::poop:");
                        robot.messageRoom('#dev', "http://i.imgur.com/AoeZXir.gif");
                    }
                }
                if (data.build.status === 'SUCCESS') {
                    if (data.name === '1stdibs.com Deploy Production PROD PROD PROD PROD' && params.Hotfix === 'true') {
                        makeSound('shipit');
                        robot.messageRoom("#release", "1stdibs.com hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.name === 'Admin-v2 Deploy (PROD)' && params.Hotfix === 'true') {
                        makeSound('shipit-adminv2');
                        robot.messageRoom("#release", "Admin v2 hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.name === 'Admin-v1 Deploy (PROD) (RACKSPACE)' && params.Hotfix === 'true') {
                        makeSound('shipit-adminv1');
                        robot.messageRoom("#release", "Admin v1 hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.name === 'JAVA-InventoryService (Hotfix to Prod)') {
                        makeSound('shipit-inventory');
                        robot.messageRoom("#release", "Inventory service hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.name === 'JAVA-IdentityService (Hotfix to Prod)') {
                        makeSound('shipit-identity');
                        robot.messageRoom("#release", "Identity service hotfix has been released!");
                        robot.messageRoom("#release", "I hope you know what you're doing...");
                    }
                    if (data.build && data.build.parameters && data.build.parameters.SERVER_HOSTNAME === 'deathstar.1stdibs.com') {
                        makeSound('deathstar');
                        robot.messageRoom("#dev", "The Death Star is now fully armed and operational");
                    }
                    if (data.name === 'MechaGodzilla .com (Prod)') {
                        makeSound('mechaloses');
                        robot.messageRoom('#dev', "Mecha Godzilla has been defeated!:excited_tomato::excited_tomato::excited_tomato:");
                        robot.messageRoom('#dev', "http://i.imgur.com/t8tLizl.gif");
                    }
                }
            }
        } catch (error) {
            logger.error(error, req.body);
        }
    });
};

<|endoftext|>