How to use ko.help.open() to display my extension's help pages

I noticed that that there is a ko function to launch the Komodo Help dialog.

Can I use it display help pages for my extension?

And if so, can you point me to some notes or samples to show how to do it?

The documentation is a bit light…

open(page)
Open the Komodo help window.

          Arguments
            page
             - String
            
          
          A page tag as defined in toc.xml

ko.open.URI("path to help page (http(s) or chrome://)","browser");
Function ko.help.open() used for opening Komodo built-in help pages defined in toc.xml (or not, @toddw can say more).
I don’t know how to open pages that placed in your add-on :frowning:

There are a few different browser APIs:

var url = "http://www.komodoide.com/";
// To open a browser view (like an editor tab):
ko.open.URI(url, "browser");
// To open in an external (or default) browser:
ko.browse.openUrlInDefaultBrowser(url);

To locate file inside of an extension:

var afile = Components.classes["@mozilla.org/file/directory_service;1"].
                    getService(Components.interfaces.nsIProperties).
                    get("ProfD", Components.interfaces.nsIFile);
// Add extensions dir
afile.append("extensions");
// Add the extension name
afile.append("sbsdiff@activestate.com");
// Add the file name
afile.append("docs.html");
// Now grab the path
var path = afile.path;

Let us know if you need more info.

Cheers,
Todd

And why do not use chrome://extension_name/content/mypage.html where extension_name defined in chrome.manifest (in most cases as first line of manifest file, for example: content extension_name content/)?

Because an external browser will not like that :stuck_out_tongue:

1 Like

Oops, I don’t think about it :smiley:
Also can I write same code as afile.append("extensions").append("sbsdiff@activestate.com").append("docs.html")?

Also in this case I think it would be better if your “Help” window will be opened as new <window> tag/object with XUL/HTML inside :blush:

Thanks, I’ve already concocted a dialog to handle external html pages or pages I’ve put in my extension chrome (see below). I was just thinking that the Komodo help dialog might be more usable (with its nifty contents pane, and navigation and print buttons.) than that strategy.

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://qplwrapper/skin/build.css" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://qplwrapper/locale/build.dtd">
<!-- qpl_help.xul     K. Dooley --> 

<dialog id="qpl_help"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        persist="screenX screenY width height"
        buttons="cancel"
        ondialogcancel="return true;"
    title="&qpl_help.title;"
    style="width: 50em; min-height: 50em;"
    onload="OpenHelp(window.arguments[0]);">

<stringbundleset id="stringbundleset">
    <stringbundle id="qplwrapper-strings" src="chrome://qplwrapper/locale/qplwrapper.properties"/>
</stringbundleset>

<browser id="helpcontent" type="content" src="about:blank" flex="1"/>


<script type="application/x-javascript" src="chrome://qplwrapper/content/qplwrapper.js"/> 
<script type="application/x-javascript" src="chrome://qplwrapper/content/qplwrapper-helper.js"/> 
<script type="application/x-javascript" >
<![CDATA[
function OpenHelp(HelpFile)
{
    qplLog("Help: " + HelpFile, true);
    if (HelpFile) {
        if (/^http:/.test(HelpFile)) {
            // qplLog(HelpFile, true);
            document.getElementById('helpcontent').setAttribute('src', HelpFile);
        }
        else {
            var ios = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces["nsIIOService"]);
            var uri = ios.newURI("chrome://qplwrapper/locale/" + HelpFile, "UTF-8", null);
            var cr = Components.classes['@mozilla.org/chrome/chrome-registry;1'].getService(Components.interfaces["nsIChromeRegistry"]);
            Path = cr.convertChromeURL(uri).spec;
            document.getElementById('helpcontent').setAttribute('src', Path);
            qplLog("Help: " + Path, true);
        }
    }
    
    return;
}
]]>
</script>