Page 1 of 1

Browser, cut-copy html code. A newbie intrusion

Posted: Mon Oct 21, 2013 3:04 pm
by Mariasole
Hello!
Sorry :oops: , I'm a absolute beginner and I should not be here :oops: ... but there is someone who would have some idea :idea: about it?
The post is published in the section "Getting Started with LiveCode - Complete Beginners" :mrgreen:

http://forums.runrev.com/viewtopic.php?f=7&t=17587


Thank you so much for reading these lines!
Sorry for the intrusion! :wink:

Mariasole

Re: Browser, cut-copy html code. A newbie intrusion

Posted: Mon Oct 21, 2013 3:50 pm
by Klaus
Hola Maria,

since Livecode does not support this directly, I got it working somehow :D ,
but the user needs to COPY (via menu or shortcut) the selected text on the page himself!

When I use "copy" in the script, it does NOT copy the selected text!?
Here is my workaround in a button script:

Code: Select all

on mouseUp
   ## copy
   ## Don't work???!!!!
   ## Although it is the SAME as if the user selectes that menu or the shortcut CMD-C!!!??? 
   ## Too funky :-D

  #ä The rest works fine when the user copies himself, see above...
   put the clipboarddata["html"] into tHtml
   set the htmltext of the templatefield to tHtml
   put the htmltext of the templatefield into a Variable
   put aVariable 
   ## HTML text with tags etc :-)

   reset the templatefield
end mouseUp
Best

Klaus

Re: Browser, cut-copy html code. A newbie intrusion

Posted: Wed Oct 23, 2013 4:56 pm
by Mariasole
Grazie Klaus!!!
You were really kind and brilliant :idea: :idea: :idea: !

I tried your solution and would be fine for other uses but not for the test I'm doing. :cry:
Let me explain. I need the exact html source of the selection of the text of the html page ...

We proceed step by step. I used your code this way:

Code: Select all

on mouseUp
   ## -----------------------------------------------
   ## (c) Klaus The Genius
   ## Codice rimasticato ignobilmente da Mariasole ;)
   ## -----------------------------------------------



   put the clipboarddata["html"] into tHtml
   set the htmltext of the templatefield to tHtml
   put the htmltext of the templatefield into aVariable
   put aVariable into field "fBrowser"
   reset the templatefield


end mouseUp


1) I go on the usual page http://en.wikipedia.org/wiki/Bart_King
2) I select text and copy:

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


3) I press the button (with the Genius Klaus Code] and here is the html that returns

Code: Select all

<p spaceabove="5" spacebelow="5"><b><font size="16">John Barton</font></b><font size="16"> "<b>Bart</b>" <b>King</b> (October 19, 1873 &ndash; October 17, 1965) was an American </font><a name="/wiki/Cricket"><u><font size="16" color="#0000FF">cricketer</font></u></a><font size="16">, active in the late 19th and early 20th centuries. </font></p>
<p>&#0;</p>


But the real HTML selection code of the web page is:

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.


From what I understand, but consider that I am a ignorant beginner :oops: , (so do not laugh :mrgreen: ), LC does his "interpretation" of HTML ...

Do you think there is a solution to have the exact html string selection?

Davvero grazie e complimenti!

Mariasole :oops:
=^..^=

Re: Browser, cut-copy html code. A newbie intrusion

Posted: Wed Oct 23, 2013 5:06 pm
by Klaus
Buongiorno Maria,

sorry, no other brilliant idea in the moment...

I consider this a bug, if Livecode gives you its interpretation of the source!


Best

Klaus