Web View

Here is where the magnanimous folks that create externals post them (.zip archives only please).

Re: Web View (Dynamic content)

Postby Dave_Higgins » Tue May 19, 2009 7:27 am

Me wrote:What would be nice is to be able to grab the generated HTML after any edits, and also after any dynamic (AJAX) content is loaded or changed.

Well, it took some serious web surfin', trial and error, and brain banging, but I figured it out. I thought that "innerHTML" should do it, but getting the exact syntax down took me a while...

For the benefit of anyone else interested, here are a few examples... To get the currently displayed HTML of:

The whole page: put "document.documentElement.innerHTML" into tJavaScript
Just the <body>: put "document.getElementsByTagName('body')[0].innerHTML" into tJavaScript
A <div> by ID: put "document.getElementById('body_left_login').innerHTML" into tJavaScript

The returned HTML uses lineFeeds, so you'll want to replace linefeeds with returns.

Another goodie... Change innerHTML to textContent and you can get just the text that's displayed on the page (or within an element). You end up with a bunch of white space which is basically linefeeds (or returns if you replaced), but they can be cleaned up with a simple:
Code: Select all
put SCWebView("doJavaScript","wd id 100",gWebView,tJavaScript) into tInfo
put replace (tInfo, linefeed, cr) into tInfo
repeat while tInfo contains cr & cr
  put replace (tInfo, cr&cr, cr) into tInfo
end repeat
put tInfo into cd fld 1

One problem here, though... textContent will include the text of any elements that are hidden. As in <div id="login_error" style="display: none;">Error:</div>... But using innerHTML will display the HTML that's in play along with any dynamic changes.

Now to figure out how to alert us that our data from an AJAX call has loaded, since it won't be triggering SCWV_frameLoaded and the frame doesn't load/reload with AJAX calls. As it stands right now, your external would basically see the page as being idle. I guess I could poll for a change by calling a function in the JS, but to me that's like the little kid in the back seat... "Are we there yet?" "No" "Are we there yet?" "No" "Are we there yet?" "No". :-)

I've been digging through the docs ad developer.apple.com on WebFrame and WebView and I see a lot of what you're using in many of the functions, so I'll see if anything stands out. What we need is something like WebViewProgressStartedNotification and WebViewProgressFinishedNotification that can be triggered by an XMLHttpRequest.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: Web View

Postby sctell » Tue May 19, 2009 10:25 am

Hi Dave,

I can't help much here because although I have written the external my use of AJAX etc. is rather limited.

If you find what you are looking for in the Apple documentation then please let me know and I will try to incorporate it into the external.

However, I will not be available for any improvements until the 2 June 2009.

Good hunting.
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby Dave_Higgins » Fri Jun 12, 2009 10:57 am

I was curious about Safari 4's ability to zoom rather than just make text larger... I asked on a WebKit-Dev list (referring to a sample WebKit app that comes with Xcode, using a WebView), and I got this reply...
I'm not sure if or when this is or will be a public API, but making the
text larger/smaller and zooming are different calls. So if you want to use
the new zooming feature you have to check first if the WebView responds
to these calls.

modify the text size:

- (void)canMakeTextSmaller;
- (void)canMakeTextLarger;
- (void)makeTextSmaller:(id)sender;
- (void)makeTextLarger:(id)sender;


Zooming (new in the new Safari 4 WebKit):

- (void)canZoomPageOut;
- (void)canZoomPageIn;
- (void)zoomPageOut:(id)sender;
- (void)zoomPageIn:(id)sender;
- (void)resetPageZoom:(id)sender;

This would be a good one to look into when you can.

Thanks.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: Web View

Postby KevinPaszalek » Wed May 22, 2013 9:02 am

Is this still available? The links are all dead. I sure would like to play with it if it can work with SC 4.5.
Blessings,
K
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby sctell » Wed May 22, 2013 10:50 pm

KevinPaszalek wrote:Is this still available?


I have placed it in a new thread here:

http://forums.supercard.us/viewtopic.php?f=16&t=1817

All the best

Terry
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby KevinPaszalek » Sun May 26, 2013 6:14 am

Thanks, Terry. I have only had time to look at it briefly today, but it seems completely amazing and so well done!
I'm looking forward to working through it.
Blessings!
K
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby KevinPaszalek » Sun Jun 02, 2013 6:35 am

Terry, I am incorporating your excellent work into one of my projects. When I copy from a webpage into a field, the text of any links comes through fine, but when I try to copy from that field to another, the text of the link disappears. Clearly there is something going on that I am missing. I have tried all the different methods of copying, but to no avail.
Can you shed some light on what is happening? I realize that the problem is not with your external, but I thought you would probably know what was going on.
Blessings,
K
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby KevinPaszalek » Sun Jun 02, 2013 6:38 am

Terry, I am incorporating your excellent work into one of my projects. When I copy from a webpage into a field, the text of any links comes through fine, but when I try to copy from that field to another, the text of the link disappears. Clearly there is something going on that I am missing. I have tried all the different methods of copying, but to no avail.
Can you shed some light on what is happening? I realize that the problem is not with your external, but I thought you would probably know what was going on.
Blessings,
Kevin
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby JoeKoomen2011 » Sun Jun 02, 2013 7:36 am

Make sure that all fields you need to have objects (like links, graphics, etc) have their 'objects' property set to true.

Code: Select all
set the allowObjects of cd fld 3 to true
Joe Koomen
>> Random! ...Damn near killed 'em! <<
User avatar
JoeKoomen2011
 
Posts: 474
Joined: Thu Mar 12, 2009 1:38 pm

Re: Web View

Postby KevinPaszalek » Sun Jun 02, 2013 8:12 am

Thanks, Joe. I set that property for the fields, but it didn't make a difference.
Kevin
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby sctell » Sun Jun 02, 2013 11:04 am

KevinPaszalek wrote:When I copy from a webpage into a field, the text of any links comes through fine, but when I try to copy from that field to another, the text of the link disappears. Clearly there is something going on that I am missing. I have tried all the different methods of copying, but to no avail.


To be honest I am not sure what happens with SC's copy and paste under the hood.

What I have noted is that if you change the Copy button text in the example to;

Code: Select all
on mouseUp
global gWebView
put SCWebView("copy","wd id 100",gWebView) into tInfo
put "" into cd fld 1
select after text of cd fld 1
paste text without style ------------- Changed to without style
end mouseUp


then you can copy and paste between fields.

Probably SC's copy/paste does not take kindly to the formatting of the text from websites.

It seems to accept the formatting from the clipboard but will not accept it when you transfer between fields.

Perhaps Mark could chip in at this point to let us know what is happening.

All my code does is call this routine of a WebView:
copy:
Action method that copies the selected content to the general pasteboard.

- (void)copy:(id)sender
Parameters
sender
The object that sent this message.

Discussion
This action method copies the selected content onto the general pasteboard, in as many formats as the receiver supports. For example, a plain text object uses NSStringPboardType for plain text, and a rich text object also uses NSRTFPboardType.

Availability
Available in Mac OS X v10.3.9 and later.
See Also
– cut:
– paste:
Declared In
WebView.h
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby KevinPaszalek » Thu Jun 06, 2013 10:54 am

Hi, everyone.
I have integrated Webview into my project. I have a window which has three cards. One of those cards has the webview.
In the runtime environment, it works fine. However in a standalone, the card having the webview acts like the focus is on the webview. I get beeps when I try to type in the other fields on the card. The buttons are grayed out and I can't click on them.
I have tried SCWebView("setFocusToSC","wd id 100",gWebView), but it doesn't seem to change anything.
Does anyone have an idea what is going on and how to fix it?
Thanks!
K
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby sctell » Fri Jun 07, 2013 3:09 am

I suspect you do not have an anchor window.

I just built a standalone from the example and it seems to work OK.

If you look at the example programme there is a window as the image below.

Screen Shot 2013-06-07 at 11.57.19.png
Screen Shot 2013-06-07 at 11.57.19.png (10.14 KiB) Viewed 13175 times


This is a palette window and is required.

It can be positioned off screen but I left it on screen in the example to emphasise it is needed.

Because the WebView is actually a Cocoa based window grouped with SC's Carbon based windows some issues may rear their head for which there is not a solution but in a simple application it should be OK (famous last words).

All the best

Terry
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby KevinPaszalek » Fri Jun 07, 2013 7:06 am

Terry,
Thanks very much!
I had an anchor window. but it wasn't a palette window. I changed the window type and it seems to work.
I appreciate all your support. I think my standalone is ready for beta testing now.
Blessings,
K
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby KevinPaszalek » Fri Jun 07, 2013 1:17 pm

Is it possible to search the webview?
K
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby sctell » Fri Jun 07, 2013 11:14 pm

KevinPaszalek wrote:Is it possible to search the webview?
K


I did spot this routine in the WebView docs.

searchFor:direction:caseSensitive:wrap:
Searches a document view for a string and highlights it if it is found.

- (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag
Parameters
string
The search string.

forward
If YES the direction of the search is forward; if NO, the direction is backward.

caseFlag
If YES if the search is case sensitive; otherwise, it is not.

wrapFlag
If YES if the search wraps; otherwise, it does not.

Return Value
YES if the search is successful; otherwise, NO.

Discussion
The search for string begins from the current selection and continues in the direction specified by forward. The search continues across all frames.

Availability
Available in OS X v10.2 with Safari 1.0 and later.
Available in OS X v10.2.7 and later.
See Also
– applicationNameForUserAgent
– setCustomUserAgent:
– customUserAgent
Declared In
WebView.h



It is not currently implemented. Is this what you are after.

It seems to search for text and highlight it if it finds it and returns YES or NO (in SC true or false).

I could add it when I get a minute, if you like?

All the best

Terry
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby KevinPaszalek » Sat Jun 08, 2013 12:47 am

Terry, this would be a wonderful addition for my purposes. It is exactly what I need.
I'm sure you have a life away from your computer, so I hate even to ask.
However, it would be very useful to me-- when you get a minute.
Blessings,
Kevin
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby sctell » Sat Jun 08, 2013 10:49 pm

KevinPaszalek wrote:Terry, this would be a wonderful addition for my purposes. It is exactly what I need.
I'm sure you have a life away from your computer, so I hate even to ask.
However, it would be very useful to me-- when you get a minute.
Blessings,
Kevin


I have added this function, you can download the external here:

http://forums.supercard.us/viewtopic.php?f=16&t=1817&p=9140#p9140


All the best

Terry
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby gonetriadrr » Sun Jun 09, 2013 9:15 am

bookbuzz wrote:But the SCWebView.bundle doesn't open in the RM.

BookBuzz


If the .bundle is dimmed in the RM's selection dialog, try changing the extension to .pkg.
For some reason i always have to do this with Terry's externals.

DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

URL field locking text

Postby KevinPaszalek » Wed Oct 09, 2013 1:54 pm

Greetings, all.
I using WebView in a stack and have been having trouble with the field where the user enters a URL. It's like something is locking the text in the URL field.
Is there anything in WebView that would cause that?
Thanks in advance!
Kevin
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby KevinPaszalek » Mon Oct 14, 2013 9:06 am

This is a followup to my last post:
It seems what is happening is that WebView is trapping the keystrokes even though another field is active: backspace causes WebView to go back to a previous webpage, spacebar causes a scroll to the bottom of the page. Any key press that WebView doesn't process just produces a beep.

Is there any way to keep these key presses from going to WebView?
Thanks
Kevin
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby sctell » Mon Oct 14, 2013 10:18 am

Hi,

I believe I have mentioned before that SCWebView is a Cocoa based overlay window that hovers above the SC window to which it is attached. I tried many times to make overlay windows work well with SC and in a limited way they do but sometimes there were difficulties which could not be overcome. These were mainly the interaction between the overlay and SC Windows and controls, the switching of focus between the overlay window and SC's window/controls.

The example programme for SCWebView contains the best I could achieve. It is not perfect and this interaction with SC was one reason why I stopped trying to work with overlay windows.

If I could have resolved the issues it would have opened up a lot of areas in Cocoa to SC. The one big one for me would have been access to NSTableView. SC does not really have a table solution and that for me limits it's use.

There a two subroutines within the external, which may help with your issue, setFocusToWebView and setFocusToSC, you should try to place those strategically to try and overcome the issue you are seeing.

Have a look at the Example URL field script for ideas.

All the best

Terry
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: Web View

Postby KevinPaszalek » Mon Oct 14, 2013 8:22 pm

Thank you, Terry. I will take a closer look.
Kevin
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View

Postby KevinPaszalek » Tue Oct 15, 2013 7:09 am

Thanks, Terry. That was the problem. I'm sorry, I should have figured that out on my own.
Kevin
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

Re: Web View-trapping for returnInField

Postby KevinPaszalek » Fri Nov 01, 2013 1:40 pm

Greetings, all.
Is it possible to trap for returnInField in WebView?
Thanks!
Kevin
KevinPaszalek
 
Posts: 105
Joined: Fri Jun 08, 2012 11:35 am

PreviousNext

Return to XCmds, XFcns, and XRtns

Who is online

Users browsing this forum: No registered users and 1 guest