jp,

The specific test i initially used with the iPhone simulator was as
follows:

1) Put "http://webkit.org/misc/DatabaseExample.html"; through a data:/
url generator ( e.g. http://software.hixie.ch/utilities/cgi/data/data
)
2) Repeat 1) with slightly modified text in the document
3) Add data url's for 1) and 2) to the home screen in the simulator
(e.g. by inserting the links on a page then navigating + adding them)
4) Add "http://webkit.org/misc/DatabaseExample.html"; to the home
screen.

You'll notice that:
* Both data:/ url's contain the same notes (they both point to the
same database)
* The link to the webkit database demo contains different notes (they
point to a different copy of the database)

Thus i was thinking that you could make use of this little feature
and, say, insert data:/ url's into your database for offline images.
e.g.:

Schema:

"CREATE TABLE DataURIS (id TEXT, uri TEXT)"

So

Then perhaps:

function setOfflineDataFor(id, uri)
{
   db.transaction(function (tx)
   {
        tx.executeSql("INSERT INTO DataURIS (id, uri) VALUES (?, ?)",
[id, uri]);
   });
}

function getOfflineDataFor(id)
{
    var res = "data:/";

    db.transaction(function(tx) {
        tx.executeSql("SELECT uri FROM WebKitStickyNotes WHERE id
LIKE ? LIMIT 1", [id], function(tx, result) {
            if (result.rows.length == 1)
               res = result.rows.item(0)['uri'];
        }, function(tx, error) {
            alert('Failed to retrieve data from database - ' +
error.message);
            return res;
        });
    });

    return res;
}

And:

// Set image data in database
// (In a real scenario, this would come from an XMLHttpRequest or
perhaps just another data:/ page)

setOfflineDataFor("webkit.png", "data:image/
png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAJjklEQVRYha2XeZAU1R3HP909091z7u7s7uzs7LCwu
%2BzCckgBssgfKiqiEiURSzRikqKiOSyPfxJzqbEqmtKYGDWFiVrxSpl4xUQiWCgqAgsih9wILOwxe8zMzn1Pd890%2FmBBQEBM5VfVVV39%2Br3v533f9XuCaZoC5xGCIJjP3DW7TRdTN0kV
%2Ble%2B2%2FPmuz2mZprnU%2FvsIZ6v%2BIPLcGtm%2Bso7n%2Bx5qXv
%2FSOSb1zQvBMEUhC%2Be%2FwVAOB8HxhpXH7zVt
%2F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mJmAAJUyz
%2FHVvqF8b4P8d%2FwUxdIwOTkEWNwAAAABJRU5ErkJggg%3D%3D");

// Create image from database
var elem = document.createElement("img");
elem.setAttribute("src", getOfflineDataFor("webkit.png"));
document.body.appendChild(elem);

Just an idea though. Not tested this out for real yet.

Regards,

~ James


On Jun 4, 4:05 am, jp <[EMAIL PROTECTED]> wrote:
> On May 30, 6:14 am, JamesU <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi there,
>
> > I've been experimenting a bit with the iPhone simulator in the SDK to
> > see if i can make web-based apps that can work off-line.
>
> > Consequently i've ended up using the "data:/" URL "hack". But i've
> > noticed that this is pretty useless apart from quick utility apps
> > (like a calculator).
>
> > Looking further, i noticed that there is client-side database support
> > in the simulator's browser. So naturally, i thought "can i combine
> > data:/ URL's and the database API to make a useful offline app?".
>
> > So i took one of the simple database examples and converted it to a
> > data:/ URL (http://webkit.org/misc/DatabaseExample.html). And it
> > seems to work rather nicely - i can create notes, close the page, open
> > it again, and see the notes i previously created. In addition i can
> > access the notes from any other "data:/" URL, which seems quite neat.
>
> James,  Any chance you can share your data:/ source code?
>
> Thanks,
> JP
>
>
>
> > Thinking about it, in theory i could store "data:/" URL's for extra
> > images in a client-side database, allowing me to significantly cut
> > down the size of my app's main "data:/" URL.
>
> > Now my question is this: Are there any really obvious limitations on a
> > real device in combining "data:/" URL's and client-side databases?
> > I've noticed that supposedly database access is restricted per-domain,
> > but this does not seem to apply to "data:/" URL's. Looking at Safari
> > on my mac for example, "data:/" URL's are all grouped under one tree
> > in the security preferences.
>
> > Any insight or further suggestions would be appreciated.
>
> > ~ James

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to