소스 검색

Save post data to localStorage

tags/v1.0.1
Matt Baer 9 년 전
부모
커밋
51ac4f1c4e
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. +15
    -0
      popup.js

+ 15
- 0
popup.js 파일 보기

@@ -41,6 +41,11 @@ function publish(content, font) {
$url.value = url;
var $urlLink = document.getElementById("url-link");
$urlLink.href = url;

// Save the data
posts = JSON.parse(H.get('posts', '[]'));
posts.push({id: id, token: editToken});
H.set('posts', JSON.stringify(posts));
} else {
alert("Failed to post. Please try again.");
}
@@ -56,6 +61,16 @@ var H = {
load: function($el, key) {
$el.value = localStorage.getItem(key);
},
set: function(key, value) {
localStorage.setItem(key, value);
},
get: function(key, defaultValue) {
var val = localStorage.getItem(key);
if (val == null) {
val = defaultValue;
}
return val;
},
};

document.addEventListener('DOMContentLoaded', function() {


불러오는 중...
취소
저장