Skip to content

Commit 38b8692

Browse files
authored
Merge pull request #7 from hadrrb/save-lang-height
Save last lang and height
2 parents 360a278 + 766b8fa commit 38b8692

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to the "wordle" extension will be documented in this file.
44

5+
## 1.0.3
6+
7+
- Ability to change height in settings as well
8+
- The last chosen language and height will be saved from now on
9+
510
## 1.0.2
611

712
- Changed English Wordle to <a href="https://mikhad.github.io/wordle/#daily">Wordle+</a> because the original cannot be loaded as an iframe because of X-Frame-Options policy.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-wordle",
33
"displayName": "Wordle for VSCode",
44
"description": "Play Wordle in your VSCode",
5-
"version": "1.0.2",
5+
"version": "1.0.3",
66
"keywords": ["wordle", "word game", "game"],
77
"publisher": "RamziHadrich",
88
"author": {
@@ -54,6 +54,11 @@
5454
"type": "string",
5555
"description": "Wordle width (in px or in %)",
5656
"default": "100%"
57+
},
58+
"wordle.height": {
59+
"type": "number",
60+
"description": "Wordle height (in px)",
61+
"default": 600
5762
}
5863
}
5964
}

src/extension.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export function activate(context: vscode.ExtensionContext) {
2525

2626
vscode.workspace.onDidChangeConfiguration((e) => {
2727
if(e.affectsConfiguration("wordle")){
28-
let lang = vscode.workspace.getConfiguration("wordle").get<string>("defaultLang");
29-
wordleProvider.setLang(lang);
28+
wordleProvider.reload();
3029
}});
3130

3231
context.subscriptions.push(wordle);

src/pick_language.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@ export async function pick_language(wordleProvider: WordleProvider) {
2929
title: "Wordle Language"
3030
});
3131
if(lang){
32-
let link = wordles[lang];
33-
if (link){
34-
wordleProvider.changeLanguage(link);
35-
}
36-
32+
vscode.workspace.getConfiguration("wordle").update("defaultLang", lang, true);
33+
wordleProvider.reload();
3734
}
3835

3936
}

src/wordle.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { pick_language, wordles } from './pick_language';
44
export class WordleProvider implements vscode.WebviewViewProvider {
55

66
private _view?: vscode.WebviewView;
7-
private height: number = 600;
8-
private wordleLink!: string;
97

108
constructor(){
119
let lang = vscode.workspace.getConfiguration("wordle").get<string>("defaultLang");
@@ -14,12 +12,9 @@ export class WordleProvider implements vscode.WebviewViewProvider {
1412

1513
public setLang(lang: string | undefined){
1614
if(lang){
17-
this.wordleLink = wordles[lang];
15+
return wordles[lang];
1816
} else {
19-
this.wordleLink = wordles["English"];
20-
}
21-
if (this._view) {
22-
this._view.webview.html = this._getHtmlForWebview();
17+
return wordles["English"];
2318
}
2419
}
2520

@@ -37,6 +32,8 @@ export class WordleProvider implements vscode.WebviewViewProvider {
3732
}
3833

3934
private _getHtmlForWebview() {
35+
let link = this.setLang(vscode.workspace.getConfiguration("wordle").get<string>("defaultLang"));
36+
let height = vscode.workspace.getConfiguration("wordle").get<string>("height");
4037
let width = vscode.workspace.getConfiguration("wordle").get<string>("width");
4138
return `<!DOCTYPE html>
4239
<html>
@@ -47,22 +44,23 @@ export class WordleProvider implements vscode.WebviewViewProvider {
4744
4845
</head>
4946
<body>
50-
<iframe src="${this.wordleLink}" height="${this.height}" width="${width}" scrolling="no" frameborder="0" wmode="transparent"></iframe>
47+
<iframe src="${link}" height="${height}" width="${width}" scrolling="no" frameborder="0" wmode="transparent"></iframe>
5148
</body>
5249
</html>`;
5350
}
5451

55-
public changeLanguage(link: string){
56-
this.wordleLink = link;
52+
public reload(){
5753
if (this._view) {
5854
this._view.webview.html = this._getHtmlForWebview();
5955
}
6056
}
6157

62-
public changeHeight(value: number){
63-
this.height = this.height + value;
64-
if (this._view) {
65-
this._view.webview.html = this._getHtmlForWebview();
58+
public changeHeight(change: number){
59+
let height = vscode.workspace.getConfiguration("wordle").get<number>("height");
60+
if(height){
61+
height = height + change;
62+
vscode.workspace.getConfiguration("wordle").update("height", height, true);
63+
this.reload();
6664
}
6765
}
6866

0 commit comments

Comments
 (0)