tbl_move_copy
[phpmyadmin/crack.git] / libraries / tbl_change.js
blobbd924b06a73ee194c0f87b468331d997524e65b5
1 /* $Id$ */
4 /**
5  * Modify from controls when the "NULL" checkbox is selected
6  *
7  * @param   string   the MySQL field type
8  * @param   string   the urlencoded field name
9  * @param   string   the md5 hashed field name
10  *
11  * @return  boolean  always true
12  */
13 function nullify(theType, urlField, md5Field)
15     var rowForm = document.forms['insertForm'];
17     if (typeof(rowForm.elements['funcs[' + urlField + ']']) != 'undefined') {
18         rowForm.elements['funcs[' + urlField + ']'].selectedIndex = -1;
19     }
21     // "SET" field , "ENUM" field with more than 20 characters
22     // or foreign key field
23     if (theType == 1 || theType == 3 || theType == 4) {
24         rowForm.elements['field_' + md5Field + '[]'].selectedIndex = -1;
25     }
26     // Other "ENUM" field
27     else if (theType == 2) {
28         var elts     = rowForm.elements['field_' + md5Field + '[]'];
29         var elts_cnt = elts.length;
30         for (var i = 0; i < elts_cnt; i++ ) {
31             elts[i].checked = false;
32         } // end for
33     }
34     // Other field types
35     else /*if (theType == 5)*/ {
36         rowForm.elements['fields[' + urlField + ']'].value = '';
37     } // end if... else if... else
39     return true;
40 } // end of the 'nullify()' function
43 /**
44  * Unchecks the "NULL" control when a function has been selected or a value
45  * entered
46  *
47  * @param   string   the urlencoded field name
48  *
49  * @return  boolean  always true
50  */
51 function unNullify(urlField)
53     var rowForm = document.forms['insertForm'];
55     if (typeof(rowForm.elements['fields_null[' + urlField + ']']) != 'undefined') {
56         rowForm.elements['fields_null[' + urlField + ']'].checked = false
57     } // end if
59     return true;
60 } // end of the 'unNullify()' function
62 /**
63   * Allows moving around inputs/select by Ctrl+arrows
64   *
65   * @param   object   event data   
66   */
67 function onKeyDownArrowsHandler(e) {
68     e = e||window.event;
69     var o = (e.srcElement||e.target);
70     if (!o) return;
71     if (o.tagName != "TEXTAREA" && o.tagName != "INPUT" && o.tagName != "SELECT") return;
72     if (!e.ctrlKey) return;
73     if (!o.id) return;
75     var pos = o.id.split("_");
76     if (pos[0] != "field" || typeof pos[2] == "undefined") return;
78     var x = pos[2], y=pos[1];
79     
80     // skip non existent fields
81     for (i=0; i<10; i++)
82     {
83         switch(e.keyCode) {
84             case 38: y--; break; // up
85             case 40: y++; break; // down
86             case 37: x--; break; // left
87             case 39: x++; break; // right
88             default: return;
89         }
91         var id = "field_" + y + "_" + x;
92         var nO = document.getElementById(id);
93         if (!nO) {
94             var id = "field_" + y + "_" + x + "_0";
95             var nO = document.getElementById(id);
96         }
97         if (nO) break;
98     }
99     
100     if (!nO) return;
101     nO.focus();
102     if (nO.tagName != 'SELECT') {
103         nO.select();
104     }
105     e.returnValue = false;