dojox.off.files._slurp
dojo.require("dojox.off.files");
defined in dojox/off/files.js
Usage
function () (view source)
if(!this._doSlurp){ return; } var handleUrl = dojo.hitch(this, function(url){ if(this._sameLocation(url)){ this.cache(url); } }); handleUrl(window.location.href); dojo.query("script").forEach(function(i){ try{ handleUrl(i.getAttribute("src")); }catch(exp){ //console.debug("dojox.off.files.slurp 'script' error: " // + exp.message||exp); } }); dojo.query("link").forEach(function(i){ try{ if(!i.getAttribute("rel") || i.getAttribute("rel").toLowerCase() != "stylesheet"){ return; } handleUrl(i.getAttribute("href")); }catch(exp){ //console.debug("dojox.off.files.slurp 'link' error: " // + exp.message||exp); } }); dojo.query("img").forEach(function(i){ try{ handleUrl(i.getAttribute("src")); }catch(exp){ //console.debug("dojox.off.files.slurp 'img' error: " // + exp.message||exp); } }); dojo.query("a").forEach(function(i){ try{ handleUrl(i.getAttribute("href")); }catch(exp){ //console.debug("dojox.off.files.slurp 'a' error: " // + exp.message||exp); } }); // FIXME: handle 'object' and 'embed' tag // parse our style sheets for inline URLs and imports dojo.forEach(document.styleSheets, function(sheet){ try{ if(sheet.cssRules){ // Firefox dojo.forEach(sheet.cssRules, function(rule){ var text = rule.cssText; if(text){ var matches = text.match(/url\(\s*([^\) ]*)\s*\)/i|>); if(!matches){ return; } for(var i = 1; i < matches.length; i++){ handleUrl(matches[i]) } } }); }else if(sheet.cssText){ // IE var matches; var text = sheet.cssText.toString(); // unfortunately, using RegExp.exec seems to be flakey // for looping across multiple lines on IE using the // global flag, so we have to simulate it var lines = text.split(/\f|\r|\n/); for(var i = 0; i < lines.length; i++){ matches = lines[i].match(/url\(\s*([^\) ]*)\s*\)/i|>); if(matches && matches.length){ handleUrl(matches[1]); } } } }catch(exp){ //console.debug("dojox.off.files.slurp stylesheet parse error: " // + exp.message||exp); } }); //this.printURLs();