Raw button doesn't work when viewing replies



  • No repro. :fa_windows: , does a 'show desktop' and ignores the a A.

    Found a(nother) discobug. If you've expanded the "Reply" button, then 'Show Raw' doesn't do anything - except turn blue.


  • sockdevs

    @dcon said:

    Found a(nother) discobug. If you've expanded the "Reply" button, then 'Show Raw' doesn't do anything - except turn blue.

    E_CANNOTREPRO



  • @dcon said:

    Found a(nother) discobug. If you've expanded the "Reply" button, then 'Show Raw' doesn't do anything - except turn blue.

    Are you sure it wasn't server cooties? Raw button stops working when connection is lost, just like everything else except rendering as if nothing happened.


  • mod

    Can repro. No network failures or console failures visible. Chrome on Win7



  • Yep, I see it on Chrome on Linux, too. No JS errors in the console, so who knows...


  • Winner of the 2016 Presidential Election

    Repro, Chrome Win 10, both machines I use



  • Also FF 44.


  • Winner of the 2016 Presidential Election

    Well I'm glad we've got the environment sorted. Yikes...



  • Repro too (Opera v.whatever). Previously, I was expanding the wrong replies >.<



  • I'm on FF40 (on win8.1)



    • repro. chrome.


  • repro

    Google Chrome	44.0.2403.155 (Official Build) (32-bit)
    Revision	cd35b37500f09a1fb584190e20be6aa85f984d92
    Platform	7077.123.0 (Official Build) stable-channel daisy
    Blink		537.36 (@614b950a55708a12f329b66b7071823b38d1f1fc)
    JavaScript	V8 4.4.63.29
    Flash		18.0.0.233-r1
    User Agent	Mozilla/5.0 (X11; CrOS armv7l 7077.123.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36
    


  • In case anyone is interested in fixing, here is the current implementation of the raw button:

    (function(){
      //@Monarch at what.thedailywtf.com
      //Button is redelcared and sligthly modified due to new scope. it can be further simplified.
      Button = function(action, label, icon, opts) {
        this.action = action;
        this.label = label;
    
        if (typeof icon === "object") { this.opts = icon; } else { this.icon = icon;}
        this.opts = this.opts || opts || {};
    
        this.render = function (buffer){
            var opts = this.opts;
            buffer.push("<button title=\"" + this.label + "\"");
            if (opts.className) { buffer.push(" class=\"" + opts.className + "\""); }
            buffer.push(" data-action=\"" + this.action + "\">");
            if (this.icon) { buffer.push("<i class=\"fa fa-" + this.icon + "\"></i>"); }
            buffer.push("</button>");
        }
      };
    
    
    
        /* Remove this clause after update from v1.4.0.beta4
            https://what.thedailywtf.com/t/fa-code-will-break-next-upgrade/49921/9?u=pjh
        */
        if (typeof Discourse.PostMenuView == 'function'){
            Discourse.PostMenuComponent = Discourse.PostMenuView;
        }
    
      Discourse.PostMenuComponent.reopen({
          buttonForRaw:function(post){
              return new Button('raw', 'view raw post', 'code', {className: "raw-button", disabled: false});
          },
    
          clickRaw:function(post){
              var topicID = post.topic_id,
                  postID =  post.post_number,
                  postArea = $("article[data-post-id='"+post.id+"'] div.contents"),
                  $rawButton = $(this.element).find("button.raw-button"),
                  styles = [{backgroundColor: 'transparent', color: '#A7A7A7'},{backgroundColor: '#08C', color: '#FFF'}];
    
              if (postArea.find('.tdwtf-raw-area').length == 0){
                  var postArea_raw_content = $('<pre class="tdwtf-raw-area"></pre>'),
                      cooked = postArea.find('.cooked');
    
                      cooked.after(postArea_raw_content);
    
                  $.get('/raw/' + topicID + '/' + postID) .done(function (content) {
                      postArea_raw_content.addClass("active");
                      $rawButton.css(styles[1]);//active
                      postArea_raw_content.css({"white-space":"pre-wrap", 'border':'2px dashed #E7E7E7','padding':'3px'}) .text(content);
                      cooked.hide();
                  });
              } else {
                  var postArea_raw_content = postArea.find('.tdwtf-raw-area');
                  if ( !postArea_raw_content.hasClass("active") ){  //raw no active
                      postArea.find('.cooked').hide();  
                      postArea.find('.tdwtf-raw-area').show();
                      postArea_raw_content.addClass("active");
                      $rawButton.css(styles[1]);
                  } else{
                      postArea.find('.cooked').show();  
                      postArea.find('.tdwtf-raw-area').hide();
                      postArea_raw_content.removeClass("active");
                      $rawButton.css(styles[0]);
                  }
              }
          }
      });    
    })();
    

Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.