More direct 'Reload' of HTML viewing window?

Is the contextual menu of HTML viewing windows the only GUI / Scripting route to Reload ?

I’m comparing DEVONthink with Brett Terpstra’s Marked 2 for live viewing of Bike outliner files (HTML outlines).

  • DT3 has the advantage of indexing a folder-full of outlines, but
  • Marked automatically updates the preview as one edits an outline in Bike.

The only route I’ve found to slightly less sluggish or cumbersome HTML preview updates in DT3 is this kind of thing:

tell application "DEVONthink 3" to activate

tell application "System Events"
	tell application process "DEVONthink 3"
		
		tell value of attribute "AXFocusedUIElement" to ¬
			perform action "AXShowMenu"
		keystroke "Reload"
		key code 36
	end tell
end tell

which seems a bit indirect …

Am I missing something a bit more direct ?


A minor note about a point at which Reload features in the documentation, under:

HTML-Based Formats > CONTEXTUAL MENU > Reload:

The gloss on that contextual menu item reads (at the moment):

Reloads the page from the Internet.

which, I suppose, expresses a reasonable assumption that an HTML file will typically be a resource “on the internet”, rather than actively and locally edited in a local folder.

Perhaps simply something like:

“Reloads the HTML page”

or

“Reloads the page”

?

The suggestion re: the documentation is noted.

The Reload command is found only in the contextual menu or the Navigation bar over the view/edit pane.

1 Like

What about

That should reload the current document in any user agent.

1 Like

location.reload()

But is that exposed to DEVONthink scripting contexts ?

(It looks like part of the DOM – exposed only to browser JS evaluation contexts, but I may be missing something)


Ah … got it. Thanks.

do JavaScript

do JavaScript (verb)Applies a string of JavaScript code to a think window. (from DEVONthink 3 Suite)

FUNCTION SYNTAX

set theResult to do JavaScript text ¬
in think window


Works well, and, of course, much faster.

Many thanks !

(() => {
    "use strict";
    
    const devonThink = Application("DEVONthink 3");
    const thinkWindow = devonThink.thinkWindows.at(0);
    
    thinkWindow.exists() && (
        devonThink.doJavaScript("location.reload()", {in: thinkWindow})
    );
})();

(And I notice that DEVONthink does, in due course, update the display after a change in the file-system, even if not explicitly prompted. Rather more slowly than Marked 2, which is understandable, as it’s watching a much larger number of files)

Well, you figured it all out… since you were talking about a HTML view, the DOM is exposed there. Which makes the whole reload thing possible.

But it’s not obvious. I remembered having seen some DOM-related code in another script, possibly by @pete31. So the credit should go to them, too.

tell application id "DNtp" to do JavaScript "location.reload();" in think window 1

:stuck_out_tongue:

1 Like