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

19
LINES

< > BotCompany Repo | #1030238 // gazelleBot_suggestPostTypes

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

Libraryless. Click here for Pure Java version (3141L/20K).

1  
sS gazelleBot_suggestPostTypes(Cl<S> postTypes, SS jsonData, bool alwaysShowText default false) {
2  
  S f_type = cast jsonData.get("f_type");
3  
  postTypes = listWithout(postTypes, dropTrailingRoundBracketStuff(f_type));
4  
  
5  
  ret !alwaysShowText && empty(postTypes) ? "" : "Suggested post " + (l(postTypes) == 1 ? "type" : "types")
6  
    + ": " +
7  
    joinWithCommaOr("-", safeMap(type -> {
8  
      bool selected = eq(f_type, type);
9  
      if (selected) ret span_title("Post type is already selected", b(htmlEncode2(type)));
10  
      ret ahref_js([[
11  
        const selectize = $("select[name=f_type]").data('selectize');
12  
        //console.log("selectize: " + selectize);
13  
        var type = ]] + jsQuote(type) + [[;
14  
        selectize.addOption({value: type, text: type});
15  
        selectize.setValue(type);
16  
      ]],
17  
      htmlEncode2(type), title := "Click to accept suggestion");
18  
    }, takeFirst(3, postTypes)));
19  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1030238
Snippet name: gazelleBot_suggestPostTypes
Eternal ID of this version: #1030238/13
Text MD5: 0237c33065d2a5a8be9a68a2c67c43dc
Transpilation MD5: 3d8b2eeea8d51a218d796e2f1ace13d1
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-12-09 18:04:17
Source code size: 919 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 216 / 327
Version history: 12 change(s)
Referenced in: [show references]