X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/530ef4b6c5b943cfa68b779d11cf7de29aa878bf..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/bootstrap.js diff --git a/bootstrap.js b/bootstrap.js new file mode 100644 index 00000000..b4c44f0f --- /dev/null +++ b/bootstrap.js @@ -0,0 +1,58 @@ +/** + * Load the library located at the same path with this file + * + * Will automatically load ext-all-debug.js if any of these conditions is true: + * - Current hostname is localhost + * - Current hostname is an IP v4 address + * - Current protocol is "file:" + * + * Will load ext-all.js (minified) otherwise + */ +(function() { + + var scripts = document.getElementsByTagName('script'), + localhostTests = [ + /^localhost$/, + /\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 + ], + host = window.location.hostname, + isDevelopment = null, + queryString = window.location.search, + test, path, i, ln, scriptSrc, match; + + for (i = 0, ln = scripts.length; i < ln; i++) { + scriptSrc = scripts[i].src; + + match = scriptSrc.match(/bootstrap\.js$/); + + if (match) { + path = scriptSrc.substring(0, scriptSrc.length - match[0].length); + break; + } + } + + if (queryString.match('(\\?|&)debug') !== null) { + isDevelopment = true; + } + else if (queryString.match('(\\?|&)nodebug') !== null) { + isDevelopment = false; + } + + if (isDevelopment === null) { + for (i = 0, ln = localhostTests.length; i < ln; i++) { + test = localhostTests[i]; + + if (host.search(test) !== -1) { + isDevelopment = true; + break; + } + } + } + + if (isDevelopment === null && window.location.protocol === 'file:') { + isDevelopment = true; + } + + document.write(''); + +})();