//function function get_keys(prog) { //alert(prog); var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","get_keys.php?fProgram="+prog,false); xmlhttp.send(); if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById('keyfield').innerHTML = xmlhttp.responseText; document.getElementById('valuefield').innerHTML = ""; } else document.getElementById('keyfield').innerHTML = "argh"; } //function function get_values(prog, key) { //alert(prog+"---"+key); var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","get_values.php?fKey="+key+"&fProgram="+prog,false); xmlhttp.send(); if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById('valuefield').innerHTML = xmlhttp.responseText; if (key=='newkey') addRow(prog, key); } else document.getElementById('valuefield').innerHTML = "argh"; } function addRow(prog, key) { tabBody=document.getElementById("valtable"); row=document.createElement("TR"); row.id='val0'; cell0 = document.createElement("TD"); cell1 = document.createElement("TD"); cell2 = document.createElement("TD"); cell3 = document.createElement("TD"); cell4 = document.createElement("TD"); cell5 = document.createElement("TD"); //case add new key (value NULL) if (key=='newkey') { input1 = document.createElement("INPUT"); input1.value = prog; input1.id = 'prog0'; input2 = document.createElement("INPUT"); input2.value = 'newkey'; input2.id = 'key0'; cell3.id = 'newval0'; textnode3=document.createTextNode("NULL"); input4 = document.createElement("INPUT"); input4.id = 'newdescr0'; input5 = document.createElement("input"); input5.value = 'Add'; input5.type = "button"; input5.onclick = function () { UpdateRow(1, 0); onclick() } cell1.appendChild(input1); cell2.appendChild(input2); cell3.appendChild(textnode3); cell4.appendChild(input4); cell5.appendChild(input5); //cell5.appendChild(button5); } //case add new val for same key else { cell1.id = 'prog0'; cell2.id = 'key0'; textnode1=document.createTextNode(prog); textnode2=document.createTextNode(key); input3 = document.createElement("INPUT"); input3.id = 'newval0'; input4 = document.createElement("INPUT"); input4.id = 'newdescr0'; input5 = document.createElement("input"); input5.value = 'Add'; input5.type = "button"; input5.onclick = function () { UpdateRow(2, 0); onclick() } cell1.appendChild(textnode1); cell2.appendChild(textnode2); cell3.appendChild(input3); cell4.appendChild(input4); cell5.appendChild(input5); } row.appendChild(cell0); row.appendChild(cell1); row.appendChild(cell2); row.appendChild(cell3); row.appendChild(cell4); row.appendChild(cell5); tabBody.appendChild(row); // to be removed later when solution for adding multiple new rows is found document.getElementById('addrow').style.display = "none"; } function EditRow(index) { oldval=document.getElementById('val'+index).innerHTML; document.getElementById('val'+index).innerHTML = ""; olddescr=document.getElementById('descr'+index).innerHTML; document.getElementById('descr'+index).innerHTML = ""; document.getElementById('action'+index).innerHTML = "" +""; } function UpdateRow(updcase,index) { // three cases of update // 1: add new key // 2: add new val (for same key) // 3: edit val // 4: delete val (ie set to NULL) if (updcase==1) { prog=document.getElementById('prog'+index).value; key=document.getElementById('key'+index).value; } else { prog=document.getElementById('prog'+index).innerHTML; key=document.getElementById('key'+index).innerHTML; } if (updcase==1) val=document.getElementById('newval'+index).innerHTML; else val=document.getElementById('newval'+index).value; descr=document.getElementById('newdescr'+index).value; if (!descr) alert("Please insert description!"); if (!key) alert("Please insert key!"); if (!val) alert("Please insert value!"); if (!val || !descr || !key) return; if (index==0) index=-1; phpcall="insert_po.php?fUpdCase="+updcase+"&fIndex="+index+"&fProgram="+prog+"&fKey="+key+"&fValue="+val+"&fDescription="+descr; //alert("u/i --- "+index+" --- "+prog+" --- "+key+" --- "+val+" --- "+descr); //alert(phpcall); var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET", phpcall, false); xmlhttp.send(); if (xmlhttp.readyState==4 && xmlhttp.status==200) alert(xmlhttp.responseText); else alert("Mist! "+xmlhttp.responseText); var xmlhttp2; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp2=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp2.open("GET","get_values.php?fKey="+key+"&fProgram="+prog,false); xmlhttp2.send(); if (xmlhttp2.readyState==4 && xmlhttp2.status==200) { document.getElementById('valuefield').innerHTML = xmlhttp2.responseText; if (key=='newkey') addRow(prog, key); } else document.getElementById('valuefield').innerHTML = "argh"; } // printf("
\n\n
\n"); function ShowCurrent() { for (var i = 1 ; i <= document.getElementById('maxindex').innerHTML ; i++) if(document.getElementById('old'+i)) document.getElementById('old'+i).style.display = "none"; document.getElementById('showcurrent').style.display = "none"; document.getElementById('showall').style.display = ""; } function ShowAll() { for (var i = 1 ; i <= document.getElementById('maxindex').innerHTML ; i++) if(document.getElementById('old'+i)) document.getElementById('old'+i).style.display = ""; document.getElementById('showcurrent').style.display = ""; document.getElementById('showall').style.display = "none"; }