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)

static S selfLink() {
  ret getActualURI();
}

static S selfLink(S p1, O... params) {
  S uri;
  if (even(l(params)))
    uri = botLink(programID(), p1);
  else
    uri = getActualURI();
  ret uri + htmlQuery(litorderedmap(concatArrays(new O[] {p1}, params)));
}

static S selfLink(Map<S, S> params, L<S> keepFields, S... newValues) {
  new Map<S, S> map;
  for (S key : keepFields) {
    S val = params.get(key);
    if (val != null)
      map.put(key, val);
  }
  for (int i = 0; i+1 < l(newValues); i += 2) {
    S key = get(newValues, i);
    S val = get(newValues, i+1);
    if (empty(key)) continue;
    if (empty(val))
      map.remove(key);
    else
      map.put(key, val);
  }
  ret getActualURI() + htmlQuery(map);
}

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: 640 / 978
Version history: 5 change(s)
Referenced in: [show references]