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

!7

// Content in: http://botcompany.de/1013927/raw/list/News+%28HTML%29

//set flag NoAI.
set flag TripleAI.

sS denkmodulID = ""; //#1013938;
sO denkmodul;

sbool towly, signIn;

static long tokenTimeout = 60*60*1000; // one hour

p {
  independentSmartBot();
  if (nempty(denkmodulID))
    runInMCVarWithAutoRestart('denkmodul, denkmodulID);
}

static ExpiringHashMap<S, Payload> tokensToPayload = new(tokenTimeout);

html {
  new Matches m;
  
  if (eq(uri, "/") && !cic(domain(), "butter") && !swic(domain(), "www."))
    ret hrefresh("https://www.botcompany.de:8443/1013826/raw");
    
  if (eq(uri, "/tokens")) ret lstr(tokensToPayload);

  S token = params.get("token");
  S q = params.get("q");
  
  Payload payload = null;
  bool loaded = false;
  if (nempty(token)) {
    payload = tokensToPayload.get(token);
    if (payload == null) {
      payload = googleVerifyUserToken2(botCompanyGoogleSignInID(), token);
      loaded = true;
      mapPut(tokensToPayload, token, payload);
    }
  }
    
  if (payload != null) {
    long time = unixTime();
    print("loaded=" + loaded + ", issued=" + (payload.getIssuedAtTimeSeconds()-time) + ", expiration=" + (payload.getExpirationTimeSeconds()-time));
  }
    
  S email = payload == null ? null : payload.getEmail();
  
  if (nempty(q)) {
    if (nempty(email)) {
      appendToMechList_noUniq("Things said on the home page by logged in users", now() + ", " + email + ": " + q);
      post(email, "said", quote(q));
    } else
      appendToMechList_noUniq("Things said on the home page by anonymous users", now() + ": " + q);
  }
    
  if (eq(uri, "/content-script")) {
    S text = "";
    if (nempty(q)) {
      text += p(small("> " + span(htmlencode(q), style := "color: gray")));
      S a = "Fehler";
      pcall { a = callAnswerFunction(denkmodul, q); }
      if (nempty(a)) {
        if (swic_trim(a, "[VIDEO] ", m))
          text += embedYoutube_newer_autoplay(m.rest(), 600);
        else
          text += p(htmlencode(a));
      }
    }
    bool again = false, de = false;
    /*if (payload == null)
      text += "You are not logged in.";*/
      
    if (nempty(email)) {
      pnlStruct(payload);
      again = post(email, "logged in", ".") == null;
      if (!payload.getEmailVerified())
        text = "Unverified email (huh?)";
    }
    
    if (empty(text)) {
      de = cic((S) payload.get("locale"), "de");
      S firstName = (S) payload.get("given_name");
      text = p(htmlencode((de ? "Hallo " : "Hello ")
        + (again ? (de ? "mal wieder, " : "again ") : "")
        + firstName + "!"));
      S pic = (S) payload.get("picture");
      if (de && isURL(pic))
        text += p(htmlencode("Was für ein hübsches Bild:"))
          + p(himg(pic, title := firstName + ", ein toller Mensch"));
    }
      
    S script =
      [[$(".BUTTON_OUT").css('display', 'inline-block');
      document.getElementById("content").innerHTML = ]] + jsQuote(text) + ";" +
      [[
        $("input[name='token']").val($TOKEN);
        $("#inputdiv").show();
        $("input[name='q']").focus();
      ]].replace("$TOKEN", jsQuote(token));
    if (de) script += [[$("input[name='q']").attr('placeholder', 'Sprich mit mir');]];
    
    print(script);
    ret script;
  }
  
  S defaultInput = "Spiel George Michael";
  
  ret hhtml(hhead(htitle("BotCompany.de")
    + hmobilefix()
    + loadJQuery()
    + googleSignIn_header()
    + hcss(andrzejButtonStyle())
    + hcookieconsent()
    + hGoogleFont("Raleway:500") 
    + loadHtml2canvas()
    + hcss("body { font-family: Raleway; font-weight: 500; }")
    + hplaceholderStyle("color: blue; opacity: 1 !important; text-align: center;"))
    + hbody(
      (nempty(params.get("noworker")) ? "" : hSilentComputator())
      + jsIsDesktopChrome()
      + hfullcenter(
        p(ahref("http://BotCompany.de", "BotCompany.de"))
        
        + htableRaw2_singleRow(ll(
              youtubeEmbed("wmA4VPl9RnY", 254, 150, "Stefan's OS"),
              youtubeEmbed("xYMFQs549i0", 254, 150, "Optical Character Recognition Demo"),
              youtubeEmbed("bS8j3gQyATM", 254, 150, "A New Approach To Image Recognition"),
              youtubeEmbed("nMRGcamgc_U", 254, 150, "Stefan's OS: Working With Files")
            ),
              ll(style := "margin-bottom: 40px"), null, ll(align := 'center, style := "padding-left: 10px; padding-right: 10px"))
        // towly
      + (!towly ? "" : p(hsnippetimg(#1013948, width := 125, height := 141, id := "towly", title := "Towly greets you"))
        + hscript([[
          //var towlyPhase = 1;
          var f1, f2;
          f1 = function() {
            $("#towly").attr("src", "https://www.botcompany.de:8443/img/1013945");
            setTimeout(f2, 300);
          };
          f2 = function() {
            $("#towly").attr("src", 
              "https://www.botcompany.de:8443/img/1013948");
            setTimeout(f1, 1000+Math.random()*6000);
          };
          setTimeout(f1, 1000);
        ]]))
      + p(/*nlToBr*/(rtrim(mechList_raw("News (HTML)"))))
      + "<br><br>"
      + (!signIn ? "" : googleSignIn_signInButton(relativeRawBotLink(programID(), "content-script"), [[
         eval(data);
         ]], [[
         $(".BUTTON_OUT").css('display', 'none');
         document.getElementById("content").innerHTML = "";
         ]])
      //+ hsmall(ahref(googleSignIn_signOutURL(), "Sign out"))
      + ahref(googleSignIn_signOutURL(), div("Sign out", class := "BUTTON_OUT", style := "display: none"))
      + "<br><br>"
      + div("", id := "content", style := "font-size: 30px")
      
      + hjavascript([[
        function postIt() {
          var q = $("input[name='q']").val();
          var token = $("input[name='token']").val();
          console.log("Posting to ${POSTLINK}, q=" + q);
          $.post('${POSTLINK}', { q : q, token: token },
            function(data, status) {
              console.log("Got data: " + data + "\nStatus: " + status);
              eval(data);
          });
        }
        ]].replace("${POSTLINK}", myRelativeRawLink("/content-script")))
      + hform(hhidden('token, "")
      + div(htextinput('q,
        style := "text-align: center; width: 600px; font-size: 20px",
        placeholder := "Tell me something / Sag mir was",
        value := defaultInput,
        autofocus := 'autofocus,
        onfocus := "this.select()") + " " + hsubmit("OK"), id := 'inputdiv)
      /*+ hjavascript([[
        var inp = $("input[name='q']");
        //inp.setSelectionRange(0, inp.value.length);
        inp.focus(function() { var save_this = $(this); window.setTimeout(function(){ save_this.select(); }, 100); });
      ]])*/,
      onSubmit := "postIt(); return false;"))
      + p(ahref("https://botcompany.de/chat", "[more]") + " "
      + ahref("mailto:info@botcompany.de", "[mail]"))
      )));
}

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: 1210 / 6830
Version history: 179 change(s)
Referenced in: #1003253 - New Homepage (LIVE)