fixed douplicate functions for getting nodes and topics
This commit is contained in:
55
backend/js/custom_topics.js
Normal file
55
backend/js/custom_topics.js
Normal file
@@ -0,0 +1,55 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user