downloads in cappuccino

153 views
Skip to first unread message

angel imaz rivero

unread,
Aug 12, 2009, 1:36:05 PM8/12/09
to objec...@googlegroups.com
Hello,

How can I download files from a cappuccino app?
My functional requirement is similar to the download button in 280
slides.
User will be clicking in the toolbar and a file will we downloaded.

Thank you!

Angel

Tom Robinson

unread,
Aug 12, 2009, 2:41:47 PM8/12/09
to objec...@googlegroups.com
We use a hidden iframe to initiate the download without reloading the
page. This is probably something that would be worth building into
Cappuccino, though I'm not sure where.

Here's the function we use in 280 Slides. It's supposed to be able to
handle multiple downloads (as long as the download begins within 2
seconds)

var DownloadIFrame = null,
DownloadSlotNext = null;

var downloadURL = function downloadURL(url)
{
if (DownloadIFrame == null)
{
DownloadIFrame = document.createElement("iframe");
DownloadIFrame.style.position = "absolute";
DownloadIFrame.style.top = "-100px";
DownloadIFrame.style.left = "-100px";
DownloadIFrame.style.height = "0px";
DownloadIFrame.style.width = "0px";
document.body.appendChild(DownloadIFrame);
}

var now = new Date().getTime(),
downloadSlot = (DownloadSlotNext && DownloadSlotNext >
now) ? DownloadSlotNext : now;

DownloadSlotNext = downloadSlot + 2000;

window.setTimeout(function() {
if (DownloadIFrame != null)
DownloadIFrame.src = url;
}, downloadSlot - now);

angel imaz rivero

unread,
Aug 12, 2009, 3:22:25 PM8/12/09
to objec...@googlegroups.com
Thank's a lot Tom!
Reply all
Reply to author
Forward
0 new messages