Skip to content

Commit e985840

Browse files
committed
fix
1 parent 015c8a5 commit e985840

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

interface.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
# WebAppInterface Methods Documentation
33

4-
This document describes all the interface methods available in questphone. check [here](index.html) for complete usage
4+
This document describes all the interface methods available in questphone. check [here](index.html) for complete usage.
5+
6+
Check interface listener's code for questphone on android [here](https://github.com/QuestPhone/questphone/blob/main/app/src/main/java/neth/iecal/questphone/app/screens/quest/view/external_integration/webview/WebAppInterface.kt)
57
---
68

79
## `onQuestCompleted()`

setup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ <h3>Your Quest Configuration</h3>
118118
unique_id: generateUUID(),
119119
quest_json: {
120120
// This is the link to your page that displays when a quest is opened.
121-
webviewUrl: "https://questphone.github.io/apidocs/index.html",
121+
webviewUrl: "https://questphone.github.io/api-docs/view.html",
122122
setting1: document.getElementById('setting1')?.value || '',
123123
setting2: document.getElementById('setting2')?.value || '',
124124
option1: document.getElementById('option1')?.checked || false

setup.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Your page should have these sections:
3737
* Time Range (`array of two numbers`)
3838
* Optional Settings (`all strings`)
3939

40-
> **Important:** These values will be dynamically set and are **directly injected into your webpage at `webviewUrl`**.
4140

4241
3. **Generate Button**
4342

@@ -223,17 +222,3 @@ Header → Quest Title → Active Days → Time Range → Custom Settings → Ge
223222
* Later, make your page interactive, colorful, and fun
224223

225224
**Working example page:** [setup.html](setup.html)
226-
227-
---
228-
229-
This guide now clearly states that:
230-
231-
* **All custom settings in `quest_json` are strings**
232-
* They are **dynamic**, user-editable values
233-
* They are **directly injected into your webpage at `webviewUrl`**, so your webpage can use them for the quest
234-
235-
---
236-
237-
If you want, I can also write a **tiny “cheat sheet table”** that shows beginners exactly **what keys, types, and example values** to put in `quest_json` to speed up their setup.
238-
239-
Do you want me to make that cheat sheet too?

view.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,36 @@ <h2>Live Camera Test</h2>
206206
function onStatsReceived(stats) {
207207
WebAppInterface.toast("Quest stats: " + stats);
208208
}
209+
210+
211+
// This is the function that automatically receives the quest_json data injected from the setup page when questphone loads this page
212+
function injectData(data) {
213+
try {
214+
let parsed;
215+
if (typeof data === "object") {
216+
parsed = data;
217+
} else if (typeof data === "string") {
218+
parsed = JSON.parse(data);
219+
if (typeof parsed === "string") {
220+
parsed = JSON.parse(parsed);
221+
WebAppInterface.toast("Parsed nested JSON string");
222+
}
223+
} else {
224+
throw new Error("Invalid data format");
225+
}
226+
}
227+
catch (e) {
228+
WebAppInterface.toast("Error parsing injected data: " + e.message);
229+
return;
230+
}
231+
}
232+
233+
// This is a function that automatically applies the theme based on user preference in questphone
234+
function applyTheme(theme) {
235+
// the theme data is in this format https://github.com/QuestPhone/questphone/blob/0e965be267e60f870aff11a86eeaff9de9966171/app/src/main/java/neth/iecal/questphone/app/screens/quest/view/external_integration/webview/ExtIntWebview.kt#L107
236+
237+
// example usage: https://github.com/nethical6/qp_pomodoro/blob/main/index.html
238+
}
209239
</script>
210240
</body>
211241
</html>

0 commit comments

Comments
 (0)