Am Dienstag, 2. Dezember 2014 04:56:35 UTC+1 schrieb RichShumaker:
>
> Is there a tool in TW5 to tell you the sizes of each Tiddler
>

Try this macro:

/*\
title: $:/macros/skeeve/length.js
type: application/javascript
module-type: macro

<<length text>>

Examples:
<<length "sometext">>
<<length tiddler:"tiddlertitle">>
<$macrocall $name="length" text="sometext"/>
<$macrocall $name="length" tiddler={{!!title}}/>

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Information about this macro
This is a macro to get the length of a string/text or a tiddler.

For a tiddler's length the string-length of its JSON representation is used.
*/

exports.name = "length";

exports.params = [
    { name: "text" },
    { name: "tiddler" },
];

/*
Run the macro
*/
exports.run = function(text, tiddler) {
    if(!text) {
        if(!tiddler) {
            return 0;
        }
        text = $tw.wiki.getTiddlerAsJson(tiddler);
    }
    return text.length.toString();
};

})();

The serialized form of the tiddler is taken when you call for the length of 
a tiddler. This is not the real amount of data used when storing the 
tiddler, but it gives a good esitmate, I think, and should be consistant 
across all tiddlers.

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to