I have a AppleScript Studio project that I am working on which is eventually going to help me post blog entries to my website from my desktop.
What I have so far is a XML-RPC call that searches my remote MySQL database, creates a new document, or gets the contents of an existing document, and takes the HTML source of that document and sets it to an editable instance of a web view and (for editing the raw html) an ordinary text view in a second (popup) window.
The actual HTML content is initially set in a variable called docContent. To assign it in its default, freshly downloaded sate to both the web view and the text view, I put this in my script.
set rawHTML to text view "rawHtmlEdit" of scroll view "rawHtmlScroll" of window "rawHtmlWindow"
set content of rawHTML to docContent
set richText to view "webView" of window "editWindow"
call method "setEditable:" of (richText) with parameters {true}
call method "loadHTMLString:baseURL:" of (call method "mainFrame" of object richText) with parameter (docContent)
This works brilliantly. The web view shows the content laid out exactly as the html should be rendered, and I can add and delete words, etc…
The text area (which pops open in a new window on button click) shows the raw html of docContent. Perfect!
Now, when I change the raw html in the text view and I click “update”, this is executed:
set rawHTML to text view "rawHtmlEdit" of scroll view "rawHtmlScroll" of window "rawHtmlWindow"
set richText to view "webView" of window "editWindow"
call method "setEditable:" of (richText) with parameters {true}
call method "loadHTMLString:baseURL:" of (call method "mainFrame" of object richText) with parameter (content of rawHTML)
close window of theObject
which basically repeats the initialization of the web view again, but this time loads it with the current content of the text view, so now the web view reloads and reflects the changes I made in the raw html. it also closes the rawHTML window when the “update” button is clicked.
So my question is when I change the content of the editable web view and I click the button to open the raw html text view, how can I get the source code of the newly edited web view so I can pass it to the text view, and of course eventually send it back to the server to be inserted into the database? Is it possible to get the source of the current web view?
-sD-
Dr. Scotty Delicious, Scientist.