www.webdeveloper.com
Results 1 to 2 of 2

Thread: Recognizing links in selection

  1. #1
    Join Date
    Oct 2007
    Posts
    103

    Recognizing links in selection

    Hello! I'm writing bookmarklet right now which sends the links from selection to external server. I don't know how to write part responsible for extract links from selection. For instance, i need:

    1) Recognizing links in selection written in plain text, for example:

    Code:
    http://www.x.com/dddffsfds/fsdfdsfdsfds
    http://www.x.com/dddffsfds/fsdfdsfdsfds
    http://www.x.com/dddffsfds/fsdfdsfdsfds
    http://www.x.com/dddffsfds/fsdfdsfdsfds
    http://www.x.com/dddffsfds/fsdfdsfdsfds
    2) Recognizing links in selection written in html, for example:

    Code:
    <a href="http://www.x.com/dddffsfds/fsdfdsfdsfds">CLUTTER - IGNORE IF HERE IS ALSO http://(...) and so on</a>CLUTTER<a href="http://www.x.com/dddffsfds/fsdfdsfdsfds">CLUTTER - IGNORE IF HERE IS ALSO http://(...) and so on</a>CLUTTER<a href="http://www.x.com/dddffsfds/fsdfdsfdsfds">CLUTTER - IGNORE IF HERE IS ALSO http://(...) and so on</a>
    How I can handle this both methods simultaneously? Any idea? That's is my current code:

    Code:
    // Helper - remove duplicates from array.
    Array.prototype.unique = function () {
    	var r = new Array();
    	o:for(var i = 0, n = this.length; i < n; i++)
    	{
    		for(var x = 0, y = r.length; x < y; x++)
    		{
    			if(r[x]==this[i])
    			{
    				continue o;
    			}
    		}
    		r[r.length] = this[i];
    	}
    	return r;
    }
    
    // We are getting selection
    
    selection = ???????????
    
    // We are looking for links in selection and make array from they
    
    files = ???????????????
    
    if (files.length < 1)
    {
      unique = files.unique();
      urls = unique.join('|');
      location.href 'http://x/imports/new?from=bookmarklet&urls=' + urls
    }
    else
    {
      alert('There is no any links in selection.');
    }

  2. #2
    Join Date
    Oct 2007
    Posts
    103
    Nobody have any idea? :-(

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles