HTML and CSS Reference
In-Depth Information
There is a famous quote by Donald Knuth:
"We should forget about small efficiencies, say about 97% of the time: premature
optimization is the root of all evil"
This functionality will also clear the input fields and hide the edit portion of the screen.
This ensures that if a user clicks the “Add task” button, the fields will not be prepopulated
with data from the previous edit.
The final version of the Web storage based storage engine should be as follows:
storageEngine = function() {
var initialized = false;
var initializedObjectStores = {};
function getStorageObject(type) {
var item = localStorage.getItem(type);
var parsedItem = JSON.parse(item);
return parsedItem;
return {
init : function(successCallback, errorCallback) {
if (window.localStorage) {
initialized = true;
} else {
errorCallback('storage_api_not_supported', 'The web storage api is not supported');
initObjectStore : function(type, successCallback, errorCallback) {
if (!initialized) {
errorCallback('storage_api_not_initialized', 'The storage engine has not been initialized');
} else if (!localStorage.getItem(type)) {
localStorage.setItem(type, JSON.stringify({}));
Search WWH ::

Custom Search