1.1 --- a/java/sql-vyuka/web/vstupniPole.js Sat May 30 15:35:10 2009 +0200
1.2 +++ b/java/sql-vyuka/web/vstupniPole.js Thu May 24 15:47:48 2012 +0200
1.3 @@ -4,63 +4,63 @@
1.4
1.5 function zpracujTabulatory(evt) {
1.6
1.7 - var t = evt.target;
1.8 - var ss = t.selectionStart;
1.9 - var se = t.selectionEnd;
1.10 + var t = evt.target;
1.11 + var ss = t.selectionStart;
1.12 + var se = t.selectionEnd;
1.13
1.14
1.15 - // Tabulátor
1.16 - if (evt.keyCode == 9) {
1.17 - evt.preventDefault();
1.18 + // Tabulátor
1.19 + if (evt.keyCode == 9) {
1.20 + evt.preventDefault();
1.21
1.22 - // Víceřádkový výběr
1.23 - if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) {
1.24 - var pre = t.value.slice(0,ss);
1.25 - var sel = t.value.slice(ss,se).replace(/\n/g,"\n"+tab);
1.26 - var post = t.value.slice(se,t.value.length);
1.27 - t.value = pre.concat(tab).concat(sel).concat(post);
1.28 - t.selectionStart = ss + tab.length;
1.29 - t.selectionEnd = se + tab.length;
1.30 - }
1.31 + // Víceřádkový výběr
1.32 + if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) {
1.33 + var pre = t.value.slice(0,ss);
1.34 + var sel = t.value.slice(ss,se).replace(/\n/g,"\n"+tab);
1.35 + var post = t.value.slice(se,t.value.length);
1.36 + t.value = pre.concat(tab).concat(sel).concat(post);
1.37 + t.selectionStart = ss + tab.length;
1.38 + t.selectionEnd = se + tab.length;
1.39 + }
1.40
1.41 - // Jednořádkový nebo žádný výběr
1.42 - else {
1.43 - t.value = t.value.slice(0,ss).concat(tab).concat(t.value.slice(ss,t.value.length));
1.44 - if (ss == se) {
1.45 - t.selectionStart = t.selectionEnd = ss + tab.length;
1.46 - }
1.47 - else {
1.48 - t.selectionStart = ss + tab.length;
1.49 - t.selectionEnd = se + tab.length;
1.50 - }
1.51 - }
1.52 - }
1.53 + // Jednořádkový nebo žádný výběr
1.54 + else {
1.55 + t.value = t.value.slice(0,ss).concat(tab).concat(t.value.slice(ss,t.value.length));
1.56 + if (ss == se) {
1.57 + t.selectionStart = t.selectionEnd = ss + tab.length;
1.58 + }
1.59 + else {
1.60 + t.selectionStart = ss + tab.length;
1.61 + t.selectionEnd = se + tab.length;
1.62 + }
1.63 + }
1.64 + }
1.65
1.66 - // Backspace
1.67 - else if (evt.keyCode==8 && t.value.slice(ss - 4,ss) == tab) {
1.68 - evt.preventDefault();
1.69 - t.value = t.value.slice(0,ss - 4).concat(t.value.slice(ss,t.value.length));
1.70 - t.selectionStart = t.selectionEnd = ss - tab.length;
1.71 - }
1.72 + // Backspace
1.73 + else if (evt.keyCode==8 && t.value.slice(ss - 4,ss) == tab) {
1.74 + evt.preventDefault();
1.75 + t.value = t.value.slice(0,ss - 4).concat(t.value.slice(ss,t.value.length));
1.76 + t.selectionStart = t.selectionEnd = ss - tab.length;
1.77 + }
1.78
1.79 - // Delete
1.80 - else if (evt.keyCode==46 && t.value.slice(se,se + 4) == tab) {
1.81 - evt.preventDefault();
1.82 - t.value = t.value.slice(0,ss).concat(t.value.slice(ss + 4,t.value.length));
1.83 - t.selectionStart = t.selectionEnd = ss;
1.84 - }
1.85 + // Delete
1.86 + else if (evt.keyCode==46 && t.value.slice(se,se + 4) == tab) {
1.87 + evt.preventDefault();
1.88 + t.value = t.value.slice(0,ss).concat(t.value.slice(ss + 4,t.value.length));
1.89 + t.selectionStart = t.selectionEnd = ss;
1.90 + }
1.91
1.92 - // Doleva
1.93 - else if (evt.keyCode == 37 && t.value.slice(ss - 4,ss) == tab) {
1.94 - alert("levá");
1.95 - evt.preventDefault();
1.96 - t.selectionStart = t.selectionEnd = ss - 4;
1.97 - }
1.98 + // Doleva
1.99 + else if (evt.keyCode == 37 && t.value.slice(ss - 4,ss) == tab) {
1.100 + alert("levá");
1.101 + evt.preventDefault();
1.102 + t.selectionStart = t.selectionEnd = ss - 4;
1.103 + }
1.104
1.105 - // Doprava
1.106 - else if (evt.keyCode == 39 && t.value.slice(ss,ss + 4) == tab) {
1.107 - alert("pravá");
1.108 - evt.preventDefault();
1.109 - t.selectionStart = t.selectionEnd = ss + 4;
1.110 - }
1.111 -}
1.112 \ No newline at end of file
1.113 + // Doprava
1.114 + else if (evt.keyCode == 39 && t.value.slice(ss,ss + 4) == tab) {
1.115 + alert("pravá");
1.116 + evt.preventDefault();
1.117 + t.selectionStart = t.selectionEnd = ss + 4;
1.118 + }
1.119 +}