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

1  
sclass HFlagsWithCount {
2  
  new MultiSet<S> countryMultiSet;
3  
  Map<S, Int> countriesByCount;
4  
  
5  
  S headStuff() { ret hcss_flags(); }
6  
  
7  
  void addCountry(S country) {
8  
    if (nempty(country))
9  
      countryMultiSet.add(country);
10  
  }
11  
  
12  
  S html() {
13  
    countriesByCount = sortedByValue(countryMultiSet.asMap());
14  
  
15  
    ret joinWithSpace(
16  
      map(countriesByCount, (country, n) -> 
17  
        div("", class := "iti__flag iti__" + lower(country),
18  
          style := "display: inline-block",
19  
          title := makeTitle(country, n))
20  
          + appendBracketedCountUnlessOne(n)));
21  
  }
22  
  
23  
  S makeTitle(S country, int n) {
24  
    ret nVisitors(n) + " from " + country;
25  
  }
26  
}

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: 112 / 187
Version history: 1 change(s)
Referenced in: [show references]