Diff
Not logged in

Differences From Artifact [3559e64002]:

To Artifact [d38818786f]:


934
935
936
937
938
939
940
941
942
943


944
945
946
947


















948
949
950
951
952
953
954
955
          if( m.fmime
              && m.fmime.startsWith("image/")
              && Chat.settings.getBool('images-inline',true)
            ){
            contentTarget.appendChild(D.img("chat-download/" + m.msgid));
            ds.hasImage = 1;
          }else{
            const a = D.a(
              window.fossil.rootPath+
                'chat-download/' + m.msgid+'/'+encodeURIComponent(m.fname),


              // ^^^ add m.fname to URL to cause downloaded file to have that name.
              "(" + m.fname + " " + m.fsize + " bytes)"
            )
            D.attr(a,'target','_blank');


















            contentTarget.appendChild(a);
          }
        }
        if(m.xmsg){
          if(m.fsize>0){
            /* We have file/image content, so need another element for
               the message text. */
            contentTarget = D.div();







|
|
|
>
>




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
          if( m.fmime
              && m.fmime.startsWith("image/")
              && Chat.settings.getBool('images-inline',true)
            ){
            contentTarget.appendChild(D.img("chat-download/" + m.msgid));
            ds.hasImage = 1;
          }else{
            // Add a download link.
            const downloadUri = window.fossil.rootPath+
                  'chat-download/' + m.msgid+'/'+encodeURIComponent(m.fname);
            const w = D.addClass(D.div(), 'attachment-link');
            const a = D.a(downloadUri,
              // ^^^ add m.fname to URL to cause downloaded file to have that name.
              "(" + m.fname + " " + m.fsize + " bytes)"
            )
            D.attr(a,'target','_blank');
            D.append(w, a);
            if(/\.html$/i.test(m.fname)){
              /* Add an option to embed HTML attachments in an iframe. The primary
                 use case is attached diffs. */
              D.addClass(contentTarget, 'wide');
              const embedTarget = this.e.content;
              const btnEmbed = D.button("Embed", function(){
                D.remove(btnEmbed);
                const iframe = document.createElement('iframe');
                D.append(embedTarget, iframe);
                iframe.addEventListener('load', function(){
                  iframe.style.maxHeight = iframe.style.height
                    = iframe.contentWindow.document.documentElement.scrollHeight + 'px';
                });
                iframe.setAttribute('src', downloadUri);
              });
              D.append(w, btnEmbed);
            }
            contentTarget.appendChild(w);
          }
        }
        if(m.xmsg){
          if(m.fsize>0){
            /* We have file/image content, so need another element for
               the message text. */
            contentTarget = D.div();