<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>.rtd{background-color:#F0E0D6;}</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
var onddbut;
var previewImg;
var noimg_del_f;

$(function(){
  var dispdel_a = false;
  var dispdel_b = true;
  
  $(".deleted").each(function(idx,item){
    item.style.display = "none";
  });
  
  $("table").filter(function(idx,elem){
    if($(this).find("blockquote").length > 0 && $(this).find("img").length == 0){
      $(this).addClass("noimgtable");
    }
  });
  
  onddbut = function() {
    if(document.getElementById("ddbut")){
      document.getElementById("ddbut").innerHTML=dispdel_a?"見る":"隠す";
      
      $(".deleted").each(function(idx,item){
        item.style.display = dispdel_a?"none":"block";
      });
      dispdel_a = !dispdel_a;
    }
  }
  
  previewImg = function(itemID,imgPath) {
    var imgID   = itemID + "_img";
    var imgItem = document.getElementById(imgID);
    var item = document.getElementById(itemID);
    if(!imgItem) {
      // [見る] -> [隠す]
      var imgNode = document.createElement('img');
      imgNode.src = imgPath;
      imgNode.style.maxWidth = '200px';
      imgNode.style.height = 'auto';
      var aNode = document.createElement('a');
      aNode.href = imgPath;
      aNode.target = '_blank';
      aNode.appendChild(imgNode);
      var divNode = document.createElement('div');
      divNode.appendChild(aNode);
      divNode.id = imgID;
      item.parentNode.parentNode.insertBefore(divNode,item.parentNode);
      item.innerHTML = '[隠す]';
    }else{
      // [隠す] -> [見る]
      imgItem.parentNode.removeChild(imgItem);
      item.innerHTML = '[見る]';
    }
  }
  
  noimg_del_f = function() {
    $("table.noimgtable").each(function(){
      if( !$(this).hasClass("deleted") ){
        $(this).css("display", dispdel_b?"none":"block");
      }
    });
    $("button#noimgbtn").text(dispdel_b?"全レス表示":"画像レスのみ")
    dispdel_b = !dispdel_b;
  }
  $("span").each(function(idx,elem){
    if(idx == 0){
      $("<button id='noimgbtn' onclick='noimg_del_f()' >画像レスのみ</button>").insertAfter(this);
    }
  });
});
</script>


