artifacts: centralise the descriptions of the artifact types/fragment names, and fix an incorrect warning concerning the new amar artifacts

This commit is contained in:
Jon Atkins 2014-02-23 00:24:47 +00:00
parent 50b2633257
commit c634720cf1
2 changed files with 32 additions and 19 deletions

View File

@ -72,8 +72,9 @@ window.artifact.processData = function(data) {
artifact.clearData();
$.each (data.artifacts, function(i,artData) {
if (artData.artifactId != 'jarvis') {
// jarvis artifacts - fragmentInfos and targetInfos
// if we have no descriptions for a type, we don't know about it
if (!artifact.getArtifactDescriptions(artData.artifactId)) {
// jarvis and amar artifacts - fragmentInfos and targetInfos
// (future types? completely unknown at this time!)
console.warn('Note: unknown artifactId '+artData.artifactId+' - guessing how to handle it');
}
@ -141,6 +142,15 @@ window.artifact.isArtifact = function(type) {
return type in artifact.artifactTypes;
}
window.artifact.getArtifactDescriptions = function(type) {
var descriptions = {
'jarvis': { 'title': "Jarvis Shards", 'fragmentName': "shards" },
'amar': { 'title': "Amar Artifacts", 'fragmentName': "artifacts" }
};
return descriptions[type];
}
// used to render portals that would otherwise be below the visible level
window.artifact.getArtifactEntities = function() {
var entities = [];
@ -244,7 +254,9 @@ window.artifact.showArtifactList = function() {
}
$.each(artifact.artifactTypes, function(type,type2) {
var name = typeNames[type] || ('New artifact type: '+type);
var description = artifact.getArtifactDescriptions(type);
var name = description ? description.title : ('unknown artifact type: '+type);
html += '<hr><div><b>'+name+'</b></div>';
@ -273,7 +285,8 @@ window.artifact.showArtifactList = function() {
if (data[type].target) {
row += '<br>';
}
row += '<span class="fragments'+(data[type].target?' '+TEAM_TO_CSS[data[type].target]:'')+'">Shard: #'+data[type].fragments.join(', #')+'</span> ';
var fragmentName = description ? description.fragmentName : 'fragment';
row += '<span class="fragments'+(data[type].target?' '+TEAM_TO_CSS[data[type].target]:'')+'">'+fragmentName+': #'+data[type].fragments.join(', #')+'</span> ';
sortVal = Math.min.apply(null, data[type].fragments); // use min shard number at portal as sort key
}

View File

@ -203,14 +203,11 @@ window.getPortalMiscDetails = function(guid,d) {
// artifact details
// 2014-02-06: stock site changed from supporting 'jarvis shards' to 'amar artifacts'(?) - so let's see what we can do to be generic...
var artifactTypes = {
'jarvis': { 'name': 'Jarvis', 'fragmentName': 'shard(s)' },
'amar': { 'name': 'Amar', 'fragmentName': 'artifact(s)' },
};
$.each(artifactTypes,function(type,details) {
$.each(artifact.getArtifactTypes(),function(index,type) {
var artdata = artifact.getPortalData (guid, type);
if (artdata) {
var details = artifact.getArtifactDescriptions(type);
if (details) {
// the genFourColumnTable function below doesn't handle cases where one column is null and the other isn't - so default to *something* in both columns
var target = ['',''], shards = [details.fragmentName,'(none)'];
if (artdata.target) {
@ -221,6 +218,9 @@ window.getPortalMiscDetails = function(guid,d) {
}
randDetailsData.push (target, shards);
} else {
console.warn('Unknown artifact type '+type+': no names, so cannot display');
}
}
});