Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSK-19435: Add an example add-in for the newly added open-url API #12

Merged
merged 2 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Examples/Images/open-url.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Examples/Open URL/chemdraw-addin-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Open URL API Tester",
"description": "Test add-in for openURLInDefaultBrowser API",
"version": "1.0",
"menuItemText": "Open URL API Tester",
"minimumAPIVersion": "1.2",
"url": "main.html"
}
59 changes: 59 additions & 0 deletions Examples/Open URL/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://unify-dev.scienceaccelerated.com/1.0.5/pe.css" rel="stylesheet">

<script>
function onLoadBody() {
ChemDrawAPI.window.resizeTo(500, 230);
}

function changeLink() {
var url = document.getElementById('url').value;
document.getElementById('openLink').href = url;
return true;
}

function openURL() {
var url = document.getElementById('url').value;

try {
ChemDrawAPI.openURLInDefaultBrowser(url);
}
catch(err) {
alert(err.message);
}

return false;
}
</script>
</head>

<body onload="onLoadBody()">
<div class="modal-body">
<div class="row">
<div class="col-xs-12">
<h4>Open URL API Tester</h4>
<br/>
</div>
</div>
<div class="row form-group">
<div class="col-xs-12">
<input id="url" class="form-control" value="http://www.perkinelmer.com/category/chemdraw" type="text"/>
</div>
</div>
<div class="row">
<div class="col-xs-6 text-center">
<a id="openLink" href="#" onclick="changeLink()">Open url in this window</a>
</div>
<div class="col-xs-6 text-center">
<a id="openLink" href="#" onclick="openURL()">Open url in default browser</a>
</div>
</div>
</div>
</body>
</html>
Binary file added Examples/OpenURL.chemdrawaddin
Binary file not shown.
8 changes: 7 additions & 1 deletion Examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ A ChemDraw add-in that uses ChemDraw JavaScript API to add and get data in the a

A ChemDraw add-in that uses the selection API to get the preview image of the selected structures in the active document.

![Selection Monitor](./Images/selection-monitor.png)
![Selection Monitor](./Images/selection-monitor.png)

## Open URL

A ChemDraw add-in that uses the openURLInDefaultBrowser API to open a given URL in system's default browser.

![Open URL](./Images/open-url.png)