Skip to content

Commit c1ca7d2

Browse files
committed
First swath of chapter 12 examples
1 parent 40c7602 commit c1ca7d2

File tree

8 files changed

+109
-0
lines changed

8 files changed

+109
-0
lines changed

‎Chapter 12/arrow.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
varPages;
2+
(function(Pages){
3+
varLoginPage=(function(){
4+
functionLoginPage(container){
5+
var_this=this;
6+
container.on("click",".login-link",function(item){
7+
_this.login();
8+
});
9+
container.on("click",".login-link",function(item){
10+
this.login();
11+
});
12+
}
13+
LoginPage.prototype.login=function(){
14+
console.log("logged in");
15+
};
16+
returnLoginPage;
17+
})();
18+
Pages.LoginPage=LoginPage;
19+
})(Pages||(Pages={}));

‎Chapter 12/arrow.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Pages{
2+
exportclassLoginPage{
3+
constructor(container: JQuery){
4+
container.on("click",".login-link",(item)=>{
5+
this.login();
6+
});
7+
container.on("click",".login-link",function(item){
8+
this.login();
9+
});
10+
}
11+
12+
login(){
13+
console.log("logged in");
14+
}
15+
}
16+
}

‎Chapter 12/castle.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
varCastle=(function(){
2+
functionCastle(name){
3+
this.name=name;
4+
}
5+
Castle.prototype.Build=function(){
6+
console.log("Castle built: "+this.name);
7+
};
8+
returnCastle;
9+
})();

‎Chapter 12/castle.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
classCastle{
2+
constructor(publicname){
3+
}
4+
publicBuild(){
5+
console.log("Castle built: "+this.name);
6+
}
7+
}

‎Chapter 12/castle2.js‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var__extends=this.__extends||function(d,b){
2+
for(varpinb)if(b.hasOwnProperty(p))d[p]=b[p];
3+
function__(){this.constructor=d;}
4+
__.prototype=b.prototype;
5+
d.prototype=new__();
6+
};
7+
varWestros;
8+
(function(Westros){
9+
(function(Buildings){
10+
varBaseStructure=(function(){
11+
functionBaseStructure(){
12+
console.log("Structure built");
13+
}
14+
returnBaseStructure;
15+
})();
16+
Buildings.BaseStructure=BaseStructure;
17+
18+
varCastle=(function(_super){
19+
__extends(Castle,_super);
20+
functionCastle(name){
21+
_super.call(this);
22+
this.name=name;
23+
}
24+
Castle.prototype.Build=function(){
25+
console.log("Castle built: "+this.name);
26+
};
27+
returnCastle;
28+
})(BaseStructure);
29+
Buildings.Castle=Castle;
30+
})(Westros.Buildings||(Westros.Buildings={}));
31+
varBuildings=Westros.Buildings;
32+
})(Westros||(Westros={}));

‎Chapter 12/castle2.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Westros.Buildings{
2+
exportclassBaseStructure{
3+
constructor(){
4+
console.log("Structure built");
5+
}
6+
}
7+
8+
exportclassCastleextendsBaseStructure{
9+
constructor(publicname){
10+
super();
11+
}
12+
publicBuild(){
13+
console.log("Castle built: "+this.name);
14+
}
15+
}
16+
}

‎Chapter 12/typescript1.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
varnumbers=[];
2+
numbers.push(7);
3+
numbers.push(9);
4+
varunknown=numbers.pop();
5+
console.log(unknown.substr(0,1));

‎Chapter 12/typescript1.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
varnumbers: Array<number>=[];
2+
numbers.push(7);
3+
numbers.push(9);
4+
varunknown=numbers.pop();
5+
console.log(unknown.substr(0,1));

0 commit comments

Comments
(0)