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

26
LINES

< > BotCompany Repo | #1033607 // HFlagsWithCount

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

Libraryless. Click here for Pure Java version (5737L/31K).

sclass HFlagsWithCount {
  new MultiSet<S> countryMultiSet;
  Map<S, Int> countriesByCount;
  
  S headStuff() { ret hcss_flags(); }
  
  void addCountry(S country) {
    if (nempty(country))
      countryMultiSet.add(country);
  }
  
  S html() {
    countriesByCount = sortedByValue(countryMultiSet.asMap());
  
    ret joinWithSpace(
      map(countriesByCount, (country, n) -> 
        div("", class := "iti__flag iti__" + lower(country),
          style := "display: inline-block",
          title := makeTitle(country, n))
          + appendBracketedCountUnlessOne(n)));
  }
  
  S makeTitle(S country, int n) {
    ret nVisitors(n) + " from " + country;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033607
Snippet name: HFlagsWithCount
Eternal ID of this version: #1033607/2
Text MD5: 9f680acc32e2bfddb15b6bc8748a7998
Transpilation MD5: ae1d737cd01be0bd9475c2178e9ee316
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-11-15 23:48:53
Source code size: 691 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 162 / 262
Version history: 1 change(s)
Referenced in: [show references]