Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / bootstrap.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * Load the library located at the same path with this file
17  *
18  * Will automatically load ext-all-debug.js if any of these conditions is true:
19  * - Current hostname is localhost
20  * - Current hostname is an IP v4 address
21  * - Current protocol is "file:"
22  *
23  * Will load ext-all.js (minified) otherwise
24  */
25 (function() {
26
27     var scripts = document.getElementsByTagName('script'),
28         localhostTests = [
29             /^localhost$/,
30             /\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:\d{1,5})?\b/ // IP v4
31         ],
32         host = window.location.hostname,
33         isDevelopment = null,
34         queryString = window.location.search,
35         test, path, i, ln, scriptSrc, match;
36
37     for (i = 0, ln = scripts.length; i < ln; i++) {
38         scriptSrc = scripts[i].src;
39
40         match = scriptSrc.match(/bootstrap\.js$/);
41
42         if (match) {
43             path = scriptSrc.substring(0, scriptSrc.length - match[0].length);
44             break;
45         }
46     }
47
48     if (queryString.match('(\\?|&)debug') !== null) {
49         isDevelopment = true;
50     }
51     else if (queryString.match('(\\?|&)nodebug') !== null) {
52         isDevelopment = false;
53     }
54
55     if (isDevelopment === null) {
56         for (i = 0, ln = localhostTests.length; i < ln; i++) {
57             test = localhostTests[i];
58
59             if (host.search(test) !== -1) {
60                 isDevelopment = true;
61                 break;
62             }
63         }
64     }
65
66     if (isDevelopment === null && window.location.protocol === 'file:') {
67         isDevelopment = true;
68     }
69
70     document.write('<script type="text/javascript" src="' + path + 'ext-all' + ((isDevelopment) ? '-debug' : '') + '.js"></script>');
71
72 })();
73