Skip to content

Commit

Permalink
Merge pull request #39 from privrja/test
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
privrja committed Apr 23, 2021
2 parents 40ea6dd + 52042e2 commit c60e2ef
Show file tree
Hide file tree
Showing 44 changed files with 501 additions and 446 deletions.
30 changes: 22 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,33 @@ SmilesDrawer.apply = function(options, selector='canvas[data-smiles]', themeName
for (var i = 0; i < elements.length; i++) {
let element = elements[i];

SmilesDrawer.parse(element.getAttribute('data-smiles'), function(tree) {
smilesDrawer.draw(tree, element, themeName, false);
}, function(err) {
if (onError) {
onError(err);
}
});
let smiles = element.getAttribute('data-smiles');
if (!smiles || smiles === '') {
const context = element.getContext('2d');
context.clearRect(0, 0, element.width, element.height);
} else {
SmilesDrawer.parse(element.getAttribute('data-smiles'), function (tree) {
smilesDrawer.draw(tree, element, themeName, false);
}, function (err) {
if (onError) {
onError(err);
}
});
}
}
};

SmilesDrawer.clear = function(selector = 'canvas[data-smiles]') {
let elements = document.querySelectorAll(selector);
elements.forEach(canvas => {
const context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
})
};

/**
* Parses the entered smiles string.
*
*
* @static
* @param {String} smiles A SMILES string.
* @param {Function} successCallback A callback that is called on success with the parse tree.
Expand Down
39 changes: 30 additions & 9 deletions dist/smiles-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,33 @@ SmilesDrawer.apply = function (options, selector = 'canvas[data-smiles]', themeN

for (var i = 0; i < elements.length; i++) {
let element = elements[i];
SmilesDrawer.parse(element.getAttribute('data-smiles'), function (tree) {
smilesDrawer.draw(tree, element, themeName, false);
}, function (err) {
if (onError) {
onError(err);
}
});
let smiles = element.getAttribute('data-smiles');

if (!smiles || smiles === '') {
const context = element.getContext('2d');
context.clearRect(0, 0, element.width, element.height);
} else {
SmilesDrawer.parse(element.getAttribute('data-smiles'), function (tree) {
smilesDrawer.draw(tree, element, themeName, false);
}, function (err) {
if (onError) {
onError(err);
}
});
}
}
};

SmilesDrawer.clear = function (selector = 'canvas[data-smiles]') {
let elements = document.querySelectorAll(selector);
elements.forEach(canvas => {
const context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
});
};
/**
* Parses the entered smiles string.
*
*
* @static
* @param {String} smiles A SMILES string.
* @param {Function} successCallback A callback that is called on success with the parse tree.
Expand Down Expand Up @@ -2204,6 +2219,12 @@ class Drawer {
}
}
}

clear() {
if (this.canvasWrapper) {
this.canvasWrapper.clear();
}
}
/**
* Returns the number of rings this edge is a part of.
*
Expand Down Expand Up @@ -4209,7 +4230,7 @@ class Drawer {
this.createRing(nextRing, nextCenter, vertex);
}
} else {
// Draw the non-ring vertices connected to this one
// Draw the non-ring vertices connected to this one
let isStereoCenter = vertex.value.isStereoCenter;
let tmpNeighbours = vertex.getNeighbours();
let neighbours = Array(); // Remove neighbours that are not drawn
Expand Down
2 changes: 1 addition & 1 deletion dist/smiles-drawer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/smiles-drawer.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/ArrayHelper.html
Original file line number Diff line number Diff line change
Expand Up @@ -3398,7 +3398,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Thu Apr 22 2021 09:00:40 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Fri Apr 23 2021 08:47:34 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/ArrayHelper.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ <h1 class="page-title">ArrayHelper.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Thu Apr 22 2021 09:00:40 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Fri Apr 23 2021 08:47:34 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/Atom.html
Original file line number Diff line number Diff line change
Expand Up @@ -2906,7 +2906,7 @@ <h4 class="name" id="restoreRings"><span class="type-signature"></span>restoreRi
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Thu Apr 22 2021 09:00:40 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Fri Apr 23 2021 08:47:34 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/Atom.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ <h1 class="page-title">Atom.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Thu Apr 22 2021 09:00:40 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Fri Apr 23 2021 08:47:34 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/CanvasWrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -3783,7 +3783,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Thu Apr 22 2021 09:00:40 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Fri Apr 23 2021 08:47:34 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/CanvasWrapper.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ <h1 class="page-title">CanvasWrapper.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Thu Apr 22 2021 09:00:40 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Fri Apr 23 2021 08:47:34 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion doc/DecayPoint.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h1 class="page-title">DecayPoint.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Thu Apr 22 2021 09:00:40 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Fri Apr 23 2021 08:47:34 GMT+0200 (Středoevropský letní čas) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
Loading

0 comments on commit c60e2ef

Please sign in to comment.