Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #16463

Re: Sending email with attachments

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!uucp.gnuu.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <13393244.ro2WoL5f8n@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Organization PointedEars Software (PES)
Date Mon, 08 Oct 2012 11:13:34 +0200
User-Agent KNode/4.4.11
Content-Transfer-Encoding 8Bit
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Subject Re: Sending email with attachments
Newsgroups comp.lang.javascript
References <JqadnXQNAdXTHffNnZ2dnUVZ_qSdnZ2d@earthlink.com> <2610175.x4FWaXcEle@PointedEars.de> <i-mdne2bX43RGfLNnZ2dnUVZ_hidnZ2d@earthlink.com> <7238984.617k9mAqVa@PointedEars.de> <iZSdnZOJXZQ0G-3NnZ2dnUVZ_vqdnZ2d@earthlink.com> <3592620.Gox2ZXX9UI@PointedEars.de> <WMmdnXmiOKk-tuzNnZ2dnUVZ_qidnZ2d@earthlink.com> <6035717.rH6HMBR8Db@PointedEars.de> <McudnUcZceMaju_NnZ2dnUVZ_vWdnZ2d@earthlink.com> <1876351.4oM7Z9lvqd@PointedEars.de> <ZKydnRadRqSm7e_NnZ2dnUVZ_qidnZ2d@earthlink.com>
Followup-To comp.lang.javascript
MIME-Version 1.0
Lines 136
NNTP-Posting-Date 08 Oct 2012 11:13:35 CEST
NNTP-Posting-Host 6230c3af.newsspool2.arcor-online.net
X-Trace DXC=Ql_gl^d;]gi016@cHD@m;jA9EHlD;3Ycb4Fo<]lROoRa8kF<OcfhCOkgUnZ0:D:6`jDZm8W4\YJNlJ`:FmdeL>K`MbG5PB_J>1lN^R9`g^RH4m
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:16463

Followups directed to: comp.lang.javascript

Show key headers only | View raw


Patricia Shanahan wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Patricia Shanahan wrote:
>>> […] Suppose a JS+HTML application were to exist that had tabular data in
>>> JavaScript data structures, and needed to transfer it to a spreadsheet
>>> on a workstation without using any special server set-up. What would be
>>> the best ways to do it?
>> 
>> That depends.
>> 
>> [Possibilities: DOM Storage, cloud storage]
> 
> I am certainly going to need storage for offline operation. In some
> cases, the data collection will happen offline, but the transfer of the
> data to the workstation will be done in a WiFi Internet environment.
> 
> DOM storage seemed to me to be far more practical for a data table than
> cookies.

The curious thing is that, contrary to my expectations, DOM Storage [1] 
(about to be standardized as Web Storage [2]) also only allows you to store 
string values.  That is, the main advantage of Web storage over cookies is 
that you can store more information there than in cookies (> 4 KiB).

If you want to store/retrieved structured data to/from Web Storage, you 
still have to serialize/unserialize it.  Which is a bit disappointing.  One 
would have expected the following to be possible in 21st century browser 
scripting:

  window.localStorage.setItem("foo", {bar: 42});

  /* Object */
  var item = window.localStorage.getItem("foo");

  /* Number */
  var bar = item.bar;

But you have to do:

  window.localStorage.setItem("foo_bar", "42");

  /* Number */
  var bar = +window.localStorage.getItem("foo_bar");

or

  window.localStorage.setItem("foo", JSON.stringify({bar: 42});

  /* Object */
  var item = JSON.parse(window.localStorage.getItem("foo"));

  /* Number */
  var bar = item.bar;

So you are probably about to write your own wrapper for Web Storage [3].

> I want to minimize the risk of data loss in case of e.g. the browser
> being closed, so I plan to write data to DOM storage as I go along,
> rather than waiting to the end of the observing session.

Good idea.  Events [4, 5] will come in handy there.
 
> I'm planning to use JSON to turn individual observation records
> into strings for storage.

So you have noticed :)

> I'm currently planning to use the string version of an integer sequence
> number, concatenated with a session identifier, as the storage key.

A session identifier does not appear to me to be of much use here, for you 
would want to retrieve the data regardless of the session you are in (or are 
you considering an application for several users on the same device? In that 
case the session identifier should be the user ID).  ISTM to be more 
important that you use a proper prefix so that data from your application 
separates itself from that of other applications.
 
>> But a Thick Client Web application (in an HTML document in a Web browser)
>> is capable of displaying those spreadsheets and charts by itself, so
>> transferring the data might not be necessary in the first place.
> 
> The data from one device may have to be combined with data collected on
> other devices, and will be analyzed and reorganized, before ending up
> summarized in graphs and tables in a scientific paper.
> 
> I've seen my lead user's office. He has an iPad, but he also has a
> Windows workstation, and when he wanted to email me some of the result
> files for a project, he used the workstation.

Fair enough.

>>> The simplest and most general solution I have thought of is to display
>>> the data as CSV text, so that the user can select and copy it to the
>>> clipboard. From there, they can do all sorts of things with it, subject
>>> only to device limitations, including pasting it into the body of an
>>> e-mail, or, pasting it into a text editor window and saving it, as a
>>> .csv file, on a thumb drive.
>> That is another option.  You can also generate and process JSON or XML,
>> with the additional advantage of transferring more structured
>> information.
> 
> It does have to be a format that spreadsheet programs, especially Excel,
> can read. XML is a possibility - I've used it several times in other
> projects - 

Yes, given that OpenDocument Spreadsheet (.ods, .fods) and Office Open XML 
Spreadsheet (.xlsx) are XML-based, XML might be your best option with regard 
to compatibility.  However, it also has the greatest overhead of all formats 
mentioned so far.

> but can Excel read JSON?

I think that native support is very unlikely.  See <http://json.org/> for 
more.

> CSV seems to be the most familiar to the end users.

I was thinking more along the lines of having the same application 
processing the code on the workstation that was generated by it on the 
mobile device here.


PointedEars
___________
[1] <https://developer.mozilla.org/en-US/docs/DOM/Storage>
[2] <http://www.w3.org/TR/webstorage/>
[3] <http://stackoverflow.com/questions/2010892/storing-objects-in-html5-
localstorage>
[4] <http://www.w3.org/TR/html5/webappapis.html#events>
[5] <https://developer.mozilla.org/en-US/docs/HTML/HTML5>
-- 
    realism:    HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness:    XHTML 1.1 as application/xhtml+xml
                                                    -- Bjoern Hoehrmann

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-01 22:49 -0700
  Re: Sending email with attachments Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-02 04:20 -0700
    Re: Sending email with attachments Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-02 05:16 -0700
      Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-02 07:10 -0700
        Re: Sending email with attachments Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-02 10:57 -0700
    Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-02 07:03 -0700
      Re: Sending email with attachments Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-02 10:50 -0700
        Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-02 11:16 -0700
          Re: Sending email with attachments dann90038@gmail.com - 2012-10-02 12:15 -0700
      Re: Sending email with attachments "Tom de Neef" <tdeneef@qolor.nl> - 2012-10-02 21:28 +0200
        Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-02 12:59 -0700
  Re: Sending email with attachments Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-02 22:26 +0200
    Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-03 20:04 +0100
    Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-06 02:07 +0100
      Re: Sending email with attachments Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-06 08:48 +0200
        Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-06 20:29 +0100
          Re: Sending email with attachments Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-06 21:49 +0200
            Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-07 08:13 +0100
              Re: Sending email with attachments Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-07 14:28 +0200
                Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-08 00:43 +0100
                Re: Sending email with attachments Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-08 03:26 +0200
                Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-08 07:18 +0100
                Re: Sending email with attachments Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-08 11:13 +0200
                Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-08 18:57 +0100
                Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-08 09:46 +0100
                Re: Sending email with attachments Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-10-08 12:01 +0200
                Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-08 19:16 +0100
                Re: Sending email with attachments Gene Wirchenko <genew@ocis.net> - 2012-10-08 09:28 -0700
                Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-08 18:34 +0100
          Re: Sending email with attachments Stefan Weiss <krewecherl@gmail.com> - 2012-10-07 12:46 +0200
            Re: Sending email with attachments Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-07 18:55 +0200
              Re: Sending email with attachments Stefan Weiss <krewecherl@gmail.com> - 2012-10-07 20:06 +0200
                Re: Sending email with attachments Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-07 22:12 +0200
            Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-07 19:54 +0100
            Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-08 01:09 +0100
              Re: Sending email with attachments Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-08 13:10 +0200
                Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-08 19:20 +0100
              OT: Mac vs PC for development  (Was: Sending email with attachments) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-10-08 08:38 -0700
  Re: Sending email with attachments Dr J R Stockton <reply1240@merlyn.demon.co.uk.invalid> - 2012-10-03 19:49 +0100
    Re: Sending email with attachments Eli the Bearded <*@eli.users.panix.com> - 2012-10-03 23:08 +0000
      Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-04 02:46 +0100
        Re: Sending email with attachments Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-03 19:42 -0700
    Re: Sending email with attachments Patricia Shanahan <pats@acm.org> - 2012-10-04 02:43 +0100
      Re: Sending email with attachments Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-03 19:54 -0700

csiph-web