fixed & error on synapse desc display

This commit is contained in:
Devin Howard 2013-02-16 17:32:50 -05:00
parent 1ea2317ab4
commit f1a7e040fb

View file

@ -300,6 +300,9 @@ var nodeSettings = {
var desc = adj.getData("desc"); var desc = adj.getData("desc");
var showDesc = adj.getData("showDesc"); var showDesc = adj.getData("showDesc");
if( desc != "" && showDesc ) { if( desc != "" && showDesc ) {
// '&' to '&'
desc = decodeEntities(desc);
//now adjust the label placement //now adjust the label placement
var ctx = canvas.getCtx(); var ctx = canvas.getCtx();
var radius = canvas.getSize(); var radius = canvas.getSize();
@ -449,3 +452,14 @@ function onPlaceLabelHandler(domElement, node) {
style = label.style; style = label.style;
style.left = (-(w / 2 + 106)) + 'px'; style.left = (-(w / 2 + 106)) + 'px';
} }
// thanks to http://stackoverflow.com/questions/4338963/
// convert-html-character-entities-back-to-regular-text-using-javascript
function decodeEntities(desc) {
var str, temp = document.createElement('p');
temp.innerHTML = desc; //browser handles the entities
str = temp.textContent || temp.innerText;
temp = null; //delete the element;
return str;
}//decodeEntities