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

49
LINES

< > BotCompany Repo | #1030268 // OpenerText [text beside chat bot opener icon, Include]

JavaX fragment (include) [tags: use-pretranspiled]

1  
concept OpenerTextConfig {
2  
  S text;
3  
  S textForMobile;
4  
  bool enabled;
5  
  
6  
  S spans() {
7  
    if (!enabled) ret "";
8  
    S mob = or2_trim(textForMobile, text);
9  
    ret span(text, class := "for-desk") + "\n" + span(mob, class := "for-mobile");
10  
  }
11  
}
12  
13  
sclass OpenerText {
14  
  sO html(S uri, SS params, AuthedDialogID auth) null {
15  
    S uri2 = appendSlash(uri);
16  
    bool requestAuthed = auth != null;
17  
  
18  
    if (startsWith(uri2, "/opener-text-admin/")) {
19  
      if (!requestAuthed) ret serveAuthForm(params.get('uri));
20  
      ret serveAdmin(uri, params);
21  
    }
22  
  }
23  
    
24  
  sS serveAdmin(S uri, SS params) {
25  
    uniq(OpenerTextConfig);
26  
    
27  
    S _nav = p(ahref(rawBotLink(dbBotID), "Main admin") + " | " + ahref(baseLink + "/opener-text-admin", "Opener text"));
28  
    
29  
    HCRUD_Concepts<OpenerTextConfig> data = new HCRUD_Concepts<>(OpenerTextConfig);
30  
    data.fieldHelp = litmap(
31  
      text := [[Text to show beside chat bot opener icon (e.g. "Contact us")]],
32  
      textForMobile := [[Text to show on mobile devices (or empty to use value from above)]],
33  
      enabled := "Actually show the text"
34  
    );
35  
36  
    HCRUD crud = new(rawLink("opener-text-admin"), data) {
37  
      S frame(S title, S contents) {
38  
        ret hhtml(hhead_title_htmldecode(title) + hbody(
39  
          hsansserif() + hcss_responstable()
40  
          + _nav + h1(title)
41  
          + contents));
42  
      }
43  
    };
44  
    crud.singleton = true;
45  
    crud.cmdsLeft = true;
46  
    crud.tableClass = "responstable";
47  
    ret crud.renderPage(params);
48  
  }
49  
}

Author comment

Began life as a copy of #1028517

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030268
Snippet name: OpenerText [text beside chat bot opener icon, Include]
Eternal ID of this version: #1030268/4
Text MD5: e2e94a6558814d69e735299d95f53fd3
Author: stefan
Category: javax / web chat bot
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-27 18:54:22
Source code size: 1537 bytes / 49 lines
Pitched / IR pitched: No / No
Views / Downloads: 284 / 333
Version history: 3 change(s)
Referenced in: [show references]