aboutsummaryrefslogtreecommitdiff
path: root/mod/minify/lib/min/builder/bm.js
blob: 10d19438143c3a7317f9b15e0679316be6970f56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
javascript:(function() {
    var d = document
       ,uris = []
       ,i = 0
       ,o
       ,home = (location + '').split('/').splice(0, 3).join('/') + '/';
    function add(uri) {
        return (0 === uri.indexOf(home))
            && (!/[\?&]/.test(uri))
            && uris.push(escape(uri.substr(home.length)));
    };
    function sheet(ss) {
        // we must check the domain with add() before accessing ss.cssRules
        // otherwise a security exception will be thrown
        if (ss.href && add(ss.href) && ss.cssRules) {
            var i = 0, r;
            while (r = ss.cssRules[i++])
                r.styleSheet && sheet(r.styleSheet);
        }
    };
    while (o = d.getElementsByTagName('script')[i++])
        o.src && !(o.type && /vbs/i.test(o.type)) && add(o.src);
    i = 0;
    while (o = d.styleSheets[i++])
    /* http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-DocumentStyle-styleSheets
    document.styleSheet is a list property where [0] accesses the 1st element and 
    [outOfRange] returns null. In IE, styleSheets is a function, and also throws an 
    exception when you check the out of bounds index. (sigh) */
        sheet(o);
    if (uris.length)
        window.open('%BUILDER_URL%#' + uris.join(','));
    else
        alert('No js/css files found with URLs within "' 
            + home.split('/')[2]
            + '".\n(This tool is limited to URLs with the same domain.)');
})();