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

57
LINES

< > BotCompany Repo | #1016073 // Mech Lists With Text [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1113K of libraries. Click here for Pure Java version (19248L/101K).

1  
!7
2  
3  
please include function mL.
4  
5  
cmodule2 MechLists > DynCalculatedList {
6  
  SS listToMD5;
7  
  transient ReliableSingleThread rst = new(r downloadAll);
8  
  transient bool authed;
9  
  switchable double downloadInterval = 10.0;
10  
  
11  
  visualize {
12  
    JComponent c = super.visualize();
13  
    onDoubleClickOrEnter(list, voidfunc(S listName) {
14  
      showText(listName, mechList_raw_localCopy(listName))
15  
    });
16  
    if (!authed) ret c;
17  
    ret withLeftAlignedButtonsOnTop(c, "Create...", r createList);
18  
  }
19  
  
20  
  start {
21  
    set serverMechList_raw_fresh_verbose;
22  
    setModuleName("Mech Lists With Text" + trueFalseNull(authed = mech_authedOnServer(), " [Authed]", " [Not Authed]", ""));
23  
    actualCalc();
24  
    if (!isTrue(vm_generalMap_get('noMechDownload)))
25  
      doEvery(5.0, downloadInterval, rst);
26  
    bot("Mech Lists Mirror.");
27  
    dm_registerMainClassAs mechListsHolder();
28  
  }
29  
  
30  
  void actualCalc { setField(results := sortedIC(keys(listToMD5))); }
31  
  
32  
  L<S> calc() { ret results; }
33  
34  
  void downloadAll {
35  
    // TODO: transmit timestamp and get only changes
36  
    L<LS> l = mechListMD5sAndStatuses_fresh();
37  
    new HashMap listToMD5;
38  
    for (LS x : l) {
39  
      S name = first(x);
40  
      listToMD5.put(name, second(x));
41  
      saveTextFileIfDifferent(remoteMechListMirrorMetaFile(name),
42  
        struct(litmap("Name" := name, "Status" := third(x))));
43  
    }
44  
    deleteLocalMechListCopiesOtherThan(keys(listToMD5));
45  
    setField(+listToMD5);
46  
    actualCalc();
47  
    mechList_completeLocalCopies(listToMD5);
48  
  }
49  
  
50  
  void createList enter {
51  
    inputText("List Name", voidfunc(S name) {
52  
      if (emptyAfterTrim(name)) ret;
53  
      createMechList(trim(name));
54  
      rst.trigger();
55  
    });
56  
  }
57  
}

Author comment

Began life as a copy of #1015978

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016073
Snippet name: Mech Lists With Text [Dyn Module]
Eternal ID of this version: #1016073/35
Text MD5: 2cf0925b32b88bfa20f55458ddc66c4a
Transpilation MD5: 6c358ad1706bf0034b42c2c740e0cdc5
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-29 21:06:08
Source code size: 1726 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 577 / 50756
Version history: 34 change(s)
Referenced in: [show references]