This was a talk on emerging technologies. These are ideas, not fully fleshed out code, that you can imagine how a mobile/javascript event driven internet will act, rather than a server/full http page request internet looks.
Although I have used variations of these in live apps....
Andy Martha
catch me at andymartha.com, twitter.com/biolithic
drupal, codeigniter, phonegap, front-end mobile web
First, basic web functionality was through html tags.
Most of web functionality shifted to server side scripting (php/ruby/etc...)
From databases to user sessions to data sorting, html5+javascript balancing the load towards the front-end for 2010's
Mainly due to mobile usage for on the go business where a connection might not be so good.
Serving up static pages yields no server load, but who's serving static pages?
Most websites are made of sorting lists and rows from a database (Facebook to Ebay to spreadsheet-like applications)
php script process and html page refresh
+ database transaction
= server resources
- php script process and no html page refresh
+ database transaction
= server resources
html elements processed by javascript
+ no database transaction
= no server resources
html5 data-attributes are like "html variables" you can set up beforehand from the first server call. Each database row comes out as an html list element. Put the elements (which are objects) in an array by grabbing the selector of the html data-attribute. Sort the array elements using javascript (based on alphabetical, numerical, by date, etc...). Erase the old list from the dom and append the new array to the DOM in one call.
// Let us pretend you are making an ajax call to get some photo
// comments/info from a database using json
// in a loop of top ten latest items.
// our sorting category (html5 variable) is called data-comments:
var oneline = "<li style='height:135px;' data-comments='" + blah.photo.comments._content + "' data-date='" + blah.photo.dates.taken + "'data-title='" + blah.photo.title._content + "'>";
$('#listrow').append(oneline);
// in your html, print out a dummy button.
// reroute the event of the button to be onclick, run code like this...
listItems = myarray.sort(function(a,b){ return $(b).attr('data-comments') - $(a).attr('data-comments'); });
// this way, you can sort the information from the database in different ways without making calls to your server again
// there is a Jquery plugin for this, but this example will work no matter what, even if no framework is used
A common usage is an offline database of key-value pairs
window.localStorage.setItem("favourite team", "Chicago Bears");
We're not going to do that today
"Let's limit the number of times a user can submit a form per day to reduce spam on our mobile site/app"
"We need to set up user accounts in database, server sessions, cookies, hidden input fields..."
use a simple localstorage trick
var old = localStorage.getItem("eventcounter");
if(old === null)
{
window.localStorage.setItem("eventcounter",d);
}
else if (old.indexOf(d) == -1)
{
window.localStorage.removeItem("eventcounter");
console.log("yesterdays news");
window.localStorage.setItem("eventcounter",d);
}
else if(old == measurement)
{
alert("You have already signed up for too many events!");
return false;
}
else
{
old = old + d;
window.localStorage.setItem("eventcounter",old);
}
Here is how to sneak into a submit handler. Var d is a form of new Date();
Check to see if the person has submitted the form today on their mobile device (or multiple times/over the limit).
If not, save today's date in localstorage. If yes, match up the dates and possibly tell the user a message or block something!
This should probably be used for a mobile context, but it works in newer computer browsers too.
The Android/iPad/etc...will only use submit the form that many times per day, and tomorrow the user can try again.
The server doesn't have to spend time checking for and denying requests.


Actually, you don't need to use Phonegap. I like PhoneGap, but you don't need to ship your application to the Itunes store and all the different stores to get it to work offline. You can use plain ol' webpages on the internet too.
Not really time to explain this, but look it up.
var online = window.navigator.onLine;
if(online != true)
{
$('#submittip').append("Error: You are offline. Try again when you have a network connection.");
return false;
}
else
{
// do some stuff!!!
If you are online, the button will work. If not, save the data in localstorage until next time? Remember to style (or use/steal) nice UX/UI error messages.
CACHE:
index.html
mygreatstylesheet.css
// all your files
NETWORK:
http://search.twitter.com
http://api.twitter.com
http://twitter.com
https://twitter.com
http://a0.twimg.com/
// FOR A SINGLE AJAX REQUEST TO GET TWEETS
http://ajax.googleapis.com
// FOR CDN JQUERY OR OTHERS?
// other ajax request domains you may have
- You know what you need to cache offline...
- But you need to tell the app SPECIFICALLY WHAT DOMAINS you DO need to connect to if you have a good connection
- the network section is your application's "white list" of ajax connections
- super fun math problem!: How many internet domains do you think you need to white-list to post or retrieve a Facebook wall post?
- hint -- it's not only 1! (facebook.com)
This would reside at example.com or example.com/[hash]
- works on computers, tablets, e-readers, and phones
- no need for following store guidelines
- easy to update
- can set it up on a "hidden" folder of your website (+ robots.txt and htaccess files)
This would reside as a binary file to be installed using Phonegap or other.
- works on tablets, e-readers, and phones
- easier to find
- can set it up for download for Android devices, 100-device limit plug-in-play for Apple devices
IOS 3-6, Android 2.2+, Blackberry newish...?
Opera, Chrome, Safari, tablets, phones, e-readers, computers
demonstrated using jqMobi and also Jquery
I'm publishing a e-book on using jqMobi with Phonegap soon that is a walkthrough on this. If you are interested in this topic further, it will be available for all major mobile platforms before the winter.
- biolithicapps@gmail.com
http://andymartha.com/banpsuccess
to help on an open source project on github using Chicago crime city data from Socrata!Brian Moschel, Justin Love, Justin Meyer, Zishan Ahmad
Enova Financial and Bitovi