Skip to content

Commit

Permalink
Merge pull request #9 from gnpis/develop
Browse files Browse the repository at this point in the history
Merge release 2.1.0 to master
  • Loading branch information
gcornut authored Jan 24, 2018
2 parents 2110fa0 + 6fa5b64 commit aff98ab
Show file tree
Hide file tree
Showing 14 changed files with 23,419 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ deployLocal.sh

demo/data/private/

build/
dist/index.html
node_modules/
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,11 @@ The Breeding API used in this widget **must implement** the [observation variabl

### In Ephesis ontology portal

The latest release of this widget is accessible on the [:link: Ephesis ontology portal](https://urgi.versailles.inra.fr/ephesis/ephesis/ontologyportal.do).

### From release

1. Download the latest `distrib-wit-demo.zip` on the [release page ](https://github.com/gnpis/trait-ontology-widget/releases).
2. Run a static HTTP server in the extracted folder (required for Ajax loading)
3. Open the web page in the browser
The latest release of this widget is accessible on the [:link: Ephesis ontology portal](https://urgi.versailles.inra.fr/ephesis/ephesis/ontologyportal.do) or on the [:link: Ephesis search form](https://urgi.versailles.inra.fr/ephesis/ephesis/viewer.do#showForm).

### From source code

1. Clone the repository
1. Clone the repository or download a [release archive](/releases)
2. Install [Node.js](https://nodejs.org/)
3. Fetch dependencies:

Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

BUILD_FOLDER="./build"
BUILD_FOLDER="./dist"
MODULES="./node_modules"

[ -d "$MODULES" ] || {
Expand Down Expand Up @@ -36,7 +36,7 @@ DEST_MIN_FILE="${BUILD_FOLDER}/cropOntologyWidget.min"

echo -ne "[JS]\t"
echo " ${DEST_FILE}.js => ${DEST_MIN_FILE}.js "
"${MODULES}/uglifyjs/bin/uglifyjs" "${DEST_FILE}.js" -o "${DEST_MIN_FILE}.js"
"${MODULES}/uglify-js/bin/uglifyjs" "${DEST_FILE}.js" -o "${DEST_MIN_FILE}.js"

echo -ne "[CSS]\t"
echo " ${DEST_FILE}.css => ${DEST_MIN_FILE}.css "
Expand Down
58 changes: 49 additions & 9 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,70 @@
<link rel="stylesheet" href="cropOntologyWidget.css"></link>
</head>
<body>

<!-- The target DIV in which the widget is added -->
<div id="trait-ontology-widget"></div>

<!-- Initialize widget with javascript -->
<script type="text/javascript">
// Instanciate widget
var widget = new CropOntologyWidget("#trait-ontology-widget", {
// Breeding API server
"breedingAPIEndpoint": "https://urgi.versailles.inra.fr/ws/webresources/brapi/v1/",
// options
"showCheckBoxes": true, "useSearchField": true
});

/* Some example of interactions with the widget : */
function getIds() {
var ids = widget.getSelectedNodeIds();
if (!ids.length) ids = "No node selected"
window.alert(ids);
console.log(ids);
}
</script>

<!-- Example JS interactions with the widget -->
<button onclick="getIds()">Get selected node IDs</button>
<button onclick="widget.showAll()">Show all</button>
<button onclick="widget.hideAll()">Hide all</button>
<button onclick="widget.reset()">Reset</button>
<button onclick="widget.resetSelection()">Reset selection</button>
<button onclick="emptyOutput()">Clear output below</button>

<div id="output"></div>
<script type="text/javascript">
var output = document.getElementById("output");
function emptyOutput() {
output.querySelectorAll("div").forEach(function(element) {
element.remove();
});
}
function logOutput(action, message) {
var div = document.createElement('div');
var spanAction = document.createElement('span');
spanAction.textContent = action;
div.append(spanAction);
var spanMessage = document.createElement('span');
spanMessage.textContent = message;
div.append(spanMessage);
output.prepend(div);
}

function getIds() {
var ids = widget.getSelectedNodeIds();
if (!ids.length) ids = "No node selected";
logOutput("Get selected leaf node ids:", ids.join(", "));
}

// Display selection change
widget.addSelectionChangeHandler(function(el, node) {
logOutput("Node selection:", node.id);
getIds();
});
</script>
<style>
#output > div {
color: gray;
}
#output > div:first-child {
color: black;
}
#output > div > span:first-child {
font-weight: bold;
margin-right: 10px;
}
</style>
</body>
</html>
Loading

0 comments on commit aff98ab

Please sign in to comment.