Skip to content

Commit 43d5fef

Browse files
committed
Add Wisdom!
1 parent 8798593 commit 43d5fef

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

contextmenucontroller.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ window.addEventListener("load", function () {
5858
const leaderboardCtx = document.querySelector("#leaderboard-ctx");
5959

6060
const newNode = this.document.createElement("p");
61-
const nameFromLs = this.localStorage.getItem(LOCAL_STORAGE_USERNAME_KEY);
6261
newNode.innerHTML = getNameButtonText();
6362
newNode.addEventListener("click", leaderboardNamePrompt);
6463
newNode.id = "leaderboard-ctx-name";

index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<script src="solver.js"></script>
8383
<script src="draggables.js"></script>
8484
<script src="desktop.js"></script>
85+
<script src="wisdom.js"></script>
8586

8687
<div class="selection-box"></div>
8788

@@ -200,7 +201,7 @@ <h2 name="np-search">Search</h2>
200201
<h2 name="np-help">Help</h2>
201202
</div>
202203
</div>
203-
<textarea>hello vro</textarea>
204+
<textarea id="notebox-text"></textarea>
204205
</div>
205206

206207
<div class="context-menu">
@@ -269,6 +270,10 @@ <h2 name="np-help">Help</h2>
269270
</div>
270271
<hr />
271272
</div>
273+
274+
<div name="np-file" onclick="applyWisdomToNotepad()">
275+
<p>Restore Daily Wisdom</p>
276+
</div>
272277
</div>
273278

274279
<script type="text/javascript">

wisdom.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
let wisdom = "";
2+
3+
const loadWisdom = async () => {
4+
wisdom = await getDailyWisdom();
5+
applyWisdomToNotepad();
6+
};
7+
8+
const applyWisdomToNotepad = () => {
9+
const textarea = document.getElementById("notebox-text");
10+
textarea.innerHTML = wisdom;
11+
textarea.value = wisdom;
12+
};
13+
14+
const getDailyWisdom = async () => {
15+
const results = await fetch(`${SERVER_URL}/wisdoms/today`);
16+
17+
return await results.text();
18+
};
19+
20+
loadWisdom();

0 commit comments

Comments
 (0)