Closed alanruttenberg closed 9 years ago
The proper way to change the displayed text is to overwrite the YASR.plugins.table.defaults.getCellContent function (see http://yasr.yasgui.org/doc/).
But something which is easier, is to add a css entry: td sup {display:none;}
, which hides all the datatype information for you
Yes, that's what I did, copying and modifying the base code. But I thought it would be better built-in as it took some effort to understand the code enough to be able to do this. Also, I wasn't sure where to get the helper functions (I'm not familiar with how the whole module system works) so landed up copying them.
var getCellContentMod = function(yasr, plugin, bindings, sparqlVar, context) {
var binding = bindings[sparqlVar];
var value = null;
if (binding.type == "uri") {
var title = null;
var href = binding.value;
var visibleString = href;
if (context.usedPrefixes) {
for (var prefix in context.usedPrefixes) {
if (visibleString.indexOf(context.usedPrefixes[prefix]) == 0) {
visibleString = prefix + ':' + href.substring(context.usedPrefixes[prefix].length);
break;
}
}
}
if (plugin.options.mergeLabelsWithUris) {
var postFix = (typeof plugin.options.mergeLabelsWithUris == "string"? plugin.options.mergeLabelsWithUris: "Label");
if (bindings[sparqlVar + postFix]) {
visibleString = formatLiteral(yasr, plugin, bindings[sparqlVar + postFix]);
title = href;
}
}
value = "<a " + (title? "title='" + href + "' ": "") + "class='uri' target='_blank' href='" + href + "'>" + visibleString + "</a>";
} else {
value = "<span class='nonUri'>" + formatLiteral(yasr, plugin, binding) + "</span>";
}
return "<div>" + value + "</div>";
};
var escapeHtmlEntities= function(unescaped) {
return unescaped.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') ;
}
var formatLiteral = function(yasr, plugin, literalBinding) {
return(escapeHtmlEntities(literalBinding.value));
}
YASGUI.YASR.plugins.table.defaults.getCellContent=getCellContentMod;
Best, Alan
My comment was submitted accidentally before I finished. An alternative to your approach, would be to use css as follows: td sup {display:none;}, which hides all the datatype information for you
oh, that's better :)
Most of the time I don't need the datatype information and having it displayed distracts the eye. I'd be happy with a defaults switch, but another option would be to add a small checkbox to enable or disable showing them.