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

192
LINES

< > BotCompany Repo | #1013826 // Stefan's OS Download Page [Formerly: Google Sign-In & Bot Hello] [LIVE at http://botcompany.de/]

JavaX source code (desktop) [tags: butter use-pretranspiled] - run with: x30.jar - homepage

Download Jar. Uses 2381K of libraries. Click here for Pure Java version (27266L/201K).

1  
!7
2  
3  
// Content in: http://botcompany.de/1013927/raw/list/News+%28HTML%29
4  
5  
//set flag NoAI.
6  
set flag TripleAI.
7  
8  
sS denkmodulID = ""; //#1013938;
9  
sO denkmodul;
10  
11  
sbool towly, signIn;
12  
13  
static long tokenTimeout = 60*60*1000; // one hour
14  
15  
p {
16  
  independentSmartBot();
17  
  if (nempty(denkmodulID))
18  
    runInMCVarWithAutoRestart('denkmodul, denkmodulID);
19  
}
20  
21  
static ExpiringHashMap<S, Payload> tokensToPayload = new(tokenTimeout);
22  
23  
html {
24  
  new Matches m;
25  
  
26  
  if (eq(uri, "/") && !cic(domain(), "butter") && !swic(domain(), "www."))
27  
    ret hrefresh("https://www.botcompany.de:8443/1013826/raw");
28  
    
29  
  if (eq(uri, "/tokens")) ret lstr(tokensToPayload);
30  
31  
  S token = params.get("token");
32  
  S q = params.get("q");
33  
  
34  
  Payload payload = null;
35  
  bool loaded = false;
36  
  if (nempty(token)) {
37  
    payload = tokensToPayload.get(token);
38  
    if (payload == null) {
39  
      payload = googleVerifyUserToken2(botCompanyGoogleSignInID(), token);
40  
      loaded = true;
41  
      mapPut(tokensToPayload, token, payload);
42  
    }
43  
  }
44  
    
45  
  if (payload != null) {
46  
    long time = unixTime();
47  
    print("loaded=" + loaded + ", issued=" + (payload.getIssuedAtTimeSeconds()-time) + ", expiration=" + (payload.getExpirationTimeSeconds()-time));
48  
  }
49  
    
50  
  S email = payload == null ? null : payload.getEmail();
51  
  
52  
  if (nempty(q)) {
53  
    if (nempty(email)) {
54  
      appendToMechList_noUniq("Things said on the home page by logged in users", now() + ", " + email + ": " + q);
55  
      post(email, "said", quote(q));
56  
    } else
57  
      appendToMechList_noUniq("Things said on the home page by anonymous users", now() + ": " + q);
58  
  }
59  
    
60  
  if (eq(uri, "/content-script")) {
61  
    S text = "";
62  
    if (nempty(q)) {
63  
      text += p(small("> " + span(htmlencode(q), style := "color: gray")));
64  
      S a = "Fehler";
65  
      pcall { a = callAnswerFunction(denkmodul, q); }
66  
      if (nempty(a)) {
67  
        if (swic_trim(a, "[VIDEO] ", m))
68  
          text += embedYoutube_newer_autoplay(m.rest(), 600);
69  
        else
70  
          text += p(htmlencode(a));
71  
      }
72  
    }
73  
    bool again = false, de = false;
74  
    /*if (payload == null)
75  
      text += "You are not logged in.";*/
76  
      
77  
    if (nempty(email)) {
78  
      pnlStruct(payload);
79  
      again = post(email, "logged in", ".") == null;
80  
      if (!payload.getEmailVerified())
81  
        text = "Unverified email (huh?)";
82  
    }
83  
    
84  
    if (empty(text)) {
85  
      de = cic((S) payload.get("locale"), "de");
86  
      S firstName = (S) payload.get("given_name");
87  
      text = p(htmlencode((de ? "Hallo " : "Hello ")
88  
        + (again ? (de ? "mal wieder, " : "again ") : "")
89  
        + firstName + "!"));
90  
      S pic = (S) payload.get("picture");
91  
      if (de && isURL(pic))
92  
        text += p(htmlencode("Was für ein hübsches Bild:"))
93  
          + p(himg(pic, title := firstName + ", ein toller Mensch"));
94  
    }
95  
      
96  
    S script =
97  
      [[$(".BUTTON_OUT").css('display', 'inline-block');
98  
      document.getElementById("content").innerHTML = ]] + jsQuote(text) + ";" +
99  
      [[
100  
        $("input[name='token']").val($TOKEN);
101  
        $("#inputdiv").show();
102  
        $("input[name='q']").focus();
103  
      ]].replace("$TOKEN", jsQuote(token));
104  
    if (de) script += [[$("input[name='q']").attr('placeholder', 'Sprich mit mir');]];
105  
    
106  
    print(script);
107  
    ret script;
108  
  }
109  
  
110  
  S defaultInput = "Spiel George Michael";
111  
  
112  
  ret hhtml(hhead(htitle("BotCompany.de")
113  
    + hmobilefix()
114  
    + loadJQuery()
115  
    + googleSignIn_header()
116  
    + hcss(andrzejButtonStyle())
117  
    + hcookieconsent()
118  
    + hGoogleFont("Raleway:500") 
119  
    + loadHtml2canvas()
120  
    + hcss("body { font-family: Raleway; font-weight: 500; }")
121  
    + hplaceholderStyle("color: blue; opacity: 1 !important; text-align: center;"))
122  
    + hbody(
123  
      (nempty(params.get("noworker")) ? "" : hSilentComputator())
124  
      + jsIsDesktopChrome()
125  
      + hfullcenter(
126  
        p(ahref("http://BotCompany.de", "BotCompany.de"))
127  
        
128  
        + htableRaw2_singleRow(ll(
129  
              youtubeEmbed("wmA4VPl9RnY", 254, 150, "Stefan's OS"),
130  
              youtubeEmbed("xYMFQs549i0", 254, 150, "Optical Character Recognition Demo"),
131  
              youtubeEmbed("bS8j3gQyATM", 254, 150, "A New Approach To Image Recognition"),
132  
              youtubeEmbed("nMRGcamgc_U", 254, 150, "Stefan's OS: Working With Files")
133  
            ),
134  
              ll(style := "margin-bottom: 40px"), null, ll(align := 'center, style := "padding-left: 10px; padding-right: 10px"))
135  
        // towly
136  
      + (!towly ? "" : p(hsnippetimg(#1013948, width := 125, height := 141, id := "towly", title := "Towly greets you"))
137  
        + hscript([[
138  
          //var towlyPhase = 1;
139  
          var f1, f2;
140  
          f1 = function() {
141  
            $("#towly").attr("src", "https://www.botcompany.de:8443/img/1013945");
142  
            setTimeout(f2, 300);
143  
          };
144  
          f2 = function() {
145  
            $("#towly").attr("src", 
146  
              "https://www.botcompany.de:8443/img/1013948");
147  
            setTimeout(f1, 1000+Math.random()*6000);
148  
          };
149  
          setTimeout(f1, 1000);
150  
        ]]))
151  
      + p(/*nlToBr*/(rtrim(mechList_raw("News (HTML)"))))
152  
      + "<br><br>"
153  
      + (!signIn ? "" : googleSignIn_signInButton(relativeRawBotLink(programID(), "content-script"), [[
154  
         eval(data);
155  
         ]], [[
156  
         $(".BUTTON_OUT").css('display', 'none');
157  
         document.getElementById("content").innerHTML = "";
158  
         ]])
159  
      //+ hsmall(ahref(googleSignIn_signOutURL(), "Sign out"))
160  
      + ahref(googleSignIn_signOutURL(), div("Sign out", class := "BUTTON_OUT", style := "display: none"))
161  
      + "<br><br>"
162  
      + div("", id := "content", style := "font-size: 30px")
163  
      
164  
      + hjavascript([[
165  
        function postIt() {
166  
          var q = $("input[name='q']").val();
167  
          var token = $("input[name='token']").val();
168  
          console.log("Posting to ${POSTLINK}, q=" + q);
169  
          $.post('${POSTLINK}', { q : q, token: token },
170  
            function(data, status) {
171  
              console.log("Got data: " + data + "\nStatus: " + status);
172  
              eval(data);
173  
          });
174  
        }
175  
        ]].replace("${POSTLINK}", myRelativeRawLink("/content-script")))
176  
      + hform(hhidden('token, "")
177  
      + div(htextinput('q,
178  
        style := "text-align: center; width: 600px; font-size: 20px",
179  
        placeholder := "Tell me something / Sag mir was",
180  
        value := defaultInput,
181  
        autofocus := 'autofocus,
182  
        onfocus := "this.select()") + " " + hsubmit("OK"), id := 'inputdiv)
183  
      /*+ hjavascript([[
184  
        var inp = $("input[name='q']");
185  
        //inp.setSelectionRange(0, inp.value.length);
186  
        inp.focus(function() { var save_this = $(this); window.setTimeout(function(){ save_this.select(); }, 100); });
187  
      ]])*/,
188  
      onSubmit := "postIt(); return false;"))
189  
      + p(ahref("https://botcompany.de/chat", "[more]") + " "
190  
      + ahref("mailto:info@botcompany.de", "[mail]"))
191  
      )));
192  
}

Author comment

Began life as a copy of #1013810

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1013826
Snippet name: Stefan's OS Download Page [Formerly: Google Sign-In & Bot Hello] [LIVE at http://botcompany.de/]
Eternal ID of this version: #1013826/180
Text MD5: efcf70c065e195a3f134e6595cb9971c
Transpilation MD5: 675224d534f4fc26f528daf7669375f5
Author: stefan
Category: javax / web
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-14 13:09:11
Source code size: 7023 bytes / 192 lines
Pitched / IR pitched: No / No
Views / Downloads: 1094 / 6505
Version history: 179 change(s)
Referenced in: [show references]