Closed Thread Icon

Topic awaiting preservation: Capture data from page... Pages that link to <a href="https://ozoneasylum.com/backlink?for=27078" title="Pages that link to Topic awaiting preservation: Capture data from page..." rel="nofollow" >Topic awaiting preservation: Capture data from page...\

 
Author Thread
DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 12-01-2005 04:32

Hi guys

Not sure where to even begin with this, so let me lay out what I want to do -

I have a links page as part of my site. I have an admin page where I add links. The form has an input for the link Title, the link URL, a description, and a couple of other things.

What I would like to be able to do is create a bookmark where I can click on the link and it will grab the title and the URL from the current page, and bring me to my link admin page with the Title and URL form fields filled in with that information.

So first of all - can I do this?

Second of all - would it be possible to also have some text on the page selected, and pass that selected text as a variable as well?

The URL I could get server-side, but I assume the title will need to be capture with js, and have no idea if the selected text is possible...

Any pointers on how to get started with this would be greatly appreciated - I have very little experience with javascript, and most of that has been editing other people's scripts...not writing them from scratch.

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 12-01-2005 19:02

Are you saying that as you surf the web, you want to be able to click a button, or link and have the information about that pages used to fill in the form on your admin page?

.



-- not necessarily stoned... just beautiful.

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 12-01-2005 19:16

[quick_post] Check one of the many del.icio.us bookmarklet. [/quick_post]

kuckus
Paranoid (IV) Mad Librarian

From: GlieBeGe
Insane since: Dec 2001

posted posted 12-01-2005 19:40
quote:

poi said:

[quick_post] Check one of the many del.icio.us bookmarklet. [/quick_post]


Here's the code from the one I have in my toolbar:

code:
javascript:location.href='http://del.icio.us/kuckus?v=3&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)



So you'll basically just have to take out the 'http://del.icio.us/kuckus?v=3&' bit and put the URL of your own script in and then let it do whatever needs to be done using $_GET['url'] and $_GET['title'].

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-01-2005 20:40

Small Update to kuckus'

code:
javascript: location.href='myadminpage.php?s=' +encodeURIComponent(window.getSelection())+'&h=' +encodeURIComponent(location.href)+ '&t='+encodeURIComponent(document.title);



On Firefox that will also grab the selected text. You could get rid of the PHP Part and actually implement it as an extension fairly easily.



.:[ Never resist a perfect moment ]:.

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 12-01-2005 21:14
quote:

hyperbole said:
Are you saying that as you surf the web, you want to be able
to click a button, or link and have the information about that pages
used to fill in the form on your admin page?



Exactly.

Kuckus, Bitdamaged - thanks a ton! I was afraid it would be a lot more complicated than that

Poi - not familiar with del.icio.us, guess i'll take a look

{{edit -

bit - Firefox is all I am worried about for the moment, but for future reference, is there a way to do the text-selection for IE, NN, etc?





(Edited by DL-44 on 12-01-2005 21:15)

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-01-2005 21:30

yep

Well at least for those browsers that support it in some format.



.:[ Never resist a perfect moment ]:.

kuckus
Paranoid (IV) Mad Librarian

From: GlieBeGe
Insane since: Dec 2001

posted posted 12-01-2005 21:35
quote:
is there a way to do the text-selection for IE, NN, etc?



At least for IE, there is - don't know about Opera, they might have added it in the more recent versions.

You can see the IE way in the grail's posting_input.js:

code:
/* * *
 * Quote (part of) a post
 */

// Inspired by Emperor, http://www.the-emperor.org/
function quotePost(quoteID) {
  quoteAuthor = stripHTML(getObj("post_" + quoteID + "_author").innerHTML);
  quoteText = stripHTML(getObj("post_" + quoteID).innerHTML);

  // Get selection
  if ((clientVer >= 4) && is_ie && is_win) { // Internet Explorer
    theSelection = stripHTML(document.selection.createRange().htmlText);
  }
  else if (document.getSelection) { // Mozilla
    theSelection = document.getSelection();
  }

  // check if the selection is part of the post
  if (theSelection && filterWhitespace(quoteText).indexOf(filterWhitespace(theSelection)) != -1) {
    quoteText = theSelection;
  }

  quoteText = trim(decodeHTMLEntities(quoteText));

  quoteUBB = "[quote]\n[b]" + quoteAuthor + " said:[/b]\n\n" + quoteText + "\n[/quote]\n";

  insertCode(quoteUBB);
}

// Strip HTML tags, replace <br />s with line breaks
function stripHTML(str) {
  return str.split("\n").join("").replace(/<\/p>\r<p>/gi, "\r\n\r\n").replace(/<br \/>/gi, "\r\n").replace(/<[^>]*>/g, "");
}



'theSelection = stripHTML(.....)' is the important line.

Can't say how exactly you'd fit the browser check into a bookmarklet, though....


del.icio.us is pretty neat by the way - I first thought of replicating (..?) a bookmark DB like the one you have at indented.com on my site, but then found delicious which was so much less of a hassle

{{stupid code tags}}

(Edited by kuckus on 12-01-2005 21:37)

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 12-01-2005 21:36

excellent - thanks for the link.

d'oh, kuckus snuck in while i was submitting...

Good stuff. I'm not worried about browser detection, just want to make sure i can make one of these on more than one browser



(Edited by DL-44 on 12-01-2005 21:38)

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 12-01-2005 22:53

working beautifully =)

thanks again...

« BackwardsOnwards »

Show Forum Drop Down Menu