diff -r e56b79cc18a9 -r d900e5a112cc java/sql-vyuka/web/vstupniPole.js --- a/java/sql-vyuka/web/vstupniPole.js Sat May 30 15:35:10 2009 +0200 +++ b/java/sql-vyuka/web/vstupniPole.js Thu May 24 15:47:48 2012 +0200 @@ -4,63 +4,63 @@ function zpracujTabulatory(evt) { - var t = evt.target; - var ss = t.selectionStart; - var se = t.selectionEnd; + var t = evt.target; + var ss = t.selectionStart; + var se = t.selectionEnd; - // Tabulátor - if (evt.keyCode == 9) { - evt.preventDefault(); + // Tabulátor + if (evt.keyCode == 9) { + evt.preventDefault(); - // Víceřádkový výběr - if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) { - var pre = t.value.slice(0,ss); - var sel = t.value.slice(ss,se).replace(/\n/g,"\n"+tab); - var post = t.value.slice(se,t.value.length); - t.value = pre.concat(tab).concat(sel).concat(post); - t.selectionStart = ss + tab.length; - t.selectionEnd = se + tab.length; - } + // Víceřádkový výběr + if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) { + var pre = t.value.slice(0,ss); + var sel = t.value.slice(ss,se).replace(/\n/g,"\n"+tab); + var post = t.value.slice(se,t.value.length); + t.value = pre.concat(tab).concat(sel).concat(post); + t.selectionStart = ss + tab.length; + t.selectionEnd = se + tab.length; + } - // Jednořádkový nebo žádný výběr - else { - t.value = t.value.slice(0,ss).concat(tab).concat(t.value.slice(ss,t.value.length)); - if (ss == se) { - t.selectionStart = t.selectionEnd = ss + tab.length; - } - else { - t.selectionStart = ss + tab.length; - t.selectionEnd = se + tab.length; - } - } - } + // Jednořádkový nebo žádný výběr + else { + t.value = t.value.slice(0,ss).concat(tab).concat(t.value.slice(ss,t.value.length)); + if (ss == se) { + t.selectionStart = t.selectionEnd = ss + tab.length; + } + else { + t.selectionStart = ss + tab.length; + t.selectionEnd = se + tab.length; + } + } + } - // Backspace - else if (evt.keyCode==8 && t.value.slice(ss - 4,ss) == tab) { - evt.preventDefault(); - t.value = t.value.slice(0,ss - 4).concat(t.value.slice(ss,t.value.length)); - t.selectionStart = t.selectionEnd = ss - tab.length; - } + // Backspace + else if (evt.keyCode==8 && t.value.slice(ss - 4,ss) == tab) { + evt.preventDefault(); + t.value = t.value.slice(0,ss - 4).concat(t.value.slice(ss,t.value.length)); + t.selectionStart = t.selectionEnd = ss - tab.length; + } - // Delete - else if (evt.keyCode==46 && t.value.slice(se,se + 4) == tab) { - evt.preventDefault(); - t.value = t.value.slice(0,ss).concat(t.value.slice(ss + 4,t.value.length)); - t.selectionStart = t.selectionEnd = ss; - } + // Delete + else if (evt.keyCode==46 && t.value.slice(se,se + 4) == tab) { + evt.preventDefault(); + t.value = t.value.slice(0,ss).concat(t.value.slice(ss + 4,t.value.length)); + t.selectionStart = t.selectionEnd = ss; + } - // Doleva - else if (evt.keyCode == 37 && t.value.slice(ss - 4,ss) == tab) { - alert("levá"); - evt.preventDefault(); - t.selectionStart = t.selectionEnd = ss - 4; - } + // Doleva + else if (evt.keyCode == 37 && t.value.slice(ss - 4,ss) == tab) { + alert("levá"); + evt.preventDefault(); + t.selectionStart = t.selectionEnd = ss - 4; + } - // Doprava - else if (evt.keyCode == 39 && t.value.slice(ss,ss + 4) == tab) { - alert("pravá"); - evt.preventDefault(); - t.selectionStart = t.selectionEnd = ss + 4; - } -} \ No newline at end of file + // Doprava + else if (evt.keyCode == 39 && t.value.slice(ss,ss + 4) == tab) { + alert("pravá"); + evt.preventDefault(); + t.selectionStart = t.selectionEnd = ss + 4; + } +}