javascript - Trying to add websites to localstorage in chrome extension options page -
i want able add websites chrome extension options page. have text box "save" button , want able save multiple websites ability edit or remove them later. this:
enter url: |_________| |_save_|
edit remove - www.google.com
edit remove - www.msn.com
edit remove - www.yahoo.com
once enter website , click save, add list of websites there. i've been trying scavenge internet try figure out how accomplish this, don't know enough complete it.
i'd recommend chrome.storage
instead of localstorage
: http://developer.chrome.com/extensions/storage.html
it's fantastic. can choose store data online in google profile (100kb max). otherwise offline (100mb max, think).
api super simple too:
chrome.storage.local.get('websites', function(items) { console.log('websites:', items.websites); });
unlike localstorage
, it's async, you'll using callbacks. it's lightning fast, ui won't notice.
what i'd not keep virtual record of storage, keep in html , read from/write necessary:
- btnadd adds new li list , saves list
- btnedit fills textfield , removes li list (no save) (saving via btnadd)
- btndelete removes li list , saves list
- save = items list array , save storage
- init = load items storage , fill list
http://jsfiddle.net/rudiedirkx/zbpmx/
i'm assuming jquery since it's popular. it's not necessary of course.
if you're having problems already, chrome extension insanely difficult.
Comments
Post a Comment