/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to trunk/svg Converter/SVG_httpAjax.js

  • Committer: a11patfr at his
  • Date: 2013-03-28 14:56:16 UTC
  • mto: (4.7.6 GammaBear)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: a11patfr@student.his.se-20130328145616-7otkydi3v47zwg30
Fixed formatting. trunk/svg Converter/SVG_httpAjax.js

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
                /*--------------------------------------------------------------------------------
3
 
                         AJAX Queue
4
 
                ----------------------------------------------------------------------------------*/            
5
 
 
6
 
                var AJAXQueue = new Array;
7
 
                var AJAXServiceRunning=false;
8
 
                var AJAXReturnfunction;
9
 
 
10
 
                var httpAjax = false;
11
 
 
12
 
                function getSVG(fileName){
13
 
                                paramstr="svgname="+escape(fileName);
14
 
                                AjaxService("SVG_TO_CANVAS_III.php",paramstr,"returnedSVG");
15
 
                }
16
 
                                
17
 
                /*--------------------------------------------------------------------------------
18
 
                                AjaxService
19
 
                                
20
 
                                This is the only interface to the AJAX wrapper. This makes the ajax service 
21
 
                                browser agnostic and provides a single interface for all of the services.
22
 
                                
23
 
                                Each service uses a different url and a different parameter layout.
24
 
                                                                
25
 
                ----------------------------------------------------------------------------------*/
26
 
 
27
 
                function AjaxService(servicename,serviceparam,returnfunction){
28
 
                                                                
29
 
                                AJAXQueue.push(servicename);
30
 
                                AJAXQueue.push(serviceparam);
31
 
                                AJAXQueue.push(returnfunction);
32
 
 
33
 
                                if(!AJAXServiceRunning){
34
 
                                                AJAXServiceRunning=true;
35
 
                                                AJAXReturnfunction=AJAXQueue.pop();
36
 
                                                var Aparam=AJAXQueue.pop();
37
 
                                                var Aservice=AJAXQueue.pop();
38
 
                                                AjaxServiceExec(Aservice,Aparam);
39
 
                                }                               
40
 
                }
41
 
 
42
 
                /*--------------------------------------------------------------------------------
43
 
                                AjaxService
44
 
                                
45
 
                                This is the only interface to the AJAX wrapper. This makes the ajax service 
46
 
                                browser agnostic and provides a single interface for all of the services.
47
 
                                
48
 
                                Each service uses a different url and a different parameter layout.
49
 
                                                                
50
 
                ----------------------------------------------------------------------------------*/
51
 
 
52
 
                function AjaxServiceExec(servicename,serviceparam){
53
 
 
54
 
                        // Parameters are set, initiate AJAX engine
55
 
                  if (window.XMLHttpRequest) {
56
 
                        httpAjax = new XMLHttpRequest();
57
 
                    if (httpAjax.overrideMimeType) {
58
 
                        httpAjax.overrideMimeType('text/xml');
59
 
                    }
60
 
                  }else if(window.ActiveXObject){
61
 
                                try{
62
 
                                        httpAjax = new ActiveXObject("Msxml2.XMLHTTP");
63
 
                                                }catch(e){
64
 
                                                        try{
65
 
                                                                httpAjax = new ActiveXObject("Microsoft.XMLHTTP");
66
 
                                }catch(e){
67
 
                                                                alert("Couldn�t build an AJAX instance.");
68
 
                                  return false;
69
 
                                                        }
70
 
                                                }
71
 
                                }
72
 
                                
73
 
                                // Send request to Server and initiate callback.
74
 
                                
75
 
                    try{
76
 
                                        httpAjax.onreadystatechange = getPage;
77
 
                    }catch(e){
78
 
                                        alert("onreadystatechange didn�t go well!");
79
 
                                        return false;
80
 
                                }try{
81
 
                                        httpAjax.open('POST', servicename, true);
82
 
                                  httpAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
83
 
                    }catch(e){
84
 
                                        alert("Couldn�t open url.");
85
 
                      return false;
86
 
                    }try{
87
 
                                                httpAjax.send(serviceparam);                            
88
 
                    }catch(e){
89
 
                                        alert("Couldn�t send request.");
90
 
                                        return false;
91
 
                                }
92
 
                   
93
 
                         return true;
94
 
 
95
 
                }
96
 
 
97
 
                /*--------------------------------------------------------------------------------
98
 
                                getPage
99
 
 
100
 
                                This is the AJAX callback function. It detects the invoking service and handles
101
 
                                the reply from each service accordingly.                                
102
 
                                                                
103
 
                ----------------------------------------------------------------------------------*/
104
 
 
105
 
        function getPage() {
106
 
                                        
107
 
                if(httpAjax.readyState == 4){
108
 
 
109
 
                                str=httpAjax.responseText;
110
 
                                eval(AJAXReturnfunction+'(str);');
111
 
 
112
 
                                if(AJAXQueue.length>0){
113
 
                                                AJAXReturnfunction=AJAXQueue.pop();
114
 
                                                var Aparam=AJAXQueue.pop();
115
 
                                                var Aservice=AJAXQueue.pop();
116
 
                                                AjaxServiceExec(Aservice,Aparam);
117
 
                                }else{
118
 
                                                AJAXServiceRunning=false;                               
119
 
                                }
120
 
                                                                
121
 
                                return true;                            
122
 
                }else{
123
 
                        // If any other ready state than prepared, do nothing!
124
 
          }
125
 
        }
126
 
 
 
1
/*--------------------------------------------------------------------------------
 
2
  AJAX Queue
 
3
  ----------------------------------------------------------------------------------*/          
 
4
 
 
5
var AJAXQueue = new Array;
 
6
var AJAXServiceRunning = false;
 
7
var AJAXReturnfunction;
 
8
var httpAjax = false;
 
9
 
 
10
function getSVG(fileName) {
 
11
        paramstr = "svgname=" + escape(fileName);
 
12
        AjaxService("SVG_TO_CANVAS_III.php", paramstr, "returnedSVG");
 
13
}
 
14
 
 
15
/*--------------------------------------------------------------------------------
 
16
  AjaxService
 
17
 
 
18
  This is the only interface to the AJAX wrapper. This makes the ajax service 
 
19
  browser agnostic and provides a single interface for all of the services.
 
20
 
 
21
  Each service uses a different url and a different parameter layout.
 
22
 
 
23
  ----------------------------------------------------------------------------------*/
 
24
 
 
25
function AjaxService(servicename, serviceparam, returnfunction) {
 
26
 
 
27
        AJAXQueue.push(servicename);
 
28
        AJAXQueue.push(serviceparam);
 
29
        AJAXQueue.push(returnfunction);
 
30
 
 
31
        if(!AJAXServiceRunning) {
 
32
                AJAXServiceRunning = true;
 
33
                AJAXReturnfunction = AJAXQueue.pop();
 
34
                var Aparam = AJAXQueue.pop();
 
35
                var Aservice = AJAXQueue.pop();
 
36
                AjaxServiceExec(Aservice, Aparam);
 
37
        }                               
 
38
}
 
39
 
 
40
/*--------------------------------------------------------------------------------
 
41
  AjaxService
 
42
 
 
43
  This is the only interface to the AJAX wrapper. This makes the ajax service 
 
44
  browser agnostic and provides a single interface for all of the services.
 
45
 
 
46
  Each service uses a different url and a different parameter layout.
 
47
 
 
48
  ----------------------------------------------------------------------------------*/
 
49
 
 
50
function AjaxServiceExec(servicename, serviceparam) {
 
51
        // Parameters are set, initiate AJAX engine
 
52
        if(window.XMLHttpRequest) {
 
53
                httpAjax = new XMLHttpRequest();
 
54
                if(httpAjax.overrideMimeType) {
 
55
                        httpAjax.overrideMimeType('text/xml');
 
56
                }
 
57
        } else if(window.ActiveXObject) {
 
58
                try {
 
59
                        httpAjax = new ActiveXObject("Msxml2.XMLHTTP");
 
60
                } catch(e) {
 
61
                        try {
 
62
                                httpAjax = new ActiveXObject("Microsoft.XMLHTTP");
 
63
                        } catch(e) {
 
64
                                alert("Couldn�t build an AJAX instance.");
 
65
                                return false;
 
66
                        }
 
67
                }
 
68
        }
 
69
 
 
70
        // Send request to Server and initiate callback.
 
71
        try {
 
72
                httpAjax.onreadystatechange = getPage;
 
73
        } catch(e) {
 
74
                alert("onreadystatechange didn�t go well!");
 
75
                return false;
 
76
        } try {
 
77
                httpAjax.open('POST', servicename, true);
 
78
                httpAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
 
79
        } catch(e) {
 
80
                alert("Couldn�t open url.");
 
81
                return false;
 
82
        } try {
 
83
                httpAjax.send(serviceparam);                            
 
84
        } catch(e) {
 
85
                alert("Couldn�t send request.");
 
86
                return false;
 
87
        }
 
88
        return true;
 
89
}
 
90
 
 
91
/*--------------------------------------------------------------------------------
 
92
  getPage
 
93
 
 
94
  This is the AJAX callback function. It detects the invoking service and handles
 
95
  the reply from each service accordingly.                              
 
96
 
 
97
  ----------------------------------------------------------------------------------*/
 
98
 
 
99
function getPage() {
 
100
        if(httpAjax.readyState == 4) {
 
101
                str=httpAjax.responseText;
 
102
                eval(AJAXReturnfunction + '(str);');
 
103
                if(AJAXQueue.length > 0) {
 
104
                        AJAXReturnfunction = AJAXQueue.pop();
 
105
                        var Aparam = AJAXQueue.pop();
 
106
                        var Aservice = AJAXQueue.pop();
 
107
                        AjaxServiceExec(Aservice, Aparam);
 
108
                } else {
 
109
                        AJAXServiceRunning = false;                             
 
110
                }
 
111
                return true;                            
 
112
        } else {
 
113
                // If any other ready state than prepared, do nothing!
 
114
        }
 
115
}