Page 1 of 2

Browser: How to copy the html code from a selection?(=^‥^=)

Posted: Sat Oct 19, 2013 9:48 am
by Mariasole
Hello to all!
I am continuing to study LiveCode and I am very satisfied by the power and simplicity of this amazing software!
I'm experimenting with the browser (the InetBrowser stack).
But ... how to copy the html code from a text selection? This is the problem ...

es. text selected from browser, only copy (--> <--):

bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
--> Che bella cosa e' na jurnata'e'sole
n'aria serena doppo na
tempesta <--
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla

paste after copy in other field:

<p>Che <strong>bella cosa e' na jurnata'e'sole <br />
n'aria serena doppo na</strong> tempesta</p>



I have two commands available. One is revBrowserGet (htmltext) but copying the entire source. The other is revBrowserGet (selected)but copy only the text .. There is a hybrid? Like... "selectedHTML" ;)


Thanks to all of you experts, Gurus and Chevaliers for support and patience with absolute beginners! :D


Ciao e grazie!
Mariasole
(=^-ω-^=)

Ma n'atu sole
cchiu' bello, oi ne'.
'O sole mio
sta 'nfronte a te!
'O sole, 'o sole mio
sta 'nfronte a te,
sta 'nfronte a te!

Re: How to copy the html code from a text selection? (=^‥^=)

Posted: Sat Oct 19, 2013 10:02 am
by jmburnod
Hi MariaSol,

I think "HTMLText" is your magic word in this case
Something like that:

get fld "myHtmlText"
set the HTMLText of field 1 to it

All the best
Jean-Marc

Re: How to copy the html code from a text selection? (=^‥^=)

Posted: Sat Oct 19, 2013 10:52 am
by Mariasole
Grazie!

But I think I explained badly ... My English is obviously terrible! Excuse me!
So ..

a) I am surfing with our browser (InetBrowser)

b) I'm on page http://en.wikipedia.org/wiki/Bart_King

c) I'm selecting with the mouse

John Barton "Bart" King (October 19, 1873 – October 17, 1965) was an American cricketer, active in the late 19th and early 20th centuries

d) I would like to copy not only the text (plain) but its html code selection.

In this case would be:

Code: Select all

<b>John Barton</b> "<b>Bart</b>" <b>King</b> (October 19, 1873 – October 17, 1965) was an American <a href="http://en.wikipedia.org/wiki/Cricket" title="Cricket">cricketer</a>, active in the late 19th and early 20th centuries.

The plain text I was able to copy it using the command revBrowserGet (selected)...
But I can not copy only the part of html on the selection ...

Baci! e Grazie!

Mariasole
(=^-ω-^=)

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Sat Oct 19, 2013 8:05 pm
by jacque
I don't see a way to do that. You could submit a feature request for it, I think it would be useful to others.

Your English is good, by the way. You have nothing to worry about.

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Mon Oct 21, 2013 10:10 am
by Mariasole
Grazie Jacque,
sei molto gentile! :)
It would be a very useful function, how can I submit a 'feature request' to the staff? :oops:
Grazie ancora!

Mariasole

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Mon Oct 21, 2013 6:43 pm
by jacque
I had to look up and translate "sei molto gentile". I'm a dumb, one-language American, unlike you.

You can submit bug reports or feature requests here: http://quality.runrev.com/

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Mon Oct 21, 2013 6:45 pm
by Klaus
Cara Maria,

please check my answer to your post in the Internet forum :D


Best

Klaus

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Wed Oct 23, 2013 4:31 pm
by Mariasole
jacque wrote:I had to look up and translate "sei molto gentile". I'm a dumb, one-language American, unlike you.

You can submit bug reports or feature requests here: http://quality.runrev.com/
Caro Jacque...
A dumb? :oops: No! You're really a gentleman :D , a real gentleman in Los Angeles! Nay, more, a Hyperactive gentleman ! :D :D :D

Un bacio

Mariasole
(=^‥^=)

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Wed Oct 23, 2013 4:35 pm
by Klaus
Well, Jaqueline is more a gentlewoman! 8)

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Wed Oct 23, 2013 4:36 pm
by Mariasole
Klaus wrote:Cara Maria,

please check my answer to your post in the Internet forum :D


Best

Klaus

Caro Klaus,
you have been very kind (and genial :idea: ) to give me a solution! But..... unfortunately...... I do not think it is exactly "the solution"! :oops: :oops: :oops:
Now I go on Internet forum and I'll explain .... :arrow:

a tra poco... :shock:

Mariasole (=^‥^=)

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Wed Oct 23, 2013 4:40 pm
by Mariasole
Klaus wrote:Well, Jaqueline is more a gentlewoman! 8)


:oops: SORRY!!!! YES gentlewoman!!!!!! :oops:

I read only Jacque and I thought it was a boy!

Sorry Jaqueline :oops: , nice to meet you and it's nice that you're a girl like me!

Mariasole

(=^‥^=)

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Wed Oct 23, 2013 9:34 pm
by jacque
LOL. Everyone thinks I'm a boy. You aren't the only one. :)

http://jacque.on-rev.com/jacque/jacque.irev

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Wed Oct 23, 2013 10:53 pm
by SparkOut
Cara Maria,

The best I can do is this, using a javascript function discovered on stackoverflow http://stackoverflow.com/questions/4176 ... ected-text

Make a custom property of the card your browser object is on, call it (in this case) cGetHtmlTextCode and set the contents to

Code: Select all

function getSelectionHtml() {
    var html = "";
    if (typeof window.getSelection != "undefined") {
        var sel = window.getSelection();
        if (sel.rangeCount) {
            var container = document.createElement("div");
            for (var i = 0, len = sel.rangeCount; i < len; ++i) {
                container.appendChild(sel.getRangeAt(i).cloneContents());
            }
            html = container.innerHTML;
        }
    } else if (typeof document.selection != "undefined") {
        if (document.selection.type == "Text") {
            html = document.selection.createRange().htmlText;
        }
    }
    return html;
}

var result = getSelectionHtml();
Then you can use the revBrowserExecuteScript command to call the javascript function:

Code: Select all

put revBrowserExecuteScript(gBrowserId, the cGetHtmlTextCode of this card) into tHtmlText
set the text of field "htmlView" to tHtmlText
It still suffers from some "interpretations" but it gives me the result:

Code: Select all

<B>John Barton</B> "<B>Bart</B>" <B>King</B> (October 19, 1873 – October 17, 
1965) was an American <A title=Cricket href="/wiki/Cricket">cricketer</A>, 
active in the late 19th and early 20th centuries.
which at least resembles your version, although the tags are all rendered as uppercase and the quotes are stripped from the title declaration (and pretty much any other quotes are stripped from attribute declarations).
I hope it gets you nearer to your need.
ciao!

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Thu Oct 24, 2013 10:33 am
by Mariasole
Thank you SparkOut :idea: ! :D
Tou taught me a new technique (the "javascript calling") that I will study now :)
Unfortunately :oops: , in fact, even this solution while being almost perfect, is not the exact html code that is below the page :cry: ...
Hopefully LC will soon put this new feature ... :!: :?:

Grazie :idea: SparkOut :idea: !
Un bacio!

Mariasole
(=^‥^=)

Re: Browser: How to copy the html code from a selection?(=^‥

Posted: Thu Oct 24, 2013 10:38 am
by Mariasole
jacque wrote:LOL. Everyone thinks I'm a boy. You aren't the only one. :)

http://jacque.on-rev.com/jacque/jacque.irev

Hi Jwack! :)
You are really pretty!
And remember... nomen omen! :D

Un bacio!!!!
Mariasole
(=^‥^=)