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

31
LINES

< > BotCompany Repo | #1002389 // selfLink - make a HTML self-link with modified parameters (for sub-bots)

JavaX fragment (include)

1  
static S selfLink() {
2  
  ret getActualURI();
3  
}
4  
5  
static S selfLink(S p1, O... params) {
6  
  S uri;
7  
  if (even(l(params)))
8  
    uri = botLink(programID(), p1);
9  
  else
10  
    uri = getActualURI();
11  
  ret uri + htmlQuery(litorderedmap(concatArrays(new O[] {p1}, params)));
12  
}
13  
14  
static S selfLink(Map<S, S> params, L<S> keepFields, S... newValues) {
15  
  new Map<S, S> map;
16  
  for (S key : keepFields) {
17  
    S val = params.get(key);
18  
    if (val != null)
19  
      map.put(key, val);
20  
  }
21  
  for (int i = 0; i+1 < l(newValues); i += 2) {
22  
    S key = get(newValues, i);
23  
    S val = get(newValues, i+1);
24  
    if (empty(key)) continue;
25  
    if (empty(val))
26  
      map.remove(key);
27  
    else
28  
      map.put(key, val);
29  
  }
30  
  ret getActualURI() + htmlQuery(map);
31  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002389
Snippet name: selfLink - make a HTML self-link with modified parameters (for sub-bots)
Eternal ID of this version: #1002389/6
Text MD5: 9542714bb599f65d60961b7fb6db4b0c
Author: stefan
Category: eleu
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-16 21:08:06
Source code size: 757 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 714 / 1060
Version history: 5 change(s)
Referenced in: [show references]