On Tuesday, August 29, 2017 at 1:09:02 PM UTC-7, Sergey Litvinov wrote:
>
> I'm writing a macro to display tiddlywiki file size.
>
> could you please help me with the code required to withdraw the file 
> (itself) size?
>

For security reasons, browsers severely restrict access to file system 
information.  As such, it is not possible to directly read the size of the 
file stored on disk.

However, there are some ways for getting the size of the *currently loaded* 
HTML content, by using

document.head.innerHTML.length + document.body.innerHTML.length
or
document.documentElement.innerHTML.length

Note: these values only approximate the actual file size.  For example, 
using Chrome's built-in Developer Tools with a downloaded copy 
of http://tiddlywiki.com/empty.html yields the following:

document.head.innerHTML.length + document.body.innerHTML.length
   = 1806387
document.documentElement.innerHTML.length
   = 1806430
However, the actual file size (as reported by Win10 file "Properties" 
dialog)
   = 1938885

perhaps this is close enough for your purposes?

let me know how it goes...

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals


-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" 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 https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/677c0209-2234-4083-b0b5-538e309c1f66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to