SVN: toys/rsget.pl: README rsget.pl.user.js

sparky sparky at pld-linux.org
Tue Dec 15 01:53:40 CET 2009


Author: sparky
Date: Tue Dec 15 01:53:39 2009
New Revision: 11044

Modified:
   toys/rsget.pl/README
   toys/rsget.pl/rsget.pl.user.js
Log:
- use containsNode function to check for selected nodes - fixes many problems


Modified: toys/rsget.pl/README
==============================================================================
--- toys/rsget.pl/README	(original)
+++ toys/rsget.pl/README	Tue Dec 15 01:53:39 2009
@@ -11,7 +11,10 @@
 - Fix freezing http server - move to separate thread/process ?
 - Fix bugs in http server, and speed it up.
 - Better file writing methods, to allow downloading from multiple sources.
-- Backoff if captcha fails too many times; lower prio.
+- Backoff if captcha fails too many times; lower uri prio.
+- If multi-download problem appears while checking files force check on
+  another interface/ip.
+- Posibility to mark uri as "cannot continue".
 
 Planned features:
 - Multiuser support (may require major changes in the code).

Modified: toys/rsget.pl/rsget.pl.user.js
==============================================================================
--- toys/rsget.pl/rsget.pl.user.js	(original)
+++ toys/rsget.pl/rsget.pl.user.js	Tue Dec 15 01:53:39 2009
@@ -146,9 +146,12 @@
 	}
 }
 
-function crawl_nodes( links, node, end )
+function crawl_nodes( links, node, selection )
 {
-	while ( node != end ) {
+	while ( node ) {
+		if ( selection.containsNode( node, false ) )
+			push_from_node( links, node );
+
 		if ( node.firstChild ) {
 			node = node.firstChild;
 		} else if ( node.nextSibling ) {
@@ -156,14 +159,11 @@
 		} else {
 			do {
 				node = node.parentNode;
-				if ( node == end )
+				if ( ! node )
 					return;
 			} while ( !node.nextSibling );
 			node = node.nextSibling;
 		}
-		if ( node == end )
-			return;
-		push_from_node( links, node );
 	}
 }
 
@@ -174,14 +174,20 @@
 	var sel_text;
 	try {
 		selection = window.getSelection();
-		sel_text = selection.toString()
+		sel_text = selection.toString();
 		range = selection.getRangeAt( 0 );
 	} catch ( e ) {};
 	var links = new Array;
 
 
 	if ( !range || range.collapsed ) {
-		crawl_nodes( links, docbody(), document );
+		crawl_nodes( links, docbody(),
+			{
+				containsNode: function ( node, flag ) {
+					return true;
+				} 
+			}
+		);
 		if ( selection ) {
 			selection.selectAllChildren( docbody() );
 			sel_text = selection.toString();
@@ -192,14 +198,16 @@
 		var end = range.endContainer;
 		
 		if ( start == end ) {
-			push_from_text( links, start.nodeValue.substring( range.startOffset, range.endOffset ) );
+			push_from_text( links,
+				start.nodeValue.substring( range.startOffset, range.endOffset )
+			);
 		} else {
 			if ( start.nodeName == 'A' ) {
 				push_a_href( links, start );
 			} else if ( start.nodeName == '#text' && start.nodeValue ) {
 				push_from_text( links, start.nodeValue.substr( range.startOffset ) );
 			}
-			crawl_nodes( links, start, end );
+			crawl_nodes( links, start, selection );
 			if ( end.nodeName == 'A' ) {
 				push_a_href( end );
 			} else if ( end.nodeName == '#text' && end.nodeValue) {


More information about the pld-cvs-commit mailing list