Skip to content

Commit b81638d

Browse files
authored
Merge pull request #1 from eidng8/dev
* migrate to es5
2 parents 450e772 + f4bf295 commit b81638d

File tree

32 files changed

+14651
-282
lines changed

32 files changed

+14651
-282
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33

44
.idea/
55
node_modules/
6-
www/build/
76
platforms/*/
87
plugins/*/
98
typings/
9+
www/build/
10+
11+
app/**/*.js
12+
1013
*.swp
1114
.DS_Store
1215
Thumbs.db
16+

app/app.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {CrewProvider} from './providers/crew';
77
import {MissionProvider} from './providers/missions';
88
import {Home} from './pages/home/home';
99
import {MissionList} from './pages/mission-list/mission-list';
10+
import {TitleCase} from './pipes/titlecase';
1011

1112
@Component(
1213
{
@@ -35,9 +36,11 @@ class MyApp
3536
// used for an example of ngFor and navigation
3637
this.pages = [
3738
{
38-
component: CrewList, title: 'Crew List',
39+
component: CrewList,
40+
title: 'Crew List',
3941
}, {
40-
component: MissionList, title: 'Mission List',
42+
component: MissionList,
43+
title: 'Mission List',
4144
},
4245
];
4346

@@ -50,7 +53,7 @@ class MyApp
5053
() =>
5154
{
5255
// tslint:disable-next-line:no-string-literal
53-
if('object' == typeof window['cordova'])
56+
if('object' == typeof (<any>window).cordova)
5457
{
5558
// okay, so the platform is ready and our
5659
// plugins are available. here you can do
@@ -69,4 +72,8 @@ class MyApp
6972
}
7073
}
7174

72-
ionicBootstrap(MyApp, [DataService, CrewProvider, MissionProvider]);
75+
ionicBootstrap(
76+
MyApp,
77+
[
78+
DataService, CrewProvider, MissionProvider, TitleCase,
79+
]);

app/components/crew-item/crew-item.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
<ion-item [crew]="crew">
2-
<ion-thumbnail item-left
3-
class="star star-{{ crew.stars }} {{ unlock ? 'unlock' : '' }}">
2+
<ion-thumbnail
3+
item-left
4+
class="star star-{{ crew.stars }} {{ unlock ? 'unlock' : '' }}">
45
<img src="http://startrektimelineswiki.com{{ crew.picture }}">
56
</ion-thumbnail>
67

78
<h2>{{ crew.name }}</h2>
89

9-
<skill-item *ngIf="skill" class="skills single" [name]="skill"
10-
[value]="crew[skill][crew[skill].length - 1][crew[skill][crew[skill].length - 1].length - 1]">
10+
<skill-item
11+
*ngIf="skill" class="skills single" [name]="skill"
12+
[value]="crew.skillValue(skill)">
1113
</skill-item>
1214

1315
<p *ngIf="!skill" class="skills">
14-
<span *ngFor="let skill of skills">
15-
<skill-item *ngIf="crew[skill].length" [name]="skill"
16-
[value]="crew[skill][crew[skill].length - 1][crew[skill][crew[skill].length - 1].length - 1]">
16+
<span *ngFor="let skill of crew.possessing">
17+
<skill-item
18+
[name]="skill"
19+
[value]="crew.skillValue(skill)">
1720
</skill-item>
1821
</span>
1922
</p>

app/components/crew-item/crew-item.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*/
44

55
import {Component, Input} from '@angular/core';
6-
import {ICrew, SKILLS} from '../../interface/crew';
76
import {SkillItem} from '../skill-item/skill-item';
7+
import {CrewMember} from '../../models/crew';
88

99
@Component(
1010
{
@@ -15,24 +15,30 @@ import {SkillItem} from '../skill-item/skill-item';
1515
export class CrewItem
1616
{
1717
// tslint:disable:no-unused-variable
18-
@Input() private crew:ICrew;
18+
@Input() private crew:CrewMember;
19+
20+
// noinspection JSUnusedLocalSymbols
1921
@Input() private skill:string;
22+
23+
// noinspection JSUnusedLocalSymbols
2024
@Input() private unlock:boolean;
2125

22-
private skills:string[] = SKILLS.list.abbr;
26+
// private skills:string[] = SKILLS.list.abbr;
2327
// tslint:enable:no-unused-variable
2428

25-
private skillValue:number;
29+
// private skillValue:number;
2630

2731
private ngOnInit():void
2832
{
29-
if(!this.skill)
30-
{
31-
return;
32-
}
33-
34-
let val:any = this.crew[this.skill];
35-
val = val[val.length - 1];
36-
this.skillValue = val[val.length - 1];
33+
/*
34+
if(!this.skill)
35+
{
36+
return;
37+
}
38+
39+
let val:any = this.crew[this.skill];
40+
val = val[val.length - 1];
41+
this.skillValue = val[val.length - 1];
42+
*/
3743
}
3844
}

app/components/list/collapsible.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,27 @@ export class Collapsible
3030
// instead of the list itself.
3131
// just to remember, event registration can't be done in constructor,
3232
// due to the fact that the HTML template is not processed yet.
33-
this.elem.nativeElement.getElementsByTagName('ion-list-header')[0]
34-
.addEventListener(
35-
'click', (evt:Event) =>
36-
{
37-
evt.preventDefault();
38-
evt.stopPropagation();
39-
40-
if(this.elem.nativeElement.classList.contains(CLASS_NAME))
33+
let header:HTMLElement =
34+
this.elem.nativeElement.getElementsByTagName('ion-list-header')[0];
35+
if(header)
36+
{
37+
header
38+
.addEventListener(
39+
'click', (evt:Event) =>
4140
{
42-
this.expend();
43-
}
44-
else
45-
{
46-
this.collapse();
47-
}
48-
});
41+
evt.preventDefault();
42+
evt.stopPropagation();
43+
44+
if(this.elem.nativeElement.classList.contains(CLASS_NAME))
45+
{
46+
this.expend();
47+
}
48+
else
49+
{
50+
this.collapse();
51+
}
52+
});
53+
}
4954
}
5055

5156
private collapse():void

app/components/mission-item/mission-item.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import {Component, Input} from '@angular/core';
6-
import {IMission} from '../../interface/mission';
6+
import {IMission} from '../../interfaces/db/mission';
77
import {SkillItem} from '../skill-item/skill-item';
88

99
@Component(

app/interface/crew.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

app/interfaces/crew.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Created by JC on 2016-07-09.
3+
*/
4+
5+
import {IBaseData} from './base-data';
6+
7+
/**
8+
* List of skill abbreviations
9+
*/
10+
export const SKILLS:string[] = ['cmd', 'dip', 'eng', 'med', 'sci', 'sec'];
11+
12+
/**
13+
* List of skill names
14+
*/
15+
export const SKILL_NAMES:string[] = [
16+
'command', 'diplomacy', 'engineering', 'medicine', 'science', 'security',
17+
];
18+
19+
/**
20+
* All skill arrays are 2-dimensional, with first as star, and second as level.
21+
*/
22+
export interface ISkills
23+
{
24+
cmd?:number[][];
25+
dip?:number[][];
26+
eng?:number[][];
27+
med?:number[][];
28+
sci?:number[][];
29+
sec?:number[][];
30+
}
31+
32+
/**
33+
* Crew member data. It was originally called ICrew, and changed to current
34+
* name to avoid confusion. The word `crew` is plural while this piece of data
35+
* represents only a single crew member.
36+
*/
37+
export interface ICrewMember extends IBaseData
38+
{
39+
uri:string;
40+
picture:string;
41+
character:string;
42+
stars:number;
43+
skills:ISkills;
44+
race:string;
45+
traits:string[];
46+
}

app/interfaces/db/crew.ts

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/**
2+
* Created by JC on 2016-07-09.
3+
*/
4+
5+
import {IBaseData} from '../base-data';
6+
7+
/**
8+
* Constant that list out all skills found in data, by abbreviations and names.
9+
*/
10+
export const SKILLS:any = {
11+
list: {
12+
abbr: ['cmd', 'dip', 'eng', 'med', 'sci', 'sec'],
13+
names: [
14+
'command', 'diplomacy', 'engineering', 'medicine', 'science', 'security',
15+
],
16+
},
17+
18+
// tslint:disable-next-line:object-literal-sort-keys
19+
abbr: {
20+
cmd: 'command',
21+
dip: 'diplomacy',
22+
eng: 'engineering',
23+
med: 'medicine',
24+
sci: 'science',
25+
sec: 'security',
26+
},
27+
28+
command: 'cmd',
29+
diplomacy: 'dip',
30+
engineering: 'eng',
31+
medicine: 'med',
32+
science: 'sci',
33+
security: 'sec',
34+
};
35+
36+
/**
37+
* Crew data structure as stored in database.
38+
*
39+
* All skill arrays are 2-dimensional, with first as star, and second as level.
40+
*/
41+
export interface IDBCrew extends IBaseData
42+
{
43+
/**
44+
* URI to the wiki page
45+
*/
46+
uri:string;
47+
48+
/**
49+
* URI to the portrait picture
50+
*/
51+
picture:string;
52+
53+
/**
54+
* Original TV Character
55+
*/
56+
character:string;
57+
58+
/**
59+
* Rarity
60+
*/
61+
stars:number;
62+
63+
/**
64+
* Command skills
65+
*/
66+
cmd?:number[][];
67+
68+
/**
69+
* Diplomacy skills
70+
*/
71+
dip?:number[][];
72+
73+
/**
74+
* Engineer skills
75+
*/
76+
eng?:number[][];
77+
78+
/**
79+
* Medicine skills
80+
*/
81+
med?:number[][];
82+
83+
/**
84+
* Science skills
85+
*/
86+
sci?:number[][];
87+
88+
/**
89+
* Security skills
90+
*/
91+
sec?:number[][];
92+
93+
/**
94+
* Race
95+
*/
96+
race:string;
97+
98+
/**
99+
* Traits
100+
*/
101+
traits:string[];
102+
}

0 commit comments

Comments
 (0)