Hello there,
I'm struggling here [1]. I can't see why the function to remove duplicates is not working. The script is included below, the link is the function in a live TW.
I've spent ages looking a the this one and testing. I can't see the flaw in the logic.
ALex
[1]
https://dl.dropbox.com/u/1316865/OMM/Omm/DirectorExerimental.htmlarrUnique
========
<script>
//Adds new uniqueArr values to temp array (see-
http://www.developersnippets.com/2008/10/30/remove-duplicates-from-array-using-javascript/)
function uniqueArr(a) {
temp = new Array();
for(i=0;i<a.length;i++){
if(!contains(temp, a[i])){
temp.length+=1;
temp[temp.length-1]=a[i];
}
}
return temp;
}
//Will check for the Uniqueness
function contains(a, e) {
for(j=0;j<a.length;j++)
if(a[j]==e)return true;
return false;
}
var out=[],all=[];
tids=['Q1','Q2','Q3','Q4','Q5','Q6','Q7','Q8','Q9','Q10','Q11','Q12','Q13','Q14','Q15','Q16','Q17','Q18','Q19','Q20','Q21','Q22','Q23','Q24'];
for (var i=0; i<tids.length; i++) {
var t=tids[i].title;
var score=DataTiddler.getData(Questions[i],"score");
var val=store.getValue(tids[i],"primary");
var val1=store.getValue(tids[i],"secondary");
var filter="[tag["+val.readBracketedList().join("]][tag[")+"]]";
var filter1="[tag["+val1.readBracketedList().join("]][tag[")+"]]";
var list=store.filterTiddlers(filter).map(function(t){return""+t.title+""});
var list1=store.filterTiddlers(filter1).map(function(t){return""+t.title+""});
var list2 =(list.concat(list1));
if (score <= 2) {
all.push(list2);
}
}
out = uniqueArr(all);
return out.join(",");
</script>
Alex
[1]
--
http://www.multiurl.com/g/64