diff --git a/.DS_Store b/.DS_Store index 98d9b98..df2e0c9 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/quicknote/manifest.json b/quicknote/manifest.json index 13babe8..ac6ce52 100644 --- a/quicknote/manifest.json +++ b/quicknote/manifest.json @@ -1,14 +1,10 @@ { - "manifest_version": 1, + "manifest_version": 2, "name": "Quicknote", "version": "1.0", - "description": "Allows the user to make quick notes by clicking - a button and entering text into the resulting popup. - The notes are saved in storage and synced across - the user's sync login, even across different devices. - See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples#quicknote", + "description": "Allows the user to make quick notes by clicking a button and entering text into the resulting popup. The notes are saved in storage. See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples#quicknote", "icons": { "48": "icons/quicknote-48.png" }, diff --git a/quicknote/popup/quicknote.js b/quicknote/popup/quicknote.js index 8c902d6..0a06a9c 100644 --- a/quicknote/popup/quicknote.js +++ b/quicknote/popup/quicknote.js @@ -19,11 +19,14 @@ clearBtn.addEventListener('click', clearAll); initialize(); function initialize() { - var length = localStorage.length; - for(i = 0; i < length; i++) { - var item = localStorage.getItem(localStorage.key(i)); - displayNote(localStorage.key(i),item); - } + chrome.storage.local.get(null,function(results) { + var noteKeys = Object.keys(results) + for(i = 0; i < noteKeys.length; i++) { + var curKey = noteKeys[i]; + var curValue = results[curKey]; + displayNote(curKey,curValue); + } + }); } /* Add a note to the display, and storage */ @@ -32,7 +35,7 @@ function addNote() { var noteTitle = inputTitle.value; var noteBody = inputBody.value; - if(!localStorage.getItem(noteTitle) && noteTitle !== '' && noteBody !== '') { + if(!chrome.storage.local.get(noteTitle) && noteTitle !== '' && noteBody !== '') { inputTitle.value = ''; inputBody.value = ''; displayNote(noteTitle,noteBody); @@ -70,7 +73,7 @@ function displayNote(title, body) { deleteBtn.addEventListener('click',function(e){ evtTgt = e.target; evtTgt.parentNode.parentNode.parentNode.removeChild(evtTgt.parentNode.parentNode); - localStorage.removeItem(title); + chrome.storage.local.remove(title); }) /* create note edit box */ @@ -134,13 +137,15 @@ function displayNote(title, body) { function updateNote(delNote,newTitle,newBody) { - storeNote(newTitle, newBody); - localStorage.removeItem(delNote); - displayNote(newTitle, newBody); + chrome.storage.local.set({ newTitle : newBody }, function() { + chrome.storage.local.remove(delNote); + displayNote(newTitle, newBody); + }); } function storeNote(title, body) { - localStorage.setItem(title, body); + chrome.storage.local.set({ title : body }, function() { + }); } /* Clear all notes from the display/storage */ @@ -149,5 +154,5 @@ function clearAll() { while (noteContainer.firstChild) { noteContainer.removeChild(noteContainer.firstChild); } - localStorage.clear(); + chrome.storage.local.clear(); } \ No newline at end of file