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).

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

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: 215 / 324
Version history: 12 change(s)
Referenced in: [show references]