Fossil

Check-in [4e832e9f40]
Login

Check-in [4e832e9f40]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Import fossil bootstrapping JS into the chat app, add current login name to window.fossil.user.name, and use that name as the initial 'me' value in chat.js (resolves the FIXME in that latter part).
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | chatroom-dev
Files: files | file ages | folders
SHA3-256: 4e832e9f400243873e8e6909e8768ed0538c4866498c71292b4a310f25f11641
User & Date: stephan 2020-12-23 05:44:11.243
Context
2020-12-23
06:26
Chat message precise timestamps are now shown via a tap/click popup, rather than hoverhelp, for mobile compatibility. ... (check-in: 0101325f9d user: stephan tags: chatroom-dev)
05:44
Import fossil bootstrapping JS into the chat app, add current login name to window.fossil.user.name, and use that name as the initial 'me' value in chat.js (resolves the FIXME in that latter part). ... (check-in: 4e832e9f40 user: stephan tags: chatroom-dev)
05:28
Disable the detailed timestamp popup when browser doesn't support it. (example: Safari) ... (check-in: 5744428bfa user: mgagnon tags: chatroom-dev)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/builtin.c.
634
635
636
637
638
639
640



641
642
643
644
645
646
647
    /* can leak a local filesystem path:
       CX("name: %!j,", skin_in_use());*/
    CX("isDark: %s"
       "/*true if the current skin has the 'white-foreground' detail*/",
       skin_detail_boolean("white-foreground") ? "true" : "false");
    CX("}\n"/*fossil.config.skin*/);
    CX("};\n"/* fossil.config */);



    CX("if(fossil.config.skin.isDark) "
       "document.body.classList.add('fossil-dark-style');\n");
#if 0
    /* Is it safe to emit the CSRF token here? Some pages add it
    ** as a hidden form field. */
    if(g.zCsrfToken[0]!=0){
      CX("window.fossil.csrfToken = %!j;\n",







>
>
>







634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
    /* can leak a local filesystem path:
       CX("name: %!j,", skin_in_use());*/
    CX("isDark: %s"
       "/*true if the current skin has the 'white-foreground' detail*/",
       skin_detail_boolean("white-foreground") ? "true" : "false");
    CX("}\n"/*fossil.config.skin*/);
    CX("};\n"/* fossil.config */);
    CX("window.fossil.user = {");
    CX("name: %!j", (g.zLogin&&*g.zLogin) ? g.zLogin : "guest");
    CX("};\n"/*fossil.user*/);
    CX("if(fossil.config.skin.isDark) "
       "document.body.classList.add('fossil-dark-style');\n");
#if 0
    /* Is it safe to emit the CSRF token here? Some pages add it
    ** as a hidden form field. */
    if(g.zCsrfToken[0]!=0){
      CX("window.fossil.csrfToken = %!j;\n",
Changes to src/chat.c.
104
105
106
107
108
109
110

111
112
113
114
115
116
117
  @ </div>
  @ </form>
  @ <hr>

  /* New chat messages get inserted immediately after this element */
  @ <span id='message-inject-point'></span>


  /* Always in-line the javascript for the chat page */
  @ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
  @ let _me = "%j(g.zLogin)";
  cgi_append_content(builtin_text("chat.js"),-1);
  @ </script>

  style_finish_page();







>







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
  @ </div>
  @ </form>
  @ <hr>

  /* New chat messages get inserted immediately after this element */
  @ <span id='message-inject-point'></span>

  builtin_fossil_js_bundle_or("popupwidget", NULL);
  /* Always in-line the javascript for the chat page */
  @ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
  @ let _me = "%j(g.zLogin)";
  cgi_append_content(builtin_text("chat.js"),-1);
  @ </script>

  style_finish_page();
Changes to src/chat.js.
1
2
3
4
5
6
7
8
9
10
11
12
(function(){
  const form = document.querySelector('#chat-form');
  let mxMsg = 0;
  // let _me = "%string($me)";
let me = "drh";  // FIX ME
  form.addEventListener('submit',(e)=>{
    e.preventDefault();
    if( form.msg.value.length>0 || form.file.value.length>0 ){
      fetch("chat-send",{
        method: 'POST',
        body: new FormData(form)
      });




|







1
2
3
4
5
6
7
8
9
10
11
12
(function(){
  const form = document.querySelector('#chat-form');
  let mxMsg = 0;
  // let _me = "%string($me)";
  let me = window.fossil.user.name;
  form.addEventListener('submit',(e)=>{
    e.preventDefault();
    if( form.msg.value.length>0 || form.file.value.length>0 ){
      fetch("chat-send",{
        method: 'POST',
        body: new FormData(form)
      });