Hi!
I need a little help with javascript.
I'm trying to create a sort of Did You Know function, like Wikipedia
has. For that, each "article" tiddler has a Quotation part in it. What
I want is to display random 10 Quotations from the last 50 modified
articles.
My fET looks like this:
<<forEachTiddler
where 'tiddler.tags.contains("article")'
sortBy 'tiddler.modified' ascending
write '(index == RandomIndex) ? "*...that <<tiddler [["+tiddler.title
+"/Quotation]]'>>?" : ""'>>
I also found a script that finds random x numbers from among y
numbers.
<script>
var Found = false;
var Current = new Array();
var MaxValue = 50; //(Example 2 is equal to: 0,1,2)
var NumUnique = 10; //The number of unique numbers required
var Count = 0;
var Current = new Array(NumUnique);
GetUnique()
var i;
var u;
for (u=0; u<NumUnique; u++) {
document.write(Current[u]+"<br/>");
}
function GetUnique()
{
for (i=0;Count<NumUnique;Count++)
{
Found=false
var rndValue = get_random()
var j=0
for (j=0;j<Current.length;j++)
{
if (Current[j] == rndValue)
{
Found=true
break
}
}
if (Found)
{
Count--
} else {
Current[Count]=rndValue
}
}
}
function get_random()
{
var ranNum= Math.round(Math.random()*MaxValue);
return ranNum;
}
</script>
The problem is, I don't know how to incorporate the script into the
fET where RandomIndex is at the moment. Or vice versa maybe. Any help
would be appreciated.
w
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywiki?hl=en.