document.querySelector('.mailInfo') : query if document has the tag defined mailInfo in class
table. querySelectorAll('tr') : this will return array of tr object elements
table.getAttribute('summary') : this will return value if summary attribute exist
This is Example
function bigMailInit(){
  // 메일 인포를 찾음...
  var mailInfo = document.querySelector('.mailInfo');
  var li = mailInfo.querySelectorAll('table');
  // 널 체크, just in case
  if(li == null || li.length ==0){
   return;
  }
  var i=0;
  var table;
  // 메일 인포안에 여러개의 테이블이 있지만 대용량 테이블이 아닐수도 있어서 Summary attribute에서 체크 해야함
  for(i=0; i<li.length; i++){
   table = li[i];
   var summary = table.getAttribute('summary');
   if(summary != null){
    if(summary.indexOf('대용량') >= 0 && summary.indexOf('Mass') >= 0 ){
     var tbody= table.querySelectorAll('tbody');
     if(tbody[0].children.length <3){
      break;
     }
     var start =3; // tr의 3번째부터 첨부파일들이 나열
     for(start; start<tbody[0].children.length; start++){
      a = tbody[0].children[start].querySelectorAll('a');
      var j=0;
      for(j; j<a.length; j++){
       a[j].href = a[j].getAttribute('href');
      };
     }
     break;
    };
   };
  };
 }
No comments:
Post a Comment