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