Witten
Bainbridge
Nichols
HOME HELP PREFERENCES SEARCHFIGURESTABLES

Using JavaScript to present file size and date metadata

 1 package document
 2
 3 _pagescriptextra_ {
 4
 5   function format\_filesize (gsfilesize)
 6   \{
 7       var filesize = gsfilesize + " bytes";
 8
 9       if (gsfilesize > 1048576) \{
10         filesize = Math.round(gsfilesize / 1048576.0) + " MB"
11       \}
12       else if (gsfilesize > 1024) \{
13         filesize = Math.round(gsfilesize / 1024.0) + " KB"
14       \}
15
16       document.write(filesize);
17   \}
18
19   function format\_date (gsdate)
20   \{
21        var year\_num  = gsdate.substr(0,4);
22        var month\_num = gsdate.substr(4,2);
23        var date\_num  = gsdate.substr(6,2);
24
25        var date = new Date(year\_num,month\_num-1,date\_num)
26        var date\_str = date.toLocaleDateString();
27
28        document.write(date\_str);
29   \}
30 }

Figure 12.3: Using JavaScript to present file size and date metadata;