MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / rateBox

Function rateBox

src/dialogs/rateBox.js:5–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import dialog from "./dialog";
4
5function rateBox() {
6 const $box = dialog(
7 "Did you like the app?",
8 template,
9 strings.cancel,
10 ).onclick(onInteract);
11
12 function onInteract(e) {
13 /**
14 * @type {HTMLSpanElement}
15 */
16 const $el = e.target;
17 if (!$el) return;
18 let val = $el.getAttribute("value");
19 if (val) val = Number.parseInt(val);
20 const siblings = $el.parentElement.children;
21 const len = siblings.length;
22 for (let i = 0; i < len; ++i) {
23 const star = siblings[i];
24 star.classList.remove("stargrade", "star_outline");
25 if (i < val) star.classList.add("stargrade");
26 else star.classList.add("star_outline");
27 }
28
29 setTimeout(() => {
30 if (val === 5) {
31 system.openInBrowser(
32 `https://play.google.com/store/apps/details?id=${BuildInfo.packageName}`,
33 );
34 localStorage.dontAskForRating = true;
35 } else {
36 const stars = getStars(val);
37 const subject = "feedback - Acode editor";
38 const textBody = stars + "</br>%0A" + getFeedbackBody("</br>%0A");
39 const email = config.FEEDBACK_EMAIL;
40 system.openInBrowser(
41 `mailto:${email}?subject=${subject}&body=${textBody}`,
42 );
43 }
44 }, 100);
45
46 $box.hide();
47 }
48}
49
50/**
51 * Gets body for feedback email

Callers 1

callbackFunction · 0.85

Calls 1

dialogFunction · 0.85

Tested by

no test coverage detected