// setting the option value of the entry selection list to 1

var formBox = document.getElementById("form-box");
var options = document.getElementsByTagName("select");
for(var i=0; i<options.length;i++){
    options[i].value="1";
    options[i].style.display = "none";
    var label = <HTMLLabelElement> document.querySelector("label[for=id_form-" + i + "-Entry]");
    label.style.display = "none";
}

//options.value="1";

// setting saved_successed position

const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
const height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;

var savedSuccessedWindow = document.getElementById("successful-saved");

const savedSuccessedWindowWidth = 200;

savedSuccessedWindow.style["position"] = "fixed";
savedSuccessedWindow.style["top"] = "15px";
const savedSuccessedWindowLeft = width/2 - savedSuccessedWindowWidth;
savedSuccessedWindow.style["left"] = savedSuccessedWindowLeft.toString() + "px";

savedSuccessedWindow.style["width"] = savedSuccessedWindowWidth.toString() + "px";

var closeSuccSaved = document.getElementById("close-successful-saved");
var SuccSaved = document.getElementById("successful-saved")

closeSuccSaved.addEventListener("click",(e)=>{
    SuccSaved.style["display"] = "none";
})

var editBottonList = document.getElementsByClassName('entry-edit-button')

for (var i=0; i< editBottonList.length; i++){    
    editBottonList[i].addEventListener("click",(e)=>{
        console.log(123);
        let tgt = <HTMLElement> e.target;
        let bottonId = tgt.id;
        let entryEditRegexp = /entry-edit-(\d+)/;
        let IdNum = entryEditRegexp.exec(bottonId)[1];
        let inputBoxClassName = ".ent-mod-inp-" + IdNum; // ent-mod-inp = entry-modify-input

        let inputBoxList =  document.querySelectorAll<HTMLElement>(inputBoxClassName);
        for (var j=0; j<inputBoxList.length; j++){
            inputBoxList[j].style['display'] = 'block';
        }


    }, false)
}

