Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

87
LINES

< > BotCompany Repo | #1005922 // User Feedback [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (6461L/45K/143K).

1  
!752
2  
3  
static Action lastAction;
4  
5  
concepts.
6  
7  
concept History {
8  
  new RefL events;
9  
}
10  
11  
abstract concept Input {
12  
}
13  
14  
Input > TextInput {
15  
  S line;
16  
  
17  
  *() {}
18  
  *(S *line) { change(); }
19  
}
20  
21  
abstract concept Action {
22  
  Bool good; // true, false or null
23  
}
24  
25  
Action > NoAction {}
26  
27  
Action > PrintAction {
28  
  S text;
29  
  
30  
  *() {}
31  
  *(S *text) { change(); }
32  
}
33  
34  
static History historyObj() { ret uniq(History); }
35  
36  
static L<Concept> history() { ret historyObj().events; }
37  
static void historyAdd(Concept event) { historyObj().events.add(event); }
38  
39  
p-awt {
40  
  concepts();
41  
  
42  
  showControls(jcenteredLine(
43  
    jbutton("Good!", "good"),
44  
    jbutton("Bad!", "bad")));
45  
  
46  
  makeBot();
47  
}
48  
49  
synchronized answer {
50  
  historyAdd(new TextInput(s));
51  
  if "hello" {
52  
    S answer = "Hello!";
53  
    historyAdd(new PrintAction(answer));
54  
    ret answer;
55  
  }
56  
}
57  
58  
static Action lastAction() {
59  
  Concept last = last(history());
60  
  if (!last << Action) {
61  
    historyAdd(last = new NoAction);
62  
    print("I'm assuming you mean my lack of action?");
63  
  }
64  
  ret last/Action;
65  
}
66  
67  
svoid good {
68  
  Action action = lastAction();
69  
  if (action == null) ret;
70  
  if (isTrue(action.good))
71  
    print("Thanks, I know! :-)");
72  
  else {
73  
    cset(action, good := true);
74  
    print("Thanks, saved!");
75  
  }
76  
}
77  
78  
svoid bad {
79  
  Action action = lastAction();
80  
  if (action == null) ret;
81  
  if (isFalse(action.good))
82  
    print("I heard that before...");
83  
  else {
84  
    cset(action, good := false);
85  
    print("I don't know what I did wrong yet, but I'll save this feedback!");
86  
  }
87  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005922
Snippet name: User Feedback [dev.]
Eternal ID of this version: #1005922/1
Text MD5: f4856e8869a0cfeec21c391df58d1805
Transpilation MD5: fddc347947c34d29f0fa83ff91d9e62a
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-12 20:01:13
Source code size: 1585 bytes / 87 lines
Pitched / IR pitched: No / No
Views / Downloads: 484 / 568
Referenced in: [show references]