From fff79f97b4a207e81a3164de8365b39bf2ec8990 Mon Sep 17 00:00:00 2001 From: Len Kranendonk Date: Fri, 9 May 2003 08:34:03 +0000 Subject: [PATCH] Support for link target selection --- www/extras/htmlArea/editor.js | 61 ++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/www/extras/htmlArea/editor.js b/www/extras/htmlArea/editor.js index c049f7feb..ee0a84ff1 100644 --- a/www/extras/htmlArea/editor.js +++ b/www/extras/htmlArea/editor.js @@ -372,10 +372,63 @@ function editor_action(button_id) { if (cmdID.toLowerCase() == 'subscript' && editdoc.queryCommandState('superscript')) { editdoc.execCommand('superscript'); } if (cmdID.toLowerCase() == 'superscript' && editdoc.queryCommandState('subscript')) { editdoc.execCommand('subscript'); } - // insert link - if (cmdID.toLowerCase() == 'createlink'){ - editdoc.execCommand(cmdID,1); - } + // insert link (modified) + if (cmdID.toLowerCase() == 'createlink') { + if (editdoc.selection.createRange().text != "") { + var highlightedText = editdoc.selection.createRange().text; + } + else { var highlightedText = ""; } + + var href_attribute = ''; + var tar_attribute = ''; + var linkText = ''; + + if (editdoc.selection.createRange().parentElement().outerHTML.search(/^\<[A|a]/) != -1) { + + var fullElement = editdoc.selection.createRange().parentElement().outerHTML; + fullElement = fullElement.replace(/\"/g, ""); + fullElement = fullElement.replace(/\'/g, ""); + + // here, we have an tag. Now let's extract... + // 1. the href attribute + var href_value = fullElement.split(/href=/); + href_value2 = href_value[1].split(/\s|>/); + href_attribute = href_value2[0]; + + // 2. the target attribute + if (fullElement.search(/target=/) != -1) { + var tar = fullElement.split(/target=/); + tar2 = tar[1].split(/\s|>/); + tar_attribute = tar2[0]; + } + else { tar_attribute = ''; } + + // 3. the link text + var linkText2 = fullElement.split(/>/); + var lt = linkText2[1].split(/