Files
old-lab_ui/backend/js/custom_topics.js

55 lines
880 B
JavaScript

function Topic(name, type)
{
this.name = name;
this.type = type;
this.includeInBag = false;
this.equals = function (otherTopic)
{
if( this.name == otherTopic.name && this.type == otherTopic.type)
{
return true;
}
return false;
};
};
function containsTopic(obj, list) {
var x;
for (x in list) {
if (obj.equals(list[x])) {
return true;
}
}
return false;
}
function testToics()
{
var topics = [new Topic("a","a_t"), new Topic("b","b_t"), new Topic("c","c_t")];
console.log("Testing Topic");
if (containsTopic(new Topic("a","a_t"),topics) == true)
{
console.log("pass")
}
else
{
console.log(" contains true fail")
}
if (containsTopic(new Topic("d","d_t"),topics) == false)
{
console.log("pass")
}
else
{
console.log(" contains d fail")
}
}
testToics();