Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // store information in local storage
- function storeData() {
- // This is a little bit of future proofing
- if (!submit.key) {
- // if there is no key, this is a new item and needs a new key
- var id = "ubuVers" + Math.floor(Math.random()*10000001);
- } else {
- // set the id to the existing key we are editing
- id = submit.key;
- };
- // I like to give all my form elements their own ids to give myself access
- // outside of the form as well as simple access inside of it
- var ubuVersNumValue = ge('ubuVersNum').value,
- ubuVersNameValue = ge('ubuVersName').value,
- ubuVersDict = {version: ubuVersNumValue, release: ubuVersNameValue};
- // log out those values as a double check
- console.log(ubuVersNumValue);
- console.log(ubuVersNameValue);
- // set the item in localstorage
- // note the stringify function
- localStorage.setItem(id, JSON.stringify(ubuVersDict));
- // log out the whole local storage
- console.log(localStorage);
- ge('submit').value = 'Add';
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement