Skip to content

Instantly share code, notes, and snippets.

@Schonhoffer
Created October 9, 2012 17:03
Show Gist options
  • Save Schonhoffer/3860063 to your computer and use it in GitHub Desktop.
Save Schonhoffer/3860063 to your computer and use it in GitHub Desktop.
WDBC
[Bb]in
ClientBin
[Oo]bj
build
*.suo
Log
_ReSharper.*
*.user
*.sln.cache
*.swp
*.vssscc
*.vspscc
*.build.*
*.orig
*~
.idea/
release/
.sass-cache/
/*.dotCover
*.ncrunchsolution
*.sln
*.csproj
*.d.ts
*.ts
@charset 'utf-8';
body
{
font-family: 'Segoe UI', sans-serif;
}
span {
font-style: italic;
}
var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
}
var WDBC;
(function (WDBC) {
(function (Models) {
var Bicylce = (function () {
function Bicylce(numFrontGears, numBackGears) {
this._currentFrontGear = 1;
this._currentBackGear = 1;
this._numFrontGears = this.clipToRange(numFrontGears, 1, Bicylce.maxNumGears);
this._numBackGears = this.clipToRange(numBackGears, 1, Bicylce.maxNumGears);
}
Bicylce.maxNumGears = 100;
Bicylce.prototype.clipToRange = function (value, minValue, maxValue) {
return _.max([
_.min([
value,
maxValue
]),
minValue
]);
};
Bicylce.prototype.getCurrentBackGear = function () {
return this._currentBackGear;
};
Bicylce.prototype.setCurrentBackGear = function (value) {
this._currentBackGear = this.clipToRange(value, 1, this._numBackGears);
};
Bicylce.prototype.getCurrentFrontGear = function () {
return this._currentBackGear;
};
Bicylce.prototype.setCurrentFrontGear = function (value) {
this._currentFrontGear = this.clipToRange(value, 1, this._numFrontGears);
};
return Bicylce;
})();
Models.Bicylce = Bicylce;
var RoadBike = (function (_super) {
__extends(RoadBike, _super);
function RoadBike(numFrontGears, numBackGears) {
_super.call(this, numFrontGears, numBackGears);
}
RoadBike.prototype.leetHax = function () {
_super.prototype.setCurrentBackGear.call(this, Bicylce.maxNumGears);
_super.prototype.setCurrentFrontGear.call(this, Bicylce.maxNumGears);
};
return RoadBike;
})(Bicylce);
Models.RoadBike = RoadBike;
var BicylceThief = (function () {
function BicylceThief() {
this.stolenBikes = [];
this.money = 0;
}
BicylceThief.prototype.steal = function (bike) {
this.stolenBikes.push(bike);
};
BicylceThief.prototype.fence = function () {
var _this = this;
_.each(this.stolenBikes, function (bike) {
_this.money += 100;
});
this.stolenBikes = [];
};
return BicylceThief;
})();
Models.BicylceThief = BicylceThief;
})(WDBC.Models || (WDBC.Models = {}));
var Models = WDBC.Models;
})(WDBC || (WDBC = {}));
var WDBC;
(function (WDBC) {
function main() {
var myBike = new WDBC.Models.RoadBike(3, 6);
var $content = $('#content');
myBike.setCurrentBackGear(5);
$content.html(myBike.getCurrentBackGear().toString());
}
WDBC.main = main;
})(WDBC || (WDBC = {}));
$(WDBC.main);
<!DOCTYPE HTML>
<html>
<head>
<title>WDBC Sandbox</title>
<link rel="stylesheet" href="app.css" type="text/css" />
<script type="text/javascript">
'use strict';
</script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.1/underscore-min.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<script type="text/javascript">
</script>
</head>
<body>
<div id="content">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment