> http://www.TiddlyTools.com/#VisitorCounter
> is an inline script [1] that provides a *private* cookie-based visit
> counter that tracks both the number of visits and the date/time of
> your last visit. To trigger the script at startup, embed the
> following in your MainMenu (or any other tiddler that is displayed by
> default):
> @@display:none;<<tiddler VisitorCounter>>@@
> When the script is invoked, it sets internal variables:
> config.options.txtFirstVisit
> config.options.txtLastVisit
>
> ... and, you can use these variables to calculate the #ofdays for the
> <<recentChanges>> macro this way:
> <<recentChanges {{(new Date()-config.options.txtLastVisit)/
> 86400000}}>>
nlineJavascriptPlugin
RecentChangesPlugin works perfect but I can't get VisitCounter to
work. Make a new tiddler containing the code below and tag it with
"script". I then put the: "@@display:none;<<tiddler
VisitorCounter>>@@" inside the mainmenu. After that I save and refresh
the page. I then use: "<<recentChanges {{(new Date()-
config.options.txtLastVisit)/
> 86400000}}>" but nothing new happens except the normal function from
> RecentChangesPlugin.
I've tried it on my local computer, on a local intranet server and on
tiddlyspot.
I appear to be a bit slow :p
Code:
/%
|Name|VisitCounter|
|Source|http://www.TiddlyTools.com/#VisitCounter|
|Version|2.1.0|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements <br>and
[[Creative Commons Attribution-ShareAlike 2.5 License|http://
creativecommons.org/licenses/by-sa/2.5/]]|
|~CoreVersion|2.1|
|Type|script|
|Requires|InlineJavascriptPlugin|
|Overrides||
|Description|use cookies to track/show private, personal visit counter
and timestamp of last visit|
This script tracks and displays a personal, private counter and the
timestamps for your first visit, your most recent visit, and the total
number of times you have visited a document. This information is
stored in local cookies, and is ONLY available for display in YOUR
browser. This data is not NOT tracked or aggregated across users, nor
relayed or reported to anyone other than yourself, EVER.
Usage:
{{{<<tiddler VisitCounter with: counterID firsttimegreeting>>}}}
where:
* counterID (optional) - specifies a suffix to add to the visit
tracking cookies for this document (enables tracking of multiple
documents on a single domain, such as file://).
* firsttimegreeting (optional) - message to display upon first visit
to the document. Subsequent visits report last visit timestamp and
total visit count.
Cookies used to track your visit information:
txtFirstVisit+id, txtLastVisit+id, txtVisitCount+id
The script also defines global config values that may be referenced
later by other scripts:
config.firstVisit, config.lastVisit, config.visitCount
!!!!!Revisions
<<<
2008.07.01 [2.1.0] simplified to inline script
2007.07.26 [2.0.0] re-written as plugin
2007.05.02 [1.0.0] initial release (as inline script, VisitCounter)
!end revisions
!outputFormat
This is your <html><hide linebreaks><a href="javascript:;"
title="Reset personal visit counter"
onclick="if (!confirm('Are you sure you want to reset your personal
visit counter?')) return false;
config.visitCount=config.options['txtVisitCount%0']=1;
config.firstVisit=config.options['txtFirstVisit%0']=new Date();
config.lastVisit=config.options['txtLastVisit%0']=new Date();
saveOptionCookie('txtVisitCount%0');
saveOptionCookie('txtFirstVisit%0');
saveOptionCookie('txtLastVisit%0');
var t=story.findContainingTiddler(this);
if(t)story.refreshTiddler(t.getAttribute('tiddler'),null,true);
">''%1 visit''</a></html> since %2. Your last visit was on %3.
!end outputFormat
%/<script>
var out="";
var id="";
if ("$1"!="$"+"1") id="_$1";
var greeting="";
if ("$2"!="$"+"2") greeting="$2";
if (config.firstVisit==undefined) { // only do this once per session
// create the 'first visit' timestamp cookie
if (!config.options["txtFirstVisit"+id] || !config.options
["txtFirstVisit"+id].length) {
config.options["txtFirstVisit"+id]=new Date();
saveOptionCookie("txtFirstVisit"+id);
}
config.firstVisit=config.options["txtFirstVisit"+id];
}
if (config.lastVisit==undefined) { // only do this once per session
config.lastVisit=config.options["txtLastVisit"+id];
if (config.lastVisit==undefined) config.lastVisit="";
config.options["txtLastVisit"+id]=new Date();
saveOptionCookie("txtLastVisit"+id);
var c=config.options["txtVisitCount"+id]?parseInt(config.options
["txtVisitCount"+id]):0;
config.visitCount=config.options["txtVisitCount"+id]=c+1;
saveOptionCookie("txtVisitCount"+id);
}
// get and format # of visits
var count=config.options["txtVisitCount"+id]; if (!count) count=1;
var wordmap=
['---','first','second','third','fourth','fifth','sixth','seventh','eighth','ninth'];
var suffixmap=['th','st','nd','rd','th','th','th','th','th','th'];
var digits=count.toString().substr(count.toString().length-2,2);
if (count<10) count=wordmap[count];
else if (digits>=10&&digits<=13) count=count+'th';
else count=count+suffixmap[digits.substr(1,1)];
var out=greeting; // initial greeting for first visit only
if (config.lastVisit.length) {
var first=new Date(config.firstVisit).formatString("MMM DDth
YYYY");
var last=new Date(config.lastVisit).formatString("MMM DDth YYYY
at
0hh12:0mm:0ss am");
out=store.getTiddlerText("VisitCounter##outputFormat").format
([id,count,first,last])
}
return out;
</script>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---