<commit_before>/* Copyright (c) 2012 Brendan Hickey
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 * Good luck. Have fun.
 */

var MILLIS_PER_MINUTE = 60 * 1000;
var INTERVAL = 250;

var LANGUAGE = {
  ENGLISH : {
    season: ["Spring", "Summer", "Fall", "Winter"],
    cont: "Continue",
    end: "End"
  },
  FRENCH : {
    season: ["Printemps", "\u00C9t\u00E9", "Automne", "Hiver"],
    cont: "Continuer",
    end: "Fin"
  },
  GERMAN : {
    season: ["Fr\u00FChling", "Somner", "Herbst", "Winter"],
    cont: "Weiter",
    end: "Ende"
  },
  SPANISH : {
    season: ["Primavera", "Verano", "Oto\u00F1o", "Invierno"],
    cont: "Siga",
    end: "Final"
  },
  ITALIAN : {
    season: ["la primavera", "l\u00B4estate","l\u00B4autunno","l\u00B4inverno"],
    cont: "Continuare",
    end: "Fine"
  },
  CHEF : {
    season: ["Bork", "Bork Bork", "B\u00F6rk", "Bork Bork!"],
    cont: "Bork bork bork",
    end: "bork"
  }
 };

var SEASON = {
  SPRING : {value: 0},
  SUMMER : {value: 1},
  FALL   : {value: 2},
  WINTER : {value: 3}
};

var DipClock = function(year, season, spring, fall, writing, wait, end_year, language) {
   this.language = language;
   this.running = false;
   this.year = year;
   this.season = season;
   this.spring = spring;
   this.fall = fall;
   this.writing = writing;
   this.wait = wait;
   this.end_year = end_year;
   this.language = language;
   this.resetClock();
   this.init();
   this.pauseCount = 0;
};

DipClock.prototype.isOver = function() {
  return this.year >= this.end_year;
};

DipClock.prototype.updateLimits = function() {
  this.spring = Number($('#spring').attr('value')) * MILLIS_PER_MINUTE;
  this.fall = Number($('#fall').attr('value')) * MILLIS_PER_MINUTE;
};

DipClock.prototype.resetClock = function() {
  this.curr_writing = this.writing;
 if (this.season == SEASON.SPRING) {
    this.time = this.spring;
  }
  if (this.season == SEASON.FALL) {
    this.time = this.fall;
  }
  if (this.season == SEASON.SUMMER || this.season == SEASON.WINTER) {
    this.time = 0;
  }
};

DipClock.prototype.adjustClock = function(milliseconds) {
  this.time += milliseconds;
};

DipClock.prototype.advanceSeason = function() {
  if (this.season == SEASON.SUMMER) {
    this.season = SEASON.FALL;
    return;
  }
  if (this.season == SEASON.WINTER) {
    this.season = SEASON.SPRING;
    this.year += 1;
    return;
  }
  if (this.season == SEASON.SPRING) {
    if (this.wait === true) {
      this.season = SEASON.SUMMER;
      this.pause();
    } else {
      this.season = SEASON.FALL;
    }
    return;
  }
  if (this.season == SEASON.FALL) {
    if (this.wait === true) {
      this.season = SEASON.WINTER;
      this.pause();
    } else {
      this.season = SEASON.SPRING;
      this.year += 1;
    }
  }
  return;
};

 DipClock.prototype.rewindSeason = function() {
  if (this.season == SEASON.SUMMER) {
    this.season = SEASON.SPRING;
    return;
  }
  if (this.season == SEASON.WINTER) {
    this.season = SEASON.FALL;
    return;
  }
  if (this.season == SEASON.SPRING) {
    if (this.wait === true) {
      this.season = SEASON.WINTER;
      this.pause();
    } else {
      this.season = SEASON.FALL;
    }
    this.year -= 1;
    return;
  }
  if (this.season == SEASON.FALL) {
    if (this.wait === true) {
      this.season = SEASON.SUMMER;
      this.pause();
    } else {
      this.season = SEASON.SPRING;
    }
  }
  return;
};

DipClock.prototype.getMinutes = function() {
  return Math.floor(this.time / MILLIS_PER_MINUTE);
};

DipClock.prototype.getWritingMinutes = function() {
  return Math.floor(this.curr_writing / MILLIS_PER_MINUTE);
};

DipClock.prototype.getSeconds = function() {
  return Math.floor(this.getSubSeconds());
};

DipClock.prototype.getSubSeconds = function() {
  return (Math.floor(this.time % MILLIS_PER_MINUTE) / 1000);
};

DipClock.prototype.getWritingSeconds = function() {
  return Math.floor(this.getWritingSubSeconds());
};

DipClock.prototype.getWritingSubSeconds = function() {
  return Math.floor(this.curr_writing % MILLIS_PER_MINUTE) / 1000;
};

DipClock.prototype.isWaiting = function() {
  return this.season == SEASON.WINTER || this.season == SEASON.SUMMER;
};

DipClock.prototype.isWriting = function() {
  return this.time === 0 && this.curr_writing > 0;
};

DipClock.prototype.formatTime = function() {
  var mins = this.getMinutes();
  var secs = this.getSeconds();

  if (this.isWriting()) {
    mins = this.getWritingMinutes();
    secs = this.getWritingSeconds();
  }
  if (mins < 10) {
    mins = "0" + mins;
  }
  if (secs < 10) {
    secs = "0" + secs;
  }
  return (mins  + ":" + secs);
};
DipClock.prototype.sigmoid = function(t) {
  return (1 / (1 + (Math.exp(-t))));
};

DipClock.prototype.makeColor = function(r,g,b,t) {
  var s = this.sigmoid(t);
  r *= s;
  g *= s;
  b *= s;
  var col = "#" + this.asHex(r) + this.asHex(g) + this.asHex(b);
  return col;
};

DipClock.prototype.asHex = function(x) {
  var val = Math.floor(x * 256);
  if (val < 16) {
    return "0" + val.toString(16);
  } else {
    return val.toString(16);
  }
};

DipClock.prototype.getColor = function() {
  var secs = this.getSeconds();
  if (!this.isWriting()) {
    if (this.getMinutes() > 0) {
      return "#000";
    }
    var subsec = this.getSubSeconds();
    return this.makeColor(1,0,0, -(subsec / 10 - 3));
  }
  if (this.getWritingMinutes() > 0) {
    return "#0000FF";
  }
  var wsubsec = this.getWritingSubSeconds();
  return this.makeColor(0,0,1, (wsubsec / 10 - 3));
};

DipClock.prototype.init = function() {
   var that = this;
   $('#dip_time').click(function() {
     if (that.isWaiting()) {
        that.advanceSeason();
        that.resetClock();
        that.run();
        that.draw();
      }
  });
};

DipClock.prototype.draw = function() {
  if (!this.isWriting()) {
    $('#dip_season').text(this.language.season[this.season.value]);
    $('#dip_year').text(this.year);
  } else {
    $('#dip_season').text("Writing");
    $('#dip_year').html(this.language.season[this.season.value] + " &#x2014 " + this.year);
  }
  if (!this.isWaiting()) {
    $('#dip_time')
      .text(this.formatTime())
      .css("color", this.getColor());
  } else {
    var that = this;
    $('#dip_time')
      .html("<input type='submit' value='" + this.language.cont + "'></input>")
      .css("border","0px");
  }
  document.title = $('#dip_season').text() + " " + $('#dip_year').text() + " " + $('#dip_time').text();
};

DipClock.prototype.isRunning = function() {
  if (this.wait && (this.season == SEASON.WINTER || this.season == SEASON.SUMMER)) {
    return false;
  }
  return this.running;
};

DipClock.prototype.nudge = function(seconds) {
  this.time += seconds * 1000;
  this.decrement(0);
  this.draw();
};

DipClock.prototype.decrement = function(interval) {
  if (!this.isRunning()) {
    return;
  }
  if (this.time > 0) {
    this.time -= interval;
    if (this.time <= 0) {
      this.curr_writing += this.time;
      this.time = 0;
    }
  } else if (this.curr_writing > 0) {
    this.curr_writing -= interval;
  }

  if (this.time <= 0 && this.curr_writing <= 0) {
    var underflow = this.time + this.curr_writing;
    if (this.curr_writing <= 0) {
      this.advanceSeason();
      this.resetClock();
      this.time += underflow;
    }
  }

  this.draw();
  if (this.isOver()) {
    this.pause();
    this.gameOver();
  }
};

DipClock.prototype.gameOver = function() {
  $('#dip_time').text(this.language.end);
  document.title = this.language.end;
};

DipClock.prototype.run = function() {
  var that = this;
  this.running = true;
  this.runner = setInterval(function() { that.decrement(INTERVAL); }, INTERVAL);
};

DipClock.prototype.pause = function() {
  clearInterval(this.runner);
  this.running = false;
};

DipClock.prototype.toggle = function() {
  if (this.running) {
    this.pauseCount += 1;
    this.pause();
    $('#toggle').attr("value", "Toggle [" + this.pauseCount + "]");
    $('body').css('background','#333');
  } else {
    this.run();
    $('body').css('background','#ccc');
  }
};

DipClock.prototype.maybeStart = function() {
  if (this.season == SEASON.SPRING || this.season == SEASON.FALL) {
    this.run();
  }
};

 var DCBuilder = function DCBuilder() {
  this.year = 1901;
  this.min_end = false;
  this.max_end = false;
  this.season = SEASON.SPRING;
  this.spring = 0.05 * MILLIS_PER_MINUTE;
  this.fall = 0.05 * MILLIS_PER_MINUTE;
  this.writing = 0.1 * MILLIS_PER_MINUTE;
  this.wait = false;
  this.broken = false;
};

DCBuilder.prototype.die = function() {
  this.broken = true;
};

DCBuilder.prototype.setSeason = function(season) {
 season = season.toLowerCase();
 if (season == "winter") {
   this.season = SEASON.WINTER;
 }
 if (season == "spring") {
   this.season = SEASON.SPRING;
 }
 if (season == "fall") {
   this.season = SEASON.FALL;
 }
 if (season == "summer") {
   this.season = SEASON.SUMMER;
 }
 return this;
};

DCBuilder.prototype.setYear = function(year) {
 this.year = Number(year);
 return this;
};

DCBuilder.prototype.setRandomEnd = function(year_min, year_max) {
  if (year_min === '--' || year_max === '--') {
    this.end_year = 100000;
    return this;
  }
  var min = Number(year_min);
  var max = Number(year_max);
  if (min > max) {
    this.die();
  }
  this.end_year = min + Math.floor(Math.random() * (max-min));
  return this;
};

DCBuilder.prototype.setSpring = function(spring) {
  spring = Number(spring);
  if (isNaN(spring)) {
    spring = 12;
  }
  this.spring = spring * MILLIS_PER_MINUTE;
  return this;
};

DCBuilder.prototype.setFall = function(fall) {
  fall = Number(fall);
  if (isNaN(fall)) {
    fall = 15;
  }
  this.fall = fall * MILLIS_PER_MINUTE;
  return this;
};

DCBuilder.prototype.setWriting = function(writing) {
  writing = Number(writing);
  if (isNaN(writing)) {
    writing = 0;
  }
  this.writing = writing * MILLIS_PER_MINUTE;
  return this;
};

DCBuilder.prototype.setLanguage = function(language) {
  language = language.toLowerCase();
  switch(language) {
    case "english":
      this.language = LANGUAGE.ENGLISH;
      return this;
    case "french":
      this.language = LANGUAGE.FRENCH;
      return this;
    case "german":
      this.language = LANGUAGE.GERMAN;
      return this;
    case "spanish":
      this.language = LANGUAGE.SPANISH;
      return this;
    case "italian":
      this.language = LANGUAGE.ITALIAN;
      return this;
    case "chef":
      this.language = LANGUAGE.CHEF;
      return this;
    default:
      this.broken = true;
      return this;
  }
};

DCBuilder.prototype.waitToAdjudicate = function(wait) {
  this.wait = wait;
  return this;
};

DCBuilder.prototype.build = function() {
  if (this.broken === true) {
    return false;
  }

  if (this.year >= this.end_year) {
    return false;
  }
  return new DipClock(
    this.year, this.season,
    this.spring, this.fall,
    this.writing, this.wait,
    this.end_year, this.language);
};

var isScrolling = function() {
  var root = document.body;
  return (root.scrollHeight > root.clientHeight ||
          root.scrollWidth > root.clientWidth);
};

var scaleWhile = function() {
  var height = 300;
  while(isScrolling() && height > 0) {
    height--;
    $('body').css('font-size', height + "%");
  }
};
<commit_msg>No more hilarious speedup bugs?<commit_after>/* Copyright (c) 2012 Brendan Hickey
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 * Good luck. Have fun.
 */

var MILLIS_PER_MINUTE = 60 * 1000;
var INTERVAL = 250;

var LANGUAGE = {
  ENGLISH : {
    season: ["Spring", "Summer", "Fall", "Winter"],
    cont: "Continue",
    end: "End"
  },
  FRENCH : {
    season: ["Printemps", "\u00C9t\u00E9", "Automne", "Hiver"],
    cont: "Continuer",
    end: "Fin"
  },
  GERMAN : {
    season: ["Fr\u00FChling", "Somner", "Herbst", "Winter"],
    cont: "Weiter",
    end: "Ende"
  },
  SPANISH : {
    season: ["Primavera", "Verano", "Oto\u00F1o", "Invierno"],
    cont: "Siga",
    end: "Final"
  },
  ITALIAN : {
    season: ["la primavera", "l\u00B4estate","l\u00B4autunno","l\u00B4inverno"],
    cont: "Continuare",
    end: "Fine"
  },
  CHEF : {
    season: ["Bork", "Bork Bork", "B\u00F6rk", "Bork Bork!"],
    cont: "Bork bork bork",
    end: "bork"
  }
 };

var SEASON = {
  SPRING : {value: 0},
  SUMMER : {value: 1},
  FALL   : {value: 2},
  WINTER : {value: 3}
};

var DipClock = function(year, season, spring, fall, writing, wait, end_year, language) {
   this.language = language;
   this.running = false;
   this.year = year;
   this.season = season;
   this.spring = spring;
   this.fall = fall;
   this.writing = writing;
   this.wait = wait;
   this.end_year = end_year;
   this.language = language;
   this.resetClock();
   this.init();
   this.pauseCount = 0;
};

DipClock.prototype.isOver = function() {
  return this.year >= this.end_year;
};

DipClock.prototype.updateLimits = function() {
  this.spring = Number($('#spring').attr('value')) * MILLIS_PER_MINUTE;
  this.fall = Number($('#fall').attr('value')) * MILLIS_PER_MINUTE;
};

DipClock.prototype.resetClock = function() {
  this.curr_writing = this.writing;
 if (this.season == SEASON.SPRING) {
    this.time = this.spring;
  }
  if (this.season == SEASON.FALL) {
    this.time = this.fall;
  }
  if (this.season == SEASON.SUMMER || this.season == SEASON.WINTER) {
    this.time = 0;
  }
};

DipClock.prototype.adjustClock = function(milliseconds) {
  this.time += milliseconds;
};

DipClock.prototype.advanceSeason = function() {
  if (this.season == SEASON.SUMMER) {
    this.season = SEASON.FALL;
    return;
  }
  if (this.season == SEASON.WINTER) {
    this.season = SEASON.SPRING;
    this.year += 1;
    return;
  }
  if (this.season == SEASON.SPRING) {
    if (this.wait === true) {
      this.season = SEASON.SUMMER;
      this.pause();
    } else {
      this.season = SEASON.FALL;
    }
    return;
  }
  if (this.season == SEASON.FALL) {
    if (this.wait === true) {
      this.season = SEASON.WINTER;
      this.pause();
    } else {
      this.season = SEASON.SPRING;
      this.year += 1;
    }
  }
  return;
};

 DipClock.prototype.rewindSeason = function() {
  if (this.season == SEASON.SUMMER) {
    this.season = SEASON.SPRING;
    return;
  }
  if (this.season == SEASON.WINTER) {
    this.season = SEASON.FALL;
    return;
  }
  if (this.season == SEASON.SPRING) {
    if (this.wait === true) {
      this.season = SEASON.WINTER;
      this.pause();
    } else {
      this.season = SEASON.FALL;
    }
    this.year -= 1;
    return;
  }
  if (this.season == SEASON.FALL) {
    if (this.wait === true) {
      this.season = SEASON.SUMMER;
      this.pause();
    } else {
      this.season = SEASON.SPRING;
    }
  }
  return;
};

DipClock.prototype.getMinutes = function() {
  return Math.floor(this.time / MILLIS_PER_MINUTE);
};

DipClock.prototype.getWritingMinutes = function() {
  return Math.floor(this.curr_writing / MILLIS_PER_MINUTE);
};

DipClock.prototype.getSeconds = function() {
  return Math.floor(this.getSubSeconds());
};

DipClock.prototype.getSubSeconds = function() {
  return (Math.floor(this.time % MILLIS_PER_MINUTE) / 1000);
};

DipClock.prototype.getWritingSeconds = function() {
  return Math.floor(this.getWritingSubSeconds());
};

DipClock.prototype.getWritingSubSeconds = function() {
  return Math.floor(this.curr_writing % MILLIS_PER_MINUTE) / 1000;
};

DipClock.prototype.isWaiting = function() {
  return this.season == SEASON.WINTER || this.season == SEASON.SUMMER;
};

DipClock.prototype.isWriting = function() {
  return this.time === 0 && this.curr_writing > 0;
};

DipClock.prototype.formatTime = function() {
  var mins = this.getMinutes();
  var secs = this.getSeconds();

  if (this.isWriting()) {
    mins = this.getWritingMinutes();
    secs = this.getWritingSeconds();
  }
  if (mins < 10) {
    mins = "0" + mins;
  }
  if (secs < 10) {
    secs = "0" + secs;
  }
  return (mins  + ":" + secs);
};
DipClock.prototype.sigmoid = function(t) {
  return (1 / (1 + (Math.exp(-t))));
};

DipClock.prototype.makeColor = function(r,g,b,t) {
  var s = this.sigmoid(t);
  r *= s;
  g *= s;
  b *= s;
  var col = "#" + this.asHex(r) + this.asHex(g) + this.asHex(b);
  return col;
};

DipClock.prototype.asHex = function(x) {
  var val = Math.floor(x * 256);
  if (val < 16) {
    return "0" + val.toString(16);
  } else {
    return val.toString(16);
  }
};

DipClock.prototype.getColor = function() {
  var secs = this.getSeconds();
  if (!this.isWriting()) {
    if (this.getMinutes() > 0) {
      return "#000";
    }
    var subsec = this.getSubSeconds();
    return this.makeColor(1,0,0, -(subsec / 10 - 3));
  }
  if (this.getWritingMinutes() > 0) {
    return "#0000FF";
  }
  var wsubsec = this.getWritingSubSeconds();
  return this.makeColor(0,0,1, (wsubsec / 10 - 3));
};

DipClock.prototype.init = function() {
   var that = this;
   $('#dip_time').click(function() {
     if (that.isWaiting()) {
        that.advanceSeason();
        that.resetClock();
        that.run();
        that.draw();
      }
  });
};

DipClock.prototype.draw = function() {
  if (!this.isWriting()) {
    $('#dip_season').text(this.language.season[this.season.value]);
    $('#dip_year').text(this.year);
  } else {
    $('#dip_season').text("Writing");
    $('#dip_year').html(this.language.season[this.season.value] + " &#x2014 " + this.year);
  }
  if (!this.isWaiting()) {
    $('#dip_time')
      .text(this.formatTime())
      .css("color", this.getColor());
  } else {
    var that = this;
    $('#dip_time')
      .html("<input type='submit' value='" + this.language.cont + "'></input>")
      .css("border","0px");
  }
  document.title = $('#dip_season').text() + " " + $('#dip_year').text() + " " + $('#dip_time').text();
};

DipClock.prototype.isRunning = function() {
  if (this.wait && (this.season == SEASON.WINTER || this.season == SEASON.SUMMER)) {
    return false;
  }
  return this.running;
};

DipClock.prototype.nudge = function(seconds) {
  this.time += seconds * 1000;
  this.decrement(0);
  this.draw();
};

DipClock.prototype.decrement = function(interval) {
  if (!this.isRunning()) {
    return;
  }
  if (this.time > 0) {
    this.time -= interval;
    if (this.time <= 0) {
      this.curr_writing += this.time;
      this.time = 0;
    }
  } else if (this.curr_writing > 0) {
    this.curr_writing -= interval;
  }

  if (this.time <= 0 && this.curr_writing <= 0) {
    var underflow = this.time + this.curr_writing;
    if (this.curr_writing <= 0) {
      this.advanceSeason();
      this.resetClock();
      this.time += underflow;
    }
  }

  this.draw();
  if (this.isOver()) {
    this.pause();
    this.gameOver();
  }
};

DipClock.prototype.gameOver = function() {
  $('#dip_time').text(this.language.end);
  document.title = this.language.end;
};

DipClock.prototype.run = function() {
  if (this.running === false) {
    var that = this;
    this.running = true;
    this.runner = setInterval(function() { that.decrement(INTERVAL); }, INTERVAL);
  }
};

DipClock.prototype.pause = function() {
  clearInterval(this.runner);
  this.running = false;
};

DipClock.prototype.toggle = function() {
  if (this.running) {
    this.pauseCount += 1;
    this.pause();
    $('#toggle').attr("value", "Toggle [" + this.pauseCount + "]");
    $('body').css('background','#333');
  } else {
    this.run();
    $('body').css('background','#ccc');
  }
};

DipClock.prototype.maybeStart = function() {
  if (this.season == SEASON.SPRING || this.season == SEASON.FALL) {
    this.run();
  }
};

 var DCBuilder = function DCBuilder() {
  this.year = 1901;
  this.min_end = false;
  this.max_end = false;
  this.season = SEASON.SPRING;
  this.spring = 0.05 * MILLIS_PER_MINUTE;
  this.fall = 0.05 * MILLIS_PER_MINUTE;
  this.writing = 0.1 * MILLIS_PER_MINUTE;
  this.wait = false;
  this.broken = false;
};

DCBuilder.prototype.die = function() {
  this.broken = true;
};

DCBuilder.prototype.setSeason = function(season) {
 season = season.toLowerCase();
 if (season == "winter") {
   this.season = SEASON.WINTER;
 }
 if (season == "spring") {
   this.season = SEASON.SPRING;
 }
 if (season == "fall") {
   this.season = SEASON.FALL;
 }
 if (season == "summer") {
   this.season = SEASON.SUMMER;
 }
 return this;
};

DCBuilder.prototype.setYear = function(year) {
 this.year = Number(year);
 return this;
};

DCBuilder.prototype.setRandomEnd = function(year_min, year_max) {
  if (year_min === '--' || year_max === '--') {
    this.end_year = 100000;
    return this;
  }
  var min = Number(year_min);
  var max = Number(year_max);
  if (min > max) {
    this.die();
  }
  this.end_year = min + Math.floor(Math.random() * (max-min));
  return this;
};

DCBuilder.prototype.setSpring = function(spring) {
  spring = Number(spring);
  if (isNaN(spring)) {
    spring = 12;
  }
  this.spring = spring * MILLIS_PER_MINUTE;
  return this;
};

DCBuilder.prototype.setFall = function(fall) {
  fall = Number(fall);
  if (isNaN(fall)) {
    fall = 15;
  }
  this.fall = fall * MILLIS_PER_MINUTE;
  return this;
};

DCBuilder.prototype.setWriting = function(writing) {
  writing = Number(writing);
  if (isNaN(writing)) {
    writing = 0;
  }
  this.writing = writing * MILLIS_PER_MINUTE;
  return this;
};

DCBuilder.prototype.setLanguage = function(language) {
  language = language.toLowerCase();
  switch(language) {
    case "english":
      this.language = LANGUAGE.ENGLISH;
      return this;
    case "french":
      this.language = LANGUAGE.FRENCH;
      return this;
    case "german":
      this.language = LANGUAGE.GERMAN;
      return this;
    case "spanish":
      this.language = LANGUAGE.SPANISH;
      return this;
    case "italian":
      this.language = LANGUAGE.ITALIAN;
      return this;
    case "chef":
      this.language = LANGUAGE.CHEF;
      return this;
    default:
      this.broken = true;
      return this;
  }
};

DCBuilder.prototype.waitToAdjudicate = function(wait) {
  this.wait = wait;
  return this;
};

DCBuilder.prototype.build = function() {
  if (this.broken === true) {
    return false;
  }

  if (this.year >= this.end_year) {
    return false;
  }
  return new DipClock(
    this.year, this.season,
    this.spring, this.fall,
    this.writing, this.wait,
    this.end_year, this.language);
};

var isScrolling = function() {
  var root = document.body;
  return (root.scrollHeight > root.clientHeight ||
          root.scrollWidth > root.clientWidth);
};

var scaleWhile = function() {
  var height = 300;
  while(isScrolling() && height > 0) {
    height--;
    $('body').css('font-size', height + "%");
  }
};
<|endoftext|>


<commit_before>var PalladiumClient = require('palladium');
var logger = require('logger');
var gpio = require('rpi-gpio');
var config = require('./config.json');

var palladium = new PalladiumClient(config.palladium, config.spotify.palladium);
palladium.connect();

for(var key in config.pi.outputs) {

    channel = config.pi.outputs[key];
    gpio.setup(channel, gpio.DIR_OUT);
}

/*
*	Export GPIO to control Outputs
*/
gpio.on('export', function(channel) {

	setTimeout(function() {

		gpio.write(channel, true, function(err) {
			if(err) {
				palladium.send("fr/readyo/palladium/system/error", { "message": err });
				logger.error('Failed to close a channel '+channel+':'+err, { app: "pi" });
			} else {
				palladium.send("fr/readyo/palladium/system/info", { "message": 'The channel '+channel+' was successful closed.' });
				logger.info('The channel '+channel+' was successful closed.', { app: "pi" });
			}
		});

	}, 1000);
});

palladium.on("fr/readyo/palladium/output/open", function(data) {

	self = this;

	if(outputs.hasOwnProperty(data.channel)) {

		channel = outputs[data.channel];

		gpio.write(channel, false, function(err) {
	        if (err) {
				palladium.send("fr/readyo/palladium/system/error", { "message": err });
				logger.error('Failed to open the channel '+channel+':'+err, { app: "pi" });
	        } else  {
	        	palladium.send("fr/readyo/palladium/system/info", { "message": 'The channel '+channel+' was successful opened.' });
	        	logger.info('The channel '+channel+' was successful opened.', { app: "pi" });
		    }
	    });
	}
});

palladium.on("fr/readyo/palladium/output/close", function(data) {

	self = this;

	if(outputs.hasOwnProperty(data.channel)) {

		channel = outputs[data.channel];

		gpio.write(channel, true, function(err) {
	        if (err) {
				palladium.send("fr/readyo/palladium/system/error", { "message": err });
				logger.error('Failed to close a channel '+channel+':'+err, { app: "pi" });
	        } else {
	        	palladium.send("fr/readyo/palladium/system/info", { "message": 'The channel '+channel+' was successful closed.' });
				logger.info('The channel '+channel+' was successful closed', { app: "pi" });
	        }
	    });
	}
});<commit_msg>Mauvaise configuration chargée dans l'app Pi<commit_after>var PalladiumClient = require('palladium');
var logger = require('logger');
var gpio = require('rpi-gpio');
var config = require('./config.json');

var palladium = new PalladiumClient(config.palladium, config.pi.palladium);
palladium.connect();

for(var key in config.pi.outputs) {

    channel = config.pi.outputs[key];
    gpio.setup(channel, gpio.DIR_OUT);
}

/*
*	Export GPIO to control Outputs
*/
gpio.on('export', function(channel) {

	setTimeout(function() {

		gpio.write(channel, true, function(err) {
			if(err) {
				palladium.send("fr/readyo/palladium/system/error", { "message": err });
				logger.error('Failed to close a channel '+channel+':'+err, { app: "pi" });
			} else {
				palladium.send("fr/readyo/palladium/system/info", { "message": 'The channel '+channel+' was successful closed.' });
				logger.info('The channel '+channel+' was successful closed.', { app: "pi" });
			}
		});

	}, 1000);
});

palladium.on("fr/readyo/palladium/output/open", function(data) {

	self = this;

	if(outputs.hasOwnProperty(data.channel)) {

		channel = outputs[data.channel];

		gpio.write(channel, false, function(err) {
	        if (err) {
				palladium.send("fr/readyo/palladium/system/error", { "message": err });
				logger.error('Failed to open the channel '+channel+':'+err, { app: "pi" });
	        } else  {
	        	palladium.send("fr/readyo/palladium/system/info", { "message": 'The channel '+channel+' was successful opened.' });
	        	logger.info('The channel '+channel+' was successful opened.', { app: "pi" });
		    }
	    });
	}
});

palladium.on("fr/readyo/palladium/output/close", function(data) {

	self = this;

	if(outputs.hasOwnProperty(data.channel)) {

		channel = outputs[data.channel];

		gpio.write(channel, true, function(err) {
	        if (err) {
				palladium.send("fr/readyo/palladium/system/error", { "message": err });
				logger.error('Failed to close a channel '+channel+':'+err, { app: "pi" });
	        } else {
	        	palladium.send("fr/readyo/palladium/system/info", { "message": 'The channel '+channel+' was successful closed.' });
				logger.info('The channel '+channel+' was successful closed', { app: "pi" });
	        }
	    });
	}
});<|endoftext|>


<commit_before>
;(function (name, root, factory) {
  if (typeof exports === 'object') {
    module.exports = factory()
    module.exports['default'] = factory()
  }
  /* istanbul ignore next */
  else if (typeof define === 'function' && define.amd) {
    define(factory)
  }
  else {
    root[name] = factory()
  }
}('slugify', this, function () {
  var charMap = JSON.parse('{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ō":"O","ō":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","Ə":"E","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","ǈ":"LJ","ǉ":"lj","ǋ":"NJ","ǌ":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","ə":"e","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","ѝ":"u","џ":"dz","Ґ":"G","ґ":"g","Ғ":"GH","ғ":"gh","Қ":"KH","қ":"kh","Ң":"NG","ң":"ng","Ү":"UE","ү":"ue","Ұ":"U","ұ":"u","Һ":"H","һ":"h","Ә":"AE","ә":"ae","Ө":"OE","ө":"oe","Ա":"A","Բ":"B","Գ":"G","Դ":"D","Ե":"E","Զ":"Z","Է":"E\'","Ը":"Y\'","Թ":"T\'","Ժ":"JH","Ի":"I","Լ":"L","Խ":"X","Ծ":"C\'","Կ":"K","Հ":"H","Ձ":"D\'","Ղ":"GH","Ճ":"TW","Մ":"M","Յ":"Y","Ն":"N","Շ":"SH","Չ":"CH","Պ":"P","Ջ":"J","Ռ":"R\'","Ս":"S","Վ":"V","Տ":"T","Ր":"R","Ց":"C","Փ":"P\'","Ք":"Q\'","Օ":"O\'\'","Ֆ":"F","և":"EV","ء":"a","آ":"aa","أ":"a","ؤ":"u","إ":"i","ئ":"e","ا":"a","ب":"b","ة":"h","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ى":"a","ي":"y","ً":"an","ٌ":"on","ٍ":"en","َ":"a","ُ":"u","ِ":"e","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","پ":"p","چ":"ch","ژ":"zh","ک":"k","گ":"g","ی":"y","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","Ẁ":"W","ẁ":"w","Ẃ":"W","ẃ":"w","Ẅ":"W","ẅ":"w","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","–":"-","‘":"\'","’":"\'","“":"\\\"","”":"\\\"","„":"\\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₸":"kazakhstani tenge","₹":"indian rupee","₺":"turkish lira","₽":"russian ruble","₿":"bitcoin","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial","ﻵ":"laa","ﻷ":"laa","ﻹ":"lai","ﻻ":"la"}')
  var locales = JSON.parse('{"bg":{"Й":"Y","Ц":"Ts","Щ":"Sht","Ъ":"A","Ь":"Y","й":"y","ц":"ts","щ":"sht","ъ":"a","ь":"y"},"de":{"Ä":"AE","ä":"ae","Ö":"OE","ö":"oe","Ü":"UE","ü":"ue","%":"prozent","&":"und","|":"oder","∑":"summe","∞":"unendlich","♥":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","¢":"centavos","£":"libras","¤":"moneda","₣":"francos","∑":"suma","∞":"infinito","♥":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","¢":"centime","£":"livre","¤":"devise","₣":"franc","∑":"somme","∞":"infini","♥":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","¢":"centavo","∑":"soma","£":"libra","∞":"infinito","♥":"amor"},"uk":{"И":"Y","и":"y","Й":"Y","й":"y","Ц":"Ts","ц":"ts","Х":"Kh","х":"kh","Щ":"Shch","щ":"shch","Г":"H","г":"h"},"vi":{"Đ":"D","đ":"d"},"da":{"Ø":"OE","ø":"oe","Å":"AA","å":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"større end"}}')

  function replace (string, options) {
    if (typeof string !== 'string') {
      throw new Error('slugify: string argument expected')
    }

    options = (typeof options === 'string')
      ? {replacement: options}
      : options || {}

    var locale = locales[options.locale] || {}

    var replacement = options.replacement === undefined ? '-' : options.replacement

    var trim = options.trim === undefined ? true : options.trim

    var slug = string.normalize().split('')
      // replace characters based on charMap
      .reduce(function (result, ch) {
        return result + (locale[ch] || charMap[ch] ||  (ch === replacement ? ' ' : ch))
          // remove not allowed characters
          .replace(options.remove || /[^\w\s$*_+~.()'"!\-:@]+/g, '')
      }, '');

    if (options.strict) {
      slug = slug.replace(/[^A-Za-z0-9\s]/g, '');
    }

    if (trim) {
      slug = slug.trim()
    }

    // Replace spaces with replacement character, treating multiple consecutive
    // spaces as a single space.
    slug = slug.replace(/\s+/g, replacement);

    if (options.lower) {
      slug = slug.toLowerCase()
    }

    return slug
  }

  replace.extend = function (customMap) {
    Object.assign(charMap, customMap)
  }

  return replace
}))
<commit_msg>Build<commit_after>
;(function (name, root, factory) {
  if (typeof exports === 'object') {
    module.exports = factory()
    module.exports['default'] = factory()
  }
  /* istanbul ignore next */
  else if (typeof define === 'function' && define.amd) {
    define(factory)
  }
  else {
    root[name] = factory()
  }
}('slugify', this, function () {
  var charMap = JSON.parse('{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ō":"O","ō":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","Ə":"E","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","ǈ":"LJ","ǉ":"lj","ǋ":"NJ","ǌ":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","ə":"e","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","ѝ":"u","џ":"dz","Ґ":"G","ґ":"g","Ғ":"GH","ғ":"gh","Қ":"KH","қ":"kh","Ң":"NG","ң":"ng","Ү":"UE","ү":"ue","Ұ":"U","ұ":"u","Һ":"H","һ":"h","Ә":"AE","ә":"ae","Ө":"OE","ө":"oe","Ա":"A","Բ":"B","Գ":"G","Դ":"D","Ե":"E","Զ":"Z","Է":"E\'","Ը":"Y\'","Թ":"T\'","Ժ":"JH","Ի":"I","Լ":"L","Խ":"X","Ծ":"C\'","Կ":"K","Հ":"H","Ձ":"D\'","Ղ":"GH","Ճ":"TW","Մ":"M","Յ":"Y","Ն":"N","Շ":"SH","Չ":"CH","Պ":"P","Ջ":"J","Ռ":"R\'","Ս":"S","Վ":"V","Տ":"T","Ր":"R","Ց":"C","Փ":"P\'","Ք":"Q\'","Օ":"O\'\'","Ֆ":"F","և":"EV","ء":"a","آ":"aa","أ":"a","ؤ":"u","إ":"i","ئ":"e","ا":"a","ب":"b","ة":"h","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ى":"a","ي":"y","ً":"an","ٌ":"on","ٍ":"en","َ":"a","ُ":"u","ِ":"e","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","پ":"p","چ":"ch","ژ":"zh","ک":"k","گ":"g","ی":"y","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","Ẁ":"W","ẁ":"w","Ẃ":"W","ẃ":"w","Ẅ":"W","ẅ":"w","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","–":"-","‘":"\'","’":"\'","“":"\\\"","”":"\\\"","„":"\\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₸":"kazakhstani tenge","₹":"indian rupee","₺":"turkish lira","₽":"russian ruble","₿":"bitcoin","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial","ﻵ":"laa","ﻷ":"laa","ﻹ":"lai","ﻻ":"la"}')
  var locales = JSON.parse('{"bg":{"Й":"Y","Ц":"Ts","Щ":"Sht","Ъ":"A","Ь":"Y","й":"y","ц":"ts","щ":"sht","ъ":"a","ь":"y"},"de":{"Ä":"AE","ä":"ae","Ö":"OE","ö":"oe","Ü":"UE","ü":"ue","ß":"ss","%":"prozent","&":"und","|":"oder","∑":"summe","∞":"unendlich","♥":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","¢":"centavos","£":"libras","¤":"moneda","₣":"francos","∑":"suma","∞":"infinito","♥":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","¢":"centime","£":"livre","¤":"devise","₣":"franc","∑":"somme","∞":"infini","♥":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","¢":"centavo","∑":"soma","£":"libra","∞":"infinito","♥":"amor"},"uk":{"И":"Y","и":"y","Й":"Y","й":"y","Ц":"Ts","ц":"ts","Х":"Kh","х":"kh","Щ":"Shch","щ":"shch","Г":"H","г":"h"},"vi":{"Đ":"D","đ":"d"},"da":{"Ø":"OE","ø":"oe","Å":"AA","å":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"større end"},"nb":{"&":"og"},"it":{"&":"e"},"nl":{"&":"en"},"sv":{"&":"och"}}')

  function replace (string, options) {
    if (typeof string !== 'string') {
      throw new Error('slugify: string argument expected')
    }

    options = (typeof options === 'string')
      ? {replacement: options}
      : options || {}

    var locale = locales[options.locale] || {}

    var replacement = options.replacement === undefined ? '-' : options.replacement

    var trim = options.trim === undefined ? true : options.trim

    var slug = string.normalize().split('')
      // replace characters based on charMap
      .reduce(function (result, ch) {
        return result + (locale[ch] || charMap[ch] ||  (ch === replacement ? ' ' : ch))
          // remove not allowed characters
          .replace(options.remove || /[^\w\s$*_+~.()'"!\-:@]+/g, '')
      }, '');

    if (options.strict) {
      slug = slug.replace(/[^A-Za-z0-9\s]/g, '');
    }

    if (trim) {
      slug = slug.trim()
    }

    // Replace spaces with replacement character, treating multiple consecutive
    // spaces as a single space.
    slug = slug.replace(/\s+/g, replacement);

    if (options.lower) {
      slug = slug.toLowerCase()
    }

    return slug
  }

  replace.extend = function (customMap) {
    Object.assign(charMap, customMap)
  }

  return replace
}))
<|endoftext|>


<commit_before>var limit = 10;
var total = 0;

for (var i=0; i<=limit; i++) {
  total += i;
}

console.log(total);<commit_msg>Update index.js<commit_after>var limit = 10;
var total = 0;

for (var i=0; i<=limit; i++) {
  total += i;
  console.log(total)
}
<|endoftext|>


<commit_before>'use strict';

/* Directives */
var monadexDirectives = angular.module('monadexApp.directives', []);

monadexDirectives.directive('appVersion', ['version',
    function(version) {
        return function(scope, elm, attrs) {
            elm.text(version);
        };
    }
]);

// Style and quality panel let the customer choose the style of the
// t-shirts with various qualities.
monadexDirectives.directive('mdTshirtStyleQualityPanel',
                            ['$timeout', '$compile', 'canvasService',
   function($timeout, $compile, canvasService) {
       return {
           restrict: 'E',
           scope: {
               tshirtTypes: '=',
               baseCost: "=",
               colors: "="
           },
           templateUrl: 'partials/tshirt-designer-pages/tshirt-style-quality-panel.html',
           link: function(scope, element, attrs) {
               $timeout(function() {
                   var initColors =
                           element.find('.tshirt-variant').attr("colors");

                   scope.$apply(function() {
                       scope.colors = eval(initColors);
                   });

                   element.find('.tshirt-variant').click(function() {
                       canvasService.setAvailableBgColors(eval(
                           $(this).attr("colors")
                       ));
                   });

                   scope.$on('mdeBgAvailableColorsChanged', function(e, o) {
                       scope.$apply(function() {
                           scope.colors = o.colors;
                       });
                   });
               }, 0);
           }
       };
   }
]);

monadexDirectives.directive('mdTshirtDesignPanel', ['$timeout',
   function($timeout) {
       return {
           restrict: 'E',
           scope: {
               colors: "=",
               images: '=',
               fonts: "="
           },
           templateUrl: 'partials/tshirt-designer-pages/tshirt-design-panel.html',
           link: function(scope, element) {
               $timeout(function() {
                   element.find(".tab-link").click(function(event) {
                       event.preventDefault();
                   });
               }, 0);
           }
       };
   }
]);

monadexDirectives.directive('mdTshirtCanvas', ['$timeout', 'canvasService',
    function($timeout, canvasService) {
        var canvas;
        return {
            restrict: 'E',
            scope: {
            },
            templateUrl: 'partials/tshirt-designer-pages/tshirt-canvas.html',
            link: function(scope, element, attrs) {
                // initialize the canvasService
                canvasService.init('tcanvas', "#tshirtFacing");
                $timeout(function() {
                    element.find("#drawingArea").hover(
                        canvasService.addCanvasBorder,
                        canvasService.removeCanvasBorder
                    );

                    element.find('#flip').click(function() {
                        var flipText = element.find('#flip-text');
                        if (flipText.text()==="Show Back View") {
                            flipText.text('Show Front View');
                            canvasService.flip("img/crew_back.png");
                        } else {
                            flipText.text('Show Back View');
                            canvasService.flip("img/crew_front.png");
                        }
                    });

                    scope.$on('mdeChangeBackground', function(event, color) {
                        element.find("#shirtDiv").css("backgroundColor", color);
                    });
                }, 0);
            }
        };
    }
]);

// currently not used
monadexDirectives.directive('mdBgColorPicker', ['$timeout', 'canvasService',
    function($timeout, canvasService){
        return {
            restrict: 'E',
            scope: {
                colors: '='
            },
            templateUrl: 'partials/tshirt-designer-pages/bg-color-picker.html',
            link: function(scope, element, attrs) {
                $timeout(function() {
                    element.find('.color-preview').on("click", function(){
                        var color = $(this).css("background-color");
                        canvasService.changeBackground(color);
                    });
                }, 0);
            }
        };
    }
]);

monadexDirectives.directive('mdTextInput', ['$timeout', 'canvasService',
    function($timeout, canvasService){
        return {
            restrict: 'E',
            scope: {
                fonts: "="
            },
            templateUrl: 'partials/tshirt-designer-pages/text-input.html',
            link: function(scope, element, attrs) {
                $timeout(function() {
                    element.find('#text-fontcolor').minicolors({
                        change: function(hex) {
                            canvasService.renderActiveTextFontColor(hex);
                        }
                    });

                    element.find("#text-bold").click(
                        canvasService.toggleActiveTextBold
                    );

                    element.find("#text-italic").click(
                        canvasService.toggleActiveTextItalic
                    );

                    element.find("#text-underline").click(
                        canvasService.toggleActiveTextUnderline
                    );

                    element.find("#text-left").click(function() {
                        canvasService.setActiveTextAlignment('left');
                    });

                    element.find("#text-center").click(function() {
                        canvasService.setActiveTextAlignment('center');
                    });

                    element.find("#text-right").click(function() {
                        canvasService.setActiveTextAlignment('right');
                    });

                    element.find(".font-family-picker").change(
                        function(event) {
                            var sclass = ".font-family-picker option:selected",
                                selected = element.find(sclass)[0],
                                font = $(selected).text();

                            canvasService.changeTextFontFamily(font);
                            event.preventDefault();
                        }
                    );

                    element.find("#text-string").keyup(function(e){
                        var text = $(this)[0].value;

                        if(canvasService.activeTextP()) {
                            canvasService.renderActiveTextContent(text);
                        } else if (text != "") {
                            var miniColorValFun = function(sel) {
                                return element.find(sel).minicolors("value");
                            },
                                fontColor = miniColorValFun('#text-fontcolor'),
                                sfClass = ".font-family-picker option:selected",
                                sFontObj = element.find(sfClass)[0],
                                fontFamily = $(sFontObj).text();

                            canvasService.addTextWhenNoActiveText(
                                text, fontColor, fontFamily
                            );
                            canvasService.setTheLastObjActive();
                        }
                    });

                    scope.$on('mdeTextObjectSelected', function(event, props) {
                        element.find("#text-string").val(props.text);

                        element.find('#text-fontcolor').minicolors(
                            'value', props.fontColor
                        );

                        var index = undefined;
                        for(var i=0; i<scope.fonts.length; i++) {
                            if (scope.fonts[i].name.toLowerCase() ==
                                props.fontFamily.toLowerCase()) {
                                index = i;
                            }
                        }

                        element.find(".font-family-picker").val(index || 0);
                    });

                    scope.$on('mdeObjectCleared', function(event) {
                        element.find("#text-string").val("");
                        element.find('#text-fontcolor').minicolors(
                            'value', "#000000"
                        );

                        element.find(".font-family-picker").val(0);
                    });
                }, 0);
            }
        };
    }
]);

monadexDirectives.directive('mdImagePage', ['$timeout', 'canvasService',
    function($timeout, canvasService){
        return {
            restrict: 'E',
            scope: {
                images: "="
            },
            templateUrl: 'partials/tshirt-designer-pages/image-page.html',
            link: function(scope, element, attrs) {
                $timeout(function() {
                    element.find(".img-thumbnail").on("click", function(e){
                        var el = e.target;
                        canvasService.addImage(el.src);
                    });
                }, 0);
            }
        };
    }
]);

monadexDirectives.directive('mdImagePicker',
                            ['$timeout', '$compile', 'canvasService',
    function($timeout, $compile, canvasService){
        return {
            restrict: 'E',
            scope: {
                images: "=",
                popover: '@'
            },
            templateUrl: 'partials/tshirt-designer-pages/image-picker.html',
            link: function(scope, element, attrs) {
                $timeout(function() {
                    element.find('#image-picker').popover({
                        trigger: "focus",
                        html: true,
                        container: 'body',
                        content: function() {
                            // compile the html in popover attributes and set it
                            // as the content of the popover
                            var popoverContent = $compile(scope.popover)(scope);
                            return popoverContent;
                        }
                    });
                }, 0);
            }};
    }
]);
<commit_msg>color picker works after changing variants<commit_after>'use strict';

/* Directives */
var monadexDirectives = angular.module('monadexApp.directives', []);

monadexDirectives.directive('appVersion', ['version',
    function(version) {
        return function(scope, elm, attrs) {
            elm.text(version);
        };
    }
]);

// Style and quality panel let the customer choose the style of the
// t-shirts with various qualities.
monadexDirectives.directive('mdTshirtStyleQualityPanel',
                            ['$timeout', '$compile', 'canvasService',
   function($timeout, $compile, canvasService) {
       return {
           restrict: 'E',
           scope: {
               tshirtTypes: '=',
               baseCost: "=",
               colors: "="
           },
           templateUrl: 'partials/tshirt-designer-pages/tshirt-style-quality-panel.html',
           link: function(scope, element, attrs) {
               $timeout(function() {
                   var initColors =
                           element.find('.tshirt-variant').attr("colors");

                   scope.$apply(function() {
                       scope.colors = eval(initColors);
                   });

                   element.find('.tshirt-variant').click(function() {
                       canvasService.setAvailableBgColors(eval(
                           $(this).attr("colors")
                       ));
                   });

                   scope.$on('mdeBgAvailableColorsChanged', function(e, o) {
                       scope.$apply(function() {
                           scope.colors = o.colors;
                       });
                   });
               }, 0);
           }
       };
   }
]);

monadexDirectives.directive('mdTshirtDesignPanel', ['$timeout',
   function($timeout) {
       return {
           restrict: 'E',
           scope: {
               colors: "=",
               images: '=',
               fonts: "="
           },
           templateUrl: 'partials/tshirt-designer-pages/tshirt-design-panel.html',
           link: function(scope, element) {
               $timeout(function() {
                   element.find(".tab-link").click(function(event) {
                       event.preventDefault();
                   });
               }, 0);
           }
       };
   }
]);

monadexDirectives.directive('mdTshirtCanvas', ['$timeout', 'canvasService',
    function($timeout, canvasService) {
        var canvas;
        return {
            restrict: 'E',
            scope: {
            },
            templateUrl: 'partials/tshirt-designer-pages/tshirt-canvas.html',
            link: function(scope, element, attrs) {
                // initialize the canvasService
                canvasService.init('tcanvas', "#tshirtFacing");
                $timeout(function() {
                    element.find("#drawingArea").hover(
                        canvasService.addCanvasBorder,
                        canvasService.removeCanvasBorder
                    );

                    element.find('#flip').click(function() {
                        var flipText = element.find('#flip-text');
                        if (flipText.text()==="Show Back View") {
                            flipText.text('Show Front View');
                            canvasService.flip("img/crew_back.png");
                        } else {
                            flipText.text('Show Back View');
                            canvasService.flip("img/crew_front.png");
                        }
                    });

                    scope.$on('mdeChangeBackground', function(event, color) {
                        element.find("#shirtDiv").css("backgroundColor", color);
                    });
                }, 0);
            }
        };
    }
]);

// currently not used
monadexDirectives.directive('mdBgColorPicker', ['$timeout', 'canvasService',
    function($timeout, canvasService){
        return {
            restrict: 'E',
            scope: {
                colors: '='
            },
            templateUrl: 'partials/tshirt-designer-pages/bg-color-picker.html',
            link: function(scope, element, attrs) {
                $timeout(function() {
                    scope.$watch("colors", function() {
                        element.find('.color-preview').on("click", function(){
                            var color = $(this).css("background-color");
                            canvasService.changeBackground(color);
                        });
                    });
                }, 0);
            }
        };
    }
]);

monadexDirectives.directive('mdTextInput', ['$timeout', 'canvasService',
    function($timeout, canvasService){
        return {
            restrict: 'E',
            scope: {
                fonts: "="
            },
            templateUrl: 'partials/tshirt-designer-pages/text-input.html',
            link: function(scope, element, attrs) {
                $timeout(function() {
                    element.find('#text-fontcolor').minicolors({
                        change: function(hex) {
                            canvasService.renderActiveTextFontColor(hex);
                        }
                    });

                    element.find("#text-bold").click(
                        canvasService.toggleActiveTextBold
                    );

                    element.find("#text-italic").click(
                        canvasService.toggleActiveTextItalic
                    );

                    element.find("#text-underline").click(
                        canvasService.toggleActiveTextUnderline
                    );

                    element.find("#text-left").click(function() {
                        canvasService.setActiveTextAlignment('left');
                    });

                    element.find("#text-center").click(function() {
                        canvasService.setActiveTextAlignment('center');
                    });

                    element.find("#text-right").click(function() {
                        canvasService.setActiveTextAlignment('right');
                    });

                    element.find(".font-family-picker").change(
                        function(event) {
                            var sclass = ".font-family-picker option:selected",
                                selected = element.find(sclass)[0],
                                font = $(selected).text();

                            canvasService.changeTextFontFamily(font);
                            event.preventDefault();
                        }
                    );

                    element.find("#text-string").keyup(function(e){
                        var text = $(this)[0].value;

                        if(canvasService.activeTextP()) {
                            canvasService.renderActiveTextContent(text);
                        } else if (text != "") {
                            var miniColorValFun = function(sel) {
                                return element.find(sel).minicolors("value");
                            },
                                fontColor = miniColorValFun('#text-fontcolor'),
                                sfClass = ".font-family-picker option:selected",
                                sFontObj = element.find(sfClass)[0],
                                fontFamily = $(sFontObj).text();

                            canvasService.addTextWhenNoActiveText(
                                text, fontColor, fontFamily
                            );
                            canvasService.setTheLastObjActive();
                        }
                    });

                    scope.$on('mdeTextObjectSelected', function(event, props) {
                        element.find("#text-string").val(props.text);

                        element.find('#text-fontcolor').minicolors(
                            'value', props.fontColor
                        );

                        var index = undefined;
                        for(var i=0; i<scope.fonts.length; i++) {
                            if (scope.fonts[i].name.toLowerCase() ==
                                props.fontFamily.toLowerCase()) {
                                index = i;
                            }
                        }

                        element.find(".font-family-picker").val(index || 0);
                    });

                    scope.$on('mdeObjectCleared', function(event) {
                        element.find("#text-string").val("");
                        element.find('#text-fontcolor').minicolors(
                            'value', "#000000"
                        );

                        element.find(".font-family-picker").val(0);
                    });
                }, 0);
            }
        };
    }
]);

monadexDirectives.directive('mdImagePage', ['$timeout', 'canvasService',
    function($timeout, canvasService){
        return {
            restrict: 'E',
            scope: {
                images: "="
            },
            templateUrl: 'partials/tshirt-designer-pages/image-page.html',
            link: function(scope, element, attrs) {
                $timeout(function() {
                    element.find(".img-thumbnail").on("click", function(e){
                        var el = e.target;
                        canvasService.addImage(el.src);
                    });
                }, 0);
            }
        };
    }
]);

monadexDirectives.directive('mdImagePicker',
                            ['$timeout', '$compile', 'canvasService',
    function($timeout, $compile, canvasService){
        return {
            restrict: 'E',
            scope: {
                images: "=",
                popover: '@'
            },
            templateUrl: 'partials/tshirt-designer-pages/image-picker.html',
            link: function(scope, element, attrs) {
                $timeout(function() {
                    element.find('#image-picker').popover({
                        trigger: "focus",
                        html: true,
                        container: 'body',
                        content: function() {
                            // compile the html in popover attributes and set it
                            // as the content of the popover
                            var popoverContent = $compile(scope.popover)(scope);
                            return popoverContent;
                        }
                    });
                }, 0);
            }};
    }
]);
<|endoftext|>


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

'use strict';

// MODULES //

var ceiln = require( '@stdlib/math/base/special/ceiln' );

// MAIN //

/**
* Rounds a complex number to the nearest multiple of `10^n` toward positive infinity.
*
* @private
* @param {(Array|TypedArray|Object)} out - output array
* @param {number} re - real component
* @param {number} im - imaginary component
* @param {integer} n - integer power of 10
* @returns {(Array|TypedArray|Object)} output array
*
* @example
* var v = cceiln( -3.141592653589793, 3.141592653589793, -2 );
* // returns [ -3.14, 3.15 ]
*
* @example
* var out = new Array( 2 );
*
* var v = cceiln( out, 9.99999, 0.1, 0 );
* // returns [ 10.0, 1.0 ]
*
* var bool = ( v === out );
* // returns true
*
* @example
* var v = cceiln( 0.0, 0.0, -2 );
* // returns [ 0.0, 0.0 ]
*
* @example
* var v = cceiln( NaN, NaN, -2 );
* // returns [ NaN, NaN ]
*/
function cceiln( out, re, im, n ) {
	out[ 0 ] = ceiln( re, n );
	out[ 1 ] = ceiln( im, n );
	return out;
}

// EXPORTS //

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

'use strict';

// MODULES //

var ceiln = require( '@stdlib/math/base/special/ceiln' );

// MAIN //

/**
* Rounds a complex number to the nearest multiple of `10^n` toward positive infinity.
*
* @private
* @param {(Array|TypedArray|Object)} out - output array
* @param {number} re - real component
* @param {number} im - imaginary component
* @param {integer} n - integer power of 10
* @returns {(Array|TypedArray|Object)} output array
*
* @example
* var out = new Array( 2 );
* var v = cceiln( out, -3.141592653589793, 3.141592653589793, -2 );
* // returns [ -3.14, 3.15 ]
*
* @example
* var out = new Array( 2 );
* var v = cceiln( out, 9.99999, 0.1, 0 );
* // returns [ 10.0, 1.0 ]
*
* @example
* var out = new Array( 2 );
* var v = cceiln( out, 0.0, 0.0, -2 );
* // returns [ 0.0, 0.0 ]
*
* @example
* var out = new Array( 2 );
* var v = cceiln( out, NaN, NaN, -2 );
* // returns [ NaN, NaN ]
*/
function cceiln( out, re, im, n ) {
	out[ 0 ] = ceiln( re, n );
	out[ 1 ] = ceiln( im, n );
	return out;
}

// EXPORTS //

module.exports = cceiln;
<|endoftext|>


<commit_before>var _ = require('underscore');
var Backbone = require('backbone');
var CoreView = require('backbone/core-view');
var ColorPicker = require('../../color-picker/color-picker');
var template = require('./input-color-picker-view.tpl');
var InputColorPickerHeader = require('./input-color-picker-header');

module.exports = CoreView.extend({
  events: {
    'click .js-back': '_onClickBack'
  },

  initialize: function (opts) {
    if (!opts || !opts.ramp) throw new Error('ramp param is required');
    if (!opts.opacity) throw new Error('opacity is required');

    this.model = new Backbone.Model({
      index: this.options.index,
      ramp: opts.ramp,
      opacity: opts.opacity,
    });

    this.model.bind('change:index', this._onChangeIndex, this);
    this.model.bind('change:opacity', this._onOpacityChanged, this);
  },

  render: function () {
    this.clearSubViews();
    this.$el.empty();

    this._headerView = new InputColorPickerHeader({
      model: this.model,
      iconStylingEnabled: this.options.iconStylingEnabled
    });
    this._headerView.bind('goToAssetPicker', this._onGoToAssetPicker, this);

    this.addView(this._headerView);

    this._colorPicker = new ColorPicker({
      value: this._getColor(),
      opacity: 1,
      disableOpacity: true
    });

    this.addView(this._colorPicker);

    this._colorPicker.bind('change', this._onChangeValue, this);

    this.$el.append(template());

    this.$('.js-header').append(this._headerView.render().$el);
    this.$('.js-content').append(this._colorPicker.render().$el);

    return this;
  },

  _setColor: function (color) {
    var ramp = _.clone(this.model.get('ramp'));
    ramp[this.model.get('index')].color = color;
    this.model.set('ramp', ramp);
    this.model.trigger('change', ramp);
    this.trigger('change', ramp);
  },

  _getColor: function () {
    var ramp = this.model.get('ramp');
    return ramp[this.model.get('index') || 0].color;
  },

  _onChangeIndex: function () {
    this._colorPicker.setColor(this._getColor());
    this.trigger('changeIndex', this.model.get('index'), this);
  },

  _onChangeValue: function (color) {
    this._setColor(color.hex);
  },

  _onClickBack: function (e) {
    this.killEvent(e);
    this.trigger('back', this);
  },

  _onOpacityChanged: function () {
    var opacity = this.model.get('opacity');
    this.trigger('change:opacity', opacity);
  },

  _onGoToAssetPicker: function () {
    this.trigger('goToAssetPicker');
  }
});
<commit_msg>Minor fix<commit_after>var _ = require('underscore');
var Backbone = require('backbone');
var CoreView = require('backbone/core-view');
var ColorPicker = require('../../color-picker/color-picker');
var template = require('./input-color-picker-view.tpl');
var InputColorPickerHeader = require('./input-color-picker-header');

module.exports = CoreView.extend({
  events: {
    'click .js-back': '_onClickBack'
  },

  initialize: function (opts) {
    if (!opts || !opts.ramp) throw new Error('ramp param is required');
    if (!opts.opacity) throw new Error('opacity is required');

    this.model = new Backbone.Model({
      index: this.options.index,
      ramp: opts.ramp,
      opacity: opts.opacity
    });

    this.model.bind('change:index', this._onChangeIndex, this);
    this.model.bind('change:opacity', this._onOpacityChanged, this);
  },

  render: function () {
    this.clearSubViews();
    this.$el.empty();

    this._headerView = new InputColorPickerHeader({
      model: this.model,
      iconStylingEnabled: this.options.iconStylingEnabled
    });
    this._headerView.bind('goToAssetPicker', this._onGoToAssetPicker, this);

    this.addView(this._headerView);

    this._colorPicker = new ColorPicker({
      value: this._getColor(),
      opacity: 1,
      disableOpacity: true
    });

    this.addView(this._colorPicker);

    this._colorPicker.bind('change', this._onChangeValue, this);

    this.$el.append(template());

    this.$('.js-header').append(this._headerView.render().$el);
    this.$('.js-content').append(this._colorPicker.render().$el);

    return this;
  },

  _setColor: function (color) {
    var ramp = _.clone(this.model.get('ramp'));
    ramp[this.model.get('index')].color = color;
    this.model.set('ramp', ramp);
    this.model.trigger('change', ramp);
    this.trigger('change', ramp);
  },

  _getColor: function () {
    var ramp = this.model.get('ramp');
    return ramp[this.model.get('index') || 0].color;
  },

  _onChangeIndex: function () {
    this._colorPicker.setColor(this._getColor());
    this.trigger('changeIndex', this.model.get('index'), this);
  },

  _onChangeValue: function (color) {
    this._setColor(color.hex);
  },

  _onClickBack: function (e) {
    this.killEvent(e);
    this.trigger('back', this);
  },

  _onOpacityChanged: function () {
    var opacity = this.model.get('opacity');
    this.trigger('change:opacity', opacity);
  },

  _onGoToAssetPicker: function () {
    this.trigger('goToAssetPicker');
  }
});
<|endoftext|>


<commit_before>var CloudCmd, Util, DOM, CloudFunc, $;

(function(CloudCmd, Util, DOM, CloudFunc) {
    'use strict';

    CloudCmd.View = ViewProto;

    function ViewProto(CallBack) {
        var Name    = 'View',
            Loading = false,
            Events  = DOM.Events,
            Info    = DOM.CurrentInfo,
            Key     = CloudCmd.Key,
            Images  = DOM.Images,
            View    = Util.exec.bind(Util),
            Element, TemplateAudio, TemplateImage,
            Config      = {
                beforeShow      : function() {
                    Images.hideLoad();
                    Key.unsetBind();
                },
                beforeClose     : Key.setBind,
                fitToView       : true,
                loop            : false,
                openEffect      : 'none',
                closeEffect     : 'none',
                autoSize        : false,
                height          : '100%',
                width           : '100%',
                minWidth        : 0,
                minHeight       : 0,
                padding         : 0
            };

        View.show   = show;
        View.hide   = hide;
        View.rmKeys = rmKeys;

        function rmKeys() {
            /* remove default key binding
             * which is ruin terminal
             */
            $.fancybox.defaults.keys = null;
        }

        function init() {
            var func = CallBack || Util.bind(show, null);

            Loading = true;

            Util.loadOnLoad([
                DOM.jqueryLoad,
                load,
                func
            ]);

            Events.addKey(listener);
        }

        /**
         * function shows FancyBox
         */
        function show(data, callback, newConfig) {
            var path, element, func, name,
                config = {};

            if (!Loading) {
                Element         = $('
');

                if (data) {
                    element    = $(Element).append(data);
                    func       = Util.retExec(callback);

                    Config.afterShow = func;

                    Util.copyObj(config, Config);

                    for (name in newConfig)
                        config[name] = newConfig[name];

                    $.fancybox(element, config);

                } else {
                    Images.showLoad();
                    path   = CloudFunc.FS + Info.path;

                    if (isImage(path)) {
                        config = Util.copyObj({
                            autoSize: true
                        }, Config);

                        $.fancybox.open(path, config);
                    } else if (isMusic(path))
                        getMusicElement(path, function(element) {
                            $.fancybox.open(element, {
                                beforeShow: musicBeforeShow
                            });
                        });
                    else
                        Info.getData(function(data) {
                            var element = document.createTextNode(data);
                            /* add margin only for view text documents */
                            Element.css('margin', '2%');

                            $.fancybox(Element.append(element), Config);
                        });
                }
            }
        }

        function hide() {
            $.fancybox.close();
        }

        function isImage(name) {
            var isMatch = $.fancybox.isImage(name);

            return isMatch;
        }

        function isMusic(name) {
            var isMatch,
                isStr       = Util.isString(name),
                exts        = '.mp3|.mp4',
                extsReg     = new RegExp(exts);

            if (isStr)
                isMatch     = name.match(extsReg);

            return isMatch;
        }

        function getMusicElement(src, callback) {
            CloudCmd.getTemplate(TemplateAudio, 'view/audio', function(template) {
                var rendered, element;

                if (!TemplateAudio)
                    TemplateAudio   = template;

                rendered    = Util.render(TemplateAudio, {
                    src: src,
                    name: Info.name
                });

                element     = $(rendered);

                Util.exec(callback, element);
            });
        }

        function musicBeforeShow() {
            var audioDiv    = $('#js-audio'),
                audio       = audioDiv.find('audio'),
                width       = audio.width() +'px';

            audioDiv.width(width);

            Images.hideLoad();
        }

        /**
         * function loads css and js of FancyBox
         * @callback   -  executes, when everything loaded
         */
        function load(callback) {
            var dir    = CloudCmd.LIBDIRCLIENT + 'view/fancyBox/source/',
                files  = [
                    dir + 'jquery.fancybox.css',
                    dir + 'jquery.fancybox.js'
                ];

            Util.time(Name + ' load');

            DOM.anyLoadOnLoad([files], function() {
                Util.timeEnd(Name + ' load');
                Loading = false;
                Util.exec(callback);
                Images.hideLoad();
            })
            .cssSet({id:'view-css',
                inner : '#view {'                               +
                            'font-size: 16px;'                  +
                            'white-space :pre;'                 +
                            'outline: 0;'                       +
                        '}'                                     +
                        '#view::selection {'                    +
                            /*
                                'background: #fe57a1;'
                                'color: #fff;'
                            */
                            'background: #b3d4fc;'              +
                            'text-shadow: none;'                +
                        '}'                                     +
                        '#fancybox-loading div {'               +
                            'background: none;'                 +
                            'width: 0;'                         +
                            'height: 0'                         +
                        '}'                                     +
                        '.fancybox-overlay {'                   +
                            'background: rgba(255, 255, 255, 0.1)' +
                        '}'                                     +
                        '.fancybox-lock .fancybox-overlay {'    +
                            'overflow-y: hidden'                +
                        '}'
            });

        }

        function view() {
            Images.showLoad();
            View.show();
        }

        function listener(event) {
            var keyCode = event.keyCode,
                ESC     = Key.ESC;

            if (keyCode === ESC)
                hide();
        }

        init();

        return View;
    }

})(CloudCmd, Util, DOM, CloudFunc);
<commit_msg>feature(view) add preload:0<commit_after>var CloudCmd, Util, DOM, CloudFunc, $;

(function(CloudCmd, Util, DOM, CloudFunc) {
    'use strict';

    CloudCmd.View = ViewProto;

    function ViewProto(CallBack) {
        var Name    = 'View',
            Loading = false,
            Events  = DOM.Events,
            Info    = DOM.CurrentInfo,
            Key     = CloudCmd.Key,
            Images  = DOM.Images,
            View    = Util.exec.bind(Util),
            Element, TemplateAudio, TemplateImage,
            Config      = {
                beforeShow      : function() {
                    Images.hideLoad();
                    Key.unsetBind();
                },
                beforeClose     : Key.setBind,
                fitToView       : true,
                loop            : false,
                openEffect      : 'none',
                closeEffect     : 'none',
                autoSize        : false,
                height          : '100%',
                width           : '100%',
                minWidth        : 0,
                minHeight       : 0,
                padding         : 0,
                preload         : 0
            };

        View.show   = show;
        View.hide   = hide;
        View.rmKeys = rmKeys;

        function rmKeys() {
            /* remove default key binding
             * which is ruin terminal
             */
            $.fancybox.defaults.keys = null;
        }

        function init() {
            var func = CallBack || Util.bind(show, null);

            Loading = true;

            Util.loadOnLoad([
                DOM.jqueryLoad,
                load,
                func
            ]);

            Events.addKey(listener);
        }

        /**
         * function shows FancyBox
         */
        function show(data, callback, newConfig) {
            var path, element, func, name,
                config = {};

            if (!Loading) {
                Element         = $('
');

                if (data) {
                    element    = $(Element).append(data);
                    func       = Util.retExec(callback);

                    Config.afterShow = func;

                    Util.copyObj(config, Config);

                    for (name in newConfig)
                        config[name] = newConfig[name];

                    $.fancybox(element, config);

                } else {
                    Images.showLoad();
                    path   = CloudFunc.FS + Info.path;

                    if (isImage(path)) {
                        config = Util.copyObj({
                            autoSize: true
                        }, Config);

                        $.fancybox.open(path, config);
                    } else if (isMusic(path))
                        getMusicElement(path, function(element) {
                            $.fancybox.open(element, {
                                beforeShow: musicBeforeShow
                            });
                        });
                    else
                        Info.getData(function(data) {
                            var element = document.createTextNode(data);
                            /* add margin only for view text documents */
                            Element.css('margin', '2%');

                            $.fancybox(Element.append(element), Config);
                        });
                }
            }
        }

        function hide() {
            $.fancybox.close();
        }

        function isImage(name) {
            var isMatch = $.fancybox.isImage(name);

            return isMatch;
        }

        function isMusic(name) {
            var isMatch,
                isStr       = Util.isString(name),
                exts        = '.mp3|.mp4',
                extsReg     = new RegExp(exts);

            if (isStr)
                isMatch     = name.match(extsReg);

            return isMatch;
        }

        function getMusicElement(src, callback) {
            CloudCmd.getTemplate(TemplateAudio, 'view/audio', function(template) {
                var rendered, element;

                if (!TemplateAudio)
                    TemplateAudio   = template;

                rendered    = Util.render(TemplateAudio, {
                    src: src,
                    name: Info.name
                });

                element     = $(rendered);

                Util.exec(callback, element);
            });
        }

        function musicBeforeShow() {
            var audioDiv    = $('#js-audio'),
                audio       = audioDiv.find('audio'),
                width       = audio.width() +'px';

            audioDiv.width(width);

            Images.hideLoad();
        }

        /**
         * function loads css and js of FancyBox
         * @callback   -  executes, when everything loaded
         */
        function load(callback) {
            var dir    = CloudCmd.LIBDIRCLIENT + 'view/fancyBox/source/',
                files  = [
                    dir + 'jquery.fancybox.css',
                    dir + 'jquery.fancybox.js'
                ];

            Util.time(Name + ' load');

            DOM.anyLoadOnLoad([files], function() {
                Util.timeEnd(Name + ' load');
                Loading = false;
                Util.exec(callback);
                Images.hideLoad();
            })
            .cssSet({id:'view-css',
                inner : '#view {'                               +
                            'font-size: 16px;'                  +
                            'white-space :pre;'                 +
                            'outline: 0;'                       +
                        '}'                                     +
                        '#view::selection {'                    +
                            /*
                                'background: #fe57a1;'
                                'color: #fff;'
                            */
                            'background: #b3d4fc;'              +
                            'text-shadow: none;'                +
                        '}'                                     +
                        '#fancybox-loading div {'               +
                            'background: none;'                 +
                            'width: 0;'                         +
                            'height: 0'                         +
                        '}'                                     +
                        '.fancybox-overlay {'                   +
                            'background: rgba(255, 255, 255, 0.1)' +
                        '}'                                     +
                        '.fancybox-lock .fancybox-overlay {'    +
                            'overflow-y: hidden'                +
                        '}'
            });

        }

        function view() {
            Images.showLoad();
            View.show();
        }

        function listener(event) {
            var keyCode = event.keyCode,
                ESC     = Key.ESC;

            if (keyCode === ESC)
                hide();
        }

        init();

        return View;
    }

})(CloudCmd, Util, DOM, CloudFunc);
<|endoftext|>


<commit_before>import test from 'tape'
import { shallow } from 'enzyme'
import React from 'react'

test('<App /> with no props should throw no errors', t => {
  const App = require('./app').default
  t.doesNotThrow(() => {
    shallow(<App />)
  })
  t.end()
})
test('<App /> has a DevTools element in development', t => {
  const App = require('./app.dev').default
  const wrapper = shallow(<App />)
  t.is(wrapper.find('DevTools').length, 1)
  t.end()
})
test('<App /> has no DevTools element in production', t => {
  const App = require('./app.prod').default
  const wrapper = shallow(<App />)
  t.is(wrapper.find('DevTools').length, 0)
  t.end()
})
<commit_msg>Pass typecheck<commit_after>// @flow

import test from 'tape'
import { shallow } from 'enzyme'
import React from 'react'

test('<App /> has a DevTools element in development', t => {
  const App = require('./app.dev').default
  const wrapper = shallow(<App {...({}: any)} />)
  t.is(wrapper.find('DevTools').length, 1)
  t.end()
})
test('<App /> has no DevTools element in production', t => {
  const App = require('./app.prod').default
  const wrapper = shallow(<App {...({}: any)} />)
  t.is(wrapper.find('DevTools').length, 0)
  t.end()
})
<|endoftext|>


<commit_before>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2021
 */

/**
 * Helper methods to perform data access functionality for breach calculations
 */
import { VACCINE_ENTITIES } from '../utilities/modules/vaccines/constants';

export class VaccineDataAccess {
  constructor(dbService) {
    this.db = dbService;
  }

  getTemperatureLogsFrom = (sensorId, timeToCheckFrom) =>
    this.db
      .objects(VACCINE_ENTITIES.TEMPERATURE_LOG)
      .filtered('sensor.id == $0 AND timestamp >= $1', sensorId, timeToCheckFrom)
      .sorted('timestamp');

  getMostRecentBreachLog = sensorId => {
    const allBreachLogs = this.db
      .objects(VACCINE_ENTITIES.TEMPERATURE_LOG)
      .filtered('sensor.id == $0 AND breach != null', sensorId);
    const [mostRecentBreachLog] = allBreachLogs.sorted('timestamp', true);

    return mostRecentBreachLog;
  };

  getMostRecentBreach = sensorId => {
    const allBreaches = this.db
      .objects(VACCINE_ENTITIES.TEMPERATURE_BREACH)
      .filtered('sensorId == $0', sensorId);
    const [mostRecentBreach] = allBreaches.sorted('startTimestamp', true);

    return mostRecentBreach;
  };

  getBreachConfigs = () => {
    const configs = this.db
      .objects(VACCINE_ENTITIES.TEMPERATURE_BREACH_CONFIGURATION)
      .filtered('type == "HOT_CONSECUTIVE" OR type == "COLD_CONSECUTIVE"');
    return configs;
  };

  upsertBreaches = breaches =>
    this.db.write(() => {
      this.db.update(VACCINE_ENTITIES.TEMPERATURE_BREACH, breaches);
    });

  upsertTemperatureLog = temperatureLogs =>
    this.db.write(() => {
      this.db.update(VACCINE_ENTITIES.TEMPERATURE_LOG, temperatureLogs);
    });
}
<commit_msg>VaccineDataAccess needs to use loop; realm.update doesn't accept arrays of objects<commit_after>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2021
 */

/**
 * Helper methods to perform data access functionality for breach calculations
 */
import { VACCINE_ENTITIES } from '../utilities/modules/vaccines/constants';

export class VaccineDataAccess {
  constructor(dbService) {
    this.db = dbService;
  }

  getTemperatureLogsFrom = (sensorId, timeToCheckFrom) =>
    this.db
      .objects(VACCINE_ENTITIES.TEMPERATURE_LOG)
      .filtered('sensor.id == $0 AND timestamp >= $1', sensorId, timeToCheckFrom)
      .sorted('timestamp');

  getMostRecentBreachLog = sensorId => {
    const allBreachLogs = this.db
      .objects(VACCINE_ENTITIES.TEMPERATURE_LOG)
      .filtered('sensor.id == $0 AND breach != null', sensorId);
    const [mostRecentBreachLog] = allBreachLogs.sorted('timestamp', true);

    return mostRecentBreachLog;
  };

  getMostRecentBreach = sensorId => {
    const allBreaches = this.db
      .objects(VACCINE_ENTITIES.TEMPERATURE_BREACH)
      .filtered('sensorId == $0', sensorId);
    const [mostRecentBreach] = allBreaches.sorted('startTimestamp', true);

    return mostRecentBreach;
  };

  getBreachConfigs = () => {
    const configs = this.db
      .objects(VACCINE_ENTITIES.TEMPERATURE_BREACH_CONFIGURATION)
      .filtered('type == "HOT_CONSECUTIVE" OR type == "COLD_CONSECUTIVE"');
    return configs;
  };

  upsertBreaches = breaches =>
    this.db.write(() => {
      breaches.forEach(breach => {
        this.db.update(VACCINE_ENTITIES.TEMPERATURE_BREACH, breach);
      });
    });

  upsertTemperatureLog = temperatureLogs =>
    this.db.write(() => {
      temperatureLogs.forEach(log => {
        this.db.update(VACCINE_ENTITIES.TEMPERATURE_LOG, log);
      });
    });
}
<|endoftext|>


<commit_before>'use strict';

var window = require("global/window"),
	document = require('global/document'),
	hg = require('mercury'),
	h = require('mercury').h,
	chart0 = require('./chart0.js');
// https://github.com/trueadm/t7

var chart = new chart0("#chart");

function nextStep(state){
	state.step.set(state.step() + 1);
}

function App(){
	return hg.state({
		step : hg.value(0),
		channels : {
			clicks : nextStep
		}
	});
}

App.renderChart = function renderChart(state){

	if(state.step === 0) {
		return h("div");
	}
	else if(state.step === 1){
		return h("div", {'className' : 'chart'});
	}
	else {
		return h("div");
	}
}

App.renderText = function renderText(state){

	var contents =  [
		h("h1", {'id': 'title', 'className' : 'hero-heading'},
		[
			h("strong", "SEVENTY"),
			h("span", "SEVEN"),
			h("strong", "CENTS")
		]),
		h("p", ["Seventy seven cents per dollar is frequently cited as the gender based wage gap in America. This site empowers you to explore the data",
			h("sup", "1"),
			" for yourself."])
	];

	if(state.step === 0) {
		contents.push(h("button", {'id': 'start', 'className' : 'button', 'ev-click': hg.send(state.channels.clicks)}, "Explore"));
		return h("div", contents);
	}
	else if(state.step === 1){
		return h("div", contents);
	}
	else {
		return "";
	}
}

var state = App();

// DOM interaction
window.SSC = {};
window.SSC.state = state;
window.SSC.hg = hg;

hg.app(document.body.querySelector("#text-container"), state, App.renderText);
//hg.app(document.body.querySelector("#chart-container"), state, App.renderChart);
chart.show();
<commit_msg>tweak wording<commit_after>'use strict';

var window = require("global/window"),
	document = require('global/document'),
	hg = require('mercury'),
	h = require('mercury').h,
	chart0 = require('./chart0.js');
// https://github.com/trueadm/t7

var chart = new chart0("#chart");

function nextStep(state){
	state.step.set(state.step() + 1);
}

function App(){
	return hg.state({
		step : hg.value(0),
		channels : {
			clicks : nextStep
		}
	});
}

App.renderChart = function renderChart(state){

	if(state.step === 0) {
		return h("div");
	}
	else if(state.step === 1){
		return h("div", {'className' : 'chart'});
	}
	else {
		return h("div");
	}
}

App.renderText = function renderText(state){

	var contents =  [
		h("h1", {'id': 'title', 'className' : 'hero-heading'},
		[
			h("strong", "SEVENTY"),
			h("span", "SEVEN"),
			h("strong", "CENTS")
		]),
		h("p", ["Seventy seven cents per dollar is often cited as the gender based wage gap in America. This site empowers you to explore the data",
			h("sup", "1"),
			" for yourself."])
	];

	if(state.step === 0) {
		contents.push(h("button", {'id': 'start', 'className' : 'button', 'ev-click': hg.send(state.channels.clicks)}, "Explore"));
		return h("div", contents);
	}
	else if(state.step === 1){
		return h("div", contents);
	}
	else {
		return "";
	}
}

var state = App();

// DOM interaction
window.SSC = {};
window.SSC.state = state;
window.SSC.hg = hg;

hg.app(document.body.querySelector("#text-container"), state, App.renderText);
//hg.app(document.body.querySelector("#chart-container"), state, App.renderChart);
chart.show();
<|endoftext|>