ITeye博客

extjs debug

Darlyn · 2014-01-03 15:46 · extjs · Web前端 · Markdown

extjs新引进了bootstrap 可以在其中定义是否debug和用什么文件debug


(function() {
    var scripts = document.getElementsByTagName('script'),
        localhostTests = [
            /^localhost$/,     /*用于匹配以localhost开头的url*/
            /\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,   /*服务器自带的hostname有的是host有的是localhost*/
        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;  /*如果url后缀有'?'+debug则为询问字符串,设isDevelopment为true*/
    }else if (queryString.match('(\\?|&)nodebug') !== null) {
        isDevelopment = false;  /*如果url后缀有'?'+nodebug则为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;
    }
/*如果都不符合以上两个判定,且isDevelopment为null或url是由“file:”开头即允许以文件形式打开自动进行debug*/
    document.write('<script type="text/javascript" charset="UTF-8" src="' + 
        path + 'ext-4/ext-all' + (isDevelopment ? '-debug' : '') + '.js"></script>'); /*这里是配置ext-all-debug的路径*/
})();

--------------------------------------------------------------------------------

浏览器中的header: 浏览器中的header配置了request和response分别记录了浏览器向服务器发出请求时发出信息的类型,状态及request的方法=>get或post;和服务器向浏览器返回的信息的类型和状态。 如果request是get方法,则可以通过在url后加name=value的方式传递参数,post方法一般在传递信息安全性要求较高或信息量比较大时使用。

示例:


Request URL:http://localhost:8080/ExtjsMVC/account_manager/app/app.js
Request Method:GET
Status Code:304 Not Modified  //静态文件未修改
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch  //接受文件类型
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:localhost:8080
If-Modified-Since:Fri, 03 Jan 2014 02:53:35 GMT
If-None-Match:W/"434-1388717615724"
Referer:http://localhost:8080/ExtjsMVC/account_manager/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
Response Headersview source
Date:Fri, 03 Jan 2014 03:02:20 GMT
ETag:W/"434-1388717615724"
Server:Apache-Coyote/1.1   

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。