Changeset 27719

Show
Ignore:
Timestamp:
01/01/09 11:07:26 (4 years ago)
Author:
hoge1e3
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/nohada/js/TagBuilder.class.js

    r27703 r27719  
    3232           return this.addObj(k); 
    3333   }, 
    34    insert: function (elem,index) { 
    35       if (index==null) index=0; 
    36       return this.insertAt(index, elem); 
    37    }, 
    3834   setDecoy: function (funcs) { 
    3935       var pl=function () {}; 
     
    5147                         t.parent.appendChild(r); 
    5248              }, 
    53                   insertRow:function (idx) { 
     49                  insertRow:function () { 
     50                         checkTagName(target.tagName,"table"); 
    5451                     return e=t.parent.insertRow(t.parent.rows.length);                   
    5552                  }, 
    56                   insertCell: function (idx) { 
     53                  insertCell: function () { 
     54                         checkTagName(target.tagName,"tr"); 
    5755                     return e=t.parent.insertCell(t.parent.cells.length); 
    5856                  }                
     
    7674          return this.addObj(a);   
    7775        }, 
    78         /*insertAt: function (index, expr) { 
     76        insert: function (expr, index) { 
     77          if (index==null) index=0; 
    7978          var target=this.target; 
    8079          this.setDecoy({ 
     
    8281                 target.insertBefore(r, target.childNodes[index]); 
    8382                 }, 
    84                  insertRow:function (idx) { 
    85                      this.target=t.parent.insertRow(index);                       
     83                 insertRow:function () { 
     84                         checkTagName(target.tagName,"table"); 
     85                     return this.target=target.insertRow(index);                          
    8686                 }, 
    87                  insertCell: function (idx) { 
    88                      this.target=t.parent.insertCell(index); 
     87                 insertCell: function () { 
     88                         checkTagName(target.tagName,"tr"); 
     89                     return this.target=target.insertCell(index); 
    8990                 } 
    9091          }); 
     
    9293          this.target=target; 
    9394          return this; 
    94         },*/ 
     95        }, 
    9596        addStr: function (s) { 
    9697          var target=this.target; 
     
    160161function addNewElement(target, tagName) { 
    161162    var res; 
    162         if (tagName=="tr") { 
    163                 //if (target.tagName!="TABLE") alert("Tag is not table: "+target.tagName); 
     163        if (tagName.eqi("tr")) { 
     164                target.isDecoy || checkTagName(target.tagName,"table"); 
    164165                res=target.insertRow(target.isDecoy ? null : target.rows.length); 
    165166        } else if (tagName=="td") { 
    166                 //if (target.tagName!="TR") alert("Tag is not tr: "+target.tagName); 
     167                target.isDecoy || checkTagName(target.tagName,"tr"); 
    167168                res=target.insertCell(target.isDecoy ? null : target.cells.length); 
    168169        } else { 
     
    172173        return res; 
    173174} 
     175String.prototype.eqi=function (to) { 
     176    return this.toLowerCase()==to.toLowerCase(); 
     177}; 
     178function checkTagName(a,b) { 
     179     a.eqi(b) || alert("<"+a+">!=<"+b+">"); 
     180} 
    174181TagBuilder.getBody=function () { 
    175182   return $tag($$("body")[0]);