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