Scaffold: Add action to open test URL in internal browser (#2117)

This commit is contained in:
Abe Jellinek 2021-07-13 00:33:57 -07:00 committed by GitHub
parent 4db5b4a23f
commit d2db842938
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 6 deletions

View file

@ -1117,14 +1117,26 @@ var Scaffold = new function() {
Zotero.Utilities.Internal.copyTextToClipboard(urlOrData);
}
/*
* Open the url of the first selected test in the browser.
*/
this.openURL = function() {
/**
* Open the url of the first selected test in the browser (Browser tab or
* the system's default browser).
* @param {boolean} openExternally whether to open in the default browser
**/
this.openURL = function (openExternally) {
var listbox = document.getElementById("testing-listbox");
var item = listbox.selectedItems[0];
var url = item.getElementsByTagName("listcell")[0].getAttribute("label");
Zotero.launchURL(url);
if (openExternally) {
Zotero.launchURL(url);
}
else {
var tabs = document.getElementById('tabs');
_browser.loadURIWithFlags(
url,
Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE
);
tabs.selectedItem = document.getElementById('tab-browser');
}
}
/*

View file

@ -52,7 +52,12 @@
<menupopup id="testing-context-menue">
<menuitem label="&scaffold.testing.edit.import;" tooltiptext="Edit the input data for the current test" oncommand="Scaffold.editImportFromTest()"/>
<menuitem label="&scaffold.testing.copyToClipboard;" tooltiptext="Copy the URL or data for the current test to the clipboard" oncommand="Scaffold.copyToClipboard()"/>
<menuitem label="&scaffold.testing.openUrl;" tooltiptext="Open the URL for the current test in the browser" oncommand="Scaffold.openURL()"/>
<menu label="&scaffold.testing.openUrl;">
<menupopup>
<menuitem label="&scaffold.testing.openUrl.internally;" tooltiptext="Open the URL for the current test in the Scaffold browser" oncommand="Scaffold.openURL(false)"/>
<menuitem label="&scaffold.testing.openUrl.externally;" tooltiptext="Open the URL for the current test in your default browser" oncommand="Scaffold.openURL(true)"/>
</menupopup>
</menu>
</menupopup>
</popupset>

View file

@ -74,3 +74,5 @@
<!ENTITY scaffold.testing.edit.import "Edit Import">
<!ENTITY scaffold.testing.copyToClipboard "Copy to Clipboard">
<!ENTITY scaffold.testing.openUrl "Open URL">
<!ENTITY scaffold.testing.openUrl.internally "In Browser Tab">
<!ENTITY scaffold.testing.openUrl.externally "In External Browser">