new addr:
http://sinojelly.blog.51cto.com/attachment/200909/479153_1251823255.rar

TO DO:

   1.  Load the rating info while displying a tiddler and display the
rating info as "(Rated 4 with 176 votes)".
   2. Using lock to protect a *_fivestar_rating tiddler being broken
by more than one user at the same time to vote the same tiddler.
   3. Get the real IP address.
   4. Auto save and upload rating info after voting.
   5. Fix the Bug: when more than one tiddler in place, while mouse
over the second fivestar, but the fist fivestar highlight.
   6. Tag the rating info tiddler as shadowed.
   7. Use tag to avoid some tiddler to be voted.
   8. How to get all the tiddlers with the same rating?
   9. Avoid the *_fivestar_rating tiddlers to be voted.
  10. Fix the Bug: Sometimes, the stars still unhighlighted after
voting.(if alert a message box such as alert(n), no problem. Message
box avoid mouse rollover the stars.)
  11. Make others can vote the tiddlers, not only the owner can.
  12. Support IE.

On 9月1日, 下午11时55分, Jelly <[email protected]> wrote:
> i have wrote a five star plugin for tiddlywiki.
> i want to find someone help me to make it much better.
>
> you can find it 
> at:http://sinojelly.blog.51cto.com/attachment/200909/479153_1251819194.rar
> or at:http://sinojelly.blog.51cto.com/479153/197110
>
> /***
> |''Name''|FiveStarPlugin|
> |''Description''|Five star rating system for tiddlywiki|
> |''Icon''|<...>|
> |''Author''|Jelly Chen|
> |''Contributors''|<...>|
> |''Version''|0.1.0|
> |''Date''|Sep 1 2009|
> |''Status''|stable|
> |''Source''|http://sinojelly.TiddlySpot.com/#FiveStarPlugin|
> |''CodeRepository''|<...>|
> |''Copyright''|Guodong Workshop. 2009-2019. All rights reserved.|
> |''License''|GPL2|
> |''CoreVersion''|2.1.0|
> |''Requires''|<...>|
> |''Overrides''|<...>|
> |''Feedback''|[email protected]|
> |''Documentation''|http://sinojelly.blog.51cto.com/479153/197110|
> |''Keywords''|FiveStar, vote, rating|
> !Description
> Five star rating system for tiddlywiki, the rating info associate with
> one tiddler are stored in a tiddler named *_filestar_rating, * is
> tiddler name.
> The rating info tiddler associate with "FiveStarPlugin" looks like
> this:
> tiddler title: FiveStarPlugin_filestar_rating
> |!rating|16|!votes|4|
> |!user|!ip|!rating|!time|
> |Jelly Chen|127.0.0.1|5|Tue Sep 01 2009 22:15:24 GMT+0800|
> |Jelly Chen|127.0.0.1|4|Tue Sep 01 2009 22:19:07 GMT+0800|
> |Jelly Chen|127.0.0.1|4|Tue Sep 01 2009 22:21:54 GMT+0800|
> |Jelly Chen|127.0.0.1|3|Tue Sep 01 2009 22:22:10 GMT+0800|
> !Notes
> Only one rating macro in a tiddler and in SinglePageMode.
> First vote a tiddler, save it, and then flush, you'll find the new
> auto created tiddler.
> After voting a tiddler, then display the associated *_fivestar_rating
> tiddler, you'll find the last voting info in the last line.
> Thanks to FND for answering my question on Google TiddlyWikiDev Group.
> !Usage
> You can add macro invoke in the tiddler as follows.
> {{{
> <<rating>>}}}
>
> Also, if you want to add fivestar to every tiddlers, you should modify
> ViewTemplate as follows:
> modify:
> {{{
> <div class='viewer' macro='view text wikified'></div>}}}
>
> to:
> {{{
> <div class='viewer'><div><span macro='view text wikified'></
> div><div><span macro='rating'/></div><br/></div>}}}
>
> !!Parameters
> None
> !!Examples
> See the footer of this tiddler.
> !Configuration Options
> None
> !Revision History
> !!v0.0.1 (2009-08-27)  Client OK.
> * View fivestar ok.
> * Can be clicked to vote, but not any rating info stored.
> !!v0.1.0 (2009-09-01)  Write rating info tiddler OK.
> * Rating info store in *_fivestar_rating tiddler.
> !To Do
> # Load the rating info while displying a tiddler and display the
> rating info as "(Rated 4 with 176 votes)".
> # Using lock to protect a *_fivestar_rating tiddler being broken by
> more than one user at the same time to vote the same tiddler.
> # Get the real IP address.
> # Auto save and upload rating info after voting.
> # Fix the Bug: when more than one tiddler in place, while mouse over
> the second fivestar, but the fist fivestar highlight.
> # Tag the rating info tiddler as shadowed.
> # Use tag to avoid some tiddler to be voted.
> # How to get all the tiddlers with the same rating?
> # Avoid the *_fivestar_rating tiddlers to be voted.
> # Fix the Bug: Sometimes, the stars still unhighlighted after voting.
> (if alert a message box such as alert(n), no problem. Message box
> avoid mouse rollover the stars.)
> You're welcome to make these ToDo's implemented.I have no more time
> now.
> !Code
> ***/
> //{{{
> //var set=false;
> var v=1;  // initial value is average???  (Rated 4 with 176 votes)
> var RatingLevel = new Array("poor", "below average", "average", "above
> average", "excellent", "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp");
> function loadStars()
> {
>    star1 = new Image();
>    star1.src = "star1.png";
>    star2 = new Image();
>    star2.src= "star2.png";
>    //setStar(v); // something wrong}
>
> function highlight(x)
> {
>    //if (set==false)
>    {
>            y=x*1+1;
>            for (i=1;i<y;i++)
>            {
>                 document.getElementById(i).src= star2.src;
>            }
>            document.getElementById('vote').innerHTML=RatingLevel[x - 1];
>    }}
>
> function losehighlight(x)
> {
>    //if (set==false)
>    {
>            for (i=1;i<6;i++)
>            {
>                    document.getElementById(i).src=star1.src;
>                    
> document.getElementById('vote').innerHTML=RatingLevel[5];//""
>            }
>    }}
>
> function setStar(n)
> {
>    y = n * 1 + 1;
>    for (i=1;i<y;i++)
>    {
>         document.getElementById(i).src= star2.src;
>    }}
>
> function saveStar(n, tiddlerTitle)
> {
>     v = n;   // should be new average ?
>    setStar(v);
>    //set=true;
>    document.getElementById('vote').innerHTML="Thank you for your
> vote!";
>    title = tiddlerTitle+"_fivestar_rating";
>    var tiddler = store.createTiddler(title);
>     if (tiddler.text == "")
>     {
>        tiddler.text = "|!rating|0|!votes|0|\n";
>        tiddler.text += "|!user|!ip|!rating|!time|\n";
>     }
>     ratinginfo=tiddler.text.substr(0,40);  // should be less than 40
>     ratingnums = ratinginfo.split("|"); // split to array
>     ratingnums.shift(); //first ""
>     ratingnums.shift(); //second "!rating"
>     ratingnum1 = ratingnums.shift();
>     ratingnums.shift(); //fourth "!votes"
>     ratingnum2 = ratingnums.shift();
>     regexhead= "|!rating|"+ratingnum1 +"|!votes|"+ratingnum2+"|";
>     ratingnum1 = Number(ratingnum1) + Number(n);
>     ratingnum2 = Number(ratingnum2) + 1;
>     tiddler.text = tiddler.text.replace(regexhead, "|!
> rating|"+ratingnum1 + "|!votes|"+ratingnum2+"|");
>     var now = new Date();
>     tiddler.text += "|"+config.options.txtUserName +"|"+getHostIp()
> +"|"+n+"|"+now+"|\n";
>     alert(n);}
>
> function getHostIp()
> {
>     if((navigator.appName   ==   "Microsoft   Internet   Explorer")
> &&
>     ((navigator.appVersion.indexOf('3.')   !=   -1)   ||
>     (navigator.appVersion.indexOf('4.')   !=   -1)))
>     {
>         //document.write("Not   with   MS   IE   3.0/4.0");
>         return "Not   with   MS   IE   3.0/4.0";
>     }
>     else
>     {
>         window.onerror=null;
>         yourAddress=java.net.InetAddress.getLocalHost();
>         yourAddress2=java.net.InetAddress.getLocalHost();
>         yhost=yourAddress.getHostName();
>         yip=yourAddress.getHostAddress();
>         //document.write("Host Name:"+yhost);
>         //document.write("<br>IP:"+yip);
>         return yip;
>      }}
>
> config.macros.rating = {
>    handler: function(place, macroName, params, wikifier,
>        paramString, tiddler) {
>        loadStars();
>        wikify('<html><img src="star1.png" onmouseover="highlight
> (this.id)" onclick="setStar(this.id)" onmouseout="losehighlight
> (this.id)" onmouseup="saveStar(id,title)" id="1"  title='+tiddler.title
> +' style="width:30px; height:30px; float:left;" /><img src="star1.png"
> onmouseover="highlight(this.id)" onclick="setStar(this.id)"
> onmouseout="losehighlight(this.id)" onmouseup="saveStar(id,title)"
> id="2"  title='+tiddler.title+'  style="width:30px; height:30px;
> float:left;" /><img src="star1.png" onmouseover="highlight(this.id)"
> onclick="setStar(this.id)" onmouseout="losehighlight(this.id)"
> onmouseup="saveStar(id,title)" id="3" title='+tiddler.title+'
> style="width:30px; height:30px; float:left;" /><img src="star1.png"
> onmouseover="highlight(this.id)" onclick="setStar(this.id)"
> onmouseout="losehighlight(this.id)" onmouseup="saveStar(id,title)"
> id="4"  title='+tiddler.title+' style="width:30px; height:30px;
> float:left;" /><img src="star1.png" onmouseover="highlight(this.id)"
> onclick="setStar(this.id)" onmouseout="losehighlight(this.id)"
> onmouseup="saveStar(id,title)" id="5" title='+tiddler.title+'
> style="width:30px; height:30px; float:left;" /><div
> id="vote">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</div></html>',
> place);
>    }};
>
> //}}}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" 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/tiddlywikidev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to