source: sandbox/filemanager/js/connector.js @ 1693

Revision 1693, 3.8 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - melhorias no modulo gerenciador de arquivos para arquivos grandes

  • Property svn:executable set to *
Line 
1var progressBar;
2
3if (document.all)
4{
5        navigator.userAgent.toLowerCase().indexOf('msie 5') != -1 ? is_ie5 = true : is_ie5 = false;
6        is_ie = true;
7        is_moz1_6 = false;
8        is_mozilla = false;
9        is_ns4 = false;
10}
11else if (document.getElementById)
12{
13        navigator.userAgent.toLowerCase().match('mozilla.*rv[:]1\.6.*gecko') ? is_moz1_6 = true : is_moz1_6 = false;
14        is_ie = false;
15        is_ie5 = false;
16        is_mozilla = true;
17        is_ns4 = false;
18}
19else if (document.layers)
20{
21        is_ie = false;
22        is_ie5 = false
23        is_moz1_6 = false;
24        is_mozilla = false;
25        is_ns4 = true;
26}
27
28/****************************************** Connector Class *************************************************/
29// Constructor
30function cConnector()
31{
32        this.requests = new Array();
33        this.oxmlhttp = null;
34        this.isVisibleBar = false;
35        this.tid = 0;
36        this.progressBar = null;
37        this.oldX = 0;
38        this.oldY = 0;
39        this.updateVersion = "";
40}
41cConnector.prototype.buildBar = function()
42{
43        var div = document.getElementById('divProgressBar');
44
45        if(! div) {                                                                                           
46                div = document.createElement("DIV");
47                div.style.visibility    = "hidden";
48                div.style.width = "103px";
49                div.id = 'divProgressBar';
50                div.align = "center";
51                div.innerHTML = '&nbsp;&nbsp;<font face="Verdana" size="2" color="WHITE">'+get_lang('loading')+'...</font>&nbsp;';
52                div.style.background = "#cc4444";
53                div.style.position = 'fixed';
54                div.style.top = '0px';
55                div.style.right = '0px';
56                document.body.appendChild(div);                                                               
57
58                if(is_ie) {
59                        var elem = document.all[div.id];
60                        elem.style.position="absolute";
61                        var root = document.body;
62                        var posX = elem.offsetLeft-root.scrollLeft;
63                        var posY = elem.offsetTop-root.scrollTop;
64                        root.onscroll = function() {
65                                elem.style.right = '0px';
66                                elem.style.top = (posY + root.scrollTop) + "px";
67                        };
68                }
69        }
70}
71
72cConnector.prototype.hideProgressBar = function ()
73{
74        var div = document.getElementById('divProgressBar');
75        div.style.visibility = 'hidden';
76        this.isVisibleBar = false;
77}
78
79cConnector.prototype.showProgressBar = function(){
80        var div = document.getElementById('divProgressBar');
81        if (! div){
82                connector.buildBar();
83                connector.showProgressBar();
84                return;
85        }
86
87        div.style.visibility = 'visible';
88
89        this.isVisibleBar = true;
90}
91
92        function XMLTools()
93        {
94                this.path = "";
95        }
96var connector = new cConnector();
97
98function cExecuteForm(form, handler){
99        connector.showProgressBar();
100        if(! (divUpload = document.getElementById('divUpload'))) {
101                divUpload               = document.createElement('DIV');               
102                divUpload.id    = 'divUpload';
103                document.body.appendChild(divUpload);
104        }
105
106        handlerExecuteForm = handler;
107        var form_handler = function (data){
108                handlerExecuteForm(data);
109                handlerExecuteForm = null;
110        }
111        divUpload.innerHTML= "<iframe onload=\"connector.hideProgressBar();cExecute('./index.php/index.php?menuaction=filemanager.uifilemanager.getReturnExecuteForm',"+form_handler+");\"  style='display:none;width:0;height:0;' name='uploadFile'></iframe>";
112        form.target ="uploadFile";
113        form.submit();
114}
115
116function cExecute(requestURL,handler){
117        var AjaxRequest = function () {
118                Ajax = false;
119                if (window.XMLHttpRequest) //Gecko
120                        Ajax = new XMLHttpRequest();
121                else
122                        if (window.ActiveXObject) //Other nav.
123                                try
124                                {
125                                        Ajax = new ActiveXObject("Msxml12.XMLHTTP");
126                                } catch (e)
127                {
128                        Ajax = new ActiveXObject("Microsoft.XMLHTTP");
129                }
130        }
131        var responseRequest = function (){
132                if (Ajax.readyState == 4)
133                        if (Ajax.status == 200)
134                                handler(Ajax.responseText);
135                        else
136                                throw("Connection error!");
137        }
138
139
140        AjaxRequest();
141        if (!Ajax){
142                throw("No connection");
143                return;
144        }
145
146        Ajax.onreadystatechange = responseRequest;
147        if (typeof(method) == 'undefined')
148                method = 'GET';
149        Ajax.open(method, requestURL, true);
150        Ajax.send(null);
151}
152
Note: See TracBrowser for help on using the repository browser.