var KorpusApp = { loadAll:function(){ 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.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ var data=JSON.parse(xmlhttp.responseText); KorpusApp.parse(data); } } xmlhttp.open("POST","backend/loadAll.php",true); xmlhttp.setRequestHeader("Content-type","application/json"); xmlhttp.send(); }, search:function(data){ 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.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ var data=JSON.parse(xmlhttp.responseText); KorpusApp.parse(data); } } xmlhttp.open("POST","backend/search.php",true); xmlhttp.setRequestHeader("Content-type","application/json"); xmlhttp.send(JSON.stringify(data)); }, parse:function(data){ var resultViewer=document.getElementById('searchResults'); resultViewer.innerHTML=""; var table=document.createElement('table'); var thead=document.createElement('thead'); var tr=document.createElement('tr'); var td=document.createElement('td'); td.appendChild(document.createTextNode('Stimulus Nr.')); tr.appendChild(td); td=document.createElement('td'); td.appendChild(document.createTextNode('Textkorpus')); tr.appendChild(td); thead.appendChild(tr); table.appendChild(thead); var tbody=document.createElement('tbody'); var key; for(stim in data){ for(key in data[stim]){ var showStim=true; if(data[stim].hasOwnProperty(key)){ var tr=document.createElement('tr'); var td=document.createElement('td'); var key2; var y=0; for(key2 in data[stim][key]){ if(y>0) td.appendChild(document.createTextNode(" ")); var key3; var x=0; for(key3 in data[stim][key][key2]){ var token=data[stim][key][key2][key3] if(showStim==true){ var std=document.createElement('td'); std.appendChild(document.createTextNode(token.stimulus_nr)); tr.appendChild(std); showStim=false; } if(x>0) td.appendChild(document.createTextNode("="));; var span = document.createElement('span'); /*span.setAttribute('data-sprache',token.sprache); span.setAttribute('data-pos',token.pos); span.setAttribute('data-verbal_form',token.verbal_form); span.setAttribute('data-person',token.person); span.setAttribute('data-tempus',token.tempus); span.setAttribute('data-modus',token.modus); span.setAttribute('data-genus',token.genus); span.setAttribute('data-genus_verbi',token.genus_verbi); span.setAttribute('data-numerus',token.numerus); span.setAttribute('data-particle',token.particle); span.setAttribute('data-case',token.case);*/ span.setAttribute('onmouseover',"Tip('
Sprache: "+token.sprache+"
Wortart: "+token.pos+"
Verbform"+token.verbal_form+"
Kasus: "+token.fall+"
Bedeutung: "+token.lemma+"
Übersetzung: "+token.translation+"
',BGCOLOR,'#efefe9',BORDERCOLOR,'#0C2B01')"); /* Taxis: "+token.tempus+" Person: "+token.person+" Modus: "+token.modus+" Genus: "+token.genus+" Genus Verbi: "+token.genus_verbi+" Numerus: "+token.numerus+" Partikel: "+token.particle+" */ span.setAttribute('onmouseout','UnTip()'); span.appendChild(document.createTextNode(token.token_beta)); td.appendChild(span); x++; } y++; } tr.appendChild(td); tbody.appendChild(tr); } } } table.appendChild(tbody); resultViewer.appendChild(table); } }