[prev in list] [next in list] [prev in thread] [next in thread]
List: interchange-users
Subject: [ic] HTML5 local storage
From: Jure Kodzoman <jure.kodzoman () informa ! si>
Date: 2012-02-23 13:39:26
Message-ID: 4F46418E.905 () informastudio ! com
[Download RAW message or body]
Hi!
Local storage is a way of storing your data locally on users computer.
You can read more about it on: http://dev.w3.org/html5/webstorage/
The main benefit is if user doesn't fill out the form completely and
leaves the page, form will still be prefilled when he comes back to the
site.
I've attached an IC tag that supports local storage.
just call it with [local-storage fields="comment fname lname"] and it
will store these 3 fields.
fields should look like:
<inputid="fname"type="text"value=""name="fname">
meaning they have to have both ID and NAME filled and they have to be
the same.
hope you can find some use for this tag.
regards,
jure
--
Jure Kodzoman
Informa Studio d.o.o. - Internet Marketing Company
Zadobrovška cesta 75
SI-1000 Ljubljana, Slovenia
+386 59 066 336
http://www.informastudio.com
----
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this email in error please notify the
system manager. Please note that any views or opinions presented in this
email are solely those of the author and do not necessarily represent
those of the company.
["local_storage.tag" (text/plain)]
# local_storage.tag - Local Storage Generation tag
# ---------------------
#
# Copyright (c) 2011 Jure Kodzoman, Informa Studio d.o.o.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA.
#
UserTag local_storage Documentation <<EOD
=head1 NAME
local_storage - Store current field values in local storage
=head1 SYNOPSIS
[local-storage fields="fname lname email"]
=head1 DESCRIPTION
Store field values locally on user's computer. Requires HTML5 enabled browser.
=over 4
=item fields
Whitespace separated list of field names
=item refresh
Time in seconds after which the fields will be stored again (defaults to 5 seconds, \
which is enough for most).
=back
=head1 EXAMPLES
[local-storage fields="fname lname"] - stores fname and lname locally. When you go \
away from page and come back they will still be there
=back
=head1 AUTHORS
Jure Kodzoman <jure.kodzoman@informastudio.com>
=cut
EOD
UserTag local_storage Order fields refresh
UserTag local_storage Routine <<EOR
sub {
my ($fields, $refresh) = @_;
my $out;
# defaults
$fields ||= '';
$refresh ||= 5;
if (! $fields){
::logError("Error calling local_storage.tag. Please define at least one field");
return;
}
my @fieldlist = split(/ /,$fields);
$refresh = $refresh * 1000; # convert to ms
$out = '<script type="text/javascript"> retrievedata(); function retrievedata(){ ';
foreach my $field (@fieldlist) {
::logError("Field is $field");
$out .= qq{var $field = localStorage.getItem("$field") || ""; \
document.querySelector("\#$field").value = $field;\n}; }
$out .= '} function savedata() {';
foreach my $field (@fieldlist) {
$out .= qq{var $field = document.querySelector("\#$field").value; \
localStorage.setItem('$field', $field);\n}; }
$out .= "} var myInterval = setInterval(savedata, $refresh); </script>";
return $out;
}
EOR
_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic