Permalink
Browse files

added simpler exampler for loading page, and renamed simple.js to scr…

…ape.js
  • Loading branch information...
1 parent dbc1c62 commit 4588293e89039af7771ee86174223b3f0c753a65 thatcher committed Feb 17, 2011
Showing with 37 additions and 0 deletions.
  1. +8 −0 examples/loadpage.js
  2. +29 −0 examples/scrape.js
View
8 examples/loadpage.js
@@ -0,0 +1,8 @@
+var now = Date.now();
+
+document.location = 'http://www.zope.com/';
+
+document.addEventListener('DOMContentLoaded', function(){
+ console.log('%s (loaded in %s)', document.title, Date.now() - now);
+}, true);
+
View
29 examples/scrape.js
@@ -0,0 +1,29 @@
+//#!bin/envjs node examples/simple.js
+var testurl = 'http://localhost:8080/';
+
+var check_urls = function(event){
+ console.log('Sample: document %s loaded in %s', document.title, Date.now()-start);
+ document.removeEventListener('load', check_urls);
+ jQuery('a').each(function(){
+ console.log('a -> %s', $(this).attr('href'));
+ });
+ jQuery.ajax({
+ type:'get',
+ url: '/?fo=json',
+ dataType: 'json',
+ success: function(data){
+ console.log('loaded json via ajax %s', data);
+ },
+ error: function(xhr, status, e){
+ console.log('failed to load json via ajax %s %s \n%s',
+ xhr.status, xhr.url, e);
+ }
+ });
+ console.log('loading json via ajax');
+};
+
+document.addEventListener('load', check_urls);
+
+var start = Date.now();
+console.log('Sample: loading %s', testurl);
+document.location = testurl;

0 comments on commit 4588293

Please sign in to comment.