Diff
Not logged in

Differences From Artifact [609bc33723]:

To Artifact [87a03d35cb]:


887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911







912


913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
      D.addClass(this,'hidden');
      cs.clearFilters();
    }, false);
    return cs;
  })()/*Chat initialization*/;

  /**
     An experiment in history navigation: when a message numref is
     clicked, we push the origin message onto the history and
     set up the back button to return to that message.
  */
  if(0) window.onpopstate = function(event){
    console.debug("onpopstate event",event.state, event);
    if(event.state && event.state.msgId){
      const e = Chat.setCurrentView(Chat.e.viewMessages).
            querySelector('.message-widget[data-msgid="'+event.state.msgId+'"]');
      console.debug("Popping history back to",event.state, e);
      if(e){
        Chat.MessageWidget.scrollToMessageElem(e);
        //F.page.setPageTitle("Fossil Chat #"+event.state.msgId);
        return;
      }
    }
    Chat.scrollMessagesTo(1);
  };










  const findParentWithClass = function(e, className){
    while(e && !e.classList.contains(className)){
      e = e.parentNode;
    }
    return e;
  };
  
  /** To be passed each MessageWidget's top-level DOM element
      after initial processing of the message, to set up
      hashtag references. */
  const setupHashtags = function f(elem){
    if(!f.$click){
      f.$click = function(ev){
        /* Click handler for hashtags */
        const tag = ev.target.dataset.hashtag;
        if(tag){
          Chat.setHashtagFilter(







|



|
|
|

|
|


<





>
>
>
>
>
>
>

>
>









|







887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905

906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
      D.addClass(this,'hidden');
      cs.clearFilters();
    }, false);
    return cs;
  })()/*Chat initialization*/;

  /**
     An experiment in history navigation: when a message numtag is
     clicked, we push the origin message onto the history and
     set up the back button to return to that message.
  */
  window.onpopstate = function(event){
    const msgid = Chat.numtagHistoryStack.pop();
    if(msgid){
      const e = Chat.setCurrentView(Chat.e.viewMessages).
            querySelector('.message-widget[data-msgid="'+msgid+'"]');
      //console.debug("Popping history back to",msgid, e);
      if(e){
        Chat.MessageWidget.scrollToMessageElem(e);

        return;
      }
    }
    Chat.scrollMessagesTo(1);
  };
  Chat.numtagHistoryStack = [
    /* Relying on the pushHistory() state object for holding
       the message ID is completely misbehaving, not giving
       us the expected state object when window.onpopstate
       is triggered (plus, the browser persists it, which
       introduces its own problems). Thus we use our own
       stack of message IDs for history navigation purposes. */];

  /** If e or one of its parents has the given CSS class, that element
      is returned, else falsy is returned. */
  const findParentWithClass = function(e, className){
    while(e && !e.classList.contains(className)){
      e = e.parentNode;
    }
    return e;
  };
  
  /** To be passed each MessageWidget's top-level DOM element
      after initial processing of the message, to set up
      hashtag and numtag references. */
  const setupHashtags = function f(elem){
    if(!f.$click){
      f.$click = function(ev){
        /* Click handler for hashtags */
        const tag = ev.target.dataset.hashtag;
        if(tag){
          Chat.setHashtagFilter(
938
939
940
941
942
943
944
945
946
947
948
949
950

951
952
953
954
955
956
957
        if(tag){
          const e = Chat.e.viewMessages.querySelector(
            '.message-widget[data-msgid="'+tag+'"]'
          );
          if(e){
            Chat.MessageWidget.scrollToMessageElem(e);
            //Set up window.history() state...
            const p = 1 ? false : findParentWithClass(ev.target, 'message-widget');
            if(p){
              const state = {msgId: p.dataset.msgid};
              console.debug("Pushing history for msgid", state);
              const rc = window.history.pushState(state, "?");
              console.debug("History length =",window.history.length, rc);

            }
          }else{
            F.toast.warning("Message #"+tag+" not found in loaded messages.");
          }
        }
      };
    }







|


|
|
|
>







946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
        if(tag){
          const e = Chat.e.viewMessages.querySelector(
            '.message-widget[data-msgid="'+tag+'"]'
          );
          if(e){
            Chat.MessageWidget.scrollToMessageElem(e);
            //Set up window.history() state...
            const p = 0 ? false : findParentWithClass(ev.target, 'message-widget');
            if(p){
              const state = {msgId: p.dataset.msgid};
              Chat.numtagHistoryStack.push(p.dataset.msgid);
              const rc = window.history.pushState(state, "");
              //console.debug("Pushing history for msgid", state);
              //console.debug("Chat.numtagHistoryStack =",Chat.numtagHistoryStack);
            }
          }else{
            F.toast.warning("Message #"+tag+" not found in loaded messages.");
          }
        }
      };
    }