Merge pull request #15 from terncode/master

Improved code
This commit is contained in:
Chris Multhaupt
2019-09-10 12:37:41 +02:00
committed by GitHub
4 changed files with 6 additions and 30 deletions
@@ -290,9 +290,9 @@ export class ChatBox implements AfterViewInit, OnDestroy {
this.open(); this.open();
} }
} }
onMouseEnter(event: MouseEvent) { onMouseEnterEmojiButton(event: MouseEvent) {
if (!event.target) return; if (!event.target) return;
const emoji = _.sample(emojis) || emojis[0]; const emoji = _.sample(emojis)!;
this.btnEmoji = emoji.names[0]; this.btnEmoji = emoji.names[0];
} }
toggleChatType() { toggleChatType() {
@@ -26,4 +26,3 @@ button.game-button.chat-log-toggle(#toggleButton (click)="toggle()" title="Toggl
path.main-bubble(fill="currentColor" d="M416 192c0-88.4-93.1-160-208-160S0 103.6 0 192c0 34.3 14.1 65.9 38 92-13.4 30.2-35.5 54.2-35.8 54.5-2.2 2.3-2.8 5.7-1.5 8.7S4.8 352 8 352c36.6 0 66.9-12.3 88.7-25 32.2 15.7 70.3 25 111.3 25 114.9 0 208-71.6 208-160z") path.main-bubble(fill="currentColor" d="M416 192c0-88.4-93.1-160-208-160S0 103.6 0 192c0 34.3 14.1 65.9 38 92-13.4 30.2-35.5 54.2-35.8 54.5-2.2 2.3-2.8 5.7-1.5 8.7S4.8 352 8 352c36.6 0 66.9-12.3 88.7-25 32.2 15.7 70.3 25 111.3 25 114.9 0 208-71.6 208-160z")
path(fill="currentColor" d="M538 412c23.9-26 38-57.7 38-92 0-66.9-53.5-124.2-129.3-148.1.9 6.6 1.3 13.3 1.3 20.1 0 105.9-107.7 192-240 192-10.8 0-21.3-.8-31.7-1.9C207.8 439.6 281.8 480 368 480c41 0 79.1-9.2 111.3-25 21.8 12.7 52.1 25 88.7 25 3.2 0 6.1-1.9 7.3-4.8 1.3-2.9.7-6.3-1.5-8.7-.3-.3-22.4-24.2-35.8-54.5z") path(fill="currentColor" d="M538 412c23.9-26 38-57.7 38-92 0-66.9-53.5-124.2-129.3-148.1.9 6.6 1.3 13.3 1.3 20.1 0 105.9-107.7 192-240 192-10.8 0-21.3-.8-31.7-1.9C207.8 439.6 281.8 480 368 480c41 0 79.1-9.2 111.3-25 21.8 12.7 52.1 25 88.7 25 3.2 0 6.1-1.9 7.3-4.8 1.3-2.9.7-6.3-1.5-8.7-.3-.3-22.4-24.2-35.8-54.5z")
.whispers-count(#count) .whispers-count(#count)
@@ -76,9 +76,9 @@
label#chatlog-opacity-label Timestamp label#chatlog-opacity-label Timestamp
div div
.btn-group.mb-2(btnCheckbox) .btn-group.mb-2(btnCheckbox)
button.btn.btn-outline-secondary.d-sm-block([class.active]='off' (click)='switchTimestamp()') None button.btn.btn-outline-secondary.d-sm-block([class.active]='!browser.timestamp' (click)='switchTimestamp()') None
button.btn.btn-outline-secondary.d-sm-block([class.active]='twelve' (click)='switchTimestamp("12")') 12-hour format button.btn.btn-outline-secondary.d-sm-block([class.active]='browser.timestamp === "12"' (click)='switchTimestamp("12")') 12-hour format
button.btn.btn-outline-secondary.d-sm-block([class.active]='twentyFour' (click)='switchTimestamp("24")') 24-hour format button.btn.btn-outline-secondary.d-sm-block([class.active]='browser.timestamp === "24"' (click)='switchTimestamp("24")') 24-hour format
small.form-text.text-muted.mt-0 Displays a timestamp in front of chatlog messages small.form-text.text-muted.mt-0 Displays a timestamp in front of chatlog messages
.form-group .form-group
@@ -26,9 +26,7 @@ export class SettingsModal implements OnInit, OnDestroy {
readonly graphicsIcon = faImage; readonly graphicsIcon = faImage;
readonly exportIcon = faDownload; readonly exportIcon = faDownload;
readonly importIcon = faUpload; readonly importIcon = faUpload;
off = false;
twelve = false;
twentyFour = false;
@Output() close = new EventEmitter(); @Output() close = new EventEmitter();
account: AccountSettings = {}; account: AccountSettings = {};
browser: BrowserSettings = {}; browser: BrowserSettings = {};
@@ -62,7 +60,6 @@ export class SettingsModal implements OnInit, OnDestroy {
this.browser = this.settingsService.browser; this.browser = this.settingsService.browser;
this.setupDefaults(); this.setupDefaults();
this.subscription = this.game.onLeft.subscribe(() => this.cancel()); this.subscription = this.game.onLeft.subscribe(() => this.cancel());
this.updateTimestampRadios();
} }
ngOnDestroy() { ngOnDestroy() {
this.finishChatlogRange(); this.finishChatlogRange();
@@ -108,26 +105,6 @@ export class SettingsModal implements OnInit, OnDestroy {
if (!state) this.browser.timestamp = undefined; if (!state) this.browser.timestamp = undefined;
else if (state === '12') this.browser.timestamp = '12'; else if (state === '12') this.browser.timestamp = '12';
else if (state === '24') this.browser.timestamp = '24'; else if (state === '24') this.browser.timestamp = '24';
this.updateTimestampRadios();
}
turnOffTimestampRadioButtons() {
this.off = false;
this.twelve = false;
this.twentyFour = false;
}
updateTimestampRadios() {
this.turnOffTimestampRadioButtons();
switch (this.browser.timestamp) {
case '12':
this.twelve = true;
break;
case '24':
this.twentyFour = true;
break;
default:
this.off = true;
break;
}
} }
updateChatlogRange(range: number | undefined) { updateChatlogRange(range: number | undefined) {
document.body.classList.add('translucent-modals'); document.body.classList.add('translucent-modals');