import { rodata } from '../rodata'

const createTxtViewArea = (bun, allBunArr, i,verbBunHtml,isArrow)=>{

  console.log(verbBunHtml)
  //1つ1つのTextViewAreaをつくる
  createBox(i)
  /*  for(let i=bun.bunNo-3;i<=bun.bunNo+3;i++){
      console.log(allBunArr[i])
    }*/
  if(bun.bunNo!==0&&allBunArr[ bun.bunNo - 1]!==void 0){
    if(bun.bunNo!==1&&allBunArr[ bun.bunNo - 2]!==void 0){
      if(bun.bunNo!==2&&allBunArr[ bun.bunNo - 3]!==void 0){
        addBun('msg'+i, allBunArr[ bun.bunNo - 3], false)
      }
      addBun('msg'+i, allBunArr[ bun.bunNo - 2], false)
    }
    addBun('msg'+i, allBunArr[ bun.bunNo - 1], false)
  }


  //addBun('msg'+i,allBunArr[bun.bunNo], true)
  addWatchingBun(i,bun,true,verbBunHtml,isArrow)


  if( bun.bunNo + 1 !== allBunArr.length &&allBunArr[ bun.bunNo +1]!==void 0){
    addBun('msg'+i , allBunArr[bun.bunNo + 1], false)
    if( bun.bunNo + 2 !== allBunArr.length &&allBunArr[ bun.bunNo +2]!==void 0){
      addBun('msg'+i , allBunArr[bun.bunNo + 2], false)
      if( bun.bunNo + 3 !== allBunArr.length &&allBunArr[ bun.bunNo +3]!==void 0){
        addBun('msg'+i , allBunArr[bun.bunNo + 3], false)
      }
    }
  }
}

const createBox=(i)=>{
  //箱を作る

  let msg = document.getElementById('box')
  msg.innerHTML += '<div id="msg' + i +'" style="border-width: 1px; background-color:#ffffff; width:600px; overflow-y:scroll; margin-bottom: 5px; margin-left: 5px; margin-top: 10px; padding-bottom: 5px; padding-top: 5px;">'
}

const addBun=(id,bun,bold,verbBunHtml,isArrow)=>{
  //箱に1文を追加。boldはboolean
  let msg = document.getElementById(id)
  const talker=""
  const color="#000000"
  const bunNo = bun.bunNo
  const bunContent=bun.surfaceForm
  if(bold){msg.innerHTML+="<b>"}
  msg.innerHTML += '<font size=' + rodata.textViewFontSize + '>' + bunNo + '' + talker + ' <font color=' + color + '>【</font>'
  if(isArrow){
    msg.innerHTML +=  verbBunHtml
  }else{
    msg.innerHTML +=  bunContent
  }
  msg.innerHTML += '】</font><br><br>'
  if(bold){msg.innerHTML+="</b>"}
}

const addWatchingBun = (i,bun,isBold,verbBunHtml,isArrow) => {

  if(isArrow){
    addBun('msg'+i,bun, true,verbBunHtml,true)
  }else{
    addBun('msg'+i,bun, true,null,false)
  }
}

export{createTxtViewArea}
@@ -101,16 +101,18 @@
 )=%3E%7B%0A%0A  
+//
 console.
@@ -1676,16 +1676,18 @@
 eForm%0A  
+//
 if(bold)
@@ -1890,24 +1890,68 @@
 ml%0A  %7Delse%7B%0A
+    if(bold)%7B%0A      //console.log(%22bold%22)%0A  
     msg.inne
@@ -1959,16 +1959,23 @@
 HTML += 
+%22%3Cu%3E%22 +
  bunCont
@@ -1977,16 +1977,77 @@
 nContent
+ +%22%3C/u%3E%22%0A%0A    %7Delse%7B%0A      msg.innerHTML +=  bunContent%0A    %7D
 %0A  %7D%0A  m
@@ -2083,16 +2083,18 @@
 %3Cbr%3E'%0A  
+//
 if(bold)

add under line when we click circle.