2e06210044c87c1c2e09876eaa9b13aa758286a5
[mailer.git] / js / ajax-test.js
1 /*
2  * JavaScript for testing the browser of AJAX-compatiblity
3  * --------------------------------------------------------------------
4  * $Revision::                                                        $
5  * $Date::                                                            $
6  * $Tag:: 0.2.1-FINAL                                                 $
7  * $Author::                                                          $
8  * --------------------------------------------------------------------
9  * Copyright (c) 2003 - 2009 by Roland Haeder
10  * Copyright (c) 2009 - 2012 by Mailer Developer Team
11  * For more information visit: http://mxchange.org
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
26  * MA  02110-1301  USA
27  */
28
29 // Everthing starts with 3 seconds by default
30 var counter = 3;
31
32 // Get the element
33 var element = document.getElementById('counter');
34
35 // Holding the interval
36 var ajaxTest = null;
37
38 // Countdown function
39 function ajaxTestCounter () {
40         // Do we have element set?
41         if (element != null) {
42                 // Yes, then set the new counter value
43                 element.innerHTML = counter;
44         } // END - if
45
46         // Do we have reached zero?
47         if (counter < 1) {
48                 // Clear the interval
49                 clearInterval(ajaxTest);
50
51                 // Try to open AJAX window
52                 try {
53                         // Is the test passed?
54                         displayTestWindow('install', '#ajax_installer');
55                 } catch (e) {
56                         // Exception caught (very bad, AJAX is not working)
57                         alert(e);
58                 }
59         } else {
60                 // Count one down
61                 counter--;
62         }
63 }
64
65 // Init counter test
66 function initAjaxTest () {
67         // Start the test
68         ajaxTest = window.setInterval('ajaxTestCounter()', 1000);
69 }
70
71 // Start the test
72 initAjaxTest();