<!ENTITY common.browser.backward.accesskey "B">
<!ENTITY common.browser.reload.label "Reload">
<!ENTITY common.browser.reload.accesskey "l">
+<!ENTITY common.browser.print.label "Print Page">
+<!ENTITY common.browser.print.accesskey "P">
+<!ENTITY common.browser.help.label "Help">
+<!ENTITY common.browser.help.accesskey "H">
<!ENTITY common.textbox.cut "Cut">
<!ENTITY common.textbox.copy "Copy">
// /custom_help.html
// /help.html
//
- // If @pathname is specified, it will override the value from location.href
+ // If @pathname is specified, it will override the value from location.pathname
+ // If @hostname is specified, it will override the value from location.hostname
+ // If @port is specified, it will override the value from location.port
+ // If @protocol is specified, it will override the value from location.protocol
this.addEventListener( 'command', function(ev) { this._open_window(); }, false);
} catch(E) {
try {
var obj = this;
+ var protocol = obj.getAttribute('protocol') || location.protocol;
+ var hostname = obj.getAttribute('hostname') || location.hostname;
+ var port = obj.getAttribute('port') || location.port;
+ var pathname = obj.getAttribute('pathname') || location.pathname;
function test_url(loc) {
- if (!loc) { return false; }
+ if (loc == '/' || !loc) { return false; }
var x = new XMLHttpRequest();
- x.open("HEAD",loc,false);
+ var url = protocol + '//' + hostname + ( port ? ':' + port : '' ) + loc;
+ dump('help widget: testing <'+url+'>\n');
+ x.open("HEAD", url, false);
x.send(null);
return x.status == 200;
}
function open_url(loc) {
- window.open(loc+'?id='+obj.id,obj.getAttribute('label'),'resizable,scrollbars');
+ var url = protocol + '//' + hostname + ( port ? ':' + port : '' ) + loc +'?id='+obj.id;
+ dump('help widget: opening <'+url+'>\n');
+ window.open(url, obj.getAttribute('label'), 'resizable,scrollbars');
}
- if (test_url(this.src)) {
- open_url(this.src);
+ if (test_url('/'+this.getAttribute('src'))) {
+ open_url('/'+this.getAttribute('src'));
} else {
- var pathname = obj.getAttribute('pathname') || location.pathname;
if (test_url(pathname + '.custom_help.html')) {
open_url(pathname + '.custom_help.html');
} else {
} catch(E) {
s += E + '\n';
}
-
//this.error.sdump('D_BROWSER',s);
+
+ // Let's also update @protocol, @hostname, @port, and @pathname on the <help> widget
+ var help_btn = document.getElementById('help_btn');
+ if (help_btn) {
+ try {
+ help_btn.setAttribute('protocol', obj.get_content().location.protocol);
+ help_btn.setAttribute('hostname', obj.get_content().location.hostname);
+ help_btn.setAttribute('port', obj.get_content().location.port);
+ help_btn.setAttribute('pathname', obj.get_content().location.pathname);
+ } catch(E) {
+ dump('Error in browser.js, setting location on help widget: ' + E);
+ }
+ }
},
'buildProgressListener' : function() {
<commandset id="util_browser_cmds">
<command id="cmd_broken" />
- <command id="cmd_print" />
+ <command id="cmd_print" label="&common.browser.print.label;" accesskey="&common.browser.print.accesskey;" />
<command id="cmd_debug" />
<command id="cmd_back" label="&common.browser.backward.label;" accesskey="&common.browser.backward.accesskey;" />
<command id="cmd_reload" label="&common.browser.reload.label;" accesskey="&common.browser.reload.accesskey;" />
<button id="forward" command="cmd_forward" disabled="true" hidden="true"/>
<spacer flex="1"/>
<label id="debug" value="Debug" disabled="true" command="cmd_debug" onclick="this.doCommand();" />
- <button id="browser_print" label="Print Page" command="cmd_print" hidden="true"/>
+ <button id="browser_print" command="cmd_print" hidden="true"/>
+ <help id="help_btn" label="&common.browser.help.label;" accesskey="&common.browser.help.accesskey;" />
</hbox>
<browser id="browser_browser" flex="1" type="content"/>
</vbox>
<commandset id="util_browser_cmds">
<command id="cmd_broken" />
- <command id="cmd_print" />
+ <command id="cmd_print" label="&common.browser.print.label;" accesskey="&common.browser.print.accesskey;" />
<command id="cmd_debug" />
<command id="cmd_back" label="&common.browser.backward.label;" accesskey="&common.browser.backward.accesskey;" />
<command id="cmd_reload" label="&common.browser.reload.label;" accesskey="&common.browser.reload.accesskey;" />
<button id="forward" command="cmd_forward" disabled="true" hidden="true"/>
<spacer flex="1"/>
<label id="debug" value="Debug" disabled="true" command="cmd_debug" onclick="this.doCommand();" />
- <button id="browser_print" label="Print Page" oldcommand="cmd_print" hidden="true"
+ <button id="browser_print"
+ label="&common.browser.print.label;"
+ accesskey="&common.browser.print.accesskey;"
+ hidden="true"
+ oldcommand="cmd_print"
oncommand="netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); if (g.browser.alt_print) { JSAN.use('util.print'); var p = new util.print(); p.NSPrint(g.browser.get_content(),false,{}); } else { g.browser.get_content().print(); }"
/>
+ <help id="help_btn" label="&common.browser.help.label;" accesskey="&common.browser.help.accesskey;" />
</hbox>
<browser id="browser_browser" flex="1" type="content"/>
</vbox>