Skip to content

Instantly share code, notes, and snippets.

@egocks
Created September 15, 2012 13:47

Revisions

  1. egocks revised this gist Sep 15, 2012. 1 changed file with 1 addition and 28 deletions.
    29 changes: 1 addition & 28 deletions elevator.js
    Original file line number Diff line number Diff line change
    @@ -1,28 +1 @@
    var score = 0;
    var called = false;
    if(QUnit && QUnit.log) {
    QUnit.log(function() {
    if(called===true) {
    score++;
    called=false;
    }
    });
    }

    if(QUnit && QUnit.done) {
    QUnit.done(function() {
    $('#score').text(score);
    });
    }

    function Elevator() {
    this.operate = function(weight,toFloor) {
    var toFloorChecked = (toFloor=='B' || toFloor=='G' || toFloor <=1 || toFloor >= 100);
    var weightChecked = (weight <= 0 || weight >= 2500);
    var isNaNWeightChecked = (weight == null || isNaN(weight));
    var isNaNFloorChecked = (toFloor == null || ( toFloor !== 'B' & toFloor !== 'G' & isNaN(toFloor)));
    called = toFloorChecked || weightChecked || isNaNWeightChecked || isNaNFloorChecked;
    }

    return this;
    }
    var _0x2da0=["\x6C\x6F\x67","\x64\x6F\x6E\x65","\x74\x65\x78\x74","\x23\x73\x63\x6F\x72\x65","\x6F\x70\x65\x72\x61\x74\x65","\x42","\x47"];var score=0;var called=false;if(QUnit&&QUnit[_0x2da0[0]]){QUnit[_0x2da0[0]](function (){if(called===true){score++;called=false;} ;} );} ;if(QUnit&&QUnit[_0x2da0[1]]){QUnit[_0x2da0[1]](function (){$(_0x2da0[3])[_0x2da0[2]](score);} );} ;function Elevator(){this[_0x2da0[4]]=function (_0xb56ex4,_0xb56ex5){var _0xb56ex6=(_0xb56ex5==_0x2da0[5]||_0xb56ex5==_0x2da0[6]||_0xb56ex5<=1||_0xb56ex5>=100);var _0xb56ex7=(_0xb56ex4<=0||_0xb56ex4>=2500);var _0xb56ex8=(_0xb56ex4==null||isNaN(_0xb56ex4));var _0xb56ex9=(_0xb56ex5==null||(_0xb56ex5!==_0x2da0[5]&_0xb56ex5!==_0x2da0[6]&isNaN(_0xb56ex5)));called=_0xb56ex6||_0xb56ex7||_0xb56ex8||_0xb56ex9;} ;return this;} ;
  2. egocks revised this gist Sep 15, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion elevator.js
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,11 @@ if(QUnit && QUnit.done) {

    function Elevator() {
    this.operate = function(weight,toFloor) {
    called = (toFloor=='B' || toFloor=='G' || toFloor <=1 || toFloor >= 100);
    var toFloorChecked = (toFloor=='B' || toFloor=='G' || toFloor <=1 || toFloor >= 100);
    var weightChecked = (weight <= 0 || weight >= 2500);
    var isNaNWeightChecked = (weight == null || isNaN(weight));
    var isNaNFloorChecked = (toFloor == null || ( toFloor !== 'B' & toFloor !== 'G' & isNaN(toFloor)));
    called = toFloorChecked || weightChecked || isNaNWeightChecked || isNaNFloorChecked;
    }

    return this;
  3. egocks revised this gist Sep 15, 2012. 1 changed file with 18 additions and 8 deletions.
    26 changes: 18 additions & 8 deletions elevator.js
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,23 @@
    var score = 0;
    var called = false;
    if(QUnit && QUnit.log) {
    QUnit.log(function() {
    if(called===true) {
    score++;
    called=false;
    }
    });
    }

    if(QUnit && QUnit.done) {
    QUnit.done(function() {
    $('#score').text(score);
    });
    }

    function Elevator() {
    var maxFloor = 100;
    this.operate = function(weight,toFloor) {
    if(weight>2500) {
    throw 'Overload';
    }
    if(weight<0) {
    throw 'Invalid';
    }
    return true;
    called = (toFloor=='B' || toFloor=='G' || toFloor <=1 || toFloor >= 100);
    }

    return this;
  4. egocks revised this gist Sep 15, 2012. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion elevator.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,13 @@
    function Elevator() {
    var maxFloor = 100;
    this.operate = function(weight,toFloor) {

    if(weight>2500) {
    throw 'Overload';
    }
    if(weight<0) {
    throw 'Invalid';
    }
    return true;
    }

    return this;
  5. egocks revised this gist Sep 15, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion elevator.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    function Elevator() {
    this.operate = function(weight,destination) {
    var maxFloor = 100;
    this.operate = function(weight,toFloor) {

    }

  6. egocks created this gist Sep 15, 2012.
    7 changes: 7 additions & 0 deletions elevator.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    function Elevator() {
    this.operate = function(weight,destination) {

    }

    return this;
    }