Converting number of Excel column names no longer limited
[phpmyadmin/arisferyanto.git] / pmd / scripts / ajax.js
blob0f47bab21fa585aa397d0e07293041c429f3b28e
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  *
4  * @version $Id$
5  * @package phpMyAdmin-Designer
6  */
8 /**
9  *
10  */
11 var http_request = false;
12 var xmldoc;
13 var textdoc;
15 /**
16  *
17  */
18 function makeRequest(url, parameters)
20     http_request = false;
21     if (window.XMLHttpRequest) {
22         // Mozilla, Safari,...
23         http_request = new XMLHttpRequest();
24         if (http_request.overrideMimeType) {
25             http_request.overrideMimeType('text/xml');
26         }
27     } else if (window.ActiveXObject) {
28         // IE
29         try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); }
30         catch (e) {
31             try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); }
32             catch (e) {}
33         }
34     }
36     if (!http_request) {
37         alert('Giving up :( Cannot create an XMLHTTP instance');
38         return false;
39     }
41     http_request.onreadystatechange = alertContents;
42     http_request.open('POST', url, true);
43     http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
44     http_request.setRequestHeader("Content-length", parameters.length);
45     http_request.setRequestHeader("Connection", "close");
46     http_request.send(parameters);
47     return true;
50 /**
51  *
52  */
53 function alertContents()
55     if (http_request.readyState == 1) {
56         document.getElementById("layer_action").style.left = (document.body.clientWidth + document.body.scrollLeft - 85) + 'px';
57         document.getElementById("layer_action").style.top = (document.body.scrollTop + 10) + 'px';
58         document.getElementById("layer_action").style.visibility = 'visible'; document.getElementById("layer_action").innerHTML = 'Loading...';
59     }
60     if (http_request.readyState == 2) {
61         document.getElementById("layer_action").innerHTML = 'Loaded';
62     }
63     if (http_request.readyState == 3) {
64         document.getElementById("layer_action").innerHTML = 'Loading 99%';
65     }
66     if (http_request.readyState == 4) {
67         if (http_request.status == 200) {
68             textdoc = http_request.responseText;
69             //alert(textdoc);
70             xmldoc    = http_request.responseXML;
71             PrintXML();
72             //document.getElementById("layer_action").style.visibility = 'hidden';
73         } else {
74             alert('There was a problem with the request.');
75         }
76     }
79 function layer_alert(text)
81     document.getElementById("layer_action").innerHTML = text;
82     document.getElementById("layer_action").style.left = (document.body.clientWidth + document.body.scrollLeft - 20 - document.getElementById("layer_action").offsetWidth) + 'px';
83     document.getElementById("layer_action").style.visibility = 'visible'; 
84     setTimeout(function(){document.getElementById("layer_action").style.visibility = 'hidden';}, 2000);
87 /**
88  *
89  */
90 function PrintXML()
92     var root = xmldoc.getElementsByTagName('root').item(0);    //root
93     //alert(xmldoc.getElementsByTagName('root').item(1));
94     if (root == null) {
95         // if error
96         myWin=window.open('','Report','width=400, height=250, resizable=1, scrollbars=1, status=1');
97         var tmp = myWin.document;
98         tmp.write(textdoc);
99         tmp.close();
100     } else {
101         //alert(xmldoc.getElementsByTagName('root')[0]);
102         //alert(root.attributes[0].nodeValue);
103         //alert(xmldoc.getElementsByTagName('root')[0].attributes[0].nodeValue);
104         //xmldoc.getElementsByTagName('root')[0].getAttribute("act")
106         if (root.getAttribute('act') == 'save_pos') {
107             layer_alert(strLang[root.getAttribute('return')]);
108         }
109         if (root.getAttribute('act') == 'relation_upd') {
110             layer_alert(strLang[root.getAttribute('return')]);
111             if (root.getAttribute('b') == '1') {
112                 contr.splice(root.getAttribute('K'), 1);
113                 Re_load();
114             }
115         }
116         if (root.getAttribute('act') == 'relation_new') {
117             layer_alert(strLang[root.getAttribute('return')]);
118             if (root.getAttribute('b') == '1') {
119                 var i    = contr.length;
120                 var t1 = root.getAttribute('DB1') + '.' + root.getAttribute('T1');
121                 var f1 = root.getAttribute('F1');
122                 var t2 = root.getAttribute('DB2') + '.' + root.getAttribute('T2');
123                 var f2 = root.getAttribute('F2');
124                 contr[i] = new Array();
125                 contr[i][''] = new Array();
126                 contr[i][''][t2] = new Array();
127                 contr[i][''][t2][f2] = new Array();
128                 contr[i][''][t2][f2][0] = t1;
129                 contr[i][''][t2][f2][1] = f1;
130                 Re_load();
131             }
132         }
133     }